From a8b7626495c5b265c20ef81af79bffe63f76f26c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 12 Oct 2026 16:51:17 +0100 Subject: [PATCH] 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); + }); +});