From 28575c0f91e23f00454b5bfaf2dfe6abf9ab07cf Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 28 Jul 2026 17:05:45 +0530 Subject: [PATCH 01/10] chore: update Console SDK to 15.7.0 --- CHANGELOG.md | 8 + README.md | 2 +- docs/examples/documentsdb/update.md | 1 + docs/examples/storage/create-file.md | 3 +- docs/examples/tablesdb/update.md | 1 + docs/examples/vectorsdb/update.md | 1 + docs/examples/waf/create-challenge-rule.md | 23 ++ docs/examples/waf/update-challenge-rule.md | 23 ++ package-lock.json | 4 +- package.json | 2 +- src/client.ts | 2 +- src/models.ts | 66 +++++ src/services/backups.ts | 12 +- src/services/documents-db.ts | 25 +- src/services/mongo.ts | 4 +- src/services/mysql.ts | 4 +- src/services/postgresql.ts | 4 +- src/services/storage.ts | 23 +- src/services/tables-db.ts | 25 +- src/services/vectors-db.ts | 25 +- src/services/waf.ts | 267 +++++++++++++++++++-- 21 files changed, 456 insertions(+), 69 deletions(-) create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md diff --git a/CHANGELOG.md b/CHANGELOG.md index be9ad881..1377ae7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 15.7.0 + +* Added: `waf.createChallengeRule()` and `waf.updateChallengeRule()` for managing challenge rules +* Added: `WafRuleChallenge` model +* Added: `specification` parameter to `update()` on `tablesDB`, `documentsDB`, and `vectorsDB` +* Added: `folder` parameter to `storage.createFile()` for placing files in virtual folders +* Updated: `backups.createRestoration()` documents in-place restores when `newResourceId` is omitted + ## 15.6.0 * Added: `apps` installation methods `listInstallations`, `getInstallation`, `deleteInstallation`, and `createInstallationToken` diff --git a/README.md b/README.md index ad6fc720..fd54bfb6 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md index be18da8f..07e0eb6c 100644 --- a/docs/examples/documentsdb/update.md +++ b/docs/examples/documentsdb/update.md @@ -11,6 +11,7 @@ const result = await documentsDB.update({ databaseId: '', name: '', enabled: false, // optional + specification: 'serverless', // optional replicas: 0 // optional }); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index ddf29a00..ad7814a6 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -11,7 +11,8 @@ const result = await storage.createFile({ bucketId: '', fileId: '', file: document.getElementById('uploader').files[0], - permissions: [Permission.read(Role.any())] // optional + permissions: [Permission.read(Role.any())], // optional + folder: '' // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index bf394a7f..304175a2 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -11,6 +11,7 @@ const result = await tablesDB.update({ databaseId: '', name: '', // optional enabled: false, // optional + specification: 'serverless', // optional replicas: 0 // optional }); diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md index c85b0c5c..b70e587b 100644 --- a/docs/examples/vectorsdb/update.md +++ b/docs/examples/vectorsdb/update.md @@ -11,6 +11,7 @@ const result = await vectorsDB.update({ databaseId: '', name: '', enabled: false, // optional + specification: 'serverless', // optional replicas: 0 // optional }); diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 00000000..d2df938f --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,23 @@ +```javascript +import { Client, Waf } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const waf = new 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 +}); + +console.log(result); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 00000000..0c059987 --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,23 @@ +```javascript +import { Client, Waf } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const waf = new 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 +}); + +console.log(result); +``` diff --git a/package-lock.json b/package-lock.json index 870b1514..7f02ef94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "15.6.0", + "version": "15.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "15.6.0", + "version": "15.7.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index ac9e78ac..c5ee7b5a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "15.6.0", + "version": "15.7.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index f79c6aca..bd906ab1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -394,7 +394,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '15.6.0', + 'x-sdk-version': '15.7.0', 'X-Appwrite-Response-Format': '1.9.5', }; diff --git a/src/models.ts b/src/models.ts index a7c64ea4..f0be0563 100644 --- a/src/models.ts +++ b/src/models.ts @@ -13054,6 +13054,72 @@ export namespace Models { 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: object; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + } + /** * WafRuleRateLimit */ diff --git a/src/services/backups.ts b/src/services/backups.ts index c9e8f488..d18c2139 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -591,18 +591,18 @@ export class Backups { /** * Create and trigger a new restoration for a backup on a project. * - * For a backup of one database, the restoration resolves its destination before it is queued. Pass `newResourceId` to restore into that database ID, including the archived database ID to overwrite it. When `newResourceId` is omitted, a new database ID is generated and returned in `options`. + * For a backup of one database, the restoration resolves its destination before it is queued. When `newResourceId` is omitted, the archived database is restored in place and its own ID is returned in `options`. Pass a different `newResourceId` to restore alongside it as a new database instead. * * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. * * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. * - * When restoring a DocumentsDB or VectorsDB database to a new resource from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification. + * When restoring a DocumentsDB or VectorsDB database from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification and lands the data there. An in-place restore swaps the database onto that backing only once the restore has succeeded, and retires the backing it displaced only once that swap is confirmed, so the source keeps serving its own data until the restored data is in place and any failure leaves it untouched. A serverless source has no dedicated backing to clone and restores onto the archived database instead. * * * @param {string} params.archiveId - Backup archive ID to restore * @param {BackupServices[]} params.services - Array of services to restore - * @param {string} params.newResourceId - Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. 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.newResourceId - Destination resource ID. Omit to restore the archived resource in place, or pass a different ID to restore alongside it as a new resource. 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.newResourceName - Database name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise} @@ -611,18 +611,18 @@ export class Backups { /** * Create and trigger a new restoration for a backup on a project. * - * For a backup of one database, the restoration resolves its destination before it is queued. Pass `newResourceId` to restore into that database ID, including the archived database ID to overwrite it. When `newResourceId` is omitted, a new database ID is generated and returned in `options`. + * For a backup of one database, the restoration resolves its destination before it is queued. When `newResourceId` is omitted, the archived database is restored in place and its own ID is returned in `options`. Pass a different `newResourceId` to restore alongside it as a new database instead. * * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. * * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. * - * When restoring a DocumentsDB or VectorsDB database to a new resource from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification. + * When restoring a DocumentsDB or VectorsDB database from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification and lands the data there. An in-place restore swaps the database onto that backing only once the restore has succeeded, and retires the backing it displaced only once that swap is confirmed, so the source keeps serving its own data until the restored data is in place and any failure leaves it untouched. A serverless source has no dedicated backing to clone and restores onto the archived database instead. * * * @param {string} archiveId - Backup archive ID to restore * @param {BackupServices[]} services - Array of services to restore - * @param {string} newResourceId - Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. 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} newResourceId - Destination resource ID. Omit to restore the archived resource in place, or pass a different ID to restore alongside it as a new resource. 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} newResourceName - Database name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise} diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index e3e68577..a3483ff0 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -530,43 +530,47 @@ export class DocumentsDB { * @param {string} params.databaseId - Database ID. * @param {string} params.name - Database name. Max length: 128 chars. * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name: string, enabled?: boolean, replicas?: number }): Promise; + update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; /** * Update a database by its unique ID. * * @param {string} databaseId - Database ID. * @param {string} name - Database name. Max length: 128 chars. * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name: string, enabled?: boolean, replicas?: number): Promise; + update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - replicas: rest[2] as number + specification: rest[2] as string, + replicas: rest[3] as number }; } const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; + const specification = params.specification; const replicas = params.replicas; if (typeof databaseId === 'undefined') { @@ -584,6 +588,9 @@ export class DocumentsDB { if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof specification !== 'undefined') { + payload['specification'] = specification; + } if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } @@ -2404,7 +2411,7 @@ export class DocumentsDB { } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -2413,7 +2420,7 @@ export class DocumentsDB { */ createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. diff --git a/src/services/mongo.ts b/src/services/mongo.ts index bd23d8aa..a4d02f19 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1554,7 +1554,7 @@ export class Mongo { } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -1563,7 +1563,7 @@ export class Mongo { */ createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 9004d0e0..ea263441 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1633,7 +1633,7 @@ export class Mysql { } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -1642,7 +1642,7 @@ export class Mysql { */ createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index 36f7e940..27bfa0be 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1813,7 +1813,7 @@ export class Postgresql { } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -1822,7 +1822,7 @@ export class Postgresql { */ createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. diff --git a/src/services/storage.ts b/src/services/storage.ts index e377694a..76bb1f4c 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -535,10 +535,11 @@ export class Storage { * @param {string} params.fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {File} params.file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). * @param {string[]} params.permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.folder - Virtual folder to place the file in, for example "photos/2026". Nest folders with `/`. Defaults to the bucket root. * @throws {AppwriteException} * @returns {Promise} */ - createFile(params: { bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void }): Promise; + createFile(params: { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void }): Promise; /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. * @@ -553,35 +554,38 @@ export class Storage { * @param {string} fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {File} file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). * @param {string[]} permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} folder - Virtual folder to place the file in, for example "photos/2026". Nest folders with `/`. Defaults to the bucket root. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void): Promise; + createFile(bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void): Promise; createFile( - paramsOrFirst: { bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(string)?, (File)?, (string[])?,((progress: UploadProgress) => void)?] + paramsOrFirst: { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(string)?, (File)?, (string[])?, (string)?,((progress: UploadProgress) => void)?] ): Promise { - let params: { bucketId: string, fileId: string, file: File, permissions?: string[] }; + let params: { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string }; let onProgress: ((progress: UploadProgress) => void); if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File, permissions?: string[] }; + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string }; onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, file: rest[1] as File, - permissions: rest[2] as string[] + permissions: rest[2] as string[], + folder: rest[3] as string }; - onProgress = rest[3] as ((progress: UploadProgress) => void); + onProgress = rest[4] as ((progress: UploadProgress) => void); } const bucketId = params.bucketId; const fileId = params.fileId; const file = params.file; const permissions = params.permissions; + const folder = params.folder; if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -604,6 +608,9 @@ export class Storage { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof folder !== 'undefined') { + payload['folder'] = folder; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 344908f2..82d755ff 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -601,43 +601,47 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.name - Database name. Max length: 128 chars. * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, enabled?: boolean, replicas?: number }): Promise; + update(params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; /** * Update a database by its unique ID. * * @param {string} databaseId - Database ID. * @param {string} name - Database name. Max length: 128 chars. * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean, replicas?: number): Promise; + update(databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (number)?] + paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean, replicas?: number }; + let params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - replicas: rest[2] as number + specification: rest[2] as string, + replicas: rest[3] as number }; } const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; + const specification = params.specification; const replicas = params.replicas; if (typeof databaseId === 'undefined') { @@ -652,6 +656,9 @@ export class TablesDB { if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof specification !== 'undefined') { + payload['specification'] = specification; + } if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } @@ -725,7 +732,7 @@ export class TablesDB { } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -734,7 +741,7 @@ export class TablesDB { */ createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index f47641c8..962dcdde 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -660,43 +660,47 @@ export class VectorsDB { * @param {string} params.databaseId - Database ID. * @param {string} params.name - Database name. Max length: 128 chars. * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name: string, enabled?: boolean, replicas?: number }): Promise; + update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; /** * Update a database by its unique ID. * * @param {string} databaseId - Database ID. * @param {string} name - Database name. Max length: 128 chars. * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name: string, enabled?: boolean, replicas?: number): Promise; + update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - replicas: rest[2] as number + specification: rest[2] as string, + replicas: rest[3] as number }; } const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; + const specification = params.specification; const replicas = params.replicas; if (typeof databaseId === 'undefined') { @@ -714,6 +718,9 @@ export class VectorsDB { if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof specification !== 'undefined') { + payload['specification'] = specification; + } if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } @@ -2428,7 +2435,7 @@ export class VectorsDB { } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -2437,7 +2444,7 @@ export class VectorsDB { */ createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. diff --git a/src/services/waf.ts b/src/services/waf.ts index 0059f57d..400b87ce 100644 --- a/src/services/waf.ts +++ b/src/services/waf.ts @@ -81,7 +81,7 @@ export class Waf { } /** - * Create a bypass WAF rule. + * 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. @@ -97,7 +97,7 @@ export class Waf { */ createBypassRule(params: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Create a bypass WAF rule. + * 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. @@ -196,7 +196,7 @@ export class Waf { } /** - * Update a bypass WAF rule. + * 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. @@ -212,7 +212,7 @@ export class Waf { */ updateBypassRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Update a bypass WAF rule. + * 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. @@ -302,7 +302,242 @@ export class Waf { } /** - * Create a deny WAF rule. + * Create a challenge 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 {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. + * @throws {AppwriteException} + * @returns {Promise} + */ + createChallengeRule(params: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, challengeType?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; + /** + * Create a challenge 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 {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. + * @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): Promise; + createChallengeRule( + paramsOrFirst: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, challengeType?: string, priority?: number, enabled?: boolean, conditions?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] + ): Promise { + let params: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, challengeType?: 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, challengeType?: 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, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string + }; + } + + 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; + + 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 payload: Payload = {}; + if (typeof ruleId !== 'undefined') { + payload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + payload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof description !== 'undefined') { + payload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + payload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + payload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + payload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a challenge 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.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. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateChallengeRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, challengeType?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; + /** + * Update a challenge 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} 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. + * @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): Promise; + updateChallengeRule( + paramsOrFirst: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, challengeType?: string, priority?: number, enabled?: boolean, conditions?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] + ): Promise { + let params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, challengeType?: 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, challengeType?: 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, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string + }; + } + + 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; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/waf/rules/challenge/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const payload: Payload = {}; + if (typeof resourceType !== 'undefined') { + payload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof description !== 'undefined') { + payload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + payload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + payload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + payload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * 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. @@ -318,7 +553,7 @@ export class Waf { */ createDenyRule(params: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Create a deny WAF rule. + * 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. @@ -417,7 +652,7 @@ export class Waf { } /** - * Update a deny WAF rule. + * 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. @@ -433,7 +668,7 @@ export class Waf { */ updateDenyRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Update a deny WAF rule. + * 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. @@ -523,7 +758,7 @@ export class Waf { } /** - * Create a rate limit WAF rule. + * Create a rate limit 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. @@ -541,7 +776,7 @@ export class Waf { */ createRateLimitRule(params: { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Create a rate limit WAF rule. + * Create a rate limit 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. @@ -658,7 +893,7 @@ export class Waf { } /** - * Update a rate limit WAF rule. + * Update a rate limit 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. @@ -676,7 +911,7 @@ export class Waf { */ updateRateLimitRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Update a rate limit WAF rule. + * Update a rate limit 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. @@ -778,7 +1013,7 @@ export class Waf { } /** - * Create a redirect WAF rule. + * 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. @@ -796,7 +1031,7 @@ export class Waf { */ 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. + * 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. @@ -913,7 +1148,7 @@ export class Waf { } /** - * Update a redirect WAF rule. + * 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. @@ -931,7 +1166,7 @@ export class Waf { */ 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. + * 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. From 28be12d935e8063f70d7fa373dc4e76e7c84f950 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 30 Jul 2026 12:15:54 +0530 Subject: [PATCH 02/10] chore: update Console SDK to 15.8.0 --- CHANGELOG.md | 16 +++ README.md | 2 +- docs/examples/documentsdb/create.md | 3 +- docs/examples/documentsdb/update.md | 3 +- docs/examples/mongo/create.md | 3 +- docs/examples/mysql/create.md | 3 +- docs/examples/postgresql/create.md | 3 +- .../project/update-session-duration-policy.md | 2 +- .../project/update-user-limit-policy.md | 2 +- docs/examples/tablesdb/create.md | 3 +- docs/examples/tablesdb/update.md | 3 +- docs/examples/vectorsdb/create.md | 3 +- docs/examples/vectorsdb/update.md | 3 +- docs/examples/waf/create-challenge-rule.md | 4 +- docs/examples/waf/create-rate-limit-rule.md | 1 + docs/examples/waf/update-challenge-rule.md | 4 +- docs/examples/waf/update-rate-limit-rule.md | 1 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 2 +- src/enums/build-runtime.ts | 1 + src/enums/runtime.ts | 1 + src/models.ts | 102 ++++++++++++--- src/services/documents-db.ts | 42 ++++-- src/services/mongo.ts | 21 +-- src/services/mysql.ts | 25 ++-- src/services/postgresql.ts | 25 ++-- src/services/project.ts | 26 ++-- src/services/tables-db.ts | 42 ++++-- src/services/vectors-db.ts | 42 ++++-- src/services/waf.ts | 122 ++++++++++++------ 31 files changed, 339 insertions(+), 177 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1377ae7a..fab38509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Change Log +## 15.8.0 + +* Breaking: `create()` on `mysql`, `postgresql`, and `mongo` no longer accepts `api` +* Breaking: `project.updateSessionLimitPolicy()` now requires `total` +* Added: `syncMode` parameter to `create()` and `update()` on `tablesDB`, `documentsDB`, and `vectorsDB` +* Added: `difficulty` and `ttl` parameters to `waf.createChallengeRule()` and `waf.updateChallengeRule()` +* Added: `key` parameter to `waf.createRateLimitRule()` and `waf.updateRateLimitRule()` +* Added: replication sync state fields to `DatabaseStatus` and `DedicatedDatabaseReplicas` +* Added: `syncMode` to the `DedicatedDatabase` model +* Added: `difficulty` and `ttl` to `WafRuleChallenge`, and `key` to `WafRuleRateLimit` +* Added: `requestedType` and `fallbackReason` to `DedicatedDatabaseBackup` +* Added: `attempt` and `lastError` to `DatabaseMigration` +* Added: `node-26` to the `Runtime` and `BuildRuntime` enums +* Updated: `DatabaseStatusReplica.role` documents the `unknown` role during topology transitions +* Updated: Project policy limits for password history, session duration, session count, and users + ## 15.7.0 * Added: `waf.createChallengeRule()` and `waf.updateChallengeRule()` for managing challenge rules diff --git a/README.md b/README.md index fd54bfb6..81912f3b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md index 461af3e9..a397d8b3 100644 --- a/docs/examples/documentsdb/create.md +++ b/docs/examples/documentsdb/create.md @@ -12,7 +12,8 @@ const result = await documentsDB.create({ name: '', enabled: false, // optional specification: 'serverless', // optional - replicas: 0 // optional + replicas: 0, // optional + syncMode: 'async' // optional }); console.log(result); diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md index 07e0eb6c..9ff70bb4 100644 --- a/docs/examples/documentsdb/update.md +++ b/docs/examples/documentsdb/update.md @@ -12,7 +12,8 @@ const result = await documentsDB.update({ name: '', enabled: false, // optional specification: 'serverless', // optional - replicas: 0 // optional + replicas: 0, // optional + syncMode: 'async' // optional }); console.log(result); diff --git a/docs/examples/mongo/create.md b/docs/examples/mongo/create.md index a701bda8..7863da83 100644 --- a/docs/examples/mongo/create.md +++ b/docs/examples/mongo/create.md @@ -22,8 +22,7 @@ const result = await mongo.create({ pitrRetentionDays: 1, // optional storageAutoscaling: false, // optional storageAutoscalingThresholdPercent: 50, // optional - storageAutoscalingMaxGb: 0, // optional - api: 'tablesdb' // optional + storageAutoscalingMaxGb: 0 // optional }); console.log(result); diff --git a/docs/examples/mysql/create.md b/docs/examples/mysql/create.md index 408c78c3..9a7e5afb 100644 --- a/docs/examples/mysql/create.md +++ b/docs/examples/mysql/create.md @@ -22,8 +22,7 @@ const result = await mysql.create({ pitrRetentionDays: 1, // optional storageAutoscaling: false, // optional storageAutoscalingThresholdPercent: 50, // optional - storageAutoscalingMaxGb: 0, // optional - api: 'tablesdb' // optional + storageAutoscalingMaxGb: 0 // optional }); console.log(result); diff --git a/docs/examples/postgresql/create.md b/docs/examples/postgresql/create.md index ed60c77c..45e36030 100644 --- a/docs/examples/postgresql/create.md +++ b/docs/examples/postgresql/create.md @@ -22,8 +22,7 @@ const result = await postgresql.create({ pitrRetentionDays: 1, // optional storageAutoscaling: false, // optional storageAutoscalingThresholdPercent: 50, // optional - storageAutoscalingMaxGb: 0, // optional - api: 'tablesdb' // optional + storageAutoscalingMaxGb: 0 // optional }); console.log(result); diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md index b5c9852a..b6a71ae8 100644 --- a/docs/examples/project/update-session-duration-policy.md +++ b/docs/examples/project/update-session-duration-policy.md @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateSessionDurationPolicy({ - duration: 5 + duration: 60 }); console.log(result); diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md index c85620a4..ed8769eb 100644 --- a/docs/examples/project/update-user-limit-policy.md +++ b/docs/examples/project/update-user-limit-policy.md @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateUserLimitPolicy({ - total: 1 + total: 0 }); console.log(result); diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 01c2a5a6..e7faf04a 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -12,7 +12,8 @@ const result = await tablesDB.create({ name: '', enabled: false, // optional specification: 'serverless', // optional - replicas: 0 // optional + replicas: 0, // optional + syncMode: 'async' // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 304175a2..f7467075 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -12,7 +12,8 @@ const result = await tablesDB.update({ name: '', // optional enabled: false, // optional specification: 'serverless', // optional - replicas: 0 // optional + replicas: 0, // optional + syncMode: 'async' // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md index c7198a38..e10365e8 100644 --- a/docs/examples/vectorsdb/create.md +++ b/docs/examples/vectorsdb/create.md @@ -12,7 +12,8 @@ const result = await vectorsDB.create({ name: '', enabled: false, // optional specification: 'serverless', // optional - replicas: 0 // optional + replicas: 0, // optional + syncMode: 'async' // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md index b70e587b..fd375177 100644 --- a/docs/examples/vectorsdb/update.md +++ b/docs/examples/vectorsdb/update.md @@ -12,7 +12,8 @@ const result = await vectorsDB.update({ name: '', enabled: false, // optional specification: 'serverless', // optional - replicas: 0 // optional + replicas: 0, // optional + syncMode: 'async' // optional }); console.log(result); diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md index d2df938f..d183f84f 100644 --- a/docs/examples/waf/create-challenge-rule.md +++ b/docs/examples/waf/create-challenge-rule.md @@ -16,7 +16,9 @@ const result = await waf.createChallengeRule({ challengeType: 'compute', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional + difficulty: 1, // optional + ttl: 900 // optional }); console.log(result); diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md index ede249e1..53a50fcc 100644 --- a/docs/examples/waf/create-rate-limit-rule.md +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -15,6 +15,7 @@ const result = await waf.createRateLimitRule({ interval: 1, resourceId: '', // optional description: '', // optional + key: 'ip', // 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 index 0c059987..07bb6867 100644 --- a/docs/examples/waf/update-challenge-rule.md +++ b/docs/examples/waf/update-challenge-rule.md @@ -16,7 +16,9 @@ const result = await waf.updateChallengeRule({ challengeType: 'compute', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional + difficulty: 1, // optional + ttl: 900 // optional }); console.log(result); diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md index 3444a022..e979510a 100644 --- a/docs/examples/waf/update-rate-limit-rule.md +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -15,6 +15,7 @@ const result = await waf.updateRateLimitRule({ description: '', // optional limit: 1, // optional interval: 1, // optional + key: 'ip', // optional priority: -100000, // optional enabled: false, // optional conditions: '' // optional diff --git a/package-lock.json b/package-lock.json index 7f02ef94..cc029a80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "15.7.0", + "version": "15.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "15.7.0", + "version": "15.8.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index c5ee7b5a..ec2cf115 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "15.7.0", + "version": "15.8.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index bd906ab1..2aa0d176 100644 --- a/src/client.ts +++ b/src/client.ts @@ -394,7 +394,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '15.7.0', + 'x-sdk-version': '15.8.0', 'X-Appwrite-Response-Format': '1.9.5', }; diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 6c0f0008..50f152ac 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -9,6 +9,7 @@ export enum BuildRuntime { Node23 = 'node-23', Node24 = 'node-24', Node25 = 'node-25', + Node26 = 'node-26', Php80 = 'php-8.0', Php81 = 'php-8.1', Php82 = 'php-8.2', diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 40616625..63e04b2a 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -9,6 +9,7 @@ export enum Runtime { Node23 = 'node-23', Node24 = 'node-24', Node25 = 'node-25', + Node26 = 'node-26', Php80 = 'php-8.0', Php81 = 'php-8.1', Php82 = 'php-8.2', diff --git a/src/models.ts b/src/models.ts index f0be0563..8b48f119 100644 --- a/src/models.ts +++ b/src/models.ts @@ -946,7 +946,7 @@ export namespace Models { */ status?: DatabaseStatus; /** - * Underlying engine of the dedicated backing: postgresql, mysql, mariadb, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. + * Underlying engine of the dedicated backing: postgresql, mysql, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. */ engine?: string; /** @@ -9018,6 +9018,14 @@ export namespace Models { * Backup type. Possible values: full (complete database snapshot), incremental (changes since last backup), wal (write-ahead log continuous archival). */ type: string; + /** + * Backup type that was requested. Differs from `type` when the backend could not run the requested type and took a different one instead, in which case `fallbackReason` explains why. Empty for backups taken before the requested type was recorded. + */ + requestedType: string; + /** + * Why the backend ran a different backup type than the one requested. Empty when the backup ran as requested. + */ + fallbackReason: string; /** * Backup status. Possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error), verified (integrity check passed). */ @@ -9705,7 +9713,7 @@ export namespace Models { */ host: string; /** - * Branch port. + * Branch port. Null until the backing reports one. */ port: number; /** @@ -9725,7 +9733,7 @@ export namespace Models { */ ssl: boolean; /** - * Database engine. Possible values: postgresql, mysql, mariadb, mongodb. + * Database engine. Possible values: postgresql, mysql, mongodb. */ engine: string; /** @@ -9946,6 +9954,14 @@ export namespace Models { * Migration phase. Possible values: pending, provisioned, capturing, backfilling, catching_up, verifying, ready_to_cutover, cutover, soaking, done, failed, rolled_back. */ phase: string; + /** + * Number of times a migration step has failed and been recorded. + */ + attempt: number; + /** + * Reason the most recent migration step failed, empty while none has. + */ + lastError: string; /** * Number of documents still pending replication to the target. */ @@ -10001,7 +10017,7 @@ export namespace Models { */ api: string; /** - * Database engine: postgresql, mysql, mariadb, or mongodb. + * Database engine: postgresql, mysql, or mongodb. */ engine: string; /** @@ -10021,7 +10037,7 @@ export namespace Models { */ hostname: string; /** - * Database port for connections. + * Database port for connections. Derived from the engine when the backing has not reported one yet. */ connectionPort: number; /** @@ -10101,7 +10117,7 @@ export namespace Models { */ crossRegionReplicas: number; /** - * Maximum concurrent connections. + * Maximum concurrent client connections. This is the limit a client pool may reach; the engine's own max_connections reported by the status endpoint is a smaller backend limit the pooler multiplexes onto and does not constrain a client pool. */ networkMaxConnections: number; /** @@ -10281,7 +10297,7 @@ export namespace Models { */ ready: boolean; /** - * Database engine: postgresql, mysql, mariadb, or mongodb. + * Database engine: postgresql, mysql, or mongodb. */ engine: string; /** @@ -10297,7 +10313,31 @@ export namespace Models { */ connections: DatabaseStatusConnections; /** - * List of database replicas and their status. + * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing. + */ + syncMode: string; + /** + * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. + */ + effectiveSyncMode?: string; + /** + * Whether the enforced replication is weaker than the requested syncMode. + */ + syncDegraded: boolean; + /** + * Number of standby acknowledgements the primary waits for before a write is committed. + */ + syncAcknowledgements: number; + /** + * Number of standbys registered with the primary for synchronous replication. + */ + syncStandbyCount: number; + /** + * Whether the reported sync state was read from the engine. When false the state could not be confirmed and the other sync fields carry no reading. + */ + syncStateConfirmed: boolean; + /** + * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ replicas: DatabaseStatusReplica[]; /** @@ -10747,11 +10787,11 @@ export namespace Models { */ $id: string; /** - * Member role. Possible values: primary (accepts reads and writes), replica (read-only follower). + * Member role. Possible values: primary (accepts reads and writes), replica (read-only follower), unknown (placement not established; reported while a transition is moving or restarting the topology and this member has not been probed, so no member can be named the write target). */ role: string; /** - * Member pod status. Possible values: provisioning (pod missing or Pending), starting (Running but not Ready), active (Running and Ready), failed (Failed phase or CrashLoopBackOff container), or the lowercased pod phase reported by the cluster. + * Member pod status. Possible values: pending (configured but absent from the backend topology, so nothing is bringing it up), provisioning (pod missing or Pending), starting (Running but not Ready), active (Running and Ready), failed (Failed phase or CrashLoopBackOff container), or the lowercased pod phase reported by the cluster. */ status: string; /** @@ -10833,9 +10873,29 @@ export namespace Models { */ replicas: number; /** - * Replication sync mode. Possible values: async (asynchronous, fastest), sync (synchronous, strong consistency), quorum (quorum-based, majority of replicas must confirm). + * Requested replication sync mode. Possible values: async (asynchronous, fastest), sync (synchronous, strong consistency), quorum (quorum-based, majority of replicas must confirm). This is what was asked for; compare it with effectiveSyncMode for what the primary is enforcing. */ syncMode: string; + /** + * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. A value below the requested syncMode means writes are being acknowledged with weaker durability than configured. + */ + effectiveSyncMode?: string; + /** + * Whether the enforced replication is weaker than the requested syncMode. + */ + syncDegraded: boolean; + /** + * Number of standby acknowledgements the primary waits for before a write is committed. Zero means writes are acknowledged locally. + */ + syncAcknowledgements: number; + /** + * Number of standbys registered with the primary for synchronous replication. + */ + syncStandbyCount: number; + /** + * Whether the reported sync state was read from the engine. When false the state could not be confirmed and the other sync fields carry no reading. + */ + syncStateConfirmed: boolean; /** * Per-pod statuses for the primary and every replica. */ @@ -11463,7 +11523,7 @@ export namespace Models { */ mode: string; /** - * Maximum number of pooled connections. + * Client-connection ceiling the pooler accepts. Enforced on MySQL and MariaDB; on PostgreSQL the pooler has no client cap, so this reports the database's advertised networkMaxConnections and cannot be set here. */ maxConnections: number; /** @@ -11785,7 +11845,7 @@ export namespace Models { */ current: number; /** - * Maximum allowed connections. + * The engine's own max_connections. On a pooled database this is the backend limit the pooler multiplexes onto, not the ceiling a client pool may reach — that is networkMaxConnections on the database resource. */ max: number; } @@ -11795,11 +11855,11 @@ export namespace Models { */ export type DatabaseStatusReplica = { /** - * StatefulSet pod index (0 = primary, 1+ = replicas). + * Member index within the database. Read `role` for which member accepts writes: a failover moves the primary without renumbering the indexes. */ index: number; /** - * Replica role: primary or replica. + * Member role. Possible values: primary (accepts reads and writes), replica (read-only follower), unknown (placement not established; reported while a transition is moving or restarting the topology, so no member can be named the write target). */ role: string; /** @@ -13118,6 +13178,14 @@ export namespace Models { * 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; } /** @@ -13188,6 +13256,10 @@ export namespace Models { * 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; } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index a3483ff0..2049019f 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -82,10 +82,11 @@ export class DocumentsDB { * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; + create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; /** * Create a new Database. * @@ -95,26 +96,28 @@ export class DocumentsDB { * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; + create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, specification: rest[2] as string, - replicas: rest[3] as number + replicas: rest[3] as number, + syncMode: rest[4] as string }; } @@ -123,6 +126,7 @@ export class DocumentsDB { const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; + const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -148,6 +152,9 @@ export class DocumentsDB { if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } + if (typeof syncMode !== 'undefined') { + payload['syncMode'] = syncMode; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -532,10 +539,11 @@ export class DocumentsDB { * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; + update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; /** * Update a database by its unique ID. * @@ -544,26 +552,28 @@ export class DocumentsDB { * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; + update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, specification: rest[2] as string, - replicas: rest[3] as number + replicas: rest[3] as number, + syncMode: rest[4] as string }; } @@ -572,6 +582,7 @@ export class DocumentsDB { const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; + const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -594,6 +605,9 @@ export class DocumentsDB { if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } + if (typeof syncMode !== 'undefined') { + payload['syncMode'] = syncMode; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/mongo.ts b/src/services/mongo.ts index a4d02f19..5c9d7fbe 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -81,11 +81,10 @@ export class Mongo { * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. - * @param {string} params.api - Product API that owns this database: tablesdb, documentsdb, or vectorsdb. Omit for a raw database reached directly; its api is its engine. tablesdb/documentsdb/vectorsdb databases are reached only through their product APIs. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }): Promise; + create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }): Promise; /** * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. * @@ -104,20 +103,19 @@ export class Mongo { * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. - * @param {string} api - Product API that owns this database: tablesdb, documentsdb, or vectorsdb. Omit for a raw database reached directly; its api is its engine. tablesdb/documentsdb/vectorsdb databases are reached only through their product APIs. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string): Promise; + create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?, (string)?] + paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?] ): Promise { - let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }; + let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; } else { params = { databaseId: paramsOrFirst as string, @@ -134,8 +132,7 @@ export class Mongo { pitrRetentionDays: rest[10] as number, storageAutoscaling: rest[11] as boolean, storageAutoscalingThresholdPercent: rest[12] as number, - storageAutoscalingMaxGb: rest[13] as number, - api: rest[14] as string + storageAutoscalingMaxGb: rest[13] as number }; } @@ -154,7 +151,6 @@ export class Mongo { const storageAutoscaling = params.storageAutoscaling; const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; - const api = params.api; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -210,9 +206,6 @@ export class Mongo { if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; } - if (typeof api !== 'undefined') { - payload['api'] = api; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/mysql.ts b/src/services/mysql.ts index ea263441..c9d2c7a8 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -81,11 +81,10 @@ export class Mysql { * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. - * @param {string} params.api - Product API that owns this database: tablesdb, documentsdb, or vectorsdb. Omit for a raw database reached directly; its api is its engine. tablesdb/documentsdb/vectorsdb databases are reached only through their product APIs. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }): Promise; + create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }): Promise; /** * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. * @@ -104,20 +103,19 @@ export class Mysql { * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. - * @param {string} api - Product API that owns this database: tablesdb, documentsdb, or vectorsdb. Omit for a raw database reached directly; its api is its engine. tablesdb/documentsdb/vectorsdb databases are reached only through their product APIs. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string): Promise; + create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?, (string)?] + paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?] ): Promise { - let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }; + let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; } else { params = { databaseId: paramsOrFirst as string, @@ -134,8 +132,7 @@ export class Mysql { pitrRetentionDays: rest[10] as number, storageAutoscaling: rest[11] as boolean, storageAutoscalingThresholdPercent: rest[12] as number, - storageAutoscalingMaxGb: rest[13] as number, - api: rest[14] as string + storageAutoscalingMaxGb: rest[13] as number }; } @@ -154,7 +151,6 @@ export class Mysql { const storageAutoscaling = params.storageAutoscaling; const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; - const api = params.api; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -210,9 +206,6 @@ export class Mysql { if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; } - if (typeof api !== 'undefined') { - payload['api'] = api; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2027,7 +2020,7 @@ export class Mysql { * * @param {string} params.databaseId - Database ID. * @param {string} params.mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. - * @param {number} params.maxConnections - Maximum pooled connections. + * @param {number} params.maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. * @param {number} params.defaultPoolSize - Default pool size per user. * @param {boolean} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. * @param {string} params.poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). @@ -2043,7 +2036,7 @@ export class Mysql { * * @param {string} databaseId - Database ID. * @param {string} mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. - * @param {number} maxConnections - Maximum pooled connections. + * @param {number} maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. * @param {number} defaultPoolSize - Default pool size per user. * @param {boolean} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. * @param {string} poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index 27bfa0be..529f5522 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -81,11 +81,10 @@ export class Postgresql { * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. - * @param {string} params.api - Product API that owns this database: tablesdb, documentsdb, or vectorsdb. Omit for a raw database reached directly; its api is its engine. tablesdb/documentsdb/vectorsdb databases are reached only through their product APIs. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }): Promise; + create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }): Promise; /** * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. * @@ -104,20 +103,19 @@ export class Postgresql { * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. - * @param {string} api - Product API that owns this database: tablesdb, documentsdb, or vectorsdb. Omit for a raw database reached directly; its api is its engine. tablesdb/documentsdb/vectorsdb databases are reached only through their product APIs. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string): Promise; + create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?, (string)?] + paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?] ): Promise { - let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }; + let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, api?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; } else { params = { databaseId: paramsOrFirst as string, @@ -134,8 +132,7 @@ export class Postgresql { pitrRetentionDays: rest[10] as number, storageAutoscaling: rest[11] as boolean, storageAutoscalingThresholdPercent: rest[12] as number, - storageAutoscalingMaxGb: rest[13] as number, - api: rest[14] as string + storageAutoscalingMaxGb: rest[13] as number }; } @@ -154,7 +151,6 @@ export class Postgresql { const storageAutoscaling = params.storageAutoscaling; const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; - const api = params.api; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -210,9 +206,6 @@ export class Postgresql { if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; } - if (typeof api !== 'undefined') { - payload['api'] = api; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2207,7 +2200,7 @@ export class Postgresql { * * @param {string} params.databaseId - Database ID. * @param {string} params.mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. - * @param {number} params.maxConnections - Maximum pooled connections. + * @param {number} params.maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. * @param {number} params.defaultPoolSize - Default pool size per user. * @param {boolean} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. * @param {string} params.poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). @@ -2223,7 +2216,7 @@ export class Postgresql { * * @param {string} databaseId - Database ID. * @param {string} mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. - * @param {number} maxConnections - Maximum pooled connections. + * @param {number} maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. * @param {number} defaultPoolSize - Default pool size per user. * @param {boolean} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. * @param {string} poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). diff --git a/src/services/project.ts b/src/services/project.ts index af5b0490..a93319c5 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -5642,7 +5642,7 @@ export class Project { * * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. * - * @param {number} params.total - Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + * @param {number} params.total - Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. * @throws {AppwriteException} * @returns {Promise} */ @@ -5652,7 +5652,7 @@ export class Project { * * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. * - * @param {number} total - Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + * @param {number} total - Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -5898,7 +5898,7 @@ export class Project { /** * Update maximum duration how long sessions created within a project should stay active for. * - * @param {number} params.duration - Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + * @param {number} params.duration - Maximum session length in seconds. Minium allowed value is 60 seconds, and maximum is 1 year, which is 31536000 seconds. * @throws {AppwriteException} * @returns {Promise} */ @@ -5906,7 +5906,7 @@ export class Project { /** * Update maximum duration how long sessions created within a project should stay active for. * - * @param {number} duration - Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + * @param {number} duration - Maximum session length in seconds. Minium allowed value is 60 seconds, and maximum is 1 year, which is 31536000 seconds. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -6012,27 +6012,27 @@ export class Project { /** * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. * - * @param {number} params.total - Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. + * @param {number} params.total - Set the maximum number of sessions allowed per user. Value can be between 1 and 100. * @throws {AppwriteException} * @returns {Promise} */ - updateSessionLimitPolicy(params: { total?: number }): Promise; + updateSessionLimitPolicy(params: { total: number }): Promise; /** * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. * - * @param {number} total - Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. + * @param {number} total - Set the maximum number of sessions allowed per user. Value can be between 1 and 100. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSessionLimitPolicy(total?: number): Promise; + updateSessionLimitPolicy(total: number): Promise; updateSessionLimitPolicy( - paramsOrFirst?: { total?: number } | number + paramsOrFirst: { total: number } | number ): Promise { - let params: { total?: number }; + let params: { total: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total: number }; } else { params = { total: paramsOrFirst as number @@ -6069,7 +6069,7 @@ export class Project { /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. + * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise} */ @@ -6077,7 +6077,7 @@ export class Project { /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. + * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 82d755ff..db5b41b9 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -91,10 +91,11 @@ export class TablesDB { * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; + create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; /** * Create a new Database. * @@ -104,26 +105,28 @@ export class TablesDB { * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; + create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, specification: rest[2] as string, - replicas: rest[3] as number + replicas: rest[3] as number, + syncMode: rest[4] as string }; } @@ -132,6 +135,7 @@ export class TablesDB { const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; + const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -157,6 +161,9 @@ export class TablesDB { if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } + if (typeof syncMode !== 'undefined') { + payload['syncMode'] = syncMode; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -603,10 +610,11 @@ export class TablesDB { * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; + update(params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; /** * Update a database by its unique ID. * @@ -615,26 +623,28 @@ export class TablesDB { * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number): Promise; + update(databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?] + paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number }; + let params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, specification: rest[2] as string, - replicas: rest[3] as number + replicas: rest[3] as number, + syncMode: rest[4] as string }; } @@ -643,6 +653,7 @@ export class TablesDB { const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; + const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -662,6 +673,9 @@ export class TablesDB { if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } + if (typeof syncMode !== 'undefined') { + payload['syncMode'] = syncMode; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 962dcdde..4cc229f3 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -83,10 +83,11 @@ export class VectorsDB { * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; + create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; /** * Create a new Database. * @@ -96,26 +97,28 @@ export class VectorsDB { * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; + create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, specification: rest[2] as string, - replicas: rest[3] as number + replicas: rest[3] as number, + syncMode: rest[4] as string }; } @@ -124,6 +127,7 @@ export class VectorsDB { const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; + const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -149,6 +153,9 @@ export class VectorsDB { if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } + if (typeof syncMode !== 'undefined') { + payload['syncMode'] = syncMode; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -662,10 +669,11 @@ export class VectorsDB { * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; + update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; /** * Update a database by its unique ID. * @@ -674,26 +682,28 @@ export class VectorsDB { * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; + update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, specification: rest[2] as string, - replicas: rest[3] as number + replicas: rest[3] as number, + syncMode: rest[4] as string }; } @@ -702,6 +712,7 @@ export class VectorsDB { const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; + const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -724,6 +735,9 @@ export class VectorsDB { if (typeof replicas !== 'undefined') { payload['replicas'] = replicas; } + if (typeof syncMode !== 'undefined') { + payload['syncMode'] = syncMode; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/waf.ts b/src/services/waf.ts index 400b87ce..3027344a 100644 --- a/src/services/waf.ts +++ b/src/services/waf.ts @@ -302,7 +302,7 @@ export class Waf { } /** - * Create a challenge 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. + * 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. @@ -314,12 +314,14 @@ export class Waf { * @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 }): 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. 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. + * 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. @@ -331,19 +333,21 @@ export class Waf { * @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): Promise; + 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 } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] + 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 }; + 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 }; + 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, @@ -354,7 +358,9 @@ export class Waf { challengeType: rest[4] as string, priority: rest[5] as number, enabled: rest[6] as boolean, - conditions: rest[7] as string + conditions: rest[7] as string, + difficulty: rest[8] as number, + ttl: rest[9] as number }; } @@ -367,6 +373,8 @@ export class Waf { 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"'); @@ -407,6 +415,12 @@ export class Waf { if (typeof conditions !== 'undefined') { payload['conditions'] = conditions; } + if (typeof difficulty !== 'undefined') { + payload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -424,7 +438,7 @@ export class Waf { } /** - * Update a challenge 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. + * 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. @@ -436,12 +450,14 @@ export class Waf { * @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 }): 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. 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. + * 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. @@ -453,19 +469,21 @@ export class Waf { * @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): Promise; + 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 } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] + 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 }; + 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 }; + 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, @@ -476,7 +494,9 @@ export class Waf { challengeType: rest[4] as string, priority: rest[5] as number, enabled: rest[6] as boolean, - conditions: rest[7] as string + conditions: rest[7] as string, + difficulty: rest[8] as number, + ttl: rest[9] as number }; } @@ -489,6 +509,8 @@ export class Waf { 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"'); @@ -520,6 +542,12 @@ export class Waf { if (typeof conditions !== 'undefined') { payload['conditions'] = conditions; } + if (typeof difficulty !== 'undefined') { + payload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -758,7 +786,7 @@ export class Waf { } /** - * Create a rate limit 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. + * 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. @@ -768,15 +796,16 @@ export class Waf { * @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 {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, priority?: number, enabled?: boolean, conditions?: string }): Promise; + createRateLimitRule(params: { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, key?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Create a rate limit 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. + * 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. @@ -786,6 +815,7 @@ export class Waf { * @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 {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. @@ -793,15 +823,15 @@ export class Waf { * @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, priority?: number, enabled?: boolean, conditions?: string): Promise; + createRateLimitRule(ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, key?: string, priority?: number, enabled?: boolean, conditions?: string): Promise; createRateLimitRule( - paramsOrFirst: { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] + paramsOrFirst: { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, key?: string, priority?: number, enabled?: boolean, conditions?: string } | string, + ...rest: [(string)?, (string)?, (number)?, (number)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] ): Promise { - let params: { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }; + let params: { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, key?: string, 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, priority?: number, enabled?: boolean, conditions?: string }; + params = (paramsOrFirst || {}) as { ruleId: string, resourceType: string, name: string, limit: number, interval: number, resourceId?: string, description?: string, key?: string, priority?: number, enabled?: boolean, conditions?: string }; } else { params = { ruleId: paramsOrFirst as string, @@ -811,9 +841,10 @@ export class Waf { interval: 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 + key: rest[6] as string, + priority: rest[7] as number, + enabled: rest[8] as boolean, + conditions: rest[9] as string }; } @@ -824,6 +855,7 @@ export class Waf { const interval = params.interval; const resourceId = params.resourceId; const description = params.description; + const key = params.key; const priority = params.priority; const enabled = params.enabled; const conditions = params.conditions; @@ -867,6 +899,9 @@ export class Waf { if (typeof interval !== 'undefined') { payload['interval'] = interval; } + if (typeof key !== 'undefined') { + payload['key'] = key; + } if (typeof priority !== 'undefined') { payload['priority'] = priority; } @@ -893,7 +928,7 @@ export class Waf { } /** - * Update a rate limit 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. + * 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. @@ -903,15 +938,16 @@ export class Waf { * @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.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, priority?: number, enabled?: boolean, conditions?: string }): Promise; + updateRateLimitRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, key?: string, priority?: number, enabled?: boolean, conditions?: string }): Promise; /** - * Update a rate limit 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. + * 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. @@ -921,6 +957,7 @@ export class Waf { * @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} 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. @@ -928,15 +965,15 @@ export class Waf { * @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, priority?: number, enabled?: boolean, conditions?: string): Promise; + updateRateLimitRule(ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, key?: string, priority?: number, enabled?: boolean, conditions?: string): Promise; updateRateLimitRule( - paramsOrFirst: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, priority?: number, enabled?: boolean, conditions?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (number)?, (number)?, (number)?, (boolean)?, (string)?] + paramsOrFirst: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, key?: string, priority?: number, enabled?: boolean, conditions?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (number)?, (number)?, (string)?, (number)?, (boolean)?, (string)?] ): Promise { - let params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, priority?: number, enabled?: boolean, conditions?: string }; + let params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, key?: 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, limit?: number, interval?: number, priority?: number, enabled?: boolean, conditions?: string }; + params = (paramsOrFirst || {}) as { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, limit?: number, interval?: number, key?: string, priority?: number, enabled?: boolean, conditions?: string }; } else { params = { ruleId: paramsOrFirst as string, @@ -946,9 +983,10 @@ export class Waf { description: rest[3] as string, limit: rest[4] as number, interval: rest[5] as number, - priority: rest[6] as number, - enabled: rest[7] as boolean, - conditions: rest[8] as string + key: rest[6] as string, + priority: rest[7] as number, + enabled: rest[8] as boolean, + conditions: rest[9] as string }; } @@ -959,6 +997,7 @@ export class Waf { const description = params.description; const limit = params.limit; const interval = params.interval; + const key = params.key; const priority = params.priority; const enabled = params.enabled; const conditions = params.conditions; @@ -987,6 +1026,9 @@ export class Waf { if (typeof interval !== 'undefined') { payload['interval'] = interval; } + if (typeof key !== 'undefined') { + payload['key'] = key; + } if (typeof priority !== 'undefined') { payload['priority'] = priority; } From 0cc7c5bfa79ea537e9d64488f2742babedfac715 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 30 Jul 2026 13:09:52 +0530 Subject: [PATCH 03/10] chore: update Console SDK to 15.8.0 --- package-lock.json | 247 +++++++++++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 144 insertions(+), 105 deletions(-) diff --git a/package-lock.json b/package-lock.json index cc029a80..52f95b55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@rollup/plugin-typescript": "12.3.0", "@types/json-bigint": "1.0.4", "playwright": "1.56.1", - "rollup": "4.62.2", + "rollup": "4.62.3", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3" @@ -139,9 +139,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.2.tgz", - "integrity": "sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.3.tgz", + "integrity": "sha512-c0wdcekXtQvvn5Tsrk/+op/gUArrbWaFduBnTLP2l1cKLSQs4diMWjJw3m6A0DdzT8dAAX95KpkJ3qynCePbmw==", "cpu": [ "arm" ], @@ -153,9 +153,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.2.tgz", - "integrity": "sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.3.tgz", + "integrity": "sha512-3YjElDdWN+qXAFbJ/CzPV+0wspLqh54k/I6GfdYtEJRqg7buSgc1yPM3B+93j1M4neobtkATHZTmxK2AMVGfnA==", "cpu": [ "arm64" ], @@ -167,9 +167,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.2.tgz", - "integrity": "sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.3.tgz", + "integrity": "sha512-Pch2pFNOxxz1hTjypIdPyRTR6riiwRl84+VcN9djS680fw+Co1nAJINrdpqp7KV0NvyuU8ilZXZCjd7ykJl1GQ==", "cpu": [ "arm64" ], @@ -181,9 +181,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.2.tgz", - "integrity": "sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.3.tgz", + "integrity": "sha512-LEuncFUHFiF8t4yZVZvvZA1wk0pjAscRnsrn1EfTEmN4HXotBi2YtcnLRyaK6UbuczW7xZS5ES+81Rdz8Z0T6g==", "cpu": [ "x64" ], @@ -195,9 +195,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.2.tgz", - "integrity": "sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.3.tgz", + "integrity": "sha512-zvBUvsQUpOWALdDsk6qbS8bXf2VxmPisuudNDrY7x0p0jBdsoZl8HsHczIOgkQiZldmcacMKtBzpoGVNeIe2bQ==", "cpu": [ "arm64" ], @@ -209,9 +209,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.2.tgz", - "integrity": "sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.3.tgz", + "integrity": "sha512-C2KmNrcSem/AMg984H/dev+si0lieQGdXdR/lYGJnuumXnFb9Y7QdiI62obFdLlxRYLBv4P0eUVIDbD4c1vVvw==", "cpu": [ "x64" ], @@ -223,13 +223,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.2.tgz", - "integrity": "sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.3.tgz", + "integrity": "sha512-ggXnsTAEzNQx74XpunRsiZ9aBZDsI7XIa0hm2nzR9f4WzH5/f/d73ZSDaC5ejJ8YLY4NW+V3wr0tjOaeCq8hqA==", "cpu": [ "arm" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -237,13 +240,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.2.tgz", - "integrity": "sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.3.tgz", + "integrity": "sha512-2vng+FlzNUhKZxtej3IUqJgbZoQk2M/dwQM20+ULV0R/E/8tr9/P6uEf2iiGIk4HL0zMKh5Jry7mUHdUOvyGgA==", "cpu": [ "arm" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -251,13 +257,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.2.tgz", - "integrity": "sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.3.tgz", + "integrity": "sha512-LLLFZKt4/Nraf9rxDkhiU8QVgLF4WmCkfr0L4fj0fPfIZFBib0DeiFk1hhaYKd03LFAFJcxHslhDFlNJLylf5Q==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -265,13 +274,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.2.tgz", - "integrity": "sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.3.tgz", + "integrity": "sha512-WJkdQCvS9sWNOUBJZfQRKpZGFBztRzcowI+nndmflKgU4XY+3a420FgTOSKTsVqJbnzSxeT4vaJalpOaPo2YCQ==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -279,13 +291,16 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.2.tgz", - "integrity": "sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.3.tgz", + "integrity": "sha512-PwHXCCS2n64/1Ot6rP1YEYA02MGYBcQlr8CSZZyrUG2O7NH6NklYmvr9v3Jy+5e/eDeNchc/ukmKJi9LuflMIQ==", "cpu": [ "loong64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -293,13 +308,16 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.2.tgz", - "integrity": "sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.3.tgz", + "integrity": "sha512-vUjxINQu3RC8NZS3ykk1gN65gIz8pAopOq2HXuZhiIxHdx7TFvDG+jgrdSgInu1Eza4/Rfi2VzZgyIgEH4WOaw==", "cpu": [ "loong64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -307,13 +325,16 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.2.tgz", - "integrity": "sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.3.tgz", + "integrity": "sha512-wzko4aJ13+0G3kGnviCg5gnXFKd40izKsrf2uOw12US4XqprkDrmwOpeW14aSNa37V8bfPcz5Fkob6LZ3BAPmA==", "cpu": [ "ppc64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -321,13 +342,16 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.2.tgz", - "integrity": "sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.3.tgz", + "integrity": "sha512-8120ue0JUMSwy11stlwnfdX3pPd+WZYGCDBwEHWtIHi6pOpZmsEF5QKB7a/UN+XFdqvobxz98kv8RTqikyCEBw==", "cpu": [ "ppc64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -335,13 +359,16 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.2.tgz", - "integrity": "sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.3.tgz", + "integrity": "sha512-XLFHnR3tXMjbOCh2vtVJHmxt+995uJsTERQyseFDRA0xxMxyTZPLa3OIUlyFaO4mF/Lu0FjmWHCuPXJT1n/IOg==", "cpu": [ "riscv64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -349,13 +376,16 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.2.tgz", - "integrity": "sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.3.tgz", + "integrity": "sha512-se6yXvNGMIl0f+RQzyh7XAmia8/9kplQx424wnG2w0C1oi6XgO6Y8otKhdXFHbHs88Ihavzmvh1NWjuovE76BQ==", "cpu": [ "riscv64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -363,13 +393,16 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.2.tgz", - "integrity": "sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.3.tgz", + "integrity": "sha512-gNoxRefktVIiGflpONuxWWXZAzIQG++z9qHO3xKwk4WdDMuQja3JHGfE1u0i3PfPDyvhypdk+WrgIJqLhGG7sg==", "cpu": [ "s390x" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -377,13 +410,16 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.2.tgz", - "integrity": "sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.3.tgz", + "integrity": "sha512-V4KtWtQfAFMU7+9/A/VDps/VI8CHd3cYz0L8sgJzz8qK7eY7wI4ruFD82UYIYvW9Z4DtlTfhQcsl4XyPHW5uSg==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -391,13 +427,16 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.2.tgz", - "integrity": "sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.3.tgz", + "integrity": "sha512-LBx9LYXvj2CBkMkjLdNAWLwH0MLMin7do2VcVo9kVPibGLkY0BQQut2fv7NVqkXqZ/CrAu9LqDHVV1xHCMpCPw==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -405,9 +444,9 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.2.tgz", - "integrity": "sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.3.tgz", + "integrity": "sha512-ABVf3Q0RCu7NcyCCOZQI0pJ3GuSdfSl8EXcy88QtdceIMIoCUdfhsJChZ64L9zVM2aJHjde1Bhn5uqSRcX9ySA==", "cpu": [ "x64" ], @@ -419,9 +458,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.2.tgz", - "integrity": "sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.3.tgz", + "integrity": "sha512-+2Cy/ldweGBLlPIKsQLF8U5N44a0KDdbrk1rAjHOM9M2K+kGdIVjHLmmrZIcx+9Ny3ke/1JomCsDI1ocb11+sg==", "cpu": [ "arm64" ], @@ -433,9 +472,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.2.tgz", - "integrity": "sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.3.tgz", + "integrity": "sha512-dtZvzc8BedpSaFNy75x6uiWwAGTH+aZHDtdrqP6qk+WcLJrfti6sGje1ZJ9UxyzDLF23d/mV+PaMwuC0hL7UVA==", "cpu": [ "arm64" ], @@ -447,9 +486,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.2.tgz", - "integrity": "sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.3.tgz", + "integrity": "sha512-Rj8Ra4noo+aYy7sKBggCx0407mws34kAb1ySyWuq5DAtFBQdkSwnsjCgPrhPe9cvgBKZIukpE+CVHvORCS93kQ==", "cpu": [ "ia32" ], @@ -461,9 +500,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.2.tgz", - "integrity": "sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.3.tgz", + "integrity": "sha512-vp7N084ew/odXn2gi/mzm9mUkQu9l6AiN6dt4IeUM2Uvm9o+cVmP+YkqbMOteLbiGgqBBlJZjIMYVCfOOIVbVQ==", "cpu": [ "x64" ], @@ -475,9 +514,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.2.tgz", - "integrity": "sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.3.tgz", + "integrity": "sha512-MOG/3gTOn4Fwf574RVOaY61I5o6P90legkFADiTyn1hyjNydT+cerU2rLUwPdZkKKyJ+iT+K9p7WXK4LM1Ka6g==", "cpu": [ "x64" ], @@ -838,9 +877,9 @@ } }, "node_modules/rollup": { - "version": "4.62.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.2.tgz", - "integrity": "sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==", + "version": "4.62.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.3.tgz", + "integrity": "sha512-Gu0c0iH9FzgX1L1t7ByIbbS3Vmdz+6KHm/EsqmmC71gUQ82yvZRkTK6XzrFObSka91WUVdynqp6nsfilzr5k6Q==", "dev": true, "license": "MIT", "dependencies": { @@ -854,31 +893,31 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.62.2", - "@rollup/rollup-android-arm64": "4.62.2", - "@rollup/rollup-darwin-arm64": "4.62.2", - "@rollup/rollup-darwin-x64": "4.62.2", - "@rollup/rollup-freebsd-arm64": "4.62.2", - "@rollup/rollup-freebsd-x64": "4.62.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.62.2", - "@rollup/rollup-linux-arm-musleabihf": "4.62.2", - "@rollup/rollup-linux-arm64-gnu": "4.62.2", - "@rollup/rollup-linux-arm64-musl": "4.62.2", - "@rollup/rollup-linux-loong64-gnu": "4.62.2", - "@rollup/rollup-linux-loong64-musl": "4.62.2", - "@rollup/rollup-linux-ppc64-gnu": "4.62.2", - "@rollup/rollup-linux-ppc64-musl": "4.62.2", - "@rollup/rollup-linux-riscv64-gnu": "4.62.2", - "@rollup/rollup-linux-riscv64-musl": "4.62.2", - "@rollup/rollup-linux-s390x-gnu": "4.62.2", - "@rollup/rollup-linux-x64-gnu": "4.62.2", - "@rollup/rollup-linux-x64-musl": "4.62.2", - "@rollup/rollup-openbsd-x64": "4.62.2", - "@rollup/rollup-openharmony-arm64": "4.62.2", - "@rollup/rollup-win32-arm64-msvc": "4.62.2", - "@rollup/rollup-win32-ia32-msvc": "4.62.2", - "@rollup/rollup-win32-x64-gnu": "4.62.2", - "@rollup/rollup-win32-x64-msvc": "4.62.2", + "@rollup/rollup-android-arm-eabi": "4.62.3", + "@rollup/rollup-android-arm64": "4.62.3", + "@rollup/rollup-darwin-arm64": "4.62.3", + "@rollup/rollup-darwin-x64": "4.62.3", + "@rollup/rollup-freebsd-arm64": "4.62.3", + "@rollup/rollup-freebsd-x64": "4.62.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.62.3", + "@rollup/rollup-linux-arm-musleabihf": "4.62.3", + "@rollup/rollup-linux-arm64-gnu": "4.62.3", + "@rollup/rollup-linux-arm64-musl": "4.62.3", + "@rollup/rollup-linux-loong64-gnu": "4.62.3", + "@rollup/rollup-linux-loong64-musl": "4.62.3", + "@rollup/rollup-linux-ppc64-gnu": "4.62.3", + "@rollup/rollup-linux-ppc64-musl": "4.62.3", + "@rollup/rollup-linux-riscv64-gnu": "4.62.3", + "@rollup/rollup-linux-riscv64-musl": "4.62.3", + "@rollup/rollup-linux-s390x-gnu": "4.62.3", + "@rollup/rollup-linux-x64-gnu": "4.62.3", + "@rollup/rollup-linux-x64-musl": "4.62.3", + "@rollup/rollup-openbsd-x64": "4.62.3", + "@rollup/rollup-openharmony-arm64": "4.62.3", + "@rollup/rollup-win32-arm64-msvc": "4.62.3", + "@rollup/rollup-win32-ia32-msvc": "4.62.3", + "@rollup/rollup-win32-x64-gnu": "4.62.3", + "@rollup/rollup-win32-x64-msvc": "4.62.3", "fsevents": "~2.3.2" } }, diff --git a/package.json b/package.json index ec2cf115..eccff621 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@rollup/plugin-typescript": "12.3.0", "@types/json-bigint": "1.0.4", "playwright": "1.56.1", - "rollup": "4.62.2", + "rollup": "4.62.3", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3" From 02d07047c6d9ff477a328bda2892303e3fe08279 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 31 Jul 2026 10:45:57 +0530 Subject: [PATCH 04/10] chore: update Console SDK to 15.9.0 --- CHANGELOG.md | 4 ++++ README.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/client.ts | 18 +++++++++++++++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fab38509..86ec2e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 15.9.0 + +* Added: `client.setOrganization()` to send the `X-Appwrite-Organization` header + ## 15.8.0 * Breaking: `create()` on `mysql`, `postgresql`, and `mongo` no longer accepts `api` diff --git a/README.md b/README.md index 81912f3b..e817c12b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/package-lock.json b/package-lock.json index 52f95b55..4d12468e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "15.8.0", + "version": "15.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "15.8.0", + "version": "15.9.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index eccff621..b570cf40 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "15.8.0", + "version": "15.9.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 2aa0d176..3ce8b95f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -355,6 +355,7 @@ class Client { endpointRealtime: string; project: string; key: string; + organization: string; jwt: string; bearer: string; locale: string; @@ -373,6 +374,7 @@ class Client { endpointRealtime: '', project: '', key: '', + organization: '', jwt: '', bearer: '', locale: '', @@ -394,7 +396,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '15.8.0', + 'x-sdk-version': '15.9.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -533,6 +535,20 @@ class Client { this.config.key = value; return this; } + /** + * Set Organization + * + * Your organization ID + * + * @param value string + * + * @return {this} + */ + setOrganization(value: string): this { + this.headers['X-Appwrite-Organization'] = value; + this.config.organization = value; + return this; + } /** * Set JWT * From 4c18cf2bf709e59978c0f5c4493750afb22e6642 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 5 Aug 2026 11:49:44 +0530 Subject: [PATCH 05/10] chore: update Console SDK to 16.0.0 --- CHANGELOG.md | 16 +- README.md | 4 +- docs/examples/affiliates/create-link.md | 16 + docs/examples/affiliates/delete-link.md | 15 + docs/examples/affiliates/get-link.md | 15 + docs/examples/affiliates/list-links.md | 15 + docs/examples/affiliates/list-referrals.md | 15 + docs/examples/affiliates/list-rewards.md | 15 + docs/examples/affiliates/update-reward.md | 17 + .../create-text-embeddings.md | 6 +- docs/examples/proxy/create-invalidation.md | 17 + docs/examples/usage/list-events.md | 10 +- docs/examples/usage/list-gauges.md | 10 +- package-lock.json | 241 +++++----- package.json | 6 +- src/client.ts | 4 +- src/enums/invalidation-type.ts | 5 + src/enums/project-key-scopes.ts | 1 + src/enums/query-suggestion-resource.ts | 3 + src/enums/usage-event-dimension.ts | 21 + src/enums/usage-gauge-dimension.ts | 7 + src/enums/usage-interval.ts | 7 + src/enums/usage-order-by.ts | 4 + src/enums/usage-order-direction.ts | 4 + src/index.ts | 10 +- src/models.ts | 264 +++++++++-- src/services/account.ts | 12 +- src/services/affiliates.ts | 432 ++++++++++++++++++ src/services/embeddings.ts | 80 ++++ src/services/proxy.ts | 80 ++++ src/services/usage.ts | 85 ++-- src/services/vectors-db.ts | 68 --- 32 files changed, 1218 insertions(+), 287 deletions(-) create mode 100644 docs/examples/affiliates/create-link.md create mode 100644 docs/examples/affiliates/delete-link.md create mode 100644 docs/examples/affiliates/get-link.md create mode 100644 docs/examples/affiliates/list-links.md create mode 100644 docs/examples/affiliates/list-referrals.md create mode 100644 docs/examples/affiliates/list-rewards.md create mode 100644 docs/examples/affiliates/update-reward.md rename docs/examples/{vectorsdb => embeddings}/create-text-embeddings.md (61%) create mode 100644 docs/examples/proxy/create-invalidation.md create mode 100644 src/enums/invalidation-type.ts create mode 100644 src/enums/usage-event-dimension.ts create mode 100644 src/enums/usage-gauge-dimension.ts create mode 100644 src/enums/usage-interval.ts create mode 100644 src/enums/usage-order-by.ts create mode 100644 src/enums/usage-order-direction.ts create mode 100644 src/services/affiliates.ts create mode 100644 src/services/embeddings.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ec2e2b..b58ae8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,18 @@ # Change Log -## 15.9.0 - -* Added: `client.setOrganization()` to send the `X-Appwrite-Organization` header +## 16.0.0 + +* Breaking: Moved `vectorsDB.createTextEmbeddings()` to the new `Embeddings` service +* Breaking: `usage.listEvents()` `interval`, `dimensions`, `orderBy`, and `orderDir` now take enums +* Breaking: `usage.listGauges()` `interval`, `dimensions`, `orderBy`, and `orderDir` now take enums +* Added: `Affiliates` service for referral links, referrals, and rewards +* Added: `Embeddings` service with `createTextEmbeddings()` +* Added: `proxy.createInvalidation()` with the `ProxyInvalidation` model and `InvalidationType` enum +* Added: `Client.setOrganization()` for organization-scoped requests +* Added: `UsageInterval`, `UsageEventDimension`, `UsageGaugeDimension`, `UsageOrderBy`, `UsageOrderDirection` enums +* Added: affiliate resources to the `QuerySuggestionResource` enum +* Added: `proxy.invalidations.write` to the `ProjectKeyScopes` enum +* Added: `affiliates.clicks` as a `usage.listEvents()` metric ## 15.8.0 diff --git a/README.md b/README.md index e817c12b..1d27d837 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Console SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.5-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.6-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) @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/affiliates/create-link.md b/docs/examples/affiliates/create-link.md new file mode 100644 index 00000000..f066dd71 --- /dev/null +++ b/docs/examples/affiliates/create-link.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.createLink({ + linkId: '', + name: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/affiliates/delete-link.md b/docs/examples/affiliates/delete-link.md new file mode 100644 index 00000000..7029e4f8 --- /dev/null +++ b/docs/examples/affiliates/delete-link.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.deleteLink({ + linkId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/affiliates/get-link.md b/docs/examples/affiliates/get-link.md new file mode 100644 index 00000000..1b9fe1e7 --- /dev/null +++ b/docs/examples/affiliates/get-link.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.getLink({ + linkId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/affiliates/list-links.md b/docs/examples/affiliates/list-links.md new file mode 100644 index 00000000..e755c3d4 --- /dev/null +++ b/docs/examples/affiliates/list-links.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.listLinks({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/affiliates/list-referrals.md b/docs/examples/affiliates/list-referrals.md new file mode 100644 index 00000000..222423aa --- /dev/null +++ b/docs/examples/affiliates/list-referrals.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.listReferrals({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/affiliates/list-rewards.md b/docs/examples/affiliates/list-rewards.md new file mode 100644 index 00000000..7849ca6e --- /dev/null +++ b/docs/examples/affiliates/list-rewards.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.listRewards({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/affiliates/update-reward.md b/docs/examples/affiliates/update-reward.md new file mode 100644 index 00000000..9771bf5b --- /dev/null +++ b/docs/examples/affiliates/update-reward.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Affiliates } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const affiliates = new Affiliates(client); + +const result = await affiliates.updateReward({ + rewardId: '', + status: 'claimed', + organizationId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md similarity index 61% rename from docs/examples/vectorsdb/create-text-embeddings.md rename to docs/examples/embeddings/create-text-embeddings.md index f5d825e4..4c9fb022 100644 --- a/docs/examples/vectorsdb/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -1,13 +1,13 @@ ```javascript -import { Client, VectorsDB, EmbeddingModel } from "@appwrite.io/console"; +import { Client, Embeddings, EmbeddingModel } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const vectorsDB = new VectorsDB(client); +const embeddings = new Embeddings(client); -const result = await vectorsDB.createTextEmbeddings({ +const result = await embeddings.createTextEmbeddings({ texts: [], model: EmbeddingModel.NomicEmbedText // optional }); diff --git a/docs/examples/proxy/create-invalidation.md b/docs/examples/proxy/create-invalidation.md new file mode 100644 index 00000000..9005b367 --- /dev/null +++ b/docs/examples/proxy/create-invalidation.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Proxy, InvalidationType } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.createInvalidation({ + domain: '', + type: InvalidationType.Tag, + reference: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/usage/list-events.md b/docs/examples/usage/list-events.md index a8d124a0..6647ed02 100644 --- a/docs/examples/usage/list-events.md +++ b/docs/examples/usage/list-events.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Usage } from "@appwrite.io/console"; +import { Client, Usage, UsageInterval, UsageEventDimension, UsageOrderBy, UsageOrderDirection } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const usage = new Usage(client); const result = await usage.listEvents({ metrics: [], queries: [], // optional - interval: '1m', // optional - dimensions: [], // optional + interval: UsageInterval.OneMinute, // optional + dimensions: [UsageEventDimension.Path], // optional startAt: '2020-10-15T06:38:00.000+00:00', // optional endAt: '2020-10-15T06:38:00.000+00:00', // optional - orderBy: 'time', // optional - orderDir: 'asc', // optional + orderBy: UsageOrderBy.Time, // optional + orderDir: UsageOrderDirection.Asc, // optional limit: 1, // optional offset: 0 // optional }); diff --git a/docs/examples/usage/list-gauges.md b/docs/examples/usage/list-gauges.md index e1007ffe..2dd225ac 100644 --- a/docs/examples/usage/list-gauges.md +++ b/docs/examples/usage/list-gauges.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Usage } from "@appwrite.io/console"; +import { Client, Usage, UsageInterval, UsageGaugeDimension, UsageOrderBy, UsageOrderDirection } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const usage = new Usage(client); const result = await usage.listGauges({ metrics: [], queries: [], // optional - interval: '1m', // optional - dimensions: [], // optional + interval: UsageInterval.OneMinute, // optional + dimensions: [UsageGaugeDimension.ResourceId], // optional startAt: '2020-10-15T06:38:00.000+00:00', // optional endAt: '2020-10-15T06:38:00.000+00:00', // optional - orderBy: 'time', // optional - orderDir: 'asc', // optional + orderBy: UsageOrderBy.Time, // optional + orderDir: UsageOrderDirection.Asc, // optional limit: 1, // optional offset: 0 // optional }); diff --git a/package-lock.json b/package-lock.json index 4d12468e..a84c7e23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "15.9.0", + "version": "16.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "15.9.0", + "version": "16.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" @@ -17,7 +17,7 @@ "@rollup/plugin-typescript": "12.3.0", "@types/json-bigint": "1.0.4", "playwright": "1.56.1", - "rollup": "4.62.3", + "rollup": "4.62.4", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3" @@ -26,7 +26,7 @@ "node": ">=18.0.0" }, "overrides": { - "brace-expansion": "5.0.8" + "brace-expansion": "5.0.9" } }, "node_modules/@jridgewell/sourcemap-codec": { @@ -36,6 +36,26 @@ "dev": true, "license": "MIT" }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, "node_modules/@rollup/plugin-commonjs": { "version": "29.0.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-29.0.3.tgz", @@ -139,9 +159,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.3.tgz", - "integrity": "sha512-c0wdcekXtQvvn5Tsrk/+op/gUArrbWaFduBnTLP2l1cKLSQs4diMWjJw3m6A0DdzT8dAAX95KpkJ3qynCePbmw==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.4.tgz", + "integrity": "sha512-RrPokAb7dmbxFoeO3TloqHyOjgye8RkBhSqmp4aJMIex4c9r46ZstPnleDQOq1t46VOVjwIuwNogIqbodV1Vvg==", "cpu": [ "arm" ], @@ -153,9 +173,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.3.tgz", - "integrity": "sha512-3YjElDdWN+qXAFbJ/CzPV+0wspLqh54k/I6GfdYtEJRqg7buSgc1yPM3B+93j1M4neobtkATHZTmxK2AMVGfnA==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.4.tgz", + "integrity": "sha512-JKuJc+pnpks2pjy7L/N3v/cAkZxYlnmuZoD840ldbMI5KDbC4iO9NKwPKYdjYFCMAIIlBzYSFHxIJVYzRo2/8A==", "cpu": [ "arm64" ], @@ -167,9 +187,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.3.tgz", - "integrity": "sha512-Pch2pFNOxxz1hTjypIdPyRTR6riiwRl84+VcN9djS680fw+Co1nAJINrdpqp7KV0NvyuU8ilZXZCjd7ykJl1GQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.4.tgz", + "integrity": "sha512-krw5uS2STmvJ02x0uTXHbqQNuz+9eZ1iw+qXk9dmW2gvV4jV7O2hEoOnuhFrpOPiel1mBFtqbxYZZtC46hXLOw==", "cpu": [ "arm64" ], @@ -181,9 +201,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.3.tgz", - "integrity": "sha512-LEuncFUHFiF8t4yZVZvvZA1wk0pjAscRnsrn1EfTEmN4HXotBi2YtcnLRyaK6UbuczW7xZS5ES+81Rdz8Z0T6g==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.4.tgz", + "integrity": "sha512-wsTxtgApb4PrOsNJIm0FZ1h3WvCC+k9uxLJ4ad75hgoS4NiRes2SoJFlDAyMwiUY8IssDqGcHbXuN0sx1tfF1A==", "cpu": [ "x64" ], @@ -195,9 +215,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.3.tgz", - "integrity": "sha512-zvBUvsQUpOWALdDsk6qbS8bXf2VxmPisuudNDrY7x0p0jBdsoZl8HsHczIOgkQiZldmcacMKtBzpoGVNeIe2bQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.4.tgz", + "integrity": "sha512-GUOnQlyZe3yAXhWOtOMsn5Qkrv5E5mZXa0thbARWi5Ei2szlVXJFQhddZ4HbAzh8q92w5twp+CQvs/eFanz9YQ==", "cpu": [ "arm64" ], @@ -209,9 +229,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.3.tgz", - "integrity": "sha512-C2KmNrcSem/AMg984H/dev+si0lieQGdXdR/lYGJnuumXnFb9Y7QdiI62obFdLlxRYLBv4P0eUVIDbD4c1vVvw==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.4.tgz", + "integrity": "sha512-/Y7f3QuxjzPKsjA/rfEDa3+0vXqyjmJ50Ln8dPpCmWkKTrUoWHG1cWhTqaAMLob2m2nESWuC7yGrREz019Ztqg==", "cpu": [ "x64" ], @@ -223,9 +243,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.3.tgz", - "integrity": "sha512-ggXnsTAEzNQx74XpunRsiZ9aBZDsI7XIa0hm2nzR9f4WzH5/f/d73ZSDaC5ejJ8YLY4NW+V3wr0tjOaeCq8hqA==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.4.tgz", + "integrity": "sha512-81wiiX3v7aqy+T+bT61TJ78yJjRquqFFTTbAPt08imfQQzkPIW8t6aJbkTagtCCrXMNc9D66+geqlK7ydLPNqA==", "cpu": [ "arm" ], @@ -240,9 +260,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.3.tgz", - "integrity": "sha512-2vng+FlzNUhKZxtej3IUqJgbZoQk2M/dwQM20+ULV0R/E/8tr9/P6uEf2iiGIk4HL0zMKh5Jry7mUHdUOvyGgA==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.4.tgz", + "integrity": "sha512-9kmDIvNZqdoHOBZgNtpTBeLWYO/LVipM3H/j62P8848/l/VPEQL6N3uxU9pvP1oZAsXyC2MEnFP3ovRjo7WYNQ==", "cpu": [ "arm" ], @@ -257,9 +277,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.3.tgz", - "integrity": "sha512-LLLFZKt4/Nraf9rxDkhiU8QVgLF4WmCkfr0L4fj0fPfIZFBib0DeiFk1hhaYKd03LFAFJcxHslhDFlNJLylf5Q==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.4.tgz", + "integrity": "sha512-CcnXHWnXg69g+DX5VWL3FHts3qMRN2uVEHX+BZvGLdd07/gXkn3ePjYtO1LDJvxkGKVHMclKBRa1QUTH+6toYQ==", "cpu": [ "arm64" ], @@ -274,9 +294,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.3.tgz", - "integrity": "sha512-WJkdQCvS9sWNOUBJZfQRKpZGFBztRzcowI+nndmflKgU4XY+3a420FgTOSKTsVqJbnzSxeT4vaJalpOaPo2YCQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.4.tgz", + "integrity": "sha512-iFOibiHnTRuhrWLlRsOQFdZJJIa7S8OwkneJr4ocALP16u5yk6lWLINFwhHaEqBFMsKDUZofLkGos7+CPzGB3g==", "cpu": [ "arm64" ], @@ -291,9 +311,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.3.tgz", - "integrity": "sha512-PwHXCCS2n64/1Ot6rP1YEYA02MGYBcQlr8CSZZyrUG2O7NH6NklYmvr9v3Jy+5e/eDeNchc/ukmKJi9LuflMIQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.4.tgz", + "integrity": "sha512-XnWYMI7euHlb5a871xPja+Gm7DRCFU+FGRrtS2sMq9N8FvqtpagUy6gD4YOemC5MRk9xbh8+jYMEJbigFQwsgA==", "cpu": [ "loong64" ], @@ -308,9 +328,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.3.tgz", - "integrity": "sha512-vUjxINQu3RC8NZS3ykk1gN65gIz8pAopOq2HXuZhiIxHdx7TFvDG+jgrdSgInu1Eza4/Rfi2VzZgyIgEH4WOaw==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.4.tgz", + "integrity": "sha512-qGDAlO0U8xedCcsdRm9oaoQY8DAx/QT7uIxJWhCdx0ceIWX783UC9QSYkdpzAe29wNiVfp24+bZdQmn49o45SQ==", "cpu": [ "loong64" ], @@ -325,9 +345,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.3.tgz", - "integrity": "sha512-wzko4aJ13+0G3kGnviCg5gnXFKd40izKsrf2uOw12US4XqprkDrmwOpeW14aSNa37V8bfPcz5Fkob6LZ3BAPmA==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.4.tgz", + "integrity": "sha512-ru4H6ezD7ysA5EiEK6qkkaEb4modH8CTej6kUy/gQi20u3kB3G7Zn8snXXkeJSCOFKG/rbPPtM/+9Wgas1961w==", "cpu": [ "ppc64" ], @@ -342,9 +362,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.3.tgz", - "integrity": "sha512-8120ue0JUMSwy11stlwnfdX3pPd+WZYGCDBwEHWtIHi6pOpZmsEF5QKB7a/UN+XFdqvobxz98kv8RTqikyCEBw==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.4.tgz", + "integrity": "sha512-2W4MO5WQVJnbJaZdvDb9rhBDuFU1nKIepPFpJUBsTh2k1YY2g+ODViaWuyOAjQ5cOP7NvrvLzt3wvHOoiAvc7w==", "cpu": [ "ppc64" ], @@ -359,9 +379,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.3.tgz", - "integrity": "sha512-XLFHnR3tXMjbOCh2vtVJHmxt+995uJsTERQyseFDRA0xxMxyTZPLa3OIUlyFaO4mF/Lu0FjmWHCuPXJT1n/IOg==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.4.tgz", + "integrity": "sha512-+fxjfuoAmVMCYV5QyjoIpu0cp5DOiOTeqYFk1AVaxGr+/ravWLX89XfQmptsoWcaVy/TGf2hexzbUOrCQIL1CQ==", "cpu": [ "riscv64" ], @@ -376,9 +396,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.3.tgz", - "integrity": "sha512-se6yXvNGMIl0f+RQzyh7XAmia8/9kplQx424wnG2w0C1oi6XgO6Y8otKhdXFHbHs88Ihavzmvh1NWjuovE76BQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.4.tgz", + "integrity": "sha512-jTn8JfHGL4djjFxPuM06LmNUJDsst2jeVlsd9OmIH6zc5sC9K6rIuO4YajXatLUpBmBKl6b35ro1QZocLi+tcA==", "cpu": [ "riscv64" ], @@ -393,9 +413,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.3.tgz", - "integrity": "sha512-gNoxRefktVIiGflpONuxWWXZAzIQG++z9qHO3xKwk4WdDMuQja3JHGfE1u0i3PfPDyvhypdk+WrgIJqLhGG7sg==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.4.tgz", + "integrity": "sha512-oCJCJL4pXsoDcP2QZ+JVlPTIRc6266zsIaeJJsWImmF7HO0W8nb6HuSgZlMWxJwaPf8ehbSw8yo0EUw925hKsA==", "cpu": [ "s390x" ], @@ -410,9 +430,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.3.tgz", - "integrity": "sha512-V4KtWtQfAFMU7+9/A/VDps/VI8CHd3cYz0L8sgJzz8qK7eY7wI4ruFD82UYIYvW9Z4DtlTfhQcsl4XyPHW5uSg==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.4.tgz", + "integrity": "sha512-W69hukhZ3KKNRCaMIEzKvcFye42hh0FE1+YoYaf5+Ikacuftoco6yO/xouz0hc5d5W/s3yBro5jRiuEE/Q5vUw==", "cpu": [ "x64" ], @@ -427,9 +447,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.3.tgz", - "integrity": "sha512-LBx9LYXvj2CBkMkjLdNAWLwH0MLMin7do2VcVo9kVPibGLkY0BQQut2fv7NVqkXqZ/CrAu9LqDHVV1xHCMpCPw==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.4.tgz", + "integrity": "sha512-qiXbGG2jkjXhzXpsFZSR2Xpb8DN/UaxYsbb/STbuR/6fpaDgRmmaq1B/LmtF2wQFOFOSsK2jdE0RZ3a0zHn4QA==", "cpu": [ "x64" ], @@ -444,9 +464,9 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.3.tgz", - "integrity": "sha512-ABVf3Q0RCu7NcyCCOZQI0pJ3GuSdfSl8EXcy88QtdceIMIoCUdfhsJChZ64L9zVM2aJHjde1Bhn5uqSRcX9ySA==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.4.tgz", + "integrity": "sha512-nWeM//hxv8mIo6jD7Hu4o48DVmV9pbV6gsKaWU+4NFyqHoPKwrkRiZGLKUhOBk8qNmDmpwFtPKg80Bo/Tn4xiQ==", "cpu": [ "x64" ], @@ -458,9 +478,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.3.tgz", - "integrity": "sha512-+2Cy/ldweGBLlPIKsQLF8U5N44a0KDdbrk1rAjHOM9M2K+kGdIVjHLmmrZIcx+9Ny3ke/1JomCsDI1ocb11+sg==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.4.tgz", + "integrity": "sha512-s62SQ/vgsRSvMwDkOEfTqfgASF0f26ZNaQuTA6Aok5lrikf89yI2W0gFHvZb2Jpgc6N8JnOKZgCK2iciO3CsxQ==", "cpu": [ "arm64" ], @@ -472,9 +492,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.3.tgz", - "integrity": "sha512-dtZvzc8BedpSaFNy75x6uiWwAGTH+aZHDtdrqP6qk+WcLJrfti6sGje1ZJ9UxyzDLF23d/mV+PaMwuC0hL7UVA==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.4.tgz", + "integrity": "sha512-J6wGf8TVGbXJq+HH+ttTvrcfNKPbuZecV6KT1B8I18BC5IURUh5kl4Yl5OEP5eFIUoI5BWxCsyYMhFsDx8kekw==", "cpu": [ "arm64" ], @@ -486,9 +506,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.3.tgz", - "integrity": "sha512-Rj8Ra4noo+aYy7sKBggCx0407mws34kAb1ySyWuq5DAtFBQdkSwnsjCgPrhPe9cvgBKZIukpE+CVHvORCS93kQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.4.tgz", + "integrity": "sha512-zmfrQd/0wu6oJs8Vq8KwY/YtsKSsLtKe/HwAP4Wqy8LhWjeT55fHRAkOhYQ12wI3ayS4Tt12d5CDRD7N96SAYQ==", "cpu": [ "ia32" ], @@ -500,9 +520,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.3.tgz", - "integrity": "sha512-vp7N084ew/odXn2gi/mzm9mUkQu9l6AiN6dt4IeUM2Uvm9o+cVmP+YkqbMOteLbiGgqBBlJZjIMYVCfOOIVbVQ==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.4.tgz", + "integrity": "sha512-qPzHqdj9rfUD+w79dtE07zi/kFwKyCJqplp5K5ygeLTp7jLpAoc16OAH39HSmRC9UpozaecsleI8uAdEj6v2yw==", "cpu": [ "x64" ], @@ -514,9 +534,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.3.tgz", - "integrity": "sha512-MOG/3gTOn4Fwf574RVOaY61I5o6P90legkFADiTyn1hyjNydT+cerU2rLUwPdZkKKyJ+iT+K9p7WXK4LM1Ka6g==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.4.tgz", + "integrity": "sha512-zD6NdeWEByGE9QF9vCrlJ5YQB4oq9q91kPZS37Jwj5hOkvR1lTBSpsKhKDw4IJtbQ35LsTS1HD9DZYGKIshU1Q==", "cpu": [ "x64" ], @@ -568,9 +588,9 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz", - "integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==", + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", + "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", "dev": true, "license": "MIT", "dependencies": { @@ -877,9 +897,9 @@ } }, "node_modules/rollup": { - "version": "4.62.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.3.tgz", - "integrity": "sha512-Gu0c0iH9FzgX1L1t7ByIbbS3Vmdz+6KHm/EsqmmC71gUQ82yvZRkTK6XzrFObSka91WUVdynqp6nsfilzr5k6Q==", + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz", + "integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==", "dev": true, "license": "MIT", "dependencies": { @@ -893,31 +913,32 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.62.3", - "@rollup/rollup-android-arm64": "4.62.3", - "@rollup/rollup-darwin-arm64": "4.62.3", - "@rollup/rollup-darwin-x64": "4.62.3", - "@rollup/rollup-freebsd-arm64": "4.62.3", - "@rollup/rollup-freebsd-x64": "4.62.3", - "@rollup/rollup-linux-arm-gnueabihf": "4.62.3", - "@rollup/rollup-linux-arm-musleabihf": "4.62.3", - "@rollup/rollup-linux-arm64-gnu": "4.62.3", - "@rollup/rollup-linux-arm64-musl": "4.62.3", - "@rollup/rollup-linux-loong64-gnu": "4.62.3", - "@rollup/rollup-linux-loong64-musl": "4.62.3", - "@rollup/rollup-linux-ppc64-gnu": "4.62.3", - "@rollup/rollup-linux-ppc64-musl": "4.62.3", - "@rollup/rollup-linux-riscv64-gnu": "4.62.3", - "@rollup/rollup-linux-riscv64-musl": "4.62.3", - "@rollup/rollup-linux-s390x-gnu": "4.62.3", - "@rollup/rollup-linux-x64-gnu": "4.62.3", - "@rollup/rollup-linux-x64-musl": "4.62.3", - "@rollup/rollup-openbsd-x64": "4.62.3", - "@rollup/rollup-openharmony-arm64": "4.62.3", - "@rollup/rollup-win32-arm64-msvc": "4.62.3", - "@rollup/rollup-win32-ia32-msvc": "4.62.3", - "@rollup/rollup-win32-x64-gnu": "4.62.3", - "@rollup/rollup-win32-x64-msvc": "4.62.3", + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.62.4", + "@rollup/rollup-android-arm64": "4.62.4", + "@rollup/rollup-darwin-arm64": "4.62.4", + "@rollup/rollup-darwin-x64": "4.62.4", + "@rollup/rollup-freebsd-arm64": "4.62.4", + "@rollup/rollup-freebsd-x64": "4.62.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.62.4", + "@rollup/rollup-linux-arm-musleabihf": "4.62.4", + "@rollup/rollup-linux-arm64-gnu": "4.62.4", + "@rollup/rollup-linux-arm64-musl": "4.62.4", + "@rollup/rollup-linux-loong64-gnu": "4.62.4", + "@rollup/rollup-linux-loong64-musl": "4.62.4", + "@rollup/rollup-linux-ppc64-gnu": "4.62.4", + "@rollup/rollup-linux-ppc64-musl": "4.62.4", + "@rollup/rollup-linux-riscv64-gnu": "4.62.4", + "@rollup/rollup-linux-riscv64-musl": "4.62.4", + "@rollup/rollup-linux-s390x-gnu": "4.62.4", + "@rollup/rollup-linux-x64-gnu": "4.62.4", + "@rollup/rollup-linux-x64-musl": "4.62.4", + "@rollup/rollup-openbsd-x64": "4.62.4", + "@rollup/rollup-openharmony-arm64": "4.62.4", + "@rollup/rollup-win32-arm64-msvc": "4.62.4", + "@rollup/rollup-win32-ia32-msvc": "4.62.4", + "@rollup/rollup-win32-x64-gnu": "4.62.4", + "@rollup/rollup-win32-x64-msvc": "4.62.4", "fsevents": "~2.3.2" } }, diff --git a/package.json b/package.json index b570cf40..80ea564c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "15.9.0", + "version": "16.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { @@ -40,13 +40,13 @@ "@rollup/plugin-typescript": "12.3.0", "@types/json-bigint": "1.0.4", "playwright": "1.56.1", - "rollup": "4.62.3", + "rollup": "4.62.4", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3" }, "overrides": { - "brace-expansion": "5.0.8" + "brace-expansion": "5.0.9" }, "jsdelivr": "dist/iife/sdk.js", "unpkg": "dist/iife/sdk.js" diff --git a/src/client.ts b/src/client.ts index 3ce8b95f..4e3ffb1d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -396,8 +396,8 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '15.9.0', - 'X-Appwrite-Response-Format': '1.9.5', + 'x-sdk-version': '16.0.0', + 'X-Appwrite-Response-Format': '1.9.6', }; /** diff --git a/src/enums/invalidation-type.ts b/src/enums/invalidation-type.ts new file mode 100644 index 00000000..828f5402 --- /dev/null +++ b/src/enums/invalidation-type.ts @@ -0,0 +1,5 @@ +export enum InvalidationType { + Tag = 'tag', + Path = 'path', + All = 'all', +} \ No newline at end of file diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index b0ac3cdf..a6fd8052 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -97,6 +97,7 @@ export enum ProjectKeyScopes { WafRulesRead = 'wafRules.read', WafRulesWrite = 'wafRules.write', EventsRead = 'events.read', + ProxyInvalidationsWrite = 'proxy.invalidations.write', AppsRead = 'apps.read', AppsWrite = 'apps.write', Oauth2Read = 'oauth2.read', diff --git a/src/enums/query-suggestion-resource.ts b/src/enums/query-suggestion-resource.ts index be2277b2..feb6f5e4 100644 --- a/src/enums/query-suggestion-resource.ts +++ b/src/enums/query-suggestion-resource.ts @@ -67,6 +67,9 @@ export enum QuerySuggestionResource { ShInstallations = 'sh_installations', MigrationDatabases = 'migrationdatabases', MigrationProjects = 'migrationprojects', + AffiliateLinks = 'affiliatelinks', + AffiliateReferrals = 'affiliatereferrals', + AffiliateRewards = 'affiliaterewards', Apps = 'apps', AppSecrets = 'appsecrets', AppInstallations = 'appinstallations', diff --git a/src/enums/usage-event-dimension.ts b/src/enums/usage-event-dimension.ts new file mode 100644 index 00000000..446f977b --- /dev/null +++ b/src/enums/usage-event-dimension.ts @@ -0,0 +1,21 @@ +export enum UsageEventDimension { + Path = 'path', + Method = 'method', + Status = 'status', + Service = 'service', + ResourceType = 'resourceType', + Country = 'country', + ContinentCode = 'continentCode', + City = 'city', + Region = 'region', + Hostname = 'hostname', + Ip = 'ip', + OsName = 'osName', + ClientType = 'clientType', + ClientName = 'clientName', + DeviceName = 'deviceName', + Sdk = 'sdk', + SdkVersion = 'sdkVersion', + TeamId = 'teamId', + ResourceId = 'resourceId', +} \ No newline at end of file diff --git a/src/enums/usage-gauge-dimension.ts b/src/enums/usage-gauge-dimension.ts new file mode 100644 index 00000000..ec8e10a8 --- /dev/null +++ b/src/enums/usage-gauge-dimension.ts @@ -0,0 +1,7 @@ +export enum UsageGaugeDimension { + ResourceId = 'resourceId', + TeamId = 'teamId', + Service = 'service', + ResourceType = 'resourceType', + Ordinal = 'ordinal', +} \ No newline at end of file diff --git a/src/enums/usage-interval.ts b/src/enums/usage-interval.ts new file mode 100644 index 00000000..813d82dc --- /dev/null +++ b/src/enums/usage-interval.ts @@ -0,0 +1,7 @@ +export enum UsageInterval { + OneMinute = '1m', + FifteenMinutes = '15m', + ThirtyMinutes = '30m', + OneHour = '1h', + OneDay = '1d', +} \ No newline at end of file diff --git a/src/enums/usage-order-by.ts b/src/enums/usage-order-by.ts new file mode 100644 index 00000000..7c63910f --- /dev/null +++ b/src/enums/usage-order-by.ts @@ -0,0 +1,4 @@ +export enum UsageOrderBy { + Time = 'time', + Value = 'value', +} \ No newline at end of file diff --git a/src/enums/usage-order-direction.ts b/src/enums/usage-order-direction.ts new file mode 100644 index 00000000..ca39bbb2 --- /dev/null +++ b/src/enums/usage-order-direction.ts @@ -0,0 +1,4 @@ +export enum UsageOrderDirection { + Asc = 'asc', + Desc = 'desc', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6eb9ae16..e200dd7a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ export { Client, Query, AppwriteException } from './client'; export { Account } from './services/account'; export { Activities } from './services/activities'; +export { Affiliates } from './services/affiliates'; export { Apps } from './services/apps'; export { Avatars } from './services/avatars'; export { Backups } from './services/backups'; @@ -16,6 +17,7 @@ export { Console } from './services/console'; export { Databases } from './services/databases'; export { DocumentsDB } from './services/documents-db'; export { Domains } from './services/domains'; +export { Embeddings } from './services/embeddings'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; @@ -78,6 +80,7 @@ export { OrderBy } from './enums/order-by'; export { DocumentsDBIndexType } from './enums/documents-db-index-type'; export { DomainRegistrationType } from './enums/domain-registration-type'; export { DomainSuggestionType } from './enums/domain-suggestion-type'; +export { EmbeddingModel } from './enums/embedding-model'; export { Runtime } from './enums/runtime'; export { ProjectKeyScopes } from './enums/project-key-scopes'; export { FunctionTemplateUseCase } from './enums/function-template-use-case'; @@ -111,6 +114,7 @@ export { ProjectSMTPSecure } from './enums/project-smtp-secure'; export { ProjectUsageRange } from './enums/project-usage-range'; export { ScheduleResourceType } from './enums/schedule-resource-type'; export { Status } from './enums/status'; +export { InvalidationType } from './enums/invalidation-type'; export { StatusCode } from './enums/status-code'; export { ProxyResourceType } from './enums/proxy-resource-type'; export { Framework } from './enums/framework'; @@ -120,10 +124,14 @@ export { SiteTemplateUseCase } from './enums/site-template-use-case'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; export { TablesDBIndexType } from './enums/tables-db-index-type'; +export { UsageInterval } from './enums/usage-interval'; +export { UsageEventDimension } from './enums/usage-event-dimension'; +export { UsageOrderBy } from './enums/usage-order-by'; +export { UsageOrderDirection } from './enums/usage-order-direction'; +export { UsageGaugeDimension } from './enums/usage-gauge-dimension'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; export { VCSDetectionType } from './enums/vcs-detection-type'; -export { EmbeddingModel } from './enums/embedding-model'; export { VectorsDBIndexType } from './enums/vectors-db-index-type'; export { DatabaseType } from './enums/database-type'; export { DatabaseStatus } from './enums/database-status'; diff --git a/src/models.ts b/src/models.ts index 8b48f119..f67829bb 100644 --- a/src/models.ts +++ b/src/models.ts @@ -7363,35 +7363,35 @@ export namespace Models { /** * Aggregated number of text embedding calls per period. */ - embeddingsText: Metric; + embeddingsText: Metric[]; /** * Aggregated number of tokens processed by text embeddings per period. */ - embeddingsTextTokens: Metric; + embeddingsTextTokens: Metric[]; /** * Aggregated duration spent generating text embeddings per period. */ - embeddingsTextDuration: Metric; + embeddingsTextDuration: Metric[]; /** * Aggregated number of errors while generating text embeddings per period. */ - embeddingsTextErrors: Metric; + embeddingsTextErrors: Metric[]; /** * Total aggregated number of text embedding calls. */ - embeddingsTextTotal: Metric; + embeddingsTextTotal: number; /** * Total aggregated number of tokens processed by text. */ - embeddingsTextTokensTotal: Metric; + embeddingsTextTokensTotal: number; /** * Total aggregated duration spent generating text embeddings. */ - embeddingsTextDurationTotal: Metric; + embeddingsTextDurationTotal: number; /** * Total aggregated number of errors while generating text embeddings. */ - embeddingsTextErrorsTotal: Metric; + embeddingsTextErrorsTotal: number; /** * Aggregated number of function executions per period. */ @@ -8784,6 +8784,170 @@ export namespace Models { billingCycleEnd: string; } + /** + * AffiliateLink + */ + export type AffiliateLink = { + /** + * Link ID. This is the shareable referral code. + */ + $id: string; + /** + * Link creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Link update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User ID of the link owner. + */ + userId: string; + /** + * Optional link name. + */ + name: string; + /** + * Link status. Can be one of `active` or `disabled`. + */ + status: string; + } + + /** + * Affiliate links list + */ + export type AffiliateLinkList = { + /** + * Total number of links that matched your query. + */ + total: number; + /** + * List of links. + */ + links: AffiliateLink[]; + } + + /** + * AffiliateReferral + */ + export type AffiliateReferral = { + /** + * Referral ID. + */ + $id: string; + /** + * Referral creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Referral update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Affiliate link ID used for attribution. + */ + linkId: string; + /** + * Privacy-safe truncated referred user ID. + */ + referredUserMaskedId: string; + /** + * ISO 3166-1 alpha-2 country code of the referred user at signup, when available. + */ + referredUserCountry: string; + /** + * Referral status. Can be one of `pending`, `converted`, or `expired`. `expired` is derived from `expiresAt` when still pending. + */ + status: string; + /** + * Attribution time in ISO 8601 format. + */ + attributedAt: string; + /** + * Attribution expiry time in ISO 8601 format. + */ + expiresAt: string; + /** + * Conversion time in ISO 8601 format. + */ + convertedAt?: string; + } + + /** + * Affiliate referrals list + */ + export type AffiliateReferralList = { + /** + * Total number of referrals that matched your query. + */ + total: number; + /** + * List of referrals. + */ + referrals: AffiliateReferral[]; + } + + /** + * AffiliateReward + */ + export type AffiliateReward = { + /** + * Reward ID. + */ + $id: string; + /** + * Reward creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Reward update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User ID of the reward owner. + */ + userId: string; + /** + * Affiliate link ID that earned this reward. + */ + linkId: string; + /** + * Referral ID that earned this reward. + */ + referralId: string; + /** + * Reward amount in USD. + */ + amount: number; + /** + * Reward status. Can be one of `pending` or `claimed`. + */ + status: string; + /** + * Organization ID the reward was claimed on. + */ + teamId?: string; + /** + * Credit document ID created when the reward was claimed. + */ + creditId?: string; + } + + /** + * Affiliate rewards list + */ + export type AffiliateRewardList = { + /** + * Total number of rewards that matched your query. + */ + total: number; + /** + * List of rewards. + */ + rewards: AffiliateReward[]; + } + /** * Breakdown */ @@ -9223,7 +9387,7 @@ export namespace Models { /** * Members */ - members: number; + members?: number; /** * Webhooks */ @@ -9319,7 +9483,7 @@ export namespace Models { /** * Activity log days */ - activityLogs: number; + activityLogs?: number; /** * Usage history days */ @@ -9415,7 +9579,7 @@ export namespace Models { /** * Does plan support backup policies. */ - backupsEnabled: boolean; + backupsEnabled?: boolean; /** * Whether usage addons are calculated per project. */ @@ -9427,7 +9591,7 @@ export namespace Models { /** * How many policies does plan support */ - backupPolicies: number; + backupPolicies?: number; /** * Maximum function and site deployment size in MB */ @@ -9465,11 +9629,11 @@ export namespace Models { /** * Addon seats */ - seats: BillingPlanAddonDetails; + seats?: BillingPlanAddonDetails; /** * Addon projects */ - projects: BillingPlanAddonDetails; + projects?: BillingPlanAddonDetails; } /** @@ -9495,7 +9659,7 @@ export namespace Models { /** * Price currency */ - currency: string; + currency?: string; /** * Price */ @@ -10017,7 +10181,7 @@ export namespace Models { */ api: string; /** - * Database engine: postgresql, mysql, or mongodb. + * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ engine: string; /** @@ -10445,9 +10609,9 @@ export namespace Models { */ renewalPrice: number; /** - * Transfer status for domains being transferred in. + * Transfer status for domains being transferred in. Null when the domain is not being transferred. */ - transferStatus: DomainTransferStatusEnum; + transferStatus?: DomainTransferStatusEnum; /** * Team ID. */ @@ -10795,9 +10959,9 @@ export namespace Models { */ status: string; /** - * Replication lag in seconds. + * Replication lag in seconds. Null when the lag is not known: a primary has none to report, and a member the backend has not probed has none yet. */ - lagSeconds: number; + lagSeconds?: number; } /** @@ -10902,6 +11066,28 @@ export namespace Models { members: DedicatedDatabaseMember[]; } + /** + * Invalidation + */ + export type ProxyInvalidation = { + /** + * Domain name. + */ + domain: string; + /** + * Invalidation type. Possible values are "tag", "path", or "all". + */ + type: string; + /** + * Invalidated reference. Depending on type this is a cache tag name, a URL path, or empty when type is all. + */ + reference: string; + /** + * Invalidation status. + */ + status: string; + } + /** * Invoice */ @@ -11029,9 +11215,9 @@ export namespace Models { */ prefs: Preferences; /** - * Project budget limit + * Project budget limit. Null when no budget is set. */ - billingBudget: number; + billingBudget?: number; /** * Project budget limit */ @@ -11067,7 +11253,7 @@ export namespace Models { /** * Start date of trial. */ - billingTrialStartDate: string; + billingTrialStartDate?: string; /** * Number of trial days. */ @@ -11087,11 +11273,11 @@ export namespace Models { /** * Default payment method. */ - billingAddressId: string; + billingAddressId?: string; /** * Backup payment method. */ - backupPaymentMethodId: string; + backupPaymentMethodId?: string; /** * Team status. */ @@ -11099,27 +11285,27 @@ export namespace Models { /** * Remarks on team status. */ - remarks: string; + remarks?: string; /** * Organization agreements */ - agreementBAA: string; + agreementBAA?: string; /** * Program manager's name. */ - programManagerName: string; + programManagerName?: string; /** * Program manager's calendar link. */ - programManagerCalendar: string; + programManagerCalendar?: string; /** * Program's discord channel name. */ - programDiscordChannelName: string; + programDiscordChannelName?: string; /** * Program's discord channel URL. */ - programDiscordChannelUrl: string; + programDiscordChannelUrl?: string; /** * Billing limits reached */ @@ -11127,11 +11313,11 @@ export namespace Models { /** * Billing plan selected for downgrade. */ - billingPlanDowngrade: string; + billingPlanDowngrade?: string; /** * Tax Id */ - billingTaxId: string; + billingTaxId?: string; /** * Marked for deletion */ @@ -11633,9 +11819,9 @@ export namespace Models { */ name: string; /** - * Does the organization have access to this region. + * Does the organization have access to this region. Null when access has not been resolved. */ - available: boolean; + available?: boolean; /** * Does the backend support this region. */ @@ -11909,7 +12095,7 @@ export namespace Models { /** * Member additional resources */ - member: AdditionalResource; + member?: AdditionalResource; /** * Realtime additional resources */ @@ -11921,7 +12107,7 @@ export namespace Models { /** * Realtime bandwidth additional resources */ - realtimeBandwidth: AdditionalResource; + realtimeBandwidth?: AdditionalResource; /** * Storage additional resources */ @@ -11941,7 +12127,7 @@ export namespace Models { /** * Credits additional resources */ - credits: AdditionalResource; + credits?: AdditionalResource; } /** @@ -12061,7 +12247,7 @@ export namespace Models { */ resourceType?: string; /** - * Replica ordinal when broken down by `ordinal`. 0 is the primary; 1+ are replicas. + * Node ordinal when broken down by `ordinal`. A stable per-node identity, not a role: ordinal 0 is the first member created, and a failover can leave the primary on any ordinal. Read the role from the database's replicas endpoint. */ ordinal?: string; } diff --git a/src/services/account.ts b/src/services/account.ts index ad38e33a..9ada6e92 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -3735,7 +3735,7 @@ export class Account { /** * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. * - * @param {string} params.sessionId - Session ID. Use the string 'current' to get the current device session. + * @param {string} params.sessionId - Session ID. Use the string 'current' to get the current device session. Defaults to 'current'. * @throws {AppwriteException} * @returns {Promise} */ @@ -3743,7 +3743,7 @@ export class Account { /** * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. * - * @param {string} sessionId - Session ID. Use the string 'current' to get the current device session. + * @param {string} sessionId - Session ID. Use the string 'current' to get the current device session. Defaults to 'current'. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3788,7 +3788,7 @@ export class Account { /** * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * - * @param {string} params.sessionId - Session ID. Use the string 'current' to update the current device session. + * @param {string} params.sessionId - Session ID. Use the string 'current' to update the current device session. Defaults to 'current'. * @throws {AppwriteException} * @returns {Promise} */ @@ -3796,7 +3796,7 @@ export class Account { /** * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * - * @param {string} sessionId - Session ID. Use the string 'current' to update the current device session. + * @param {string} sessionId - Session ID. Use the string 'current' to update the current device session. Defaults to 'current'. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3842,7 +3842,7 @@ export class Account { /** * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * - * @param {string} params.sessionId - Session ID. Use the string 'current' to delete the current device session. + * @param {string} params.sessionId - Session ID. Use the string 'current' to delete the current device session. Defaults to 'current'. * @throws {AppwriteException} * @returns {Promise<{}>} */ @@ -3850,7 +3850,7 @@ export class Account { /** * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * - * @param {string} sessionId - Session ID. Use the string 'current' to delete the current device session. + * @param {string} sessionId - Session ID. Use the string 'current' to delete the current device session. Defaults to 'current'. * @throws {AppwriteException} * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. diff --git a/src/services/affiliates.ts b/src/services/affiliates.ts new file mode 100644 index 00000000..a6ac11ff --- /dev/null +++ b/src/services/affiliates.ts @@ -0,0 +1,432 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Affiliates { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List affiliate links for the current account. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, status + * @throws {AppwriteException} + * @returns {Promise} + */ + listLinks(params?: { queries?: string[] }): Promise; + /** + * List affiliate links for the current account. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, status + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listLinks(queries?: string[]): Promise; + listLinks( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/affiliates/links'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a shareable affiliate link for the current account. Every console user is automatically in the affiliates program. + * + * + * @param {string} params.linkId - Link 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. This ID is the shareable referral code. + * @param {string} params.name - Link name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createLink(params: { linkId: string, name?: string }): Promise; + /** + * Create a shareable affiliate link for the current account. Every console user is automatically in the affiliates program. + * + * + * @param {string} linkId - Link 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. This ID is the shareable referral code. + * @param {string} name - Link name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLink(linkId: string, name?: string): Promise; + createLink( + paramsOrFirst: { linkId: string, name?: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { linkId: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { linkId: string, name?: string }; + } else { + params = { + linkId: paramsOrFirst as string, + name: rest[0] as string + }; + } + + const linkId = params.linkId; + const name = params.name; + + if (typeof linkId === 'undefined') { + throw new AppwriteException('Missing required parameter: "linkId"'); + } + + const apiPath = '/affiliates/links'; + const payload: Payload = {}; + if (typeof linkId !== 'undefined') { + payload['linkId'] = linkId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a single affiliate link owned by the current account. + * + * + * @param {string} params.linkId - Link ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getLink(params: { linkId: string }): Promise; + /** + * Get a single affiliate link owned by the current account. + * + * + * @param {string} linkId - Link ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getLink(linkId: string): Promise; + getLink( + paramsOrFirst: { linkId: string } | string + ): Promise { + let params: { linkId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { linkId: string }; + } else { + params = { + linkId: paramsOrFirst as string + }; + } + + const linkId = params.linkId; + + if (typeof linkId === 'undefined') { + throw new AppwriteException('Missing required parameter: "linkId"'); + } + + const apiPath = '/affiliates/links/{linkId}'.replace('{linkId}', encodeURIComponent(String(linkId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an affiliate link owned by the current account. Existing referrals and rewards keep their stored link IDs for history. + * + * + * @param {string} params.linkId - Link ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteLink(params: { linkId: string }): Promise<{}>; + /** + * Delete an affiliate link owned by the current account. Existing referrals and rewards keep their stored link IDs for history. + * + * + * @param {string} linkId - Link ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteLink(linkId: string): Promise<{}>; + deleteLink( + paramsOrFirst: { linkId: string } | string + ): Promise<{}> { + let params: { linkId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { linkId: string }; + } else { + params = { + linkId: paramsOrFirst as string + }; + } + + const linkId = params.linkId; + + if (typeof linkId === 'undefined') { + throw new AppwriteException('Missing required parameter: "linkId"'); + } + + const apiPath = '/affiliates/links/{linkId}'.replace('{linkId}', encodeURIComponent(String(linkId))); + const payload: 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, + payload + ); + } + + /** + * List referrals attributed to the current account's affiliate links. Responses include privacy-safe metadata only (truncated user ID and signup country), never email or name. Referrals are created automatically on signup when the invite cookie is present. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referredUserMaskedId, referredUserCountry, status, attributedAt, expiresAt, convertedAt + * @throws {AppwriteException} + * @returns {Promise} + */ + listReferrals(params?: { queries?: string[] }): Promise; + /** + * List referrals attributed to the current account's affiliate links. Responses include privacy-safe metadata only (truncated user ID and signup country), never email or name. Referrals are created automatically on signup when the invite cookie is present. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referredUserMaskedId, referredUserCountry, status, attributedAt, expiresAt, convertedAt + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listReferrals(queries?: string[]): Promise; + listReferrals( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/affiliates/referrals'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * List rewards earned by the current account from affiliate link conversions. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referralId, amount, status, teamId, creditId + * @throws {AppwriteException} + * @returns {Promise} + */ + listRewards(params?: { queries?: string[] }): Promise; + /** + * List rewards earned by the current account from affiliate link conversions. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referralId, amount, status, teamId, creditId + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRewards(queries?: string[]): Promise; + listRewards( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/affiliates/rewards'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Claim a pending affiliate reward by setting its status to `claimed`. Creates organization credits for the target organization. The current user must be an owner of that organization. + * + * + * @param {string} params.rewardId - Reward ID + * @param {string} params.status - New reward status. Use `claimed` to claim the reward as organization credits. + * @param {string} params.organizationId - Organization ID to apply credits to when claiming. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateReward(params: { rewardId: string, status: string, organizationId: string }): Promise; + /** + * Claim a pending affiliate reward by setting its status to `claimed`. Creates organization credits for the target organization. The current user must be an owner of that organization. + * + * + * @param {string} rewardId - Reward ID + * @param {string} status - New reward status. Use `claimed` to claim the reward as organization credits. + * @param {string} organizationId - Organization ID to apply credits to when claiming. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateReward(rewardId: string, status: string, organizationId: string): Promise; + updateReward( + paramsOrFirst: { rewardId: string, status: string, organizationId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { rewardId: string, status: string, organizationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { rewardId: string, status: string, organizationId: string }; + } else { + params = { + rewardId: paramsOrFirst as string, + status: rest[0] as string, + organizationId: rest[1] as string + }; + } + + const rewardId = params.rewardId; + const status = params.status; + const organizationId = params.organizationId; + + if (typeof rewardId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rewardId"'); + } + if (typeof status === 'undefined') { + throw new AppwriteException('Missing required parameter: "status"'); + } + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + const apiPath = '/affiliates/rewards/{rewardId}'.replace('{rewardId}', encodeURIComponent(String(rewardId))); + const payload: Payload = {}; + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof organizationId !== 'undefined') { + payload['organizationId'] = organizationId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } +} diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts new file mode 100644 index 00000000..7eac1e80 --- /dev/null +++ b/src/services/embeddings.ts @@ -0,0 +1,80 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { EmbeddingModel } from '../enums/embedding-model'; + +export class Embeddings { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. + * + * + * @param {string[]} params.texts - Array of text to generate embeddings. + * @param {EmbeddingModel} params.model - The embedding model to use for generating vector embeddings. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTextEmbeddings(params: { texts: string[], model?: EmbeddingModel }): Promise; + /** + * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. + * + * + * @param {string[]} texts - Array of text to generate embeddings. + * @param {EmbeddingModel} model - The embedding model to use for generating vector embeddings. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTextEmbeddings(texts: string[], model?: EmbeddingModel): Promise; + createTextEmbeddings( + paramsOrFirst: { texts: string[], model?: EmbeddingModel } | string[], + ...rest: [(EmbeddingModel)?] + ): Promise { + let params: { texts: string[], model?: EmbeddingModel }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { texts: string[], model?: EmbeddingModel }; + } else { + params = { + texts: paramsOrFirst as string[], + model: rest[0] as EmbeddingModel + }; + } + + const texts = params.texts; + const model = params.model; + + if (typeof texts === 'undefined') { + throw new AppwriteException('Missing required parameter: "texts"'); + } + + const apiPath = '/embeddings/text'; + const payload: Payload = {}; + if (typeof texts !== 'undefined') { + payload['texts'] = texts; + } + if (typeof model !== 'undefined') { + payload['model'] = model; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } +} diff --git a/src/services/proxy.ts b/src/services/proxy.ts index ebbebdc5..0ec94aee 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -2,6 +2,7 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { InvalidationType } from '../enums/invalidation-type'; import { StatusCode } from '../enums/status-code'; import { ProxyResourceType } from '../enums/proxy-resource-type'; @@ -12,6 +13,85 @@ export class Proxy { this.client = client; } + /** + * Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. + * + * Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. + * + * @param {string} params.domain - Domain name. + * @param {InvalidationType} params.type - Type of reference passed. Allowed values are: tag, path, all + * @param {string} params.reference - Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. + * @throws {AppwriteException} + * @returns {Promise} + */ + createInvalidation(params: { domain: string, type: InvalidationType, reference?: string }): Promise; + /** + * Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. + * + * Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. + * + * @param {string} domain - Domain name. + * @param {InvalidationType} type - Type of reference passed. Allowed values are: tag, path, all + * @param {string} reference - Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createInvalidation(domain: string, type: InvalidationType, reference?: string): Promise; + createInvalidation( + paramsOrFirst: { domain: string, type: InvalidationType, reference?: string } | string, + ...rest: [(InvalidationType)?, (string)?] + ): Promise { + let params: { domain: string, type: InvalidationType, reference?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, type: InvalidationType, reference?: string }; + } else { + params = { + domain: paramsOrFirst as string, + type: rest[0] as InvalidationType, + reference: rest[1] as string + }; + } + + const domain = params.domain; + const type = params.type; + const reference = params.reference; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/proxy/invalidations'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * Get a list of all the proxy rules. You can use the query params to filter your results. * diff --git a/src/services/usage.ts b/src/services/usage.ts index ebc66e68..99ca3ae7 100644 --- a/src/services/usage.ts +++ b/src/services/usage.ts @@ -2,6 +2,11 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { UsageInterval } from '../enums/usage-interval'; +import { UsageEventDimension } from '../enums/usage-event-dimension'; +import { UsageOrderBy } from '../enums/usage-order-by'; +import { UsageOrderDirection } from '../enums/usage-order-direction'; +import { UsageGaugeDimension } from '../enums/usage-gauge-dimension'; export class Usage { client: Client; @@ -19,20 +24,20 @@ export class Usage { * * `dimensions[]` breaks each point down by one or more attributes (service, path, status, country, …). `queries[]` filters the underlying events using the standard Utopia query syntax — `equal("path", ["/v1/storage/files"])`, `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `startsWith("path", ["/v1/storage"])`, `equal("status", ["200", "201"])`, `isNotNull("resourceId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `contains`, `startsWith`, `endsWith`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N by aggregated value. When `startAt` is omitted, the default window adapts to `interval` (or 7d when interval is omitted). * - * @param {string[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. + * @param {string[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. On console: `metrics[]=affiliates.clicks`. * @param {string[]} params.queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: path, method, status, service, resourceType, resourceId, teamId, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion. Allowed methods: equal, notEqual, contains, startsWith, endsWith, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. - * @param {string} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {string[]} params.dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId. + * @param {UsageInterval} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. + * @param {UsageEventDimension[]} params.dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId. * @param {string} params.startAt - Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). * @param {string} params.endAt - Range end in ISO 8601. Defaults to the current time. - * @param {string} params.orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. - * @param {string} params.orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, returns the most recent / highest-value groups first. + * @param {UsageOrderBy} params.orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. + * @param {UsageOrderDirection} params.orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, returns the most recent / highest-value groups first. * @param {number} params.limit - Maximum rows to return (1-5000). * @param {number} params.offset - Pagination offset (0-100000). * @throws {AppwriteException} * @returns {Promise} */ - listEvents(params: { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number }): Promise; + listEvents(params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }): Promise; /** * Aggregate usage event metrics. `metrics[]` (1-10) is required; the response always contains one entry per requested metric, each with its own `points[]` time series. * @@ -42,39 +47,39 @@ export class Usage { * * `dimensions[]` breaks each point down by one or more attributes (service, path, status, country, …). `queries[]` filters the underlying events using the standard Utopia query syntax — `equal("path", ["/v1/storage/files"])`, `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `startsWith("path", ["/v1/storage"])`, `equal("status", ["200", "201"])`, `isNotNull("resourceId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `contains`, `startsWith`, `endsWith`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N by aggregated value. When `startAt` is omitted, the default window adapts to `interval` (or 7d when interval is omitted). * - * @param {string[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. + * @param {string[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. On console: `metrics[]=affiliates.clicks`. * @param {string[]} queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: path, method, status, service, resourceType, resourceId, teamId, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion. Allowed methods: equal, notEqual, contains, startsWith, endsWith, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. - * @param {string} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {string[]} dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId. + * @param {UsageInterval} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. + * @param {UsageEventDimension[]} dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId. * @param {string} startAt - Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). * @param {string} endAt - Range end in ISO 8601. Defaults to the current time. - * @param {string} orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. - * @param {string} orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, returns the most recent / highest-value groups first. + * @param {UsageOrderBy} orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. + * @param {UsageOrderDirection} orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, returns the most recent / highest-value groups first. * @param {number} limit - Maximum rows to return (1-5000). * @param {number} offset - Pagination offset (0-100000). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listEvents(metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number): Promise; + listEvents(metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number): Promise; listEvents( - paramsOrFirst: { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number } | string[], - ...rest: [(string[])?, (string)?, (string[])?, (string)?, (string)?, (string)?, (string)?, (number)?, (number)?] + paramsOrFirst: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number } | string[], + ...rest: [(string[])?, (UsageInterval)?, (UsageEventDimension[])?, (string)?, (string)?, (UsageOrderBy)?, (UsageOrderDirection)?, (number)?, (number)?] ): Promise { - let params: { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number }; + let params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number }; + params = (paramsOrFirst || {}) as { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; } else { params = { metrics: paramsOrFirst as string[], queries: rest[0] as string[], - interval: rest[1] as string, - dimensions: rest[2] as string[], + interval: rest[1] as UsageInterval, + dimensions: rest[2] as UsageEventDimension[], startAt: rest[3] as string, endAt: rest[4] as string, - orderBy: rest[5] as string, - orderDir: rest[6] as string, + orderBy: rest[5] as UsageOrderBy, + orderDir: rest[6] as UsageOrderDirection, limit: rest[7] as number, offset: rest[8] as number }; @@ -151,22 +156,22 @@ export class Usage { * - Omit `interval` for a flat top-N table — `argMax(value, time)` per dimension combination over the whole window, no time axis. Useful for "top 10 resources by current storage". * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one snapshot per (time bucket × dimension combination). * - * `dimensions[]` breaks each point down further. Supported on gauges: `resourceId`, `teamId`, `service`, `resourceType`, `ordinal`. `service` and `resourceType` enable per-service / per-resource-type panels (e.g. storage-by-service: group `files.storage`, `deployments.storage`, `builds.storage`, `databases.storage` by `service`). `ordinal` separates per-node series for multi-node resources such as dedicated databases (0 is the primary; 1+ are replicas). `queries[]` filters the underlying rows using the standard Utopia query syntax — `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `equal("teamId", ["team_x"])`, `equal("ordinal", ["0"])`, `isNotNull("teamId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). + * `dimensions[]` breaks each point down further. Supported on gauges: `resourceId`, `teamId`, `service`, `resourceType`, `ordinal`. `service` and `resourceType` enable per-service / per-resource-type panels (e.g. storage-by-service: group `files.storage`, `deployments.storage`, `builds.storage`, `databases.storage` by `service`). `ordinal` separates per-node series for multi-node resources such as dedicated databases. It is a stable per-node identity, not a role — ordinal 0 is the first member created, and a failover can leave the primary on any ordinal, so read the role from the database's replicas endpoint rather than inferring it here. `queries[]` filters the underlying rows using the standard Utopia query syntax — `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `equal("teamId", ["team_x"])`, `equal("ordinal", ["0"])`, `isNotNull("teamId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). * * @param {string[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=files.storage` or `metrics[]=files.storage&metrics[]=deployments.storage` for stacked charts. * @param {string[]} params.queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: service, resourceType, resourceId, teamId, ordinal. Allowed methods: equal, notEqual, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. - * @param {string} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {string[]} params.dimensions - Break-down dimensions. Allowed: resourceId, teamId, service, resourceType, ordinal. + * @param {UsageInterval} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. + * @param {UsageGaugeDimension[]} params.dimensions - Break-down dimensions. Allowed: resourceId, teamId, service, resourceType, ordinal. * @param {string} params.startAt - Range start in ISO 8601. Defaults to endAt - 7d. * @param {string} params.endAt - Range end in ISO 8601. Defaults to the current time. - * @param {string} params.orderBy - Column to order by. Allowed: time, value. Default time. - * @param {string} params.orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. + * @param {UsageOrderBy} params.orderBy - Column to order by. Allowed: time, value. Default time. + * @param {UsageOrderDirection} params.orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. * @param {number} params.limit - Maximum rows to return (1-5000). * @param {number} params.offset - Pagination offset (0-100000). * @throws {AppwriteException} * @returns {Promise} */ - listGauges(params: { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number }): Promise; + listGauges(params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }): Promise; /** * Aggregate usage gauge snapshots. Gauges are point-in-time values (storage totals, resource counts, …); each point carries the latest snapshot in its interval via `argMax(value, time)`. `metrics[]` (1-10) is required; the response always contains one entry per requested metric, each with its own `points[]` time series. * @@ -176,41 +181,41 @@ export class Usage { * - Omit `interval` for a flat top-N table — `argMax(value, time)` per dimension combination over the whole window, no time axis. Useful for "top 10 resources by current storage". * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one snapshot per (time bucket × dimension combination). * - * `dimensions[]` breaks each point down further. Supported on gauges: `resourceId`, `teamId`, `service`, `resourceType`, `ordinal`. `service` and `resourceType` enable per-service / per-resource-type panels (e.g. storage-by-service: group `files.storage`, `deployments.storage`, `builds.storage`, `databases.storage` by `service`). `ordinal` separates per-node series for multi-node resources such as dedicated databases (0 is the primary; 1+ are replicas). `queries[]` filters the underlying rows using the standard Utopia query syntax — `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `equal("teamId", ["team_x"])`, `equal("ordinal", ["0"])`, `isNotNull("teamId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). + * `dimensions[]` breaks each point down further. Supported on gauges: `resourceId`, `teamId`, `service`, `resourceType`, `ordinal`. `service` and `resourceType` enable per-service / per-resource-type panels (e.g. storage-by-service: group `files.storage`, `deployments.storage`, `builds.storage`, `databases.storage` by `service`). `ordinal` separates per-node series for multi-node resources such as dedicated databases. It is a stable per-node identity, not a role — ordinal 0 is the first member created, and a failover can leave the primary on any ordinal, so read the role from the database's replicas endpoint rather than inferring it here. `queries[]` filters the underlying rows using the standard Utopia query syntax — `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `equal("teamId", ["team_x"])`, `equal("ordinal", ["0"])`, `isNotNull("teamId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). * * @param {string[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=files.storage` or `metrics[]=files.storage&metrics[]=deployments.storage` for stacked charts. * @param {string[]} queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: service, resourceType, resourceId, teamId, ordinal. Allowed methods: equal, notEqual, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. - * @param {string} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {string[]} dimensions - Break-down dimensions. Allowed: resourceId, teamId, service, resourceType, ordinal. + * @param {UsageInterval} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. + * @param {UsageGaugeDimension[]} dimensions - Break-down dimensions. Allowed: resourceId, teamId, service, resourceType, ordinal. * @param {string} startAt - Range start in ISO 8601. Defaults to endAt - 7d. * @param {string} endAt - Range end in ISO 8601. Defaults to the current time. - * @param {string} orderBy - Column to order by. Allowed: time, value. Default time. - * @param {string} orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. + * @param {UsageOrderBy} orderBy - Column to order by. Allowed: time, value. Default time. + * @param {UsageOrderDirection} orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. * @param {number} limit - Maximum rows to return (1-5000). * @param {number} offset - Pagination offset (0-100000). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listGauges(metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number): Promise; + listGauges(metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number): Promise; listGauges( - paramsOrFirst: { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number } | string[], - ...rest: [(string[])?, (string)?, (string[])?, (string)?, (string)?, (string)?, (string)?, (number)?, (number)?] + paramsOrFirst: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number } | string[], + ...rest: [(string[])?, (UsageInterval)?, (UsageGaugeDimension[])?, (string)?, (string)?, (UsageOrderBy)?, (UsageOrderDirection)?, (number)?, (number)?] ): Promise { - let params: { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number }; + let params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { metrics: string[], queries?: string[], interval?: string, dimensions?: string[], startAt?: string, endAt?: string, orderBy?: string, orderDir?: string, limit?: number, offset?: number }; + params = (paramsOrFirst || {}) as { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; } else { params = { metrics: paramsOrFirst as string[], queries: rest[0] as string[], - interval: rest[1] as string, - dimensions: rest[2] as string[], + interval: rest[1] as UsageInterval, + dimensions: rest[2] as UsageGaugeDimension[], startAt: rest[3] as string, endAt: rest[4] as string, - orderBy: rest[5] as string, - orderDir: rest[6] as string, + orderBy: rest[5] as UsageOrderBy, + orderDir: rest[6] as UsageOrderDirection, limit: rest[7] as number, offset: rest[8] as number }; diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 4cc229f3..99c337d6 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -2,7 +2,6 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { EmbeddingModel } from '../enums/embedding-model'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; import { OrderBy } from '../enums/order-by'; @@ -172,73 +171,6 @@ export class VectorsDB { ); } - /** - * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. - * - * - * @param {string[]} params.texts - Array of text to generate embeddings. - * @param {EmbeddingModel} params.model - The embedding model to use for generating vector embeddings. - * @throws {AppwriteException} - * @returns {Promise} - */ - createTextEmbeddings(params: { texts: string[], model?: EmbeddingModel }): Promise; - /** - * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. - * - * - * @param {string[]} texts - Array of text to generate embeddings. - * @param {EmbeddingModel} model - The embedding model to use for generating vector embeddings. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createTextEmbeddings(texts: string[], model?: EmbeddingModel): Promise; - createTextEmbeddings( - paramsOrFirst: { texts: string[], model?: EmbeddingModel } | string[], - ...rest: [(EmbeddingModel)?] - ): Promise { - let params: { texts: string[], model?: EmbeddingModel }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { texts: string[], model?: EmbeddingModel }; - } else { - params = { - texts: paramsOrFirst as string[], - model: rest[0] as EmbeddingModel - }; - } - - const texts = params.texts; - const model = params.model; - - if (typeof texts === 'undefined') { - throw new AppwriteException('Missing required parameter: "texts"'); - } - - const apiPath = '/vectorsdb/embeddings/text'; - const payload: Payload = {}; - if (typeof texts !== 'undefined') { - payload['texts'] = texts; - } - if (typeof model !== 'undefined') { - payload['model'] = model; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - 'accept': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); - } - /** * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. * From 33fea68b3680e91bf556c9a239fe3a7692aa7393 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 17 Sep 2026 15:44:31 +0100 Subject: [PATCH 06/10] chore: update Console SDK to 16.1.0 --- .prettierignore | 13 + .prettierrc | 4 + CHANGELOG.md | 20 + README.md | 11 +- dist/cjs/package.json | 2 +- dist/esm/package.json | 2 +- .../account/create-anonymous-session.md | 2 +- .../account/create-billing-address.md | 4 +- .../account/create-email-password-session.md | 4 +- docs/examples/account/create-email-token.md | 4 +- .../account/create-email-verification.md | 4 +- docs/examples/account/create-jwt.md | 4 +- docs/examples/account/create-key.md | 4 +- .../account/create-magic-url-token.md | 4 +- .../account/create-mfa-authenticator.md | 4 +- docs/examples/account/create-mfa-challenge.md | 4 +- .../account/create-mfa-recovery-codes.md | 2 +- .../account/create-o-auth-2-session.md | 5 +- .../examples/account/create-o-auth-2-token.md | 5 +- .../examples/account/create-payment-method.md | 2 +- docs/examples/account/create-phone-token.md | 4 +- .../account/create-phone-verification.md | 2 +- docs/examples/account/create-push-target.md | 4 +- docs/examples/account/create-recovery.md | 4 +- docs/examples/account/create-session.md | 4 +- docs/examples/account/create-verification.md | 4 +- docs/examples/account/create.md | 4 +- .../account/delete-billing-address.md | 4 +- docs/examples/account/delete-consent-token.md | 4 +- docs/examples/account/delete-consent.md | 4 +- docs/examples/account/delete-identity.md | 4 +- docs/examples/account/delete-key.md | 4 +- .../account/delete-mfa-authenticator.md | 4 +- .../examples/account/delete-payment-method.md | 4 +- docs/examples/account/delete-push-target.md | 4 +- docs/examples/account/delete-session.md | 4 +- docs/examples/account/delete-sessions.md | 2 +- docs/examples/account/delete.md | 2 +- docs/examples/account/get-billing-address.md | 4 +- docs/examples/account/get-consent-token.md | 4 +- docs/examples/account/get-consent.md | 4 +- docs/examples/account/get-coupon.md | 4 +- docs/examples/account/get-key.md | 4 +- .../account/get-mfa-recovery-codes.md | 2 +- docs/examples/account/get-payment-method.md | 4 +- docs/examples/account/get-prefs.md | 2 +- docs/examples/account/get-session.md | 4 +- docs/examples/account/get.md | 2 +- .../account/list-billing-addresses.md | 4 +- docs/examples/account/list-consent-tokens.md | 4 +- docs/examples/account/list-consents.md | 4 +- docs/examples/account/list-identities.md | 4 +- docs/examples/account/list-invoices.md | 4 +- docs/examples/account/list-keys.md | 4 +- docs/examples/account/list-logs.md | 4 +- docs/examples/account/list-mfa-factors.md | 2 +- docs/examples/account/list-payment-methods.md | 4 +- docs/examples/account/list-sessions.md | 2 +- .../account/update-billing-address.md | 4 +- .../account/update-email-verification.md | 4 +- docs/examples/account/update-email.md | 4 +- docs/examples/account/update-key.md | 4 +- .../account/update-magic-url-session.md | 4 +- .../account/update-mfa-authenticator.md | 4 +- docs/examples/account/update-mfa-challenge.md | 4 +- .../account/update-mfa-recovery-codes.md | 2 +- docs/examples/account/update-mfa.md | 4 +- docs/examples/account/update-name.md | 4 +- docs/examples/account/update-password.md | 4 +- .../update-payment-method-mandate-options.md | 4 +- .../account/update-payment-method-provider.md | 4 +- .../examples/account/update-payment-method.md | 4 +- docs/examples/account/update-phone-session.md | 4 +- .../account/update-phone-verification.md | 4 +- docs/examples/account/update-phone.md | 4 +- docs/examples/account/update-prefs.md | 10 +- docs/examples/account/update-push-target.md | 4 +- docs/examples/account/update-recovery.md | 4 +- docs/examples/account/update-session.md | 4 +- docs/examples/account/update-status.md | 2 +- docs/examples/account/update-verification.md | 4 +- docs/examples/activities/get-event.md | 4 +- docs/examples/activities/list-events.md | 4 +- docs/examples/advisor/delete-report.md | 4 +- docs/examples/advisor/get-insight.md | 4 +- docs/examples/advisor/get-report.md | 4 +- docs/examples/advisor/list-insights.md | 4 +- docs/examples/advisor/list-reports.md | 4 +- docs/examples/affiliates/create-link.md | 4 +- docs/examples/affiliates/delete-link.md | 4 +- docs/examples/affiliates/get-link.md | 4 +- docs/examples/affiliates/list-links.md | 4 +- docs/examples/affiliates/list-referrals.md | 4 +- docs/examples/affiliates/list-rewards.md | 4 +- docs/examples/affiliates/update-reward.md | 4 +- .../apps/create-installation-token.md | 4 +- docs/examples/apps/create-key.md | 4 +- docs/examples/apps/create-secret.md | 4 +- docs/examples/apps/create.md | 4 +- docs/examples/apps/delete-installation.md | 4 +- docs/examples/apps/delete-key.md | 4 +- docs/examples/apps/delete-secret.md | 4 +- docs/examples/apps/delete-tokens.md | 4 +- docs/examples/apps/delete.md | 4 +- docs/examples/apps/get-installation.md | 4 +- docs/examples/apps/get-key.md | 4 +- docs/examples/apps/get-secret.md | 4 +- docs/examples/apps/get.md | 4 +- .../examples/apps/list-installation-scopes.md | 2 +- docs/examples/apps/list-installations.md | 4 +- docs/examples/apps/list-keys.md | 4 +- docs/examples/apps/list-o-auth-2-scopes.md | 2 +- docs/examples/apps/list-secrets.md | 4 +- docs/examples/apps/list.md | 4 +- docs/examples/apps/update-labels.md | 4 +- docs/examples/apps/update-team.md | 4 +- docs/examples/apps/update.md | 4 +- docs/examples/assistant/chat.md | 4 +- docs/examples/avatars/get-browser.md | 4 +- docs/examples/avatars/get-credit-card.md | 4 +- docs/examples/avatars/get-favicon.md | 4 +- docs/examples/avatars/get-flag.md | 4 +- docs/examples/avatars/get-image.md | 4 +- docs/examples/avatars/get-initials.md | 4 +- docs/examples/avatars/get-photo.md | 22 + docs/examples/avatars/get-qr.md | 4 +- docs/examples/avatars/get-screenshot.md | 23 +- docs/examples/backups/create-archive.md | 4 +- docs/examples/backups/create-policy.md | 4 +- docs/examples/backups/create-restoration.md | 4 +- docs/examples/backups/delete-archive.md | 4 +- docs/examples/backups/delete-policy.md | 4 +- docs/examples/backups/get-archive.md | 4 +- docs/examples/backups/get-policy.md | 4 +- docs/examples/backups/get-restoration.md | 4 +- docs/examples/backups/list-archives.md | 4 +- docs/examples/backups/list-policies.md | 4 +- docs/examples/backups/list-restorations.md | 4 +- docs/examples/backups/update-policy.md | 4 +- .../console/create-program-membership.md | 4 +- docs/examples/console/create-source.md | 4 +- docs/examples/console/get-campaign.md | 4 +- docs/examples/console/get-coupon.md | 4 +- docs/examples/console/get-email-template.md | 9 +- docs/examples/console/get-plan.md | 4 +- docs/examples/console/get-plans.md | 4 +- docs/examples/console/get-program.md | 4 +- docs/examples/console/get-resource.md | 4 +- docs/examples/console/list-databases.md | 4 +- .../console/list-o-auth-2-providers.md | 2 +- .../console/list-organization-scopes.md | 2 +- .../console/list-postgres-extensions.md | 2 +- docs/examples/console/list-project-scopes.md | 2 +- docs/examples/console/list-regions.md | 2 +- docs/examples/console/suggest-columns.md | 4 +- docs/examples/console/suggest-indexes.md | 4 +- docs/examples/console/suggest-queries.md | 4 +- docs/examples/console/variables.md | 2 +- .../databases/create-big-int-attribute.md | 12 +- .../databases/create-boolean-attribute.md | 6 +- docs/examples/databases/create-collection.md | 4 +- .../databases/create-datetime-attribute.md | 6 +- docs/examples/databases/create-document.md | 14 +- docs/examples/databases/create-documents.md | 4 +- .../databases/create-email-attribute.md | 6 +- .../databases/create-enum-attribute.md | 10 +- .../databases/create-float-attribute.md | 12 +- docs/examples/databases/create-index.md | 11 +- .../databases/create-integer-attribute.md | 12 +- .../examples/databases/create-ip-attribute.md | 8 +- .../databases/create-line-attribute.md | 10 +- .../databases/create-longtext-attribute.md | 8 +- .../databases/create-mediumtext-attribute.md | 8 +- docs/examples/databases/create-operations.md | 22 +- .../databases/create-point-attribute.md | 6 +- .../databases/create-polygon-attribute.md | 13 +- .../create-relationship-attribute.md | 13 +- .../databases/create-string-attribute.md | 8 +- .../databases/create-text-attribute.md | 8 +- docs/examples/databases/create-transaction.md | 4 +- .../databases/create-url-attribute.md | 6 +- .../databases/create-varchar-attribute.md | 8 +- docs/examples/databases/create.md | 4 +- .../databases/decrement-document-attribute.md | 10 +- docs/examples/databases/delete-attribute.md | 4 +- docs/examples/databases/delete-collection.md | 4 +- docs/examples/databases/delete-document.md | 4 +- docs/examples/databases/delete-documents.md | 4 +- docs/examples/databases/delete-index.md | 4 +- docs/examples/databases/delete-transaction.md | 4 +- docs/examples/databases/delete.md | 4 +- docs/examples/databases/get-attribute.md | 4 +- docs/examples/databases/get-collection.md | 4 +- docs/examples/databases/get-document.md | 4 +- docs/examples/databases/get-index.md | 4 +- docs/examples/databases/get-transaction.md | 4 +- docs/examples/databases/get.md | 4 +- .../databases/increment-document-attribute.md | 10 +- docs/examples/databases/list-attributes.md | 4 +- docs/examples/databases/list-collections.md | 4 +- docs/examples/databases/list-documents.md | 4 +- docs/examples/databases/list-indexes.md | 4 +- docs/examples/databases/list-transactions.md | 4 +- docs/examples/databases/list.md | 4 +- .../databases/update-big-int-attribute.md | 12 +- .../databases/update-boolean-attribute.md | 6 +- docs/examples/databases/update-collection.md | 4 +- .../databases/update-datetime-attribute.md | 6 +- docs/examples/databases/update-document.md | 14 +- docs/examples/databases/update-documents.md | 14 +- .../databases/update-email-attribute.md | 6 +- .../databases/update-enum-attribute.md | 10 +- .../databases/update-float-attribute.md | 12 +- .../databases/update-integer-attribute.md | 12 +- .../examples/databases/update-ip-attribute.md | 8 +- .../databases/update-line-attribute.md | 12 +- .../databases/update-longtext-attribute.md | 8 +- .../databases/update-mediumtext-attribute.md | 8 +- .../databases/update-point-attribute.md | 6 +- .../databases/update-polygon-attribute.md | 15 +- .../update-relationship-attribute.md | 6 +- .../databases/update-string-attribute.md | 8 +- .../databases/update-text-attribute.md | 8 +- docs/examples/databases/update-transaction.md | 4 +- .../databases/update-url-attribute.md | 6 +- .../databases/update-varchar-attribute.md | 8 +- docs/examples/databases/update.md | 4 +- docs/examples/databases/upsert-document.md | 14 +- docs/examples/databases/upsert-documents.md | 4 +- .../examples/documentsdb/create-collection.md | 4 +- docs/examples/documentsdb/create-document.md | 15 +- docs/examples/documentsdb/create-documents.md | 5 +- docs/examples/documentsdb/create-failover.md | 4 +- docs/examples/documentsdb/create-index.md | 11 +- .../documentsdb/create-transaction.md | 4 +- docs/examples/documentsdb/create.md | 4 +- .../decrement-document-attribute.md | 10 +- .../examples/documentsdb/delete-collection.md | 4 +- docs/examples/documentsdb/delete-document.md | 4 +- docs/examples/documentsdb/delete-documents.md | 4 +- docs/examples/documentsdb/delete-index.md | 4 +- .../documentsdb/delete-transaction.md | 4 +- docs/examples/documentsdb/delete.md | 4 +- docs/examples/documentsdb/get-collection.md | 4 +- docs/examples/documentsdb/get-document.md | 4 +- docs/examples/documentsdb/get-index.md | 4 +- docs/examples/documentsdb/get-replicas.md | 4 +- docs/examples/documentsdb/get-status.md | 4 +- docs/examples/documentsdb/get-transaction.md | 4 +- docs/examples/documentsdb/get.md | 4 +- .../increment-document-attribute.md | 10 +- docs/examples/documentsdb/list-collections.md | 4 +- docs/examples/documentsdb/list-documents.md | 4 +- docs/examples/documentsdb/list-indexes.md | 4 +- docs/examples/documentsdb/list-operations.md | 6 +- .../documentsdb/list-specifications.md | 2 +- .../examples/documentsdb/list-transactions.md | 4 +- docs/examples/documentsdb/list.md | 4 +- .../examples/documentsdb/update-collection.md | 4 +- docs/examples/documentsdb/update-document.md | 4 +- docs/examples/documentsdb/update-documents.md | 4 +- .../documentsdb/update-transaction.md | 4 +- docs/examples/documentsdb/update.md | 4 +- docs/examples/documentsdb/upsert-document.md | 4 +- docs/examples/documentsdb/upsert-documents.md | 4 +- .../domains/create-preset-google-workspace.md | 4 +- .../examples/domains/create-preset-i-cloud.md | 4 +- .../examples/domains/create-preset-mailgun.md | 4 +- .../examples/domains/create-preset-outlook.md | 4 +- .../domains/create-preset-proton-mail.md | 4 +- docs/examples/domains/create-preset-zoho.md | 4 +- docs/examples/domains/create-purchase.md | 6 +- docs/examples/domains/create-record-a.md | 4 +- docs/examples/domains/create-record-aaaa.md | 4 +- docs/examples/domains/create-record-alias.md | 4 +- docs/examples/domains/create-record-caa.md | 4 +- docs/examples/domains/create-record-cname.md | 4 +- docs/examples/domains/create-record-https.md | 4 +- docs/examples/domains/create-record-mx.md | 6 +- docs/examples/domains/create-record-ns.md | 4 +- docs/examples/domains/create-record-srv.md | 10 +- docs/examples/domains/create-record-txt.md | 4 +- docs/examples/domains/create-transfer-in.md | 6 +- docs/examples/domains/create-transfer-out.md | 4 +- docs/examples/domains/create.md | 4 +- docs/examples/domains/delete-record.md | 4 +- docs/examples/domains/delete.md | 4 +- .../domains/get-preset-google-workspace.md | 4 +- docs/examples/domains/get-preset-i-cloud.md | 4 +- docs/examples/domains/get-preset-mailgun.md | 4 +- docs/examples/domains/get-preset-outlook.md | 4 +- .../domains/get-preset-proton-mail.md | 4 +- docs/examples/domains/get-preset-zoho.md | 4 +- docs/examples/domains/get-price.md | 6 +- docs/examples/domains/get-record.md | 4 +- docs/examples/domains/get-transfer-status.md | 4 +- docs/examples/domains/get-zone.md | 4 +- docs/examples/domains/get.md | 4 +- docs/examples/domains/list-prices.md | 17 + docs/examples/domains/list-records.md | 4 +- docs/examples/domains/list-suggestions.md | 4 +- docs/examples/domains/list.md | 4 +- docs/examples/domains/update-auto-renewal.md | 4 +- docs/examples/domains/update-nameservers.md | 4 +- docs/examples/domains/update-purchase.md | 4 +- docs/examples/domains/update-record-a.md | 4 +- docs/examples/domains/update-record-aaaa.md | 4 +- docs/examples/domains/update-record-alias.md | 4 +- docs/examples/domains/update-record-caa.md | 4 +- docs/examples/domains/update-record-cname.md | 4 +- docs/examples/domains/update-record-https.md | 4 +- docs/examples/domains/update-record-mx.md | 6 +- docs/examples/domains/update-record-ns.md | 4 +- docs/examples/domains/update-record-srv.md | 10 +- docs/examples/domains/update-record-txt.md | 4 +- docs/examples/domains/update-team.md | 4 +- docs/examples/domains/update-transfer-in.md | 4 +- docs/examples/domains/update-zone.md | 4 +- docs/examples/domains/verify-nameservers.md | 4 +- .../embeddings/create-text-embeddings.md | 4 +- docs/examples/functions/create-deployment.md | 4 +- .../functions/create-duplicate-deployment.md | 4 +- docs/examples/functions/create-execution.md | 4 +- .../functions/create-template-deployment.md | 4 +- docs/examples/functions/create-variable.md | 4 +- .../functions/create-vcs-deployment.md | 4 +- docs/examples/functions/create.md | 17 +- docs/examples/functions/delete-deployment.md | 4 +- docs/examples/functions/delete-execution.md | 4 +- docs/examples/functions/delete-variable.md | 4 +- docs/examples/functions/delete.md | 4 +- .../functions/get-deployment-download.md | 8 +- docs/examples/functions/get-deployment.md | 4 +- docs/examples/functions/get-execution.md | 4 +- docs/examples/functions/get-template.md | 4 +- docs/examples/functions/get-variable.md | 4 +- docs/examples/functions/get.md | 4 +- docs/examples/functions/list-deployments.md | 4 +- docs/examples/functions/list-executions.md | 4 +- docs/examples/functions/list-runtimes.md | 2 +- .../examples/functions/list-specifications.md | 4 +- docs/examples/functions/list-templates.md | 9 +- docs/examples/functions/list-variables.md | 4 +- docs/examples/functions/list.md | 4 +- .../functions/update-deployment-status.md | 4 +- .../functions/update-function-deployment.md | 4 +- docs/examples/functions/update-variable.md | 4 +- docs/examples/functions/update.md | 17 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- docs/examples/locale/get.md | 2 +- docs/examples/locale/list-codes.md | 2 +- docs/examples/locale/list-continents.md | 2 +- docs/examples/locale/list-countries-eu.md | 2 +- docs/examples/locale/list-countries-phones.md | 2 +- docs/examples/locale/list-countries.md | 2 +- docs/examples/locale/list-currencies.md | 2 +- docs/examples/locale/list-languages.md | 2 +- docs/examples/manager/create-block.md | 14 +- docs/examples/manager/delete-block.md | 9 +- docs/examples/manager/delete-cache.md | 15 +- docs/examples/manager/list-blocks.md | 9 +- docs/examples/manager/update-user-status.md | 9 +- .../messaging/create-apns-provider.md | 4 +- docs/examples/messaging/create-email.md | 4 +- .../examples/messaging/create-fcm-provider.md | 4 +- .../messaging/create-mailgun-provider.md | 6 +- .../messaging/create-msg-91-provider.md | 4 +- docs/examples/messaging/create-push.md | 6 +- .../messaging/create-resend-provider.md | 4 +- .../messaging/create-sendgrid-provider.md | 4 +- .../examples/messaging/create-ses-provider.md | 4 +- docs/examples/messaging/create-sms.md | 4 +- .../messaging/create-smtp-provider.md | 6 +- docs/examples/messaging/create-subscriber.md | 4 +- .../messaging/create-telesign-provider.md | 4 +- .../messaging/create-textmagic-provider.md | 4 +- docs/examples/messaging/create-topic.md | 4 +- .../messaging/create-twilio-provider.md | 4 +- .../messaging/create-vonage-provider.md | 4 +- docs/examples/messaging/delete-provider.md | 4 +- docs/examples/messaging/delete-subscriber.md | 4 +- docs/examples/messaging/delete-topic.md | 4 +- docs/examples/messaging/delete.md | 4 +- docs/examples/messaging/get-message.md | 4 +- docs/examples/messaging/get-provider.md | 4 +- docs/examples/messaging/get-subscriber.md | 4 +- docs/examples/messaging/get-topic.md | 4 +- docs/examples/messaging/list-messages.md | 4 +- docs/examples/messaging/list-providers.md | 4 +- docs/examples/messaging/list-subscribers.md | 4 +- docs/examples/messaging/list-targets.md | 4 +- docs/examples/messaging/list-topics.md | 4 +- .../messaging/update-apns-provider.md | 4 +- docs/examples/messaging/update-email.md | 4 +- .../examples/messaging/update-fcm-provider.md | 4 +- .../messaging/update-mailgun-provider.md | 6 +- .../messaging/update-msg-91-provider.md | 4 +- docs/examples/messaging/update-push.md | 6 +- .../messaging/update-resend-provider.md | 4 +- .../messaging/update-sendgrid-provider.md | 4 +- .../examples/messaging/update-ses-provider.md | 4 +- docs/examples/messaging/update-sms.md | 4 +- .../messaging/update-smtp-provider.md | 4 +- .../messaging/update-telesign-provider.md | 4 +- .../messaging/update-textmagic-provider.md | 4 +- docs/examples/messaging/update-topic.md | 4 +- .../messaging/update-twilio-provider.md | 4 +- .../messaging/update-vonage-provider.md | 4 +- .../migrations/create-appwrite-migration.md | 9 +- docs/examples/migrations/create-csv-export.md | 4 +- docs/examples/migrations/create-csv-import.md | 4 +- .../migrations/create-firebase-migration.md | 8 +- .../examples/migrations/create-json-export.md | 4 +- .../examples/migrations/create-json-import.md | 4 +- .../migrations/create-n-host-migration.md | 8 +- .../migrations/create-supabase-migration.md | 8 +- docs/examples/migrations/delete.md | 4 +- .../migrations/get-appwrite-report.md | 8 +- .../migrations/get-firebase-report.md | 8 +- docs/examples/migrations/get-n-host-report.md | 8 +- .../migrations/get-supabase-report.md | 8 +- docs/examples/migrations/get.md | 4 +- docs/examples/migrations/list.md | 4 +- docs/examples/migrations/retry.md | 4 +- docs/examples/mongo/create-backup-policy.md | 4 +- docs/examples/mongo/create-backup.md | 4 +- docs/examples/mongo/create-branch.md | 4 +- docs/examples/mongo/create-failover.md | 4 +- docs/examples/mongo/create-migration.md | 4 +- docs/examples/mongo/create-restoration.md | 5 +- docs/examples/mongo/create-upgrade.md | 4 +- docs/examples/mongo/create.md | 5 +- docs/examples/mongo/delete-backup-policy.md | 4 +- docs/examples/mongo/delete-backup.md | 4 +- docs/examples/mongo/delete-branch.md | 4 +- docs/examples/mongo/delete.md | 4 +- docs/examples/mongo/get-backup-policy.md | 4 +- docs/examples/mongo/get-backup.md | 4 +- docs/examples/mongo/get-pitr.md | 4 +- docs/examples/mongo/get-replicas.md | 4 +- docs/examples/mongo/get-restoration.md | 4 +- docs/examples/mongo/get-status.md | 4 +- docs/examples/mongo/get.md | 4 +- docs/examples/mongo/list-backup-policies.md | 4 +- docs/examples/mongo/list-backups.md | 4 +- docs/examples/mongo/list-branches.md | 4 +- docs/examples/mongo/list-operations.md | 6 +- docs/examples/mongo/list-restorations.md | 4 +- docs/examples/mongo/list-specifications.md | 2 +- docs/examples/mongo/list.md | 4 +- docs/examples/mongo/update-backup-policy.md | 4 +- docs/examples/mongo/update-backup-storage.md | 4 +- docs/examples/mongo/update-credentials.md | 4 +- docs/examples/mongo/update-maintenance.md | 4 +- docs/examples/mongo/update.md | 6 +- docs/examples/mysql/create-backup-policy.md | 4 +- docs/examples/mysql/create-backup.md | 4 +- docs/examples/mysql/create-branch.md | 4 +- docs/examples/mysql/create-execution.md | 4 +- docs/examples/mysql/create-failover.md | 4 +- docs/examples/mysql/create-migration.md | 4 +- docs/examples/mysql/create-restoration.md | 5 +- docs/examples/mysql/create-upgrade.md | 4 +- docs/examples/mysql/create.md | 5 +- docs/examples/mysql/delete-backup-policy.md | 4 +- docs/examples/mysql/delete-backup.md | 4 +- docs/examples/mysql/delete-branch.md | 4 +- docs/examples/mysql/delete.md | 4 +- docs/examples/mysql/get-backup-policy.md | 4 +- docs/examples/mysql/get-backup.md | 4 +- docs/examples/mysql/get-pitr.md | 4 +- docs/examples/mysql/get-pooler.md | 4 +- docs/examples/mysql/get-replicas.md | 4 +- docs/examples/mysql/get-restoration.md | 4 +- docs/examples/mysql/get-status.md | 4 +- docs/examples/mysql/get.md | 4 +- docs/examples/mysql/list-backup-policies.md | 4 +- docs/examples/mysql/list-backups.md | 4 +- docs/examples/mysql/list-branches.md | 4 +- docs/examples/mysql/list-operations.md | 6 +- docs/examples/mysql/list-restorations.md | 4 +- docs/examples/mysql/list-specifications.md | 2 +- docs/examples/mysql/list.md | 4 +- docs/examples/mysql/update-backup-policy.md | 4 +- docs/examples/mysql/update-backup-storage.md | 4 +- docs/examples/mysql/update-credentials.md | 4 +- docs/examples/mysql/update-maintenance.md | 4 +- docs/examples/mysql/update-pooler.md | 4 +- docs/examples/mysql/update.md | 6 +- docs/examples/notifications/list.md | 4 +- docs/examples/notifications/update.md | 4 +- docs/examples/oauth2/approve.md | 4 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 4 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 4 +- docs/examples/oauth2/list-organizations.md | 4 +- docs/examples/oauth2/list-projects.md | 4 +- docs/examples/oauth2/logout-post.md | 4 +- docs/examples/oauth2/logout.md | 4 +- docs/examples/oauth2/reject.md | 4 +- docs/examples/oauth2/revoke.md | 4 +- .../organization/create-installation.md | 4 +- docs/examples/organization/create-key.md | 8 +- .../organization/create-membership.md | 4 +- docs/examples/organization/create-project.md | 6 +- .../organization/delete-installation.md | 4 +- docs/examples/organization/delete-key.md | 4 +- .../organization/delete-membership.md | 4 +- docs/examples/organization/delete-project.md | 4 +- docs/examples/organization/delete.md | 2 +- .../examples/organization/get-installation.md | 4 +- docs/examples/organization/get-key.md | 4 +- docs/examples/organization/get-membership.md | 4 +- docs/examples/organization/get-project.md | 4 +- docs/examples/organization/get.md | 2 +- .../organization/list-installations.md | 4 +- docs/examples/organization/list-keys.md | 4 +- .../examples/organization/list-memberships.md | 4 +- docs/examples/organization/list-projects.md | 4 +- .../organization/update-installation.md | 4 +- docs/examples/organization/update-key.md | 8 +- .../organization/update-membership.md | 4 +- docs/examples/organization/update-project.md | 4 +- docs/examples/organization/update.md | 4 +- docs/examples/organizations/add-credit.md | 4 +- .../organizations/cancel-downgrade.md | 4 +- .../organizations/confirm-addon-payment.md | 4 +- .../organizations/create-baa-addon.md | 4 +- .../create-downgrade-feedback.md | 4 +- .../organizations/create-invoice-payment.md | 4 +- .../organizations/create-plan-estimation.md | 4 +- .../create-premium-geo-db-addon.md | 4 +- docs/examples/organizations/create.md | 4 +- docs/examples/organizations/delete-addon.md | 4 +- .../delete-backup-payment-method.md | 4 +- .../organizations/delete-billing-address.md | 4 +- .../delete-default-payment-method.md | 4 +- docs/examples/organizations/delete.md | 4 +- .../estimation-create-organization.md | 4 +- .../estimation-delete-organization.md | 4 +- .../organizations/estimation-update-plan.md | 4 +- .../examples/organizations/get-addon-price.md | 4 +- docs/examples/organizations/get-addon.md | 4 +- .../examples/organizations/get-aggregation.md | 4 +- .../organizations/get-available-credits.md | 4 +- .../organizations/get-billing-address.md | 4 +- docs/examples/organizations/get-credit.md | 4 +- .../organizations/get-invoice-download.md | 4 +- .../organizations/get-invoice-view.md | 4 +- docs/examples/organizations/get-invoice.md | 4 +- .../organizations/get-payment-method.md | 4 +- docs/examples/organizations/get-plan.md | 4 +- docs/examples/organizations/get-scopes.md | 4 +- docs/examples/organizations/get-usage.md | 4 +- docs/examples/organizations/list-addons.md | 4 +- .../organizations/list-aggregations.md | 4 +- docs/examples/organizations/list-credits.md | 4 +- docs/examples/organizations/list-invoices.md | 4 +- docs/examples/organizations/list-regions.md | 4 +- docs/examples/organizations/list.md | 4 +- .../set-backup-payment-method.md | 4 +- .../organizations/set-billing-address.md | 4 +- .../organizations/set-billing-email.md | 4 +- .../organizations/set-billing-tax-id.md | 4 +- .../set-default-payment-method.md | 4 +- docs/examples/organizations/update-budget.md | 4 +- docs/examples/organizations/update-plan.md | 4 +- .../organizations/validate-invoice.md | 4 +- .../organizations/validate-payment.md | 4 +- .../postgresql/create-backup-policy.md | 4 +- docs/examples/postgresql/create-backup.md | 4 +- docs/examples/postgresql/create-branch.md | 4 +- docs/examples/postgresql/create-execution.md | 4 +- docs/examples/postgresql/create-extension.md | 4 +- docs/examples/postgresql/create-failover.md | 4 +- docs/examples/postgresql/create-migration.md | 4 +- .../examples/postgresql/create-restoration.md | 5 +- docs/examples/postgresql/create-upgrade.md | 4 +- docs/examples/postgresql/create.md | 5 +- .../postgresql/delete-backup-policy.md | 4 +- docs/examples/postgresql/delete-backup.md | 4 +- docs/examples/postgresql/delete-branch.md | 4 +- docs/examples/postgresql/delete-extension.md | 4 +- docs/examples/postgresql/delete.md | 4 +- docs/examples/postgresql/get-backup-policy.md | 4 +- docs/examples/postgresql/get-backup.md | 4 +- docs/examples/postgresql/get-pitr.md | 4 +- docs/examples/postgresql/get-pooler.md | 4 +- docs/examples/postgresql/get-replicas.md | 4 +- docs/examples/postgresql/get-restoration.md | 4 +- docs/examples/postgresql/get-status.md | 4 +- docs/examples/postgresql/get.md | 4 +- .../postgresql/list-backup-policies.md | 4 +- docs/examples/postgresql/list-backups.md | 4 +- docs/examples/postgresql/list-branches.md | 4 +- docs/examples/postgresql/list-extensions.md | 4 +- docs/examples/postgresql/list-operations.md | 6 +- docs/examples/postgresql/list-restorations.md | 4 +- .../postgresql/list-specifications.md | 2 +- docs/examples/postgresql/list.md | 4 +- .../postgresql/update-backup-policy.md | 4 +- .../postgresql/update-backup-storage.md | 4 +- .../examples/postgresql/update-credentials.md | 4 +- .../examples/postgresql/update-maintenance.md | 4 +- docs/examples/postgresql/update-pooler.md | 4 +- docs/examples/postgresql/update.md | 6 +- docs/examples/presences/delete.md | 4 +- docs/examples/presences/get-usage.md | 4 +- docs/examples/presences/get.md | 4 +- docs/examples/presences/list.md | 4 +- docs/examples/presences/update.md | 4 +- docs/examples/presences/upsert.md | 4 +- .../project/create-android-platform.md | 4 +- .../examples/project/create-apple-platform.md | 4 +- docs/examples/project/create-ephemeral-key.md | 4 +- docs/examples/project/create-key.md | 4 +- .../examples/project/create-linux-platform.md | 4 +- docs/examples/project/create-mock-phone.md | 4 +- docs/examples/project/create-smtp-test.md | 4 +- docs/examples/project/create-variable.md | 4 +- docs/examples/project/create-web-platform.md | 4 +- .../project/create-windows-platform.md | 4 +- docs/examples/project/delete-key.md | 4 +- docs/examples/project/delete-mock-phone.md | 4 +- docs/examples/project/delete-platform.md | 4 +- docs/examples/project/delete-variable.md | 4 +- docs/examples/project/delete.md | 2 +- docs/examples/project/get-email-template.md | 9 +- docs/examples/project/get-key.md | 4 +- docs/examples/project/get-mock-phone.md | 4 +- .../examples/project/get-o-auth-2-provider.md | 4 +- docs/examples/project/get-platform.md | 4 +- docs/examples/project/get-policy.md | 4 +- docs/examples/project/get-usage.md | 4 +- docs/examples/project/get-variable.md | 4 +- docs/examples/project/get.md | 2 +- docs/examples/project/list-email-templates.md | 4 +- docs/examples/project/list-keys.md | 4 +- docs/examples/project/list-mock-phones.md | 4 +- .../project/list-o-auth-2-providers.md | 4 +- docs/examples/project/list-platforms.md | 4 +- docs/examples/project/list-policies.md | 4 +- docs/examples/project/list-variables.md | 4 +- .../project/update-android-platform.md | 4 +- .../examples/project/update-apple-platform.md | 4 +- docs/examples/project/update-auth-method.md | 4 +- .../update-deny-aliased-email-policy.md | 4 +- .../update-deny-corporate-email-policy.md | 4 +- .../update-deny-disposable-email-policy.md | 4 +- .../project/update-deny-free-email-policy.md | 4 +- .../examples/project/update-email-template.md | 9 +- docs/examples/project/update-key.md | 4 +- docs/examples/project/update-labels.md | 4 +- .../examples/project/update-linux-platform.md | 4 +- .../update-membership-privacy-policy.md | 4 +- .../project/update-mfa-factors-policy.md | 18 + docs/examples/project/update-mock-phone.md | 4 +- .../project/update-o-auth-2-amazon.md | 4 +- .../examples/project/update-o-auth-2-apple.md | 4 +- .../project/update-o-auth-2-appwrite.md | 4 +- .../project/update-o-auth-2-auth-0.md | 4 +- .../project/update-o-auth-2-authentik.md | 4 +- .../project/update-o-auth-2-autodesk.md | 4 +- .../project/update-o-auth-2-bitbucket.md | 4 +- .../examples/project/update-o-auth-2-bitly.md | 4 +- docs/examples/project/update-o-auth-2-box.md | 4 +- .../project/update-o-auth-2-cloudflare.md | 17 + .../project/update-o-auth-2-dailymotion.md | 4 +- .../project/update-o-auth-2-discord.md | 4 +- .../project/update-o-auth-2-disqus.md | 4 +- .../project/update-o-auth-2-dropbox.md | 4 +- docs/examples/project/update-o-auth-2-etsy.md | 4 +- .../project/update-o-auth-2-facebook.md | 4 +- .../examples/project/update-o-auth-2-figma.md | 4 +- .../project/update-o-auth-2-fusion-auth.md | 4 +- .../project/update-o-auth-2-git-hub.md | 4 +- .../project/update-o-auth-2-gitlab.md | 4 +- .../project/update-o-auth-2-google.md | 8 +- .../project/update-o-auth-2-hugging-face.md | 17 + .../examples/project/update-o-auth-2-kakao.md | 17 + .../project/update-o-auth-2-keycloak.md | 4 +- docs/examples/project/update-o-auth-2-kick.md | 4 +- .../project/update-o-auth-2-linkedin.md | 4 +- .../project/update-o-auth-2-microsoft.md | 4 +- .../project/update-o-auth-2-notion.md | 4 +- docs/examples/project/update-o-auth-2-oidc.md | 4 +- docs/examples/project/update-o-auth-2-okta.md | 6 +- .../project/update-o-auth-2-paypal-sandbox.md | 4 +- .../project/update-o-auth-2-paypal.md | 4 +- .../examples/project/update-o-auth-2-podio.md | 4 +- .../project/update-o-auth-2-resend.md | 17 + .../project/update-o-auth-2-salesforce.md | 4 +- .../project/update-o-auth-2-server.md | 5 +- .../examples/project/update-o-auth-2-slack.md | 4 +- .../project/update-o-auth-2-spotify.md | 4 +- .../project/update-o-auth-2-stripe.md | 4 +- .../project/update-o-auth-2-tik-tok.md | 17 + .../update-o-auth-2-tradeshift-sandbox.md | 4 +- .../project/update-o-auth-2-tradeshift.md | 4 +- .../project/update-o-auth-2-twitch.md | 4 +- .../project/update-o-auth-2-word-press.md | 4 +- .../examples/project/update-o-auth-2-yahoo.md | 4 +- .../project/update-o-auth-2-yandex.md | 4 +- docs/examples/project/update-o-auth-2-zoho.md | 4 +- docs/examples/project/update-o-auth-2-zoom.md | 4 +- docs/examples/project/update-o-auth-2x.md | 4 +- .../update-password-dictionary-policy.md | 4 +- .../project/update-password-history-policy.md | 4 +- .../update-password-personal-data-policy.md | 4 +- .../update-password-strength-policy.md | 4 +- docs/examples/project/update-protocol.md | 4 +- docs/examples/project/update-service.md | 4 +- .../project/update-session-alert-policy.md | 4 +- .../project/update-session-duration-policy.md | 4 +- .../update-session-invalidation-policy.md | 4 +- .../project/update-session-limit-policy.md | 4 +- docs/examples/project/update-smtp.md | 8 +- .../project/update-user-limit-policy.md | 4 +- docs/examples/project/update-variable.md | 4 +- docs/examples/project/update-web-platform.md | 4 +- .../project/update-windows-platform.md | 4 +- .../projects/confirm-addon-payment.md | 4 +- .../projects/create-premium-geo-db-addon.md | 4 +- docs/examples/projects/create-schedule.md | 6 +- docs/examples/projects/delete-addon.md | 4 +- docs/examples/projects/delete-dev-key.md | 4 +- docs/examples/projects/get-addon-price.md | 4 +- docs/examples/projects/get-addon.md | 4 +- docs/examples/projects/get-dev-key.md | 4 +- docs/examples/projects/get-schedule.md | 4 +- docs/examples/projects/list-addons.md | 4 +- docs/examples/projects/list-dev-keys.md | 4 +- docs/examples/projects/list-schedules.md | 4 +- docs/examples/projects/list-stages.md | 4 +- .../projects/update-console-access.md | 4 +- docs/examples/projects/update-dev-key.md | 4 +- docs/examples/projects/update-stage.md | 4 +- docs/examples/projects/update-status.md | 4 +- docs/examples/projects/update-team.md | 4 +- docs/examples/proxy/create-api-rule.md | 4 +- docs/examples/proxy/create-function-rule.md | 6 +- docs/examples/proxy/create-invalidation.md | 6 +- docs/examples/proxy/create-redirect-rule.md | 11 +- docs/examples/proxy/create-site-rule.md | 6 +- docs/examples/proxy/delete-rule.md | 4 +- docs/examples/proxy/get-rule.md | 4 +- docs/examples/proxy/list-rules.md | 4 +- docs/examples/proxy/update-rule-status.md | 4 +- docs/examples/sites/create-deployment.md | 4 +- .../sites/create-duplicate-deployment.md | 4 +- .../sites/create-template-deployment.md | 4 +- docs/examples/sites/create-variable.md | 4 +- docs/examples/sites/create-vcs-deployment.md | 4 +- docs/examples/sites/create.md | 16 +- docs/examples/sites/delete-deployment.md | 4 +- docs/examples/sites/delete-log.md | 4 +- docs/examples/sites/delete-variable.md | 4 +- docs/examples/sites/delete.md | 4 +- .../examples/sites/get-deployment-download.md | 4 +- docs/examples/sites/get-deployment.md | 4 +- docs/examples/sites/get-log.md | 4 +- docs/examples/sites/get-template.md | 4 +- docs/examples/sites/get-variable.md | 4 +- docs/examples/sites/get.md | 4 +- docs/examples/sites/list-deployments.md | 4 +- docs/examples/sites/list-frameworks.md | 2 +- docs/examples/sites/list-logs.md | 4 +- docs/examples/sites/list-specifications.md | 4 +- docs/examples/sites/list-templates.md | 9 +- docs/examples/sites/list-variables.md | 4 +- docs/examples/sites/list.md | 4 +- .../sites/update-deployment-status.md | 4 +- docs/examples/sites/update-site-deployment.md | 4 +- docs/examples/sites/update-variable.md | 4 +- docs/examples/sites/update.md | 16 +- docs/examples/storage/create-bucket.md | 10 +- docs/examples/storage/create-file.md | 4 +- docs/examples/storage/delete-bucket.md | 4 +- docs/examples/storage/delete-file.md | 4 +- docs/examples/storage/get-bucket.md | 4 +- docs/examples/storage/get-file-download.md | 4 +- docs/examples/storage/get-file-preview.md | 15 +- docs/examples/storage/get-file-view.md | 4 +- docs/examples/storage/get-file.md | 4 +- docs/examples/storage/list-buckets.md | 4 +- docs/examples/storage/list-files.md | 4 +- docs/examples/storage/update-bucket.md | 10 +- docs/examples/storage/update-file.md | 4 +- .../tablesdb/create-big-int-column.md | 12 +- .../tablesdb/create-boolean-column.md | 6 +- docs/examples/tablesdb/create-cutover.md | 16 + .../tablesdb/create-datetime-column.md | 6 +- docs/examples/tablesdb/create-email-column.md | 6 +- docs/examples/tablesdb/create-enum-column.md | 10 +- docs/examples/tablesdb/create-failover.md | 4 +- docs/examples/tablesdb/create-float-column.md | 12 +- docs/examples/tablesdb/create-index.md | 11 +- .../tablesdb/create-integer-column.md | 12 +- docs/examples/tablesdb/create-ip-column.md | 8 +- docs/examples/tablesdb/create-line-column.md | 10 +- .../tablesdb/create-longtext-column.md | 8 +- .../tablesdb/create-mediumtext-column.md | 8 +- docs/examples/tablesdb/create-migration.md | 5 +- docs/examples/tablesdb/create-operations.md | 22 +- docs/examples/tablesdb/create-point-column.md | 6 +- .../tablesdb/create-polygon-column.md | 13 +- .../tablesdb/create-relationship-column.md | 13 +- docs/examples/tablesdb/create-row.md | 14 +- docs/examples/tablesdb/create-rows.md | 4 +- .../examples/tablesdb/create-string-column.md | 8 +- docs/examples/tablesdb/create-table.md | 4 +- docs/examples/tablesdb/create-text-column.md | 8 +- docs/examples/tablesdb/create-transaction.md | 4 +- docs/examples/tablesdb/create-url-column.md | 6 +- .../tablesdb/create-varchar-column.md | 8 +- docs/examples/tablesdb/create.md | 4 +- .../examples/tablesdb/decrement-row-column.md | 10 +- docs/examples/tablesdb/delete-column.md | 4 +- docs/examples/tablesdb/delete-index.md | 4 +- docs/examples/tablesdb/delete-migration.md | 4 +- docs/examples/tablesdb/delete-row.md | 4 +- docs/examples/tablesdb/delete-rows.md | 4 +- docs/examples/tablesdb/delete-table.md | 4 +- docs/examples/tablesdb/delete-transaction.md | 4 +- docs/examples/tablesdb/delete.md | 4 +- docs/examples/tablesdb/get-column.md | 4 +- docs/examples/tablesdb/get-index.md | 4 +- docs/examples/tablesdb/get-migration.md | 4 +- docs/examples/tablesdb/get-replicas.md | 4 +- docs/examples/tablesdb/get-row.md | 4 +- docs/examples/tablesdb/get-status.md | 4 +- docs/examples/tablesdb/get-table.md | 4 +- docs/examples/tablesdb/get-transaction.md | 4 +- docs/examples/tablesdb/get.md | 4 +- .../examples/tablesdb/increment-row-column.md | 10 +- docs/examples/tablesdb/list-columns.md | 4 +- docs/examples/tablesdb/list-indexes.md | 4 +- docs/examples/tablesdb/list-migrations.md | 4 +- docs/examples/tablesdb/list-operations.md | 6 +- docs/examples/tablesdb/list-rows.md | 4 +- docs/examples/tablesdb/list-specifications.md | 2 +- docs/examples/tablesdb/list-tables.md | 4 +- docs/examples/tablesdb/list-transactions.md | 4 +- docs/examples/tablesdb/list.md | 4 +- .../tablesdb/update-big-int-column.md | 12 +- .../tablesdb/update-boolean-column.md | 6 +- .../tablesdb/update-datetime-column.md | 6 +- docs/examples/tablesdb/update-email-column.md | 6 +- docs/examples/tablesdb/update-enum-column.md | 10 +- docs/examples/tablesdb/update-float-column.md | 12 +- .../tablesdb/update-integer-column.md | 12 +- docs/examples/tablesdb/update-ip-column.md | 8 +- docs/examples/tablesdb/update-line-column.md | 12 +- .../tablesdb/update-longtext-column.md | 8 +- .../tablesdb/update-mediumtext-column.md | 8 +- docs/examples/tablesdb/update-point-column.md | 6 +- .../tablesdb/update-polygon-column.md | 15 +- .../tablesdb/update-relationship-column.md | 6 +- docs/examples/tablesdb/update-row.md | 14 +- docs/examples/tablesdb/update-rows.md | 14 +- .../examples/tablesdb/update-string-column.md | 8 +- docs/examples/tablesdb/update-table.md | 4 +- docs/examples/tablesdb/update-text-column.md | 8 +- docs/examples/tablesdb/update-transaction.md | 4 +- docs/examples/tablesdb/update-url-column.md | 6 +- .../tablesdb/update-varchar-column.md | 8 +- docs/examples/tablesdb/update.md | 4 +- docs/examples/tablesdb/upsert-row.md | 14 +- docs/examples/tablesdb/upsert-rows.md | 4 +- docs/examples/teams/create-installation.md | 4 +- docs/examples/teams/create-membership.md | 4 +- docs/examples/teams/create.md | 4 +- docs/examples/teams/delete-installation.md | 4 +- docs/examples/teams/delete-membership.md | 4 +- docs/examples/teams/delete.md | 4 +- docs/examples/teams/get-installation.md | 4 +- docs/examples/teams/get-membership.md | 4 +- docs/examples/teams/get-prefs.md | 4 +- docs/examples/teams/get.md | 4 +- docs/examples/teams/list-installations.md | 4 +- docs/examples/teams/list-logs.md | 4 +- docs/examples/teams/list-memberships.md | 4 +- docs/examples/teams/list.md | 4 +- docs/examples/teams/update-installation.md | 4 +- .../teams/update-membership-status.md | 4 +- docs/examples/teams/update-membership.md | 4 +- docs/examples/teams/update-name.md | 4 +- docs/examples/teams/update-prefs.md | 4 +- docs/examples/tokens/create-file-token.md | 4 +- docs/examples/tokens/delete.md | 4 +- docs/examples/tokens/get.md | 4 +- docs/examples/tokens/list.md | 4 +- docs/examples/tokens/update.md | 4 +- docs/examples/usage/list-events.md | 14 +- docs/examples/usage/list-gauges.md | 15 +- docs/examples/users/create-argon-2-user.md | 4 +- docs/examples/users/create-bcrypt-user.md | 4 +- docs/examples/users/create-jwt.md | 6 +- docs/examples/users/create-md-5-user.md | 4 +- .../users/create-mfa-recovery-codes.md | 4 +- docs/examples/users/create-ph-pass-user.md | 4 +- .../users/create-scrypt-modified-user.md | 4 +- docs/examples/users/create-scrypt-user.md | 12 +- docs/examples/users/create-session.md | 4 +- docs/examples/users/create-sha-user.md | 4 +- docs/examples/users/create-target.md | 4 +- docs/examples/users/create-token.md | 4 +- docs/examples/users/create.md | 4 +- docs/examples/users/delete-identity.md | 4 +- .../users/delete-mfa-authenticator.md | 4 +- docs/examples/users/delete-session.md | 4 +- docs/examples/users/delete-sessions.md | 4 +- docs/examples/users/delete-target.md | 4 +- docs/examples/users/delete.md | 4 +- docs/examples/users/get-mfa-challenge.md | 16 + docs/examples/users/get-mfa-recovery-codes.md | 4 +- docs/examples/users/get-prefs.md | 4 +- docs/examples/users/get-target.md | 4 +- docs/examples/users/get-usage.md | 4 +- docs/examples/users/get.md | 4 +- docs/examples/users/list-identities.md | 4 +- docs/examples/users/list-logs.md | 4 +- docs/examples/users/list-memberships.md | 4 +- docs/examples/users/list-mfa-factors.md | 4 +- docs/examples/users/list-sessions.md | 4 +- docs/examples/users/list-targets.md | 4 +- docs/examples/users/list.md | 4 +- .../users/update-email-verification.md | 4 +- docs/examples/users/update-email.md | 4 +- docs/examples/users/update-impersonator.md | 4 +- docs/examples/users/update-labels.md | 4 +- .../users/update-mfa-recovery-codes.md | 4 +- docs/examples/users/update-mfa.md | 4 +- docs/examples/users/update-name.md | 4 +- docs/examples/users/update-password.md | 4 +- .../users/update-phone-verification.md | 4 +- docs/examples/users/update-phone.md | 4 +- docs/examples/users/update-prefs.md | 4 +- docs/examples/users/update-status.md | 4 +- docs/examples/users/update-target.md | 4 +- .../vcs/create-repository-detection.md | 4 +- docs/examples/vcs/create-repository.md | 4 +- docs/examples/vcs/delete-installation.md | 4 +- docs/examples/vcs/get-installation.md | 4 +- docs/examples/vcs/get-repository-contents.md | 4 +- docs/examples/vcs/get-repository.md | 4 +- docs/examples/vcs/list-installations.md | 4 +- docs/examples/vcs/list-namespaces.md | 4 +- docs/examples/vcs/list-repositories.md | 4 +- docs/examples/vcs/list-repository-branches.md | 4 +- .../vcs/update-external-deployments.md | 4 +- docs/examples/vectorsdb/create-collection.md | 4 +- docs/examples/vectorsdb/create-document.md | 18 +- docs/examples/vectorsdb/create-documents.md | 5 +- docs/examples/vectorsdb/create-failover.md | 4 +- docs/examples/vectorsdb/create-index.md | 11 +- docs/examples/vectorsdb/create-operations.md | 22 +- docs/examples/vectorsdb/create-query.md | 4 +- docs/examples/vectorsdb/create-transaction.md | 4 +- docs/examples/vectorsdb/create.md | 4 +- docs/examples/vectorsdb/delete-collection.md | 4 +- docs/examples/vectorsdb/delete-document.md | 4 +- docs/examples/vectorsdb/delete-documents.md | 4 +- docs/examples/vectorsdb/delete-index.md | 4 +- docs/examples/vectorsdb/delete-transaction.md | 4 +- docs/examples/vectorsdb/delete.md | 4 +- docs/examples/vectorsdb/get-collection.md | 4 +- docs/examples/vectorsdb/get-document.md | 4 +- docs/examples/vectorsdb/get-index.md | 4 +- docs/examples/vectorsdb/get-replicas.md | 4 +- docs/examples/vectorsdb/get-status.md | 4 +- docs/examples/vectorsdb/get-transaction.md | 4 +- docs/examples/vectorsdb/get.md | 4 +- docs/examples/vectorsdb/list-collections.md | 4 +- docs/examples/vectorsdb/list-documents.md | 4 +- docs/examples/vectorsdb/list-indexes.md | 4 +- docs/examples/vectorsdb/list-operations.md | 6 +- .../examples/vectorsdb/list-specifications.md | 2 +- docs/examples/vectorsdb/list-transactions.md | 4 +- docs/examples/vectorsdb/list.md | 4 +- docs/examples/vectorsdb/update-collection.md | 4 +- docs/examples/vectorsdb/update-document.md | 4 +- docs/examples/vectorsdb/update-documents.md | 4 +- docs/examples/vectorsdb/update-transaction.md | 4 +- docs/examples/vectorsdb/update.md | 4 +- docs/examples/vectorsdb/upsert-document.md | 4 +- docs/examples/vectorsdb/upsert-documents.md | 4 +- docs/examples/waf/create-bypass-rule.md | 4 +- docs/examples/waf/create-challenge-rule.md | 4 +- docs/examples/waf/create-deny-rule.md | 4 +- docs/examples/waf/create-rate-limit-rule.md | 6 +- docs/examples/waf/create-redirect-rule.md | 4 +- docs/examples/waf/delete-rule.md | 4 +- docs/examples/waf/get-rule.md | 4 +- docs/examples/waf/list-rules.md | 4 +- docs/examples/waf/update-bypass-rule.md | 4 +- docs/examples/waf/update-challenge-rule.md | 4 +- docs/examples/waf/update-deny-rule.md | 4 +- docs/examples/waf/update-rate-limit-rule.md | 5 +- docs/examples/waf/update-redirect-rule.md | 4 +- docs/examples/webhooks/create.md | 6 +- docs/examples/webhooks/delete.md | 4 +- docs/examples/webhooks/get.md | 4 +- docs/examples/webhooks/list.md | 4 +- docs/examples/webhooks/update-secret.md | 4 +- docs/examples/webhooks/update.md | 6 +- eslint.config.mjs | 31 + package-lock.json | 1674 +++- package.json | 109 +- rollup.config.mjs | 28 +- src/channel.ts | 346 +- src/client.ts | 437 +- src/enums/account-key-scopes.ts | 2 +- src/enums/adapter.ts | 2 +- src/enums/{addon.ts => addon-key.ts} | 4 +- src/enums/appwrite-migration-resource.ts | 2 +- src/enums/attribute-status.ts | 2 +- src/enums/authentication-factor.ts | 3 +- src/enums/authenticator-type.ts | 2 +- src/enums/backup-services.ts | 2 +- src/enums/billing-plan-group.ts | 2 +- src/enums/block-mode.ts | 2 +- src/enums/block-resource-type.ts | 2 +- src/enums/browser-permission.ts | 2 +- src/enums/browser-theme.ts | 2 +- src/enums/browser.ts | 2 +- src/enums/build-runtime.ts | 5 +- src/enums/cache-database.ts | 2 +- src/enums/cache-target.ts | 2 +- src/enums/column-status.ts | 2 +- src/enums/compression.ts | 2 +- src/enums/console-resource-type.ts | 2 +- src/enums/credit-card.ts | 2 +- src/enums/database-status.ts | 2 +- src/enums/database-type.ts | 2 +- src/enums/databases-index-type.ts | 2 +- src/enums/deployment-download-type.ts | 2 +- src/enums/deployment-status.ts | 2 +- src/enums/detection-framework-type.ts | 2 +- src/enums/detection-runtime-type.ts | 2 +- src/enums/documents-db-index-type.ts | 2 +- src/enums/domain-purchase-status.ts | 2 +- src/enums/domain-registration-type.ts | 2 +- src/enums/domain-suggestion-type.ts | 2 +- src/enums/domain-transfer-status-enum.ts | 2 +- src/enums/embedding-model.ts | 4 +- src/enums/execution-method.ts | 2 +- src/enums/execution-resource-type.ts | 4 + src/enums/execution-status.ts | 2 +- src/enums/execution-trigger.ts | 2 +- src/enums/firebase-migration-resource.ts | 2 +- src/enums/flag.ts | 2 +- src/enums/framework.ts | 2 +- src/enums/function-template-use-case.ts | 2 +- src/enums/image-format.ts | 2 +- src/enums/image-gravity.ts | 3 +- src/enums/index-status.ts | 2 +- src/enums/invalidation-type.ts | 2 +- src/enums/message-priority.ts | 2 +- src/enums/message-status.ts | 2 +- src/enums/messaging-provider-type.ts | 2 +- src/enums/n-host-migration-resource.ts | 2 +- src/enums/o-auth-2-google-prompt.ts | 2 +- src/enums/o-auth-2-oidc-prompt.ts | 2 +- src/enums/o-auth-provider.ts | 7 +- src/enums/on-duplicate.ts | 2 +- src/enums/order-by.ts | 2 +- src/enums/organization-key-scopes.ts | 2 +- src/enums/password-hash.ts | 2 +- src/enums/platform-type.ts | 2 +- src/enums/platform.ts | 2 +- src/enums/project-auth-method-id.ts | 2 +- src/enums/project-email-template-id.ts | 2 +- src/enums/project-email-template-locale.ts | 2 +- src/enums/project-key-scopes.ts | 22 +- src/enums/project-o-auth-2-google-prompt.ts | 2 +- src/enums/project-o-auth-2-oidc-prompt.ts | 2 +- src/enums/project-o-auth-provider-id.ts | 7 +- src/enums/project-policy-id.ts | 3 +- src/enums/project-protocol-id.ts | 2 +- src/enums/project-service-id.ts | 2 +- src/enums/project-smtp-secure.ts | 2 +- src/enums/project-usage-range.ts | 2 +- src/enums/proxy-resource-type.ts | 2 +- .../proxy-rule-deployment-resource-type.ts | 2 +- src/enums/proxy-rule-status.ts | 2 +- src/enums/query-suggestion-resource.ts | 5 +- src/enums/region.ts | 2 +- src/enums/relation-mutate.ts | 2 +- src/enums/relationship-type.ts | 2 +- src/enums/runtime.ts | 5 +- src/enums/schedule-resource-type.ts | 2 +- src/enums/site-template-use-case.ts | 2 +- src/enums/smtp-encryption.ts | 2 +- src/enums/status-code.ts | 2 +- src/enums/status.ts | 2 +- src/enums/supabase-migration-resource.ts | 2 +- src/enums/tables-db-index-type.ts | 2 +- src/enums/template-reference-type.ts | 2 +- src/enums/timezone.ts | 2 +- src/enums/usage-event-dimension.ts | 8 +- src/enums/usage-event-metric.ts | 55 + src/enums/usage-gauge-dimension.ts | 2 +- src/enums/usage-gauge-metric.ts | 50 + src/enums/usage-interval.ts | 2 +- src/enums/usage-order-by.ts | 2 +- src/enums/usage-order-direction.ts | 2 +- src/enums/usage-range.ts | 2 +- src/enums/vcs-detection-type.ts | 2 +- src/enums/vcs-reference-type.ts | 2 +- src/enums/vectors-db-index-type.ts | 2 +- src/enums/waf-rule-action.ts | 2 +- src/id.ts | 7 +- src/index.ts | 20 +- src/models.ts | 1847 +++-- src/operator.ts | 542 +- src/permission.ts | 10 +- src/query.ts | 1242 +-- src/role.ts | 61 +- src/service.ts | 6 +- src/services/account.ts | 3437 ++++---- src/services/activities.ts | 76 +- src/services/advisor.ts | 261 +- src/services/affiliates.ts | 299 +- src/services/apps.ts | 1205 ++- src/services/assistant.ts | 37 +- src/services/avatars.ts | 754 +- src/services/backups.ts | 613 +- src/services/console.ts | 746 +- src/services/databases.ts | 6834 +++++++++++----- src/services/documents-db.ts | 2812 +++++-- src/services/domains.ts | 3758 ++++++--- src/services/embeddings.ts | 53 +- src/services/functions.ts | 2072 +++-- src/services/graphql.ts | 63 +- src/services/locale.ts | 118 +- src/services/manager.ts | 354 +- src/services/messaging.ts | 4646 ++++++++--- src/services/migrations.ts | 1298 ++- src/services/mongo.ts | 2117 +++-- src/services/mysql.ts | 2340 ++++-- src/services/notifications.ts | 90 +- src/services/oauth-2.ts | 1104 ++- src/services/organization.ts | 1015 ++- src/services/organizations.ts | 2912 ++++--- src/services/postgresql.ts | 2509 ++++-- src/services/presences.ts | 344 +- src/services/project.ts | 6331 ++++++++++----- src/services/projects.ts | 1025 ++- src/services/proxy.ts | 432 +- src/services/realtime.ts | 234 +- src/services/sites.ts | 1871 +++-- src/services/storage.ts | 971 ++- src/services/tables-db.ts | 6996 ++++++++++++----- src/services/teams.ts | 1146 ++- src/services/tokens.ts | 266 +- src/services/usage.ts | 302 +- src/services/users.ts | 2853 ++++--- src/services/vcs.ts | 788 +- src/services/vectors-db.ts | 2712 +++++-- src/services/waf.ts | 1294 ++- src/services/webhooks.ts | 382 +- tsconfig.json | 4 +- 1168 files changed, 54623 insertions(+), 26590 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 docs/examples/avatars/get-photo.md create mode 100644 docs/examples/domains/list-prices.md create mode 100644 docs/examples/project/update-mfa-factors-policy.md create mode 100644 docs/examples/project/update-o-auth-2-cloudflare.md create mode 100644 docs/examples/project/update-o-auth-2-hugging-face.md create mode 100644 docs/examples/project/update-o-auth-2-kakao.md create mode 100644 docs/examples/project/update-o-auth-2-resend.md create mode 100644 docs/examples/project/update-o-auth-2-tik-tok.md create mode 100644 docs/examples/tablesdb/create-cutover.md create mode 100644 docs/examples/users/get-mfa-challenge.md create mode 100644 eslint.config.mjs rename src/enums/{addon.ts => addon-key.ts} (84%) create mode 100644 src/enums/execution-resource-type.ts create mode 100644 src/enums/usage-event-metric.ts create mode 100644 src/enums/usage-gauge-metric.ts diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..c14dbf09 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +node_modules/ +dist/ +types/ +package-lock.json + +# CI workflow files follow the YAML conventions of the publishing repository, +# not this SDK's source formatting. +.github/ + +# README and CHANGELOG carry caller-supplied markdown verbatim, which this +# SDK's formatter must not rewrite. +README.md +CHANGELOG.md diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..9b0bb437 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "tabWidth": 4, + "singleQuote": true +} diff --git a/CHANGELOG.md b/CHANGELOG.md index b58ae8f1..554ab776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## 16.1.0 + +* Breaking: the `Addon` enum is now `AddonKey` +* Breaking: removed `EmbeddingModel.Bgesmall` and `EmbeddingModel.Embeddinggemma` +* Breaking: removed `ProjectKeyScopes.DedicatedDatabasesExecute`; dedicated database execution follows `databases.write` +* Breaking: removed the `DedicatedDatabaseSpecificationPricing` model +* Added: `avatars.getPhoto()` and `ImageGravity.Auto` +* Added: `domains.listPrices()` with the `DomainPricesList` model +* Added: `tablesDB.createCutover()` +* Added: `users.getMFAChallenge()` with the `MfaChallengeSecret` model +* Added: `project.updateMFAFactorsPolicy()` with the `PolicyMfaFactors` model, `ProjectPolicyId.Mfafactors` and `AuthenticationFactor.Custom` +* Added: `project.updateOAuth2Cloudflare()`, `updateOAuth2HuggingFace()`, `updateOAuth2Kakao()`, `updateOAuth2Resend()` and `updateOAuth2TikTok()`, with matching models and `OAuthProvider` / `ProjectOAuthProviderId` members +* Added: `UsageEventMetric` and `UsageGaugeMetric` enums for `usage.listEvents()` and `usage.listGauges()` +* Added: `ExecutionResourceType` enum +* Added: network dimensions to `UsageEventDimension` — `autonomousSystemNumber`, `autonomousSystemOrganization`, `connectionOrganization`, `connectionType`, `connectionUsageType` and `isp` +* Added: `documentsdb.*` and `vectorsdb.*` scopes plus `embeddings.write` to `ProjectKeyScopes` +* Added: `bun-1.4`, `dart-3.13` and `flutter-3.47` to the `Runtime` and `BuildRuntime` enums +* Added: `resourcesdeleted` to the `QuerySuggestionResource` enum + ## 16.0.0 * Breaking: Moved `vectorsDB.createTextEmbeddings()` to the new `Embeddings` service @@ -460,3 +479,4 @@ Fix bigint and float parsing in SDK. ## 1.5.0 * Adds support for `databasesReadsTotal` and `databasesWritesTotal` attributes + diff --git a/README.md b/README.md index 1d27d837..a9175d8a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Console SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.6-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.0.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 is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-console/releases).** +**This SDK targets Appwrite server version latest 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-console/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -25,7 +25,7 @@ npm install @appwrite.io/console --save If you're using a bundler (like [Rollup](https://rollupjs.org/) or [webpack](https://webpack.js.org/)), you can import the Appwrite module when you need it: ```js -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; ``` ### CDN @@ -33,10 +33,9 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` - ## Getting Started ### Add your Web Platform @@ -188,4 +187,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github ## License -Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. diff --git a/dist/cjs/package.json b/dist/cjs/package.json index 6a0d2ef2..1cd945a3 100644 --- a/dist/cjs/package.json +++ b/dist/cjs/package.json @@ -1,3 +1,3 @@ { "type": "commonjs" -} \ No newline at end of file +} diff --git a/dist/esm/package.json b/dist/esm/package.json index 96ae6e57..47200257 100644 --- a/dist/esm/package.json +++ b/dist/esm/package.json @@ -1,3 +1,3 @@ { "type": "module" -} \ No newline at end of file +} diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md index 8a84c929..baf532b8 100644 --- a/docs/examples/account/create-anonymous-session.md +++ b/docs/examples/account/create-anonymous-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/create-billing-address.md b/docs/examples/account/create-billing-address.md index 8382f46f..20912215 100644 --- a/docs/examples/account/create-billing-address.md +++ b/docs/examples/account/create-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await account.createBillingAddress({ streetAddress: '', addressLine2: '', // optional state: '', // optional - postalCode: '' // optional + postalCode: '', // optional }); console.log(result); diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 678501c6..e962d2a5 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.createEmailPasswordSession({ email: 'email@example.com', - password: 'password' + password: 'password', }); console.log(result); diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index ac4deedf..7f788612 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const account = new Account(client); const result = await account.createEmailToken({ userId: '', email: 'email@example.com', - phrase: false // optional + phrase: false, // optional }); console.log(result); diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md index d65d644e..fcc08c34 100644 --- a/docs/examples/account/create-email-verification.md +++ b/docs/examples/account/create-email-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.createEmailVerification({ - url: 'https://example.com' + url: 'https://example.com', }); console.log(result); diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index d3841a68..e107279d 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.createJWT({ - duration: 0 // optional + duration: 0, // optional }); console.log(result); diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md index 769228e8..34be1190 100644 --- a/docs/examples/account/create-key.md +++ b/docs/examples/account/create-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, AccountKeyScopes } from "@appwrite.io/console"; +import { Client, Account, AccountKeyScopes } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const account = new Account(client); const result = await account.createKey({ name: '', scopes: [AccountKeyScopes.Account], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/account/create-magic-url-token.md b/docs/examples/account/create-magic-url-token.md index 87fb96ae..0fbd00ee 100644 --- a/docs/examples/account/create-magic-url-token.md +++ b/docs/examples/account/create-magic-url-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await account.createMagicURLToken({ userId: '', email: 'email@example.com', url: 'https://example.com', // optional - phrase: false // optional + phrase: false, // optional }); console.log(result); diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 6e29cea2..8e31d83d 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, AuthenticatorType } from "@appwrite.io/console"; +import { Client, Account, AuthenticatorType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.createMFAAuthenticator({ - type: AuthenticatorType.Totp + type: AuthenticatorType.Totp, }); console.log(result); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 10d5136f..b8d5ed48 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, AuthenticationFactor } from "@appwrite.io/console"; +import { Client, Account, AuthenticationFactor } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.createMFAChallenge({ - factor: AuthenticationFactor.Email + factor: AuthenticationFactor.Email, }); console.log(result); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 2425d4ee..5e0aa3e8 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/create-o-auth-2-session.md b/docs/examples/account/create-o-auth-2-session.md index 304990e0..735fd2ea 100644 --- a/docs/examples/account/create-o-auth-2-session.md +++ b/docs/examples/account/create-o-auth-2-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, OAuthProvider } from "@appwrite.io/console"; +import { Client, Account, OAuthProvider } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,6 @@ account.createOAuth2Session({ provider: OAuthProvider.Amazon, success: 'https://example.com', // optional failure: 'https://example.com', // optional - scopes: [] // optional + scopes: [], // optional }); - ``` diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 5686fbc4..cf961db6 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, OAuthProvider } from "@appwrite.io/console"; +import { Client, Account, OAuthProvider } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,6 @@ account.createOAuth2Token({ provider: OAuthProvider.Amazon, success: 'https://example.com', // optional failure: 'https://example.com', // optional - scopes: [] // optional + scopes: [], // optional }); - ``` diff --git a/docs/examples/account/create-payment-method.md b/docs/examples/account/create-payment-method.md index 137b3b74..332f063e 100644 --- a/docs/examples/account/create-payment-method.md +++ b/docs/examples/account/create-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index 3b99a968..74b578a8 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.createPhoneToken({ userId: '', - phone: '+12065550100' + phone: '+12065550100', }); console.log(result); diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index 28d14c13..9e6c23a6 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/create-push-target.md b/docs/examples/account/create-push-target.md index 5f1ff794..1e26cc91 100644 --- a/docs/examples/account/create-push-target.md +++ b/docs/examples/account/create-push-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const account = new Account(client); const result = await account.createPushTarget({ targetId: '', identifier: '', - providerId: '' // optional + providerId: '', // optional }); console.log(result); diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 6174d234..383d39e9 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.createRecovery({ email: 'email@example.com', - url: 'https://example.com' + url: 'https://example.com', }); console.log(result); diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index 7e7d4798..1918832a 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.createSession({ userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index b8b93695..772576a6 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.createVerification({ - url: 'https://example.com' + url: 'https://example.com', }); console.log(result); diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index f1696abd..06ff6123 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await account.create({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/account/delete-billing-address.md b/docs/examples/account/delete-billing-address.md index bee345b6..eda14a73 100644 --- a/docs/examples/account/delete-billing-address.md +++ b/docs/examples/account/delete-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deleteBillingAddress({ - billingAddressId: '' + billingAddressId: '', }); console.log(result); diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index f8a60cbf..c4bd22fa 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.deleteConsentToken({ consentId: '', - tokenId: '' + tokenId: '', }); console.log(result); diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index 8fe33b0b..120afbb8 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deleteConsent({ - consentId: '' + consentId: '', }); console.log(result); diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 9a332b29..12e35d53 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deleteIdentity({ - identityId: '' + identityId: '', }); console.log(result); diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md index 92f4f9d7..7e22fba5 100644 --- a/docs/examples/account/delete-key.md +++ b/docs/examples/account/delete-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deleteKey({ - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 579dfbc1..b16e3594 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, AuthenticatorType } from "@appwrite.io/console"; +import { Client, Account, AuthenticatorType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deleteMFAAuthenticator({ - type: AuthenticatorType.Totp + type: AuthenticatorType.Totp, }); console.log(result); diff --git a/docs/examples/account/delete-payment-method.md b/docs/examples/account/delete-payment-method.md index d9cf02ac..38607568 100644 --- a/docs/examples/account/delete-payment-method.md +++ b/docs/examples/account/delete-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deletePaymentMethod({ - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/account/delete-push-target.md b/docs/examples/account/delete-push-target.md index a18fbfca..8aab3e35 100644 --- a/docs/examples/account/delete-push-target.md +++ b/docs/examples/account/delete-push-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deletePushTarget({ - targetId: '' + targetId: '', }); console.log(result); diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index b1f53ae1..6cdb3d4a 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.deleteSession({ - sessionId: '' + sessionId: '', }); console.log(result); diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index e1b64ddf..b363c935 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/delete.md b/docs/examples/account/delete.md index 4f1ce4e9..025be8e5 100644 --- a/docs/examples/account/delete.md +++ b/docs/examples/account/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/get-billing-address.md b/docs/examples/account/get-billing-address.md index 7ac96cc8..3be8f051 100644 --- a/docs/examples/account/get-billing-address.md +++ b/docs/examples/account/get-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.getBillingAddress({ - billingAddressId: '' + billingAddressId: '', }); console.log(result); diff --git a/docs/examples/account/get-consent-token.md b/docs/examples/account/get-consent-token.md index 8d1eff1f..18c13ebd 100644 --- a/docs/examples/account/get-consent-token.md +++ b/docs/examples/account/get-consent-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.getConsentToken({ consentId: '', - tokenId: '' + tokenId: '', }); console.log(result); diff --git a/docs/examples/account/get-consent.md b/docs/examples/account/get-consent.md index ba47b99f..1cd7874b 100644 --- a/docs/examples/account/get-consent.md +++ b/docs/examples/account/get-consent.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.getConsent({ - consentId: '' + consentId: '', }); console.log(result); diff --git a/docs/examples/account/get-coupon.md b/docs/examples/account/get-coupon.md index c3718d13..fa437bf0 100644 --- a/docs/examples/account/get-coupon.md +++ b/docs/examples/account/get-coupon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.getCoupon({ - couponId: '' + couponId: '', }); console.log(result); diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md index 24cb5eb8..035c7d12 100644 --- a/docs/examples/account/get-key.md +++ b/docs/examples/account/get-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.getKey({ - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 8f330891..e8cfcdaa 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/get-payment-method.md b/docs/examples/account/get-payment-method.md index ce60785a..be8de917 100644 --- a/docs/examples/account/get-payment-method.md +++ b/docs/examples/account/get-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.getPaymentMethod({ - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index 67801d20..850d7422 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index dee316f2..656077ce 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.getSession({ - sessionId: '' + sessionId: '', }); console.log(result); diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index 6f45cf31..56f8d381 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/list-billing-addresses.md b/docs/examples/account/list-billing-addresses.md index 21104387..6bf1a7d7 100644 --- a/docs/examples/account/list-billing-addresses.md +++ b/docs/examples/account/list-billing-addresses.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.listBillingAddresses({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/account/list-consent-tokens.md b/docs/examples/account/list-consent-tokens.md index 62e92e0c..2ebe0e27 100644 --- a/docs/examples/account/list-consent-tokens.md +++ b/docs/examples/account/list-consent-tokens.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const account = new Account(client); const result = await account.listConsentTokens({ consentId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/account/list-consents.md b/docs/examples/account/list-consents.md index 6b74896f..9bbe70f0 100644 --- a/docs/examples/account/list-consents.md +++ b/docs/examples/account/list-consents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.listConsents({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index c14c21ad..b3a989d0 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.listIdentities({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/account/list-invoices.md b/docs/examples/account/list-invoices.md index c950fe4e..99b676ee 100644 --- a/docs/examples/account/list-invoices.md +++ b/docs/examples/account/list-invoices.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.listInvoices({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md index f093b2a9..4384fd8b 100644 --- a/docs/examples/account/list-keys.md +++ b/docs/examples/account/list-keys.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.listKeys({ - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 2468c1a3..9b2d4e5c 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.listLogs({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index bbf10c48..952b0b36 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/list-payment-methods.md b/docs/examples/account/list-payment-methods.md index 7c974360..5818a6bb 100644 --- a/docs/examples/account/list-payment-methods.md +++ b/docs/examples/account/list-payment-methods.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.listPaymentMethods({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index b6f0cbc5..2270ddfd 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/update-billing-address.md b/docs/examples/account/update-billing-address.md index d21d8151..6b4fea16 100644 --- a/docs/examples/account/update-billing-address.md +++ b/docs/examples/account/update-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await account.updateBillingAddress({ streetAddress: '', addressLine2: '', // optional state: '', // optional - postalCode: '' // optional + postalCode: '', // optional }); console.log(result); diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md index 1ace42d7..a70d0af6 100644 --- a/docs/examples/account/update-email-verification.md +++ b/docs/examples/account/update-email-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updateEmailVerification({ userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 7f396f76..1487da47 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updateEmail({ email: 'email@example.com', - password: 'password' + password: 'password', }); console.log(result); diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md index d76022b8..e417b06b 100644 --- a/docs/examples/account/update-key.md +++ b/docs/examples/account/update-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, AccountKeyScopes } from "@appwrite.io/console"; +import { Client, Account, AccountKeyScopes } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await account.updateKey({ keyId: '', name: '', scopes: [AccountKeyScopes.Account], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/account/update-magic-url-session.md b/docs/examples/account/update-magic-url-session.md index 486ccd76..e0a2cb3c 100644 --- a/docs/examples/account/update-magic-url-session.md +++ b/docs/examples/account/update-magic-url-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updateMagicURLSession({ userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index f04ca1e1..19a8daf9 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, AuthenticatorType } from "@appwrite.io/console"; +import { Client, Account, AuthenticatorType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updateMFAAuthenticator({ type: AuthenticatorType.Totp, - otp: '' + otp: '', }); console.log(result); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 3ec065c9..39ecea2f 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updateMFAChallenge({ challengeId: '', - otp: '' + otp: '', }); console.log(result); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index f747ab7e..1e75b096 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/update-mfa.md b/docs/examples/account/update-mfa.md index 59b099cf..070761fd 100644 --- a/docs/examples/account/update-mfa.md +++ b/docs/examples/account/update-mfa.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.updateMFA({ - mfa: false + mfa: false, }); console.log(result); diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 88432c50..40bffbf9 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.updateName({ - name: '' + name: '', }); console.log(result); diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index f85a28b9..3eab9288 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updatePassword({ password: 'password', - oldPassword: 'password' // optional + oldPassword: 'password', // optional }); console.log(result); diff --git a/docs/examples/account/update-payment-method-mandate-options.md b/docs/examples/account/update-payment-method-mandate-options.md index 1b54e7af..5a233a16 100644 --- a/docs/examples/account/update-payment-method-mandate-options.md +++ b/docs/examples/account/update-payment-method-mandate-options.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.updatePaymentMethodMandateOptions({ - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/account/update-payment-method-provider.md b/docs/examples/account/update-payment-method-provider.md index 9ebed91f..f99cb7de 100644 --- a/docs/examples/account/update-payment-method-provider.md +++ b/docs/examples/account/update-payment-method-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await account.updatePaymentMethodProvider({ paymentMethodId: '', providerMethodId: '', name: '', - state: '' // optional + state: '', // optional }); console.log(result); diff --git a/docs/examples/account/update-payment-method.md b/docs/examples/account/update-payment-method.md index aca92fca..cd96a81a 100644 --- a/docs/examples/account/update-payment-method.md +++ b/docs/examples/account/update-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await account.updatePaymentMethod({ paymentMethodId: '', expiryMonth: 1, expiryYear: 2026, - state: '' // optional + state: '', // optional }); console.log(result); diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index 73bcd308..f1c43fe4 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updatePhoneSession({ userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 9cfd5c5b..ad5f9fb2 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updatePhoneVerification({ userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 5702ff76..b1f62528 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updatePhone({ phone: '+12065550100', - password: 'password' + password: 'password', }); console.log(result); diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index ce5cd037..41204cbb 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,10 +9,10 @@ const account = new Account(client); const result = await account.updatePrefs({ prefs: { - "language": "en", - "timezone": "UTC", - "darkTheme": true - } + language: 'en', + timezone: 'UTC', + darkTheme: true, + }, }); console.log(result); diff --git a/docs/examples/account/update-push-target.md b/docs/examples/account/update-push-target.md index fc66115e..cd8db7d4 100644 --- a/docs/examples/account/update-push-target.md +++ b/docs/examples/account/update-push-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updatePushTarget({ targetId: '', - identifier: '' + identifier: '', }); console.log(result); diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 001a77eb..046b6aeb 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const account = new Account(client); const result = await account.updateRecovery({ userId: '', secret: '', - password: 'password' + password: 'password', }); console.log(result); diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 0b455cbe..9bf22914 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const account = new Account(client); const result = await account.updateSession({ - sessionId: '' + sessionId: '', }); console.log(result); diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index b4c557cd..7b93b08d 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 5d1b312b..17de9ec0 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account } from "@appwrite.io/console"; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updateVerification({ userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md index ddf92144..ea21580b 100644 --- a/docs/examples/activities/get-event.md +++ b/docs/examples/activities/get-event.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Activities } from "@appwrite.io/console"; +import { Client, Activities } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const activities = new Activities(client); const result = await activities.getEvent({ - eventId: '' + eventId: '', }); console.log(result); diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md index eaca3dae..385132eb 100644 --- a/docs/examples/activities/list-events.md +++ b/docs/examples/activities/list-events.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Activities } from "@appwrite.io/console"; +import { Client, Activities } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const activities = new Activities(client); const result = await activities.listEvents({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/advisor/delete-report.md b/docs/examples/advisor/delete-report.md index d549dddb..376cba72 100644 --- a/docs/examples/advisor/delete-report.md +++ b/docs/examples/advisor/delete-report.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Advisor } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const advisor = new Advisor(client); const result = await advisor.deleteReport({ - reportId: '' + reportId: '', }); console.log(result); diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/advisor/get-insight.md index bf59a7ed..5ec1b6e3 100644 --- a/docs/examples/advisor/get-insight.md +++ b/docs/examples/advisor/get-insight.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Advisor } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const advisor = new Advisor(client); const result = await advisor.getInsight({ reportId: '', - insightId: '' + insightId: '', }); console.log(result); diff --git a/docs/examples/advisor/get-report.md b/docs/examples/advisor/get-report.md index cdb46636..4b96bf95 100644 --- a/docs/examples/advisor/get-report.md +++ b/docs/examples/advisor/get-report.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Advisor } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const advisor = new Advisor(client); const result = await advisor.getReport({ - reportId: '' + reportId: '', }); console.log(result); diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md index e3d97867..8eb4cbc7 100644 --- a/docs/examples/advisor/list-insights.md +++ b/docs/examples/advisor/list-insights.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Advisor } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const advisor = new Advisor(client); const result = await advisor.listInsights({ reportId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/advisor/list-reports.md index 5cf736e5..e76abbb0 100644 --- a/docs/examples/advisor/list-reports.md +++ b/docs/examples/advisor/list-reports.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Advisor } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const advisor = new Advisor(client); const result = await advisor.listReports({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/affiliates/create-link.md b/docs/examples/affiliates/create-link.md index f066dd71..1930a820 100644 --- a/docs/examples/affiliates/create-link.md +++ b/docs/examples/affiliates/create-link.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const affiliates = new Affiliates(client); const result = await affiliates.createLink({ linkId: '', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/affiliates/delete-link.md b/docs/examples/affiliates/delete-link.md index 7029e4f8..226a2bde 100644 --- a/docs/examples/affiliates/delete-link.md +++ b/docs/examples/affiliates/delete-link.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const affiliates = new Affiliates(client); const result = await affiliates.deleteLink({ - linkId: '' + linkId: '', }); console.log(result); diff --git a/docs/examples/affiliates/get-link.md b/docs/examples/affiliates/get-link.md index 1b9fe1e7..14e3a375 100644 --- a/docs/examples/affiliates/get-link.md +++ b/docs/examples/affiliates/get-link.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const affiliates = new Affiliates(client); const result = await affiliates.getLink({ - linkId: '' + linkId: '', }); console.log(result); diff --git a/docs/examples/affiliates/list-links.md b/docs/examples/affiliates/list-links.md index e755c3d4..3a422f78 100644 --- a/docs/examples/affiliates/list-links.md +++ b/docs/examples/affiliates/list-links.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const affiliates = new Affiliates(client); const result = await affiliates.listLinks({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/affiliates/list-referrals.md b/docs/examples/affiliates/list-referrals.md index 222423aa..6598ac16 100644 --- a/docs/examples/affiliates/list-referrals.md +++ b/docs/examples/affiliates/list-referrals.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const affiliates = new Affiliates(client); const result = await affiliates.listReferrals({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/affiliates/list-rewards.md b/docs/examples/affiliates/list-rewards.md index 7849ca6e..ee7d193a 100644 --- a/docs/examples/affiliates/list-rewards.md +++ b/docs/examples/affiliates/list-rewards.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const affiliates = new Affiliates(client); const result = await affiliates.listRewards({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/affiliates/update-reward.md b/docs/examples/affiliates/update-reward.md index 9771bf5b..7c853a67 100644 --- a/docs/examples/affiliates/update-reward.md +++ b/docs/examples/affiliates/update-reward.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Affiliates } from "@appwrite.io/console"; +import { Client, Affiliates } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const affiliates = new Affiliates(client); const result = await affiliates.updateReward({ rewardId: '', status: 'claimed', - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md index bcaca453..60808d5b 100644 --- a/docs/examples/apps/create-installation-token.md +++ b/docs/examples/apps/create-installation-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.createInstallationToken({ appId: '', - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/apps/create-key.md b/docs/examples/apps/create-key.md index 98b1af8e..0553fd69 100644 --- a/docs/examples/apps/create-key.md +++ b/docs/examples/apps/create-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const apps = new Apps(client); const result = await apps.createKey({ - appId: '' + appId: '', }); console.log(result); diff --git a/docs/examples/apps/create-secret.md b/docs/examples/apps/create-secret.md index 651f45ac..bb60cceb 100644 --- a/docs/examples/apps/create-secret.md +++ b/docs/examples/apps/create-secret.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const apps = new Apps(client); const result = await apps.createSecret({ - appId: '' + appId: '', }); console.log(result); diff --git a/docs/examples/apps/create.md b/docs/examples/apps/create.md index 86e839c7..a7c6d977 100644 --- a/docs/examples/apps/create.md +++ b/docs/examples/apps/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -26,7 +26,7 @@ const result = await apps.create({ enabled: false, // optional type: 'public', // optional deviceFlow: false, // optional - teamId: '' // optional + teamId: '', // optional }); console.log(result); diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index c57931f7..7bb3c64c 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.deleteInstallation({ appId: '', - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index 2229d74c..b4f94f41 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.deleteKey({ appId: '', - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index 563d686f..58a52497 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.deleteSecret({ appId: '', - secretId: '' + secretId: '', }); console.log(result); diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index ed8b5ead..0f2ad4d9 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const apps = new Apps(client); const result = await apps.deleteTokens({ - appId: '' + appId: '', }); console.log(result); diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index 4ca4b2c7..333faa60 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const apps = new Apps(client); const result = await apps.delete({ - appId: '' + appId: '', }); console.log(result); diff --git a/docs/examples/apps/get-installation.md b/docs/examples/apps/get-installation.md index 5043676b..0095f735 100644 --- a/docs/examples/apps/get-installation.md +++ b/docs/examples/apps/get-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.getInstallation({ appId: '', - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/apps/get-key.md b/docs/examples/apps/get-key.md index 9fb02e91..46ebde55 100644 --- a/docs/examples/apps/get-key.md +++ b/docs/examples/apps/get-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.getKey({ appId: '', - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/apps/get-secret.md b/docs/examples/apps/get-secret.md index 84c82082..65e9f718 100644 --- a/docs/examples/apps/get-secret.md +++ b/docs/examples/apps/get-secret.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.getSecret({ appId: '', - secretId: '' + secretId: '', }); console.log(result); diff --git a/docs/examples/apps/get.md b/docs/examples/apps/get.md index 5a278482..9e9b1b34 100644 --- a/docs/examples/apps/get.md +++ b/docs/examples/apps/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const apps = new Apps(client); const result = await apps.get({ - appId: '' + appId: '', }); console.log(result); diff --git a/docs/examples/apps/list-installation-scopes.md b/docs/examples/apps/list-installation-scopes.md index d9585fdb..e6aee5cd 100644 --- a/docs/examples/apps/list-installation-scopes.md +++ b/docs/examples/apps/list-installation-scopes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/apps/list-installations.md b/docs/examples/apps/list-installations.md index cc0805a8..34c5318c 100644 --- a/docs/examples/apps/list-installations.md +++ b/docs/examples/apps/list-installations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const apps = new Apps(client); const result = await apps.listInstallations({ appId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/apps/list-keys.md b/docs/examples/apps/list-keys.md index 0588b378..9b129252 100644 --- a/docs/examples/apps/list-keys.md +++ b/docs/examples/apps/list-keys.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const apps = new Apps(client); const result = await apps.listKeys({ appId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/apps/list-o-auth-2-scopes.md b/docs/examples/apps/list-o-auth-2-scopes.md index 52971fc9..d701935f 100644 --- a/docs/examples/apps/list-o-auth-2-scopes.md +++ b/docs/examples/apps/list-o-auth-2-scopes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/apps/list-secrets.md b/docs/examples/apps/list-secrets.md index 58124086..1c465a7e 100644 --- a/docs/examples/apps/list-secrets.md +++ b/docs/examples/apps/list-secrets.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const apps = new Apps(client); const result = await apps.listSecrets({ appId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/apps/list.md b/docs/examples/apps/list.md index 7fadc60d..ffb2bf9b 100644 --- a/docs/examples/apps/list.md +++ b/docs/examples/apps/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.list({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/apps/update-labels.md b/docs/examples/apps/update-labels.md index 502766eb..ed6c1188 100644 --- a/docs/examples/apps/update-labels.md +++ b/docs/examples/apps/update-labels.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.updateLabels({ appId: '', - labels: [] + labels: [], }); console.log(result); diff --git a/docs/examples/apps/update-team.md b/docs/examples/apps/update-team.md index fc93365c..15ec56be 100644 --- a/docs/examples/apps/update-team.md +++ b/docs/examples/apps/update-team.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const apps = new Apps(client); const result = await apps.updateTeam({ appId: '', - teamId: '' + teamId: '', }); console.log(result); diff --git a/docs/examples/apps/update.md b/docs/examples/apps/update.md index 5f792c3d..94131e6b 100644 --- a/docs/examples/apps/update.md +++ b/docs/examples/apps/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Apps } from "@appwrite.io/console"; +import { Client, Apps } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -27,7 +27,7 @@ const result = await apps.update({ type: 'public', // optional deviceFlow: false, // optional installationScopes: [], // optional - installationRedirectUrl: 'https://example.com' // optional + installationRedirectUrl: 'https://example.com', // optional }); console.log(result); diff --git a/docs/examples/assistant/chat.md b/docs/examples/assistant/chat.md index 9f8ee395..2131548d 100644 --- a/docs/examples/assistant/chat.md +++ b/docs/examples/assistant/chat.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Assistant } from "@appwrite.io/console"; +import { Client, Assistant } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const assistant = new Assistant(client); const result = await assistant.chat({ - prompt: '' + prompt: '', }); console.log(result); diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index b28ec7d9..5dd1daa6 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars, Browser } from "@appwrite.io/console"; +import { Client, Avatars, Browser } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = avatars.getBrowser({ code: Browser.AvantBrowser, width: 0, // optional height: 0, // optional - quality: -1 // optional + quality: -1, // optional }); console.log(result); diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 8949b1f4..dd386486 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars, CreditCard } from "@appwrite.io/console"; +import { Client, Avatars, CreditCard } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = avatars.getCreditCard({ code: CreditCard.AmericanExpress, width: 0, // optional height: 0, // optional - quality: -1 // optional + quality: -1, // optional }); console.log(result); diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 0df25533..ccb69b0a 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars } from "@appwrite.io/console"; +import { Client, Avatars } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const avatars = new Avatars(client); const result = avatars.getFavicon({ - url: 'https://example.com' + url: 'https://example.com', }); console.log(result); diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 122c988f..cacde8ff 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars, Flag } from "@appwrite.io/console"; +import { Client, Avatars, Flag } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = avatars.getFlag({ code: Flag.Afghanistan, width: 0, // optional height: 0, // optional - quality: -1 // optional + quality: -1, // optional }); console.log(result); diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index d24f49ef..8cf0eaa2 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars } from "@appwrite.io/console"; +import { Client, Avatars } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const avatars = new Avatars(client); const result = avatars.getImage({ url: 'https://example.com', width: 0, // optional - height: 0 // optional + height: 0, // optional }); console.log(result); diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 892497b2..ef898edd 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars } from "@appwrite.io/console"; +import { Client, Avatars } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = avatars.getInitials({ name: '', // optional width: 0, // optional height: 0, // optional - background: '' // optional + background: 'FFFFFF', // optional }); console.log(result); diff --git a/docs/examples/avatars/get-photo.md b/docs/examples/avatars/get-photo.md new file mode 100644 index 00000000..1ca4ed7e --- /dev/null +++ b/docs/examples/avatars/get-photo.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Avatars } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const avatars = new Avatars(client); + +const result = avatars.getPhoto({ + width: 0, // optional + height: 0, // optional + quality: 0, // optional + output: 'png', // optional + rating: 'g', // optional + userId: 'current()', // optional + emailHash: '', // optional + name: '', // optional +}); + +console.log(result); +``` diff --git a/docs/examples/avatars/get-qr.md b/docs/examples/avatars/get-qr.md index f15fa6e9..f6448841 100644 --- a/docs/examples/avatars/get-qr.md +++ b/docs/examples/avatars/get-qr.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars } from "@appwrite.io/console"; +import { Client, Avatars } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = avatars.getQR({ text: '', size: 1, // optional margin: 0, // optional - download: false // optional + download: false, // optional }); console.log(result); diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 45e3517f..0869f542 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -1,5 +1,12 @@ ```javascript -import { Client, Avatars, BrowserTheme, Timezone, BrowserPermission, ImageFormat } from "@appwrite.io/console"; +import { + Client, + Avatars, + BrowserTheme, + Timezone, + BrowserPermission, + ImageFormat, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,14 +17,15 @@ const avatars = new Avatars(client); const result = avatars.getScreenshot({ url: 'https://example.com', headers: { - "Authorization": "Bearer token123", - "X-Custom-Header": "value" + Authorization: 'Bearer token123', + 'X-Custom-Header': 'value', }, // optional viewportWidth: 1920, // optional viewportHeight: 1080, // optional scale: 2, // optional theme: BrowserTheme.Dark, // optional - userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional + userAgent: + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional fullpage: true, // optional locale: 'en-US', // optional timezone: Timezone.AfricaAbidjan, // optional @@ -25,12 +33,15 @@ const result = avatars.getScreenshot({ longitude: -122.4194, // optional accuracy: 100, // optional touch: true, // optional - permissions: [BrowserPermission.Geolocation, BrowserPermission.Notifications], // optional + permissions: [ + BrowserPermission.Geolocation, + BrowserPermission.Notifications, + ], // optional sleep: 3, // optional width: 800, // optional height: 600, // optional quality: 85, // optional - output: ImageFormat.Jpeg // optional + output: ImageFormat.Jpeg, // optional }); console.log(result); diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md index caccabbc..0e9f8584 100644 --- a/docs/examples/backups/create-archive.md +++ b/docs/examples/backups/create-archive.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups, BackupServices } from "@appwrite.io/console"; +import { Client, Backups, BackupServices } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const backups = new Backups(client); const result = await backups.createArchive({ services: [BackupServices.Databases], - resourceId: '' // optional + resourceId: '', // optional }); console.log(result); diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md index a1e5bc66..82370a16 100644 --- a/docs/examples/backups/create-policy.md +++ b/docs/examples/backups/create-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups, BackupServices } from "@appwrite.io/console"; +import { Client, Backups, BackupServices } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await backups.createPolicy({ schedule: '', name: '', // optional resourceId: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index c341e7e8..33154b2d 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups, BackupServices } from "@appwrite.io/console"; +import { Client, Backups, BackupServices } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await backups.createRestoration({ archiveId: '', services: [BackupServices.Databases], newResourceId: '', // optional - newResourceName: '' // optional + newResourceName: '', // optional }); console.log(result); diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index 9a32ac6a..0c334b5b 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.deleteArchive({ - archiveId: '' + archiveId: '', }); console.log(result); diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index bb2362b5..d212e307 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.deletePolicy({ - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md index ea1746e3..3329425b 100644 --- a/docs/examples/backups/get-archive.md +++ b/docs/examples/backups/get-archive.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.getArchive({ - archiveId: '' + archiveId: '', }); console.log(result); diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md index 6524dc52..91f04b2f 100644 --- a/docs/examples/backups/get-policy.md +++ b/docs/examples/backups/get-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.getPolicy({ - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md index e5374fa7..3be4bd74 100644 --- a/docs/examples/backups/get-restoration.md +++ b/docs/examples/backups/get-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.getRestoration({ - restorationId: '' + restorationId: '', }); console.log(result); diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md index b3fd6f1d..1cfba0fe 100644 --- a/docs/examples/backups/list-archives.md +++ b/docs/examples/backups/list-archives.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.listArchives({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md index 1c62348d..c67145c4 100644 --- a/docs/examples/backups/list-policies.md +++ b/docs/examples/backups/list-policies.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.listPolicies({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md index f0ed3955..1654b2e7 100644 --- a/docs/examples/backups/list-restorations.md +++ b/docs/examples/backups/list-restorations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const backups = new Backups(client); const result = await backups.listRestorations({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md index fea32a87..0dbd8651 100644 --- a/docs/examples/backups/update-policy.md +++ b/docs/examples/backups/update-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Backups } from "@appwrite.io/console"; +import { Client, Backups } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await backups.updatePolicy({ name: '', // optional retention: 1, // optional schedule: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/console/create-program-membership.md b/docs/examples/console/create-program-membership.md index 23ed45d7..3c6d7a95 100644 --- a/docs/examples/console/create-program-membership.md +++ b/docs/examples/console/create-program-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const xconsole = new Console(client); const result = await xconsole.createProgramMembership({ - programId: '' + programId: '', }); console.log(result); diff --git a/docs/examples/console/create-source.md b/docs/examples/console/create-source.md index b6307b1d..d981d8d8 100644 --- a/docs/examples/console/create-source.md +++ b/docs/examples/console/create-source.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await xconsole.createSource({ referrer: 'https://example.com', // optional utmSource: '', // optional utmCampaign: '', // optional - utmMedium: '' // optional + utmMedium: '', // optional }); console.log(result); diff --git a/docs/examples/console/get-campaign.md b/docs/examples/console/get-campaign.md index e9d41aeb..c9c1aaea 100644 --- a/docs/examples/console/get-campaign.md +++ b/docs/examples/console/get-campaign.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const xconsole = new Console(client); const result = await xconsole.getCampaign({ - campaignId: '' + campaignId: '', }); console.log(result); diff --git a/docs/examples/console/get-coupon.md b/docs/examples/console/get-coupon.md index 716d26a5..b6fd2690 100644 --- a/docs/examples/console/get-coupon.md +++ b/docs/examples/console/get-coupon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const xconsole = new Console(client); const result = await xconsole.getCoupon({ - couponId: '' + couponId: '', }); console.log(result); diff --git a/docs/examples/console/get-email-template.md b/docs/examples/console/get-email-template.md index 8f16d121..0f1ca893 100644 --- a/docs/examples/console/get-email-template.md +++ b/docs/examples/console/get-email-template.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Console, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "@appwrite.io/console"; +import { + Client, + Console, + ProjectEmailTemplateId, + ProjectEmailTemplateLocale, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +14,7 @@ const xconsole = new Console(client); const result = await xconsole.getEmailTemplate({ templateId: ProjectEmailTemplateId.Verification, - locale: ProjectEmailTemplateLocale.Af // optional + locale: ProjectEmailTemplateLocale.Af, // optional }); console.log(result); diff --git a/docs/examples/console/get-plan.md b/docs/examples/console/get-plan.md index 7171de67..cf5b96cb 100644 --- a/docs/examples/console/get-plan.md +++ b/docs/examples/console/get-plan.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const xconsole = new Console(client); const result = await xconsole.getPlan({ - planId: '' + planId: '', }); console.log(result); diff --git a/docs/examples/console/get-plans.md b/docs/examples/console/get-plans.md index c5d846a4..98cb395d 100644 --- a/docs/examples/console/get-plans.md +++ b/docs/examples/console/get-plans.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console, Platform } from "@appwrite.io/console"; +import { Client, Console, Platform } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const xconsole = new Console(client); const result = await xconsole.getPlans({ - platform: Platform.Appwrite // optional + platform: Platform.Appwrite, // optional }); console.log(result); diff --git a/docs/examples/console/get-program.md b/docs/examples/console/get-program.md index 5e19bcf0..c276879c 100644 --- a/docs/examples/console/get-program.md +++ b/docs/examples/console/get-program.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const xconsole = new Console(client); const result = await xconsole.getProgram({ - programId: '' + programId: '', }); console.log(result); diff --git a/docs/examples/console/get-resource.md b/docs/examples/console/get-resource.md index 699a83dd..76bd75a2 100644 --- a/docs/examples/console/get-resource.md +++ b/docs/examples/console/get-resource.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console, ConsoleResourceType } from "@appwrite.io/console"; +import { Client, Console, ConsoleResourceType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const xconsole = new Console(client); const result = await xconsole.getResource({ value: '', - type: ConsoleResourceType.Rules + type: ConsoleResourceType.Rules, }); console.log(result); diff --git a/docs/examples/console/list-databases.md b/docs/examples/console/list-databases.md index f5e298f4..d2097b35 100644 --- a/docs/examples/console/list-databases.md +++ b/docs/examples/console/list-databases.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const xconsole = new Console(client); const result = await xconsole.listDatabases({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/console/list-o-auth-2-providers.md b/docs/examples/console/list-o-auth-2-providers.md index 278d16da..9270d3bb 100644 --- a/docs/examples/console/list-o-auth-2-providers.md +++ b/docs/examples/console/list-o-auth-2-providers.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/console/list-organization-scopes.md b/docs/examples/console/list-organization-scopes.md index 0253b965..e6c927a0 100644 --- a/docs/examples/console/list-organization-scopes.md +++ b/docs/examples/console/list-organization-scopes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/console/list-postgres-extensions.md b/docs/examples/console/list-postgres-extensions.md index 84a2bcb3..eec953d6 100644 --- a/docs/examples/console/list-postgres-extensions.md +++ b/docs/examples/console/list-postgres-extensions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/console/list-project-scopes.md b/docs/examples/console/list-project-scopes.md index f59300a3..6ae75783 100644 --- a/docs/examples/console/list-project-scopes.md +++ b/docs/examples/console/list-project-scopes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/console/list-regions.md b/docs/examples/console/list-regions.md index ef750a85..895a8abf 100644 --- a/docs/examples/console/list-regions.md +++ b/docs/examples/console/list-regions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/console/suggest-columns.md b/docs/examples/console/suggest-columns.md index 50e866ed..e02d8775 100644 --- a/docs/examples/console/suggest-columns.md +++ b/docs/examples/console/suggest-columns.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await xconsole.suggestColumns({ tableId: '', context: '', // optional min: 1, // optional - max: 1 // optional + max: 1, // optional }); console.log(result); diff --git a/docs/examples/console/suggest-indexes.md b/docs/examples/console/suggest-indexes.md index 3014fc3d..a0c59677 100644 --- a/docs/examples/console/suggest-indexes.md +++ b/docs/examples/console/suggest-indexes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await xconsole.suggestIndexes({ databaseId: '', tableId: '', min: 1, // optional - max: 1 // optional + max: 1, // optional }); console.log(result); diff --git a/docs/examples/console/suggest-queries.md b/docs/examples/console/suggest-queries.md index cbffccc2..cfc1d5c2 100644 --- a/docs/examples/console/suggest-queries.md +++ b/docs/examples/console/suggest-queries.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console, QuerySuggestionResource } from "@appwrite.io/console"; +import { Client, Console, QuerySuggestionResource } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await xconsole.suggestQueries({ resource: QuerySuggestionResource.Activities, input: '', databaseId: '', // optional - tableId: '' // optional + tableId: '', // optional }); console.log(result); diff --git a/docs/examples/console/variables.md b/docs/examples/console/variables.md index 3eafec11..60eed558 100644 --- a/docs/examples/console/variables.md +++ b/docs/examples/console/variables.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Console } from "@appwrite.io/console"; +import { Client, Console } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md index f122c7c4..53071380 100644 --- a/docs/examples/databases/create-big-int-attribute.md +++ b/docs/examples/databases/create-big-int-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.createBigIntAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 1000000, // optional + xdefault: 0, // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 08c3b1b3..d2ccb080 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.createBooleanAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: false, // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 3cfc945d..65a37a47 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, Permission, Role } from "@appwrite.io/console"; +import { Client, Databases, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await databases.createCollection({ documentSecurity: false, // optional enabled: false, // optional attributes: [], // optional - indexes: [] // optional + indexes: [], // optional }); console.log(result); diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index 65849d9a..7d32531e 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.createDatetimeAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 4c664eca..4e814c97 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, Permission, Role } from "@appwrite.io/console"; +import { Client, Databases, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,14 +12,14 @@ const result = await databases.createDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 01ccfa64..e264c929 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.createDocuments({ databaseId: '', collectionId: '', documents: [], - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index d4b61f88..20441c04 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.createEmailAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 57794717..821034f6 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.createEnumAttribute({ databaseId: '', collectionId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', // optional - array: false // optional + xdefault: 'active', // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index 2b47891d..25e65418 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.createFloatAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10.5, // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 0f5fe9d2..01a86729 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Databases, DatabasesIndexType, OrderBy } from "@appwrite.io/console"; +import { + Client, + Databases, + DatabasesIndexType, + OrderBy, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +15,11 @@ const databases = new Databases(client); const result = await databases.createIndex({ databaseId: '', collectionId: '', - key: '', + key: '', type: DatabasesIndexType.Key, attributes: [], orders: [OrderBy.Asc], // optional - lengths: [] // optional + lengths: [], // optional }); console.log(result); diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index 346d3c42..18138ec2 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.createIntegerAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10, // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 028ce6d8..83b9e5bf 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.createIpAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional - array: false // optional + xdefault: '192.0.2.0', // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 4edfa325..e4b532ae 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,13 @@ const databases = new Databases(client); const result = await databases.createLineAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]] // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional }); console.log(result); diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md index 69e397a6..2fc6a4ad 100644 --- a/docs/examples/databases/create-longtext-attribute.md +++ b/docs/examples/databases/create-longtext-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.createLongtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md index 2f0a47bb..d32095bf 100644 --- a/docs/examples/databases/create-mediumtext-attribute.md +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.createMediumtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md index 3fb0d8e2..91dc151a 100644 --- a/docs/examples/databases/create-operations.md +++ b/docs/examples/databases/create-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,16 +10,16 @@ const databases = new Databases(client); const result = await databases.createOperations({ transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + { + action: 'create', + databaseId: '', + collectionId: '', + documentId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional }); console.log(result); diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index a42e0961..9a40ca1f 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,9 @@ const databases = new Databases(client); const result = await databases.createPointAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [1, 2] // optional + xdefault: [1, 2], // optional }); console.log(result); diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 0c1be0f2..c1e0165f 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,16 @@ const databases = new Databases(client); const result = await databases.createPolygonAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional }); console.log(result); diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 3981e35b..b5bc81da 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Databases, RelationshipType, RelationMutate } from "@appwrite.io/console"; +import { + Client, + Databases, + RelationshipType, + RelationMutate, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,9 +18,9 @@ const result = await databases.createRelationshipAttribute({ relatedCollectionId: '', type: RelationshipType.OneToOne, twoWay: false, // optional - key: '', // optional - twoWayKey: '', // optional - onDelete: RelationMutate.Cascade // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate.Cascade, // optional }); console.log(result); diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 2c33d118..62a5c5e2 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.createStringAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md index e301a34b..c79b9cf6 100644 --- a/docs/examples/databases/create-text-attribute.md +++ b/docs/examples/databases/create-text-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.createTextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md index 0cc19aff..ea5dff96 100644 --- a/docs/examples/databases/create-transaction.md +++ b/docs/examples/databases/create-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const databases = new Databases(client); const result = await databases.createTransaction({ - ttl: 60 // optional + ttl: 60, // optional }); console.log(result); diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 3886c900..1c44cb9e 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.createUrlAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md index d6a6664f..ed35bd74 100644 --- a/docs/examples/databases/create-varchar-attribute.md +++ b/docs/examples/databases/create-varchar-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.createVarcharAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 7afa30b8..bac0e977 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.create({ databaseId: '', name: '', - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index dbb0c6aa..275bfb03 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,10 +11,10 @@ const result = await databases.decrementDocumentAttribute({ databaseId: '', collectionId: '', documentId: '', - attribute: '', - value: null, // optional - min: null, // optional - transactionId: '' // optional + attribute: '', + value: 1, // optional + min: 0, // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index 911189a8..a3f89d4d 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.deleteAttribute({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 6b5b2d58..8a5962a8 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const databases = new Databases(client); const result = await databases.deleteCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); console.log(result); diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 7e14bd28..d5e12a18 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.deleteDocument({ databaseId: '', collectionId: '', documentId: '', - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 9b90816c..fd68feeb 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.deleteDocuments({ databaseId: '', collectionId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index ecdb3e2b..f1bd34fb 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.deleteIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md index 8800d0f1..680800e0 100644 --- a/docs/examples/databases/delete-transaction.md +++ b/docs/examples/databases/delete-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const databases = new Databases(client); const result = await databases.deleteTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 10424803..30228d97 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const databases = new Databases(client); const result = await databases.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index c59814cc..e8168682 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.getAttribute({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index dfeaf8b5..7d696f17 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const databases = new Databases(client); const result = await databases.getCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); console.log(result); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 2c21e0a2..d525527d 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await databases.getDocument({ collectionId: '', documentId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 030d604e..58ce1ea4 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.getIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md index a5c5be01..3a3a2e90 100644 --- a/docs/examples/databases/get-transaction.md +++ b/docs/examples/databases/get-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const databases = new Databases(client); const result = await databases.getTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index a10bf536..b0a7e7c8 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const databases = new Databases(client); const result = await databases.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 62aff0c9..733e98c0 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,10 +11,10 @@ const result = await databases.incrementDocumentAttribute({ databaseId: '', collectionId: '', documentId: '', - attribute: '', - value: null, // optional - max: null, // optional - transactionId: '' // optional + attribute: '', + value: 1, // optional + max: 100, // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 07dd4343..33ebc0b9 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.listAttributes({ databaseId: '', collectionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index c5af6024..c06ed133 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.listCollections({ databaseId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 9c412c5b..830c6ca3 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await databases.listDocuments({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); console.log(result); diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index ee4057d8..d537a018 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.listIndexes({ databaseId: '', collectionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index 11356cb6..37f2fde7 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const databases = new Databases(client); const result = await databases.listTransactions({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index c8794cfa..0b849758 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md index 48af1566..aa19ca5b 100644 --- a/docs/examples/databases/update-big-int-attribute.md +++ b/docs/examples/databases/update-big-int-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.updateBigIntAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 0, + min: 0, // optional + max: 1000000, // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index 89b2038b..c3fb9172 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateBooleanAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: false, - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index f39c0ded..c54a45f8 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, Permission, Role } from "@appwrite.io/console"; +import { Client, Databases, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await databases.updateCollection({ permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional enabled: false, // optional - purge: false // optional + purge: false, // optional }); console.log(result); diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index d83ce78d..38b6a4ad 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateDatetimeAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 4d16675e..1aeec1ca 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, Permission, Role } from "@appwrite.io/console"; +import { Client, Databases, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,14 +12,14 @@ const result = await databases.updateDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index a3c81ac8..949f3581 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,14 +11,14 @@ const result = await databases.updateDocuments({ databaseId: '', collectionId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index 12d6155a..4a9cfc5c 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateEmailAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 660ccef2..ffe1b42f 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.updateEnumAttribute({ databaseId: '', collectionId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'active', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 44b217e1..07b91e97 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.updateFloatAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10.5, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 44060d73..1dad2fd7 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const databases = new Databases(client); const result = await databases.updateIntegerAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index ad835da3..91e86d48 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateIpAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: '192.0.2.0', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index 728e06d2..1e43c8e5 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,14 @@ const databases = new Databases(client); const result = await databases.updateLineAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]], // optional - newKey: '' // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md index 71424460..6b30dc5f 100644 --- a/docs/examples/databases/update-longtext-attribute.md +++ b/docs/examples/databases/update-longtext-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateLongtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md index 691a346f..1e8ec3e3 100644 --- a/docs/examples/databases/update-mediumtext-attribute.md +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateMediumtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 040c8f68..faa33bef 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updatePointAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: [1, 2], // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index a35fbbd8..c9d40a4d 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,17 @@ const databases = new Databases(client); const result = await databases.updatePolygonAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional - newKey: '' // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 90ab8d6c..40c7c526 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, RelationMutate } from "@appwrite.io/console"; +import { Client, Databases, RelationMutate } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,9 @@ const databases = new Databases(client); const result = await databases.updateRelationshipAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', onDelete: RelationMutate.Cascade, // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 1c9e91c5..3fbbd666 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.updateStringAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md index e12557e1..8441402a 100644 --- a/docs/examples/databases/update-text-attribute.md +++ b/docs/examples/databases/update-text-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateTextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md index a46ecbd8..4e30b469 100644 --- a/docs/examples/databases/update-transaction.md +++ b/docs/examples/databases/update-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.updateTransaction({ transactionId: '', commit: false, // optional - rollback: false // optional + rollback: false, // optional }); console.log(result); diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index df026f35..be0192fd 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const databases = new Databases(client); const result = await databases.updateUrlAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md index 0ce1a55a..aaa7d392 100644 --- a/docs/examples/databases/update-varchar-attribute.md +++ b/docs/examples/databases/update-varchar-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const databases = new Databases(client); const result = await databases.updateVarcharAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index dbae9016..dcf5ad0c 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const databases = new Databases(client); const result = await databases.update({ databaseId: '', name: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 6c5a7636..ec7e32b0 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, Permission, Role } from "@appwrite.io/console"; +import { Client, Databases, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,14 +12,14 @@ const result = await databases.upsertDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index d94a1373..5ee9d710 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases } from "@appwrite.io/console"; +import { Client, Databases } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await databases.upsertDocuments({ databaseId: '', collectionId: '', documents: [], - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md index a1312824..36938f25 100644 --- a/docs/examples/documentsdb/create-collection.md +++ b/docs/examples/documentsdb/create-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, DocumentsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await documentsDB.createCollection({ documentSecurity: false, // optional enabled: false, // optional attributes: [], // optional - indexes: [] // optional + indexes: [], // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index a628708e..bde67443 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, DocumentsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,13 +12,14 @@ const result = await documentsDB.createDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, - permissions: [Permission.read(Role.any())] // optional + permissions: [Permission.read(Role.any())], // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 3880bb7e..1c961336 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,8 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.createDocuments({ databaseId: '', collectionId: '', - documents: [] + documents: [], + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create-failover.md b/docs/examples/documentsdb/create-failover.md index 067846c9..39cafef1 100644 --- a/docs/examples/documentsdb/create-failover.md +++ b/docs/examples/documentsdb/create-failover.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index d28785a0..ec398d9d 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -1,5 +1,10 @@ ```javascript -import { Client, DocumentsDB, DocumentsDBIndexType, OrderBy } from "@appwrite.io/console"; +import { + Client, + DocumentsDB, + DocumentsDBIndexType, + OrderBy, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +15,11 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.createIndex({ databaseId: '', collectionId: '', - key: '', + key: '', type: DocumentsDBIndexType.Key, attributes: [], orders: [OrderBy.Asc], // optional - lengths: [] // optional + lengths: [], // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md index a5854097..81770ad5 100644 --- a/docs/examples/documentsdb/create-transaction.md +++ b/docs/examples/documentsdb/create-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.createTransaction({ - ttl: 60 // optional + ttl: 60, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md index a397d8b3..e6ea3409 100644 --- a/docs/examples/documentsdb/create.md +++ b/docs/examples/documentsdb/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await documentsDB.create({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md index 873df72b..853c8b21 100644 --- a/docs/examples/documentsdb/decrement-document-attribute.md +++ b/docs/examples/documentsdb/decrement-document-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,10 +11,10 @@ const result = await documentsDB.decrementDocumentAttribute({ databaseId: '', collectionId: '', documentId: '', - attribute: '', - value: null, // optional - min: null, // optional - transactionId: '' // optional + attribute: '', + value: 1, // optional + min: 0, // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md index 708c1e4e..9b59e603 100644 --- a/docs/examples/documentsdb/delete-collection.md +++ b/docs/examples/documentsdb/delete-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.deleteCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md index 272379d1..a2985bab 100644 --- a/docs/examples/documentsdb/delete-document.md +++ b/docs/examples/documentsdb/delete-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await documentsDB.deleteDocument({ databaseId: '', collectionId: '', documentId: '', - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index 5aae827f..f9e603c0 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await documentsDB.deleteDocuments({ databaseId: '', collectionId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md index a36bff9f..27096d01 100644 --- a/docs/examples/documentsdb/delete-index.md +++ b/docs/examples/documentsdb/delete-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.deleteIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md index a22112d8..9ae98acf 100644 --- a/docs/examples/documentsdb/delete-transaction.md +++ b/docs/examples/documentsdb/delete-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.deleteTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md index 40e50d61..03a4b985 100644 --- a/docs/examples/documentsdb/delete.md +++ b/docs/examples/documentsdb/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md index 6179e8c5..3a20069c 100644 --- a/docs/examples/documentsdb/get-collection.md +++ b/docs/examples/documentsdb/get-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.getCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md index 916fe5c2..48df62f5 100644 --- a/docs/examples/documentsdb/get-document.md +++ b/docs/examples/documentsdb/get-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await documentsDB.getDocument({ collectionId: '', documentId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md index 0e971cb1..56508847 100644 --- a/docs/examples/documentsdb/get-index.md +++ b/docs/examples/documentsdb/get-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.getIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/documentsdb/get-replicas.md b/docs/examples/documentsdb/get-replicas.md index 73308e0b..5e9e4dd4 100644 --- a/docs/examples/documentsdb/get-replicas.md +++ b/docs/examples/documentsdb/get-replicas.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.getReplicas({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/get-status.md b/docs/examples/documentsdb/get-status.md index aecd9849..8a53e201 100644 --- a/docs/examples/documentsdb/get-status.md +++ b/docs/examples/documentsdb/get-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.getStatus({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md index 18217485..5d6fe4b2 100644 --- a/docs/examples/documentsdb/get-transaction.md +++ b/docs/examples/documentsdb/get-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.getTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md index 6c1392bd..c7f67d51 100644 --- a/docs/examples/documentsdb/get.md +++ b/docs/examples/documentsdb/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md index ba4f2e1d..3caa48d7 100644 --- a/docs/examples/documentsdb/increment-document-attribute.md +++ b/docs/examples/documentsdb/increment-document-attribute.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,10 +11,10 @@ const result = await documentsDB.incrementDocumentAttribute({ databaseId: '', collectionId: '', documentId: '', - attribute: '', - value: null, // optional - max: null, // optional - transactionId: '' // optional + attribute: '', + value: 1, // optional + max: 100, // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md index 340dbd5a..c0f532ea 100644 --- a/docs/examples/documentsdb/list-collections.md +++ b/docs/examples/documentsdb/list-collections.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await documentsDB.listCollections({ databaseId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md index fc9d443f..8d000756 100644 --- a/docs/examples/documentsdb/list-documents.md +++ b/docs/examples/documentsdb/list-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await documentsDB.listDocuments({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md index 43891aca..cfe94f50 100644 --- a/docs/examples/documentsdb/list-indexes.md +++ b/docs/examples/documentsdb/list-indexes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await documentsDB.listIndexes({ databaseId: '', collectionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/list-operations.md b/docs/examples/documentsdb/list-operations.md index c78d2f57..d0ec3a08 100644 --- a/docs/examples/documentsdb/list-operations.md +++ b/docs/examples/documentsdb/list-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,9 +9,9 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/list-specifications.md b/docs/examples/documentsdb/list-specifications.md index e3b9d45a..b5d87ea6 100644 --- a/docs/examples/documentsdb/list-specifications.md +++ b/docs/examples/documentsdb/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 6a291601..cf97fb49 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const documentsDB = new DocumentsDB(client); const result = await documentsDB.listTransactions({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md index 1812eebc..daf093de 100644 --- a/docs/examples/documentsdb/list.md +++ b/docs/examples/documentsdb/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.list({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md index 95d243d3..7bbdafc1 100644 --- a/docs/examples/documentsdb/update-collection.md +++ b/docs/examples/documentsdb/update-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, DocumentsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await documentsDB.updateCollection({ permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional enabled: false, // optional - purge: false // optional + purge: false, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md index 66d09372..ab279ca0 100644 --- a/docs/examples/documentsdb/update-document.md +++ b/docs/examples/documentsdb/update-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, DocumentsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await documentsDB.updateDocument({ documentId: '', data: {}, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md index f41af221..90b6f272 100644 --- a/docs/examples/documentsdb/update-documents.md +++ b/docs/examples/documentsdb/update-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await documentsDB.updateDocuments({ collectionId: '', data: {}, // optional queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md index 1c4daa45..f7f977d1 100644 --- a/docs/examples/documentsdb/update-transaction.md +++ b/docs/examples/documentsdb/update-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.updateTransaction({ transactionId: '', commit: false, // optional - rollback: false // optional + rollback: false, // optional }); console.log(result); diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md index 9ff70bb4..bda62362 100644 --- a/docs/examples/documentsdb/update.md +++ b/docs/examples/documentsdb/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await documentsDB.update({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md index 465d1bac..6a7c6290 100644 --- a/docs/examples/documentsdb/upsert-document.md +++ b/docs/examples/documentsdb/upsert-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, DocumentsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await documentsDB.upsertDocument({ documentId: '', data: {}, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index d67e350a..fb5a380a 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, DocumentsDB } from "@appwrite.io/console"; +import { Client, DocumentsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await documentsDB.upsertDocuments({ databaseId: '', collectionId: '', documents: [], - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md index 5d1a3502..ea79a4e5 100644 --- a/docs/examples/domains/create-preset-google-workspace.md +++ b/docs/examples/domains/create-preset-google-workspace.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPresetGoogleWorkspace({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md index 456f529c..4b39fc5e 100644 --- a/docs/examples/domains/create-preset-i-cloud.md +++ b/docs/examples/domains/create-preset-i-cloud.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPresetICloud({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md index 0cf4491c..90510b98 100644 --- a/docs/examples/domains/create-preset-mailgun.md +++ b/docs/examples/domains/create-preset-mailgun.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPresetMailgun({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md index 54410daf..07cf9277 100644 --- a/docs/examples/domains/create-preset-outlook.md +++ b/docs/examples/domains/create-preset-outlook.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPresetOutlook({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md index d881ae73..5841d976 100644 --- a/docs/examples/domains/create-preset-proton-mail.md +++ b/docs/examples/domains/create-preset-proton-mail.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPresetProtonMail({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md index 5725dab3..d00292d7 100644 --- a/docs/examples/domains/create-preset-zoho.md +++ b/docs/examples/domains/create-preset-zoho.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPresetZoho({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/create-purchase.md b/docs/examples/domains/create-purchase.md index 0e13e044..e0580e6c 100644 --- a/docs/examples/domains/create-purchase.md +++ b/docs/examples/domains/create-purchase.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createPurchase({ - domain: '', + domain: 'example.com', organizationId: '', firstName: '', lastName: '', @@ -19,7 +19,7 @@ const result = await domains.createPurchase({ addressLine3: '', // optional companyName: '', // optional periodYears: 1, // optional - autoRenewal: false // optional + autoRenewal: false, // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md index e1f86f70..dcc7de1a 100644 --- a/docs/examples/domains/create-record-a.md +++ b/docs/examples/domains/create-record-a.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordA({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md index 1bb59406..821e2670 100644 --- a/docs/examples/domains/create-record-aaaa.md +++ b/docs/examples/domains/create-record-aaaa.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordAAAA({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md index 8021cb48..b0b8c012 100644 --- a/docs/examples/domains/create-record-alias.md +++ b/docs/examples/domains/create-record-alias.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordAlias({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md index d687850d..f75caa62 100644 --- a/docs/examples/domains/create-record-caa.md +++ b/docs/examples/domains/create-record-caa.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordCAA({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md index f9ff80e2..8c61fd50 100644 --- a/docs/examples/domains/create-record-cname.md +++ b/docs/examples/domains/create-record-cname.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordCNAME({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md index ea86af0d..b1bb8059 100644 --- a/docs/examples/domains/create-record-https.md +++ b/docs/examples/domains/create-record-https.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordHTTPS({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md index dab869b4..58fca599 100644 --- a/docs/examples/domains/create-record-mx.md +++ b/docs/examples/domains/create-record-mx.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,8 +12,8 @@ const result = await domains.createRecordMX({ name: '', value: '', ttl: 1, - priority: null, - comment: '' // optional + priority: 0, + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md index d74987a6..cfdee71a 100644 --- a/docs/examples/domains/create-record-ns.md +++ b/docs/examples/domains/create-record-ns.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordNS({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md index 5ca333fd..54f4f958 100644 --- a/docs/examples/domains/create-record-srv.md +++ b/docs/examples/domains/create-record-srv.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,10 +12,10 @@ const result = await domains.createRecordSRV({ name: '', value: '', ttl: 1, - priority: null, - weight: null, - port: null, - comment: '' // optional + priority: 0, + weight: 0, + port: 0, + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md index 18111a38..7681e278 100644 --- a/docs/examples/domains/create-record-txt.md +++ b/docs/examples/domains/create-record-txt.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await domains.createRecordTXT({ name: '', ttl: 1, value: '', // optional - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/create-transfer-in.md b/docs/examples/domains/create-transfer-in.md index a5705d04..b5aac1cc 100644 --- a/docs/examples/domains/create-transfer-in.md +++ b/docs/examples/domains/create-transfer-in.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,11 +8,11 @@ const client = new Client() const domains = new Domains(client); const result = await domains.createTransferIn({ - domain: '', + domain: 'example.com', organizationId: '', authCode: '', paymentMethodId: '', - autoRenewal: false // optional + autoRenewal: false, // optional }); console.log(result); diff --git a/docs/examples/domains/create-transfer-out.md b/docs/examples/domains/create-transfer-out.md index e8107b9f..8e34d604 100644 --- a/docs/examples/domains/create-transfer-out.md +++ b/docs/examples/domains/create-transfer-out.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.createTransferOut({ domainId: '', - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md index b479e370..bbf6d079 100644 --- a/docs/examples/domains/create.md +++ b/docs/examples/domains/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.create({ teamId: '', - domain: '' + domain: 'example.com', }); console.log(result); diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md index 5d551ad9..3e7727d3 100644 --- a/docs/examples/domains/delete-record.md +++ b/docs/examples/domains/delete-record.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.deleteRecord({ domainId: '', - recordId: '' + recordId: '', }); console.log(result); diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md index b52b2565..ef437502 100644 --- a/docs/examples/domains/delete.md +++ b/docs/examples/domains/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.delete({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md index 01b78b65..c8068d2c 100644 --- a/docs/examples/domains/get-preset-google-workspace.md +++ b/docs/examples/domains/get-preset-google-workspace.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPresetGoogleWorkspace({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md index ba6eb991..fa143f7e 100644 --- a/docs/examples/domains/get-preset-i-cloud.md +++ b/docs/examples/domains/get-preset-i-cloud.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPresetICloud({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md index 3bce37db..2e94273c 100644 --- a/docs/examples/domains/get-preset-mailgun.md +++ b/docs/examples/domains/get-preset-mailgun.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPresetMailgun({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md index 67e3d8bd..a7986050 100644 --- a/docs/examples/domains/get-preset-outlook.md +++ b/docs/examples/domains/get-preset-outlook.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPresetOutlook({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md index 6fccf2c6..844428ed 100644 --- a/docs/examples/domains/get-preset-proton-mail.md +++ b/docs/examples/domains/get-preset-proton-mail.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPresetProtonMail({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md index 1dbf403e..2d4babee 100644 --- a/docs/examples/domains/get-preset-zoho.md +++ b/docs/examples/domains/get-preset-zoho.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPresetZoho({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index f3baafb5..4202f3ea 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains, DomainRegistrationType } from "@appwrite.io/console"; +import { Client, Domains, DomainRegistrationType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,9 +8,9 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getPrice({ - domain: '', + domain: 'example.com', periodYears: null, // optional - registrationType: DomainRegistrationType.New // optional + registrationType: DomainRegistrationType.New, // optional }); console.log(result); diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md index ba184a94..c5207130 100644 --- a/docs/examples/domains/get-record.md +++ b/docs/examples/domains/get-record.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.getRecord({ domainId: '', - recordId: '' + recordId: '', }); console.log(result); diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md index 3305e05c..a0620bb4 100644 --- a/docs/examples/domains/get-transfer-status.md +++ b/docs/examples/domains/get-transfer-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getTransferStatus({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md index b526aff8..e1b7a824 100644 --- a/docs/examples/domains/get-zone.md +++ b/docs/examples/domains/get-zone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.getZone({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md index b99cdc09..c2170166 100644 --- a/docs/examples/domains/get.md +++ b/docs/examples/domains/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.get({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md new file mode 100644 index 00000000..247cfebb --- /dev/null +++ b/docs/examples/domains/list-prices.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Domains, DomainRegistrationType } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const domains = new Domains(client); + +const result = await domains.listPrices({ + domains: [], + periodYears: null, // optional + registrationType: DomainRegistrationType.New, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md index ba51f9b0..eb9657a3 100644 --- a/docs/examples/domains/list-records.md +++ b/docs/examples/domains/list-records.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.listRecords({ domainId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/domains/list-suggestions.md b/docs/examples/domains/list-suggestions.md index 28c7b7ae..313c5bd2 100644 --- a/docs/examples/domains/list-suggestions.md +++ b/docs/examples/domains/list-suggestions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains, DomainSuggestionType } from "@appwrite.io/console"; +import { Client, Domains, DomainSuggestionType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.listSuggestions({ limit: null, // optional filterType: DomainSuggestionType.Premium, // optional priceMax: null, // optional - priceMin: null // optional + priceMin: null, // optional }); console.log(result); diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md index be05a032..c77ab41b 100644 --- a/docs/examples/domains/list.md +++ b/docs/examples/domains/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.list({ queries: [], // optional - search: '' // optional + search: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-auto-renewal.md b/docs/examples/domains/update-auto-renewal.md index 48512c06..e42364e2 100644 --- a/docs/examples/domains/update-auto-renewal.md +++ b/docs/examples/domains/update-auto-renewal.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.updateAutoRenewal({ domainId: '', - autoRenewal: false + autoRenewal: false, }); console.log(result); diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md index 31d34f3c..e8ad23b8 100644 --- a/docs/examples/domains/update-nameservers.md +++ b/docs/examples/domains/update-nameservers.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.updateNameservers({ domainId: '', - nameservers: [] // optional + nameservers: [], // optional }); console.log(result); diff --git a/docs/examples/domains/update-purchase.md b/docs/examples/domains/update-purchase.md index b2165d20..418bf4c2 100644 --- a/docs/examples/domains/update-purchase.md +++ b/docs/examples/domains/update-purchase.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.updatePurchase({ invoiceId: '', - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md index c8782ac9..21f66217 100644 --- a/docs/examples/domains/update-record-a.md +++ b/docs/examples/domains/update-record-a.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordA({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md index fa8064d4..2ff8cf1d 100644 --- a/docs/examples/domains/update-record-aaaa.md +++ b/docs/examples/domains/update-record-aaaa.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordAAAA({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md index 6f47e7af..691844b6 100644 --- a/docs/examples/domains/update-record-alias.md +++ b/docs/examples/domains/update-record-alias.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordAlias({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md index d380256d..ee7fda1e 100644 --- a/docs/examples/domains/update-record-caa.md +++ b/docs/examples/domains/update-record-caa.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordCAA({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md index 96bb86d4..f7911318 100644 --- a/docs/examples/domains/update-record-cname.md +++ b/docs/examples/domains/update-record-cname.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordCNAME({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md index fd17d4e0..02dfe5c1 100644 --- a/docs/examples/domains/update-record-https.md +++ b/docs/examples/domains/update-record-https.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordHTTPS({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md index d6b4157e..a0459f6e 100644 --- a/docs/examples/domains/update-record-mx.md +++ b/docs/examples/domains/update-record-mx.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,8 +13,8 @@ const result = await domains.updateRecordMX({ name: '', value: '', ttl: 1, - priority: null, - comment: '' // optional + priority: 0, + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md index 34185100..6b45612a 100644 --- a/docs/examples/domains/update-record-ns.md +++ b/docs/examples/domains/update-record-ns.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordNS({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md index 880012be..bdaaee23 100644 --- a/docs/examples/domains/update-record-srv.md +++ b/docs/examples/domains/update-record-srv.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,10 +13,10 @@ const result = await domains.updateRecordSRV({ name: '', value: '', ttl: 1, - priority: null, - weight: null, - port: null, - comment: '' // optional + priority: 0, + weight: 0, + port: 0, + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md index f1fd63ec..94046032 100644 --- a/docs/examples/domains/update-record-txt.md +++ b/docs/examples/domains/update-record-txt.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await domains.updateRecordTXT({ name: '', value: '', ttl: 1, - comment: '' // optional + comment: '', // optional }); console.log(result); diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md index 2c56c966..f0a02da9 100644 --- a/docs/examples/domains/update-team.md +++ b/docs/examples/domains/update-team.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.updateTeam({ domainId: '', - teamId: '' + teamId: '', }); console.log(result); diff --git a/docs/examples/domains/update-transfer-in.md b/docs/examples/domains/update-transfer-in.md index 04ea5201..bb44ada9 100644 --- a/docs/examples/domains/update-transfer-in.md +++ b/docs/examples/domains/update-transfer-in.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.updateTransferIn({ invoiceId: '', - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md index a8308c27..cbe1b049 100644 --- a/docs/examples/domains/update-zone.md +++ b/docs/examples/domains/update-zone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const domains = new Domains(client); const result = await domains.updateZone({ domainId: '', - content: '' + content: '', }); console.log(result); diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md index 6c082ed2..c33f5786 100644 --- a/docs/examples/domains/verify-nameservers.md +++ b/docs/examples/domains/verify-nameservers.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains } from "@appwrite.io/console"; +import { Client, Domains } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const domains = new Domains(client); const result = await domains.verifyNameservers({ - domainId: '' + domainId: '', }); console.log(result); diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 4c9fb022..0b93299b 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Embeddings, EmbeddingModel } from "@appwrite.io/console"; +import { Client, Embeddings, EmbeddingModel } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const embeddings = new Embeddings(client); const result = await embeddings.createTextEmbeddings({ texts: [], - model: EmbeddingModel.NomicEmbedText // optional + model: EmbeddingModel.NomicEmbedText, // optional }); console.log(result); diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 020c4aad..a30cf672 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await functions.createDeployment({ code: document.getElementById('uploader').files[0], activate: false, entrypoint: '', // optional - commands: '' // optional + commands: '', // optional }); console.log(result); diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md index 77e792b3..35263d98 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const functions = new Functions(client); const result = await functions.createDuplicateDeployment({ functionId: '', deploymentId: '', - buildId: '' // optional + buildId: '', // optional }); console.log(result); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 2707b790..fc11f95a 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions, ExecutionMethod } from "@appwrite.io/console"; +import { Client, Functions, ExecutionMethod } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await functions.createExecution({ xpath: '', // optional method: ExecutionMethod.GET, // optional headers: {}, // optional - scheduledAt: '' // optional + scheduledAt: '', // optional }); console.log(result); diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index 6e311461..a445c48c 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions, TemplateReferenceType } from "@appwrite.io/console"; +import { Client, Functions, TemplateReferenceType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await functions.createTemplateDeployment({ rootDirectory: '', type: TemplateReferenceType.Commit, reference: '', - activate: false // optional + activate: false, // optional }); console.log(result); diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 444a0c6c..c70f0376 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await functions.createVariable({ variableId: '', key: '', value: '', - secret: false // optional + secret: false, // optional }); console.log(result); diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index 50a54465..22b9775e 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions, VCSReferenceType } from "@appwrite.io/console"; +import { Client, Functions, VCSReferenceType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await functions.createVcsDeployment({ functionId: '', type: VCSReferenceType.Branch, reference: '', - activate: false // optional + activate: false, // optional }); console.log(result); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index cd1c7983..aeb31eff 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Functions, Runtime, ProjectKeyScopes } from "@appwrite.io/console"; +import { + Client, + Functions, + Runtime, + ProjectKeyScopes, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,9 +16,9 @@ const result = await functions.create({ functionId: '', name: '', runtime: Runtime.Node145, - execute: ["any"], // optional + execute: ['any'], // optional events: [], // optional - schedule: '', // optional + schedule: '0 0 * * *', // optional timeout: 1, // optional enabled: false, // optional logging: false, // optional @@ -27,9 +32,9 @@ const result = await functions.create({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional }); console.log(result); diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index 9fee1bfd..b5e9905e 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.deleteDeployment({ functionId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md index 4f8569be..fecb6d13 100644 --- a/docs/examples/functions/delete-execution.md +++ b/docs/examples/functions/delete-execution.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.deleteExecution({ functionId: '', - executionId: '' + executionId: '', }); console.log(result); diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index 5775d4db..dbe969e5 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.deleteVariable({ functionId: '', - variableId: '' + variableId: '', }); console.log(result); diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index 141706ca..a5538df9 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const functions = new Functions(client); const result = await functions.delete({ - functionId: '' + functionId: '', }); console.log(result); diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index 499dfc63..63242146 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Functions, DeploymentDownloadType } from "@appwrite.io/console"; +import { + Client, + Functions, + DeploymentDownloadType, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +15,7 @@ const result = functions.getDeploymentDownload({ functionId: '', deploymentId: '', type: DeploymentDownloadType.Source, // optional - token: '' // optional + token: '', // optional }); console.log(result); diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 34ebaaca..2b11b036 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.getDeployment({ functionId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index dc49ea5d..52b2192e 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.getExecution({ functionId: '', - executionId: '' + executionId: '', }); console.log(result); diff --git a/docs/examples/functions/get-template.md b/docs/examples/functions/get-template.md index 64c515d6..7202df56 100644 --- a/docs/examples/functions/get-template.md +++ b/docs/examples/functions/get-template.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const functions = new Functions(client); const result = await functions.getTemplate({ - templateId: '' + templateId: '', }); console.log(result); diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 31417ad2..9453004a 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.getVariable({ functionId: '', - variableId: '' + variableId: '', }); console.log(result); diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 9cdadfbf..3ade4a7c 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const functions = new Functions(client); const result = await functions.get({ - functionId: '' + functionId: '', }); console.log(result); diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 07f50b09..4dce4288 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await functions.listDeployments({ functionId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index b0456057..009c49f3 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const functions = new Functions(client); const result = await functions.listExecutions({ functionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 6136507d..634305df 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index d69e34a6..b67d111c 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const functions = new Functions(client); const result = await functions.listSpecifications({ - type: 'runtimes' // optional + type: 'runtimes', // optional }); console.log(result); diff --git a/docs/examples/functions/list-templates.md b/docs/examples/functions/list-templates.md index 0218028a..8226ace5 100644 --- a/docs/examples/functions/list-templates.md +++ b/docs/examples/functions/list-templates.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Functions, Runtime, FunctionTemplateUseCase } from "@appwrite.io/console"; +import { + Client, + Functions, + Runtime, + FunctionTemplateUseCase, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +17,7 @@ const result = await functions.listTemplates({ useCases: [FunctionTemplateUseCase.Starter], // optional limit: 1, // optional offset: 0, // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index 9407b8ef..a0b0e640 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const functions = new Functions(client); const result = await functions.listVariables({ functionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 83272a93..c9115bdc 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const functions = new Functions(client); const result = await functions.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md index 6a2d1472..176260f6 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.updateDeploymentStatus({ functionId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index d5fed6e0..24eca47a 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const functions = new Functions(client); const result = await functions.updateFunctionDeployment({ functionId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 5d7dc9aa..d319ba4a 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions } from "@appwrite.io/console"; +import { Client, Functions } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await functions.updateVariable({ variableId: '', key: '', // optional value: '', // optional - secret: false // optional + secret: false, // optional }); console.log(result); diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 98a161de..ad32ec14 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Functions, Runtime, ProjectKeyScopes } from "@appwrite.io/console"; +import { + Client, + Functions, + Runtime, + ProjectKeyScopes, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,9 +16,9 @@ const result = await functions.update({ functionId: '', name: '', runtime: Runtime.Node145, // optional - execute: ["any"], // optional + execute: ['any'], // optional events: [], // optional - schedule: '', // optional + schedule: '0 0 * * *', // optional timeout: 1, // optional enabled: false, // optional logging: false, // optional @@ -27,9 +32,9 @@ const result = await functions.update({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional }); console.log(result); diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index f8efffe8..25c0ffbd 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Graphql } from "@appwrite.io/console"; +import { Client, Graphql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const graphql = new Graphql(client); const result = await graphql.mutation({ - query: {} + query: {}, }); console.log(result); diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 604e431c..73b3da23 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Graphql } from "@appwrite.io/console"; +import { Client, Graphql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const graphql = new Graphql(client); const result = await graphql.query({ - query: {} + query: {}, }); console.log(result); diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 37b25923..4432c7ee 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index 739e3255..815fc01a 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 56fbe897..89bfc10a 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index aca056bb..0223e047 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 41de55a7..e172ecf1 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index f6d7b9e8..b40c2c64 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index 18fc15b6..ccdceeea 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index 93f34bf8..26688ff7 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Locale } from "@appwrite.io/console"; +import { Client, Locale } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/manager/create-block.md b/docs/examples/manager/create-block.md index a33b52f8..a63a5f11 100644 --- a/docs/examples/manager/create-block.md +++ b/docs/examples/manager/create-block.md @@ -1,8 +1,14 @@ ```javascript -import { Client, Manager, BlockResourceType, BlockMode } from "@appwrite.io/console"; +import { + Client, + Manager, + BlockResourceType, + BlockMode, +} from '@appwrite.io/console'; -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint +const client = new Client().setEndpoint( + 'https://.cloud.appwrite.io/v1', +); // Your API Endpoint const manager = new Manager(client); @@ -12,7 +18,7 @@ const result = await manager.createBlock({ resourceId: '', // optional mode: BlockMode.Full, // optional reason: '', // optional - expiredAt: '2020-10-15T06:38:00.000+00:00' // optional + expiredAt: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/manager/delete-block.md b/docs/examples/manager/delete-block.md index b9b0ded7..220da098 100644 --- a/docs/examples/manager/delete-block.md +++ b/docs/examples/manager/delete-block.md @@ -1,15 +1,16 @@ ```javascript -import { Client, Manager, BlockResourceType } from "@appwrite.io/console"; +import { Client, Manager, BlockResourceType } from '@appwrite.io/console'; -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint +const client = new Client().setEndpoint( + 'https://.cloud.appwrite.io/v1', +); // Your API Endpoint const manager = new Manager(client); const result = await manager.deleteBlock({ projectId: '', resourceType: BlockResourceType.Projects, - resourceId: '' // optional + resourceId: '', // optional }); console.log(result); diff --git a/docs/examples/manager/delete-cache.md b/docs/examples/manager/delete-cache.md index f8ee50c5..fc821a1e 100644 --- a/docs/examples/manager/delete-cache.md +++ b/docs/examples/manager/delete-cache.md @@ -1,8 +1,15 @@ ```javascript -import { Client, Manager, Region, CacheTarget, CacheDatabase } from "@appwrite.io/console"; +import { + Client, + Manager, + Region, + CacheTarget, + CacheDatabase, +} from '@appwrite.io/console'; -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint +const client = new Client().setEndpoint( + 'https://.cloud.appwrite.io/v1', +); // Your API Endpoint const manager = new Manager(client); @@ -13,7 +20,7 @@ const result = await manager.deleteCache({ database: CacheDatabase.Console, // optional projectId: '', // optional collectionId: '', // optional - documentId: '' // optional + documentId: '', // optional }); console.log(result); diff --git a/docs/examples/manager/list-blocks.md b/docs/examples/manager/list-blocks.md index 0bdd5c10..7d93e76c 100644 --- a/docs/examples/manager/list-blocks.md +++ b/docs/examples/manager/list-blocks.md @@ -1,13 +1,14 @@ ```javascript -import { Client, Manager } from "@appwrite.io/console"; +import { Client, Manager } from '@appwrite.io/console'; -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint +const client = new Client().setEndpoint( + 'https://.cloud.appwrite.io/v1', +); // Your API Endpoint const manager = new Manager(client); const result = await manager.listBlocks({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/manager/update-user-status.md b/docs/examples/manager/update-user-status.md index 34af5753..6d6a0a7e 100644 --- a/docs/examples/manager/update-user-status.md +++ b/docs/examples/manager/update-user-status.md @@ -1,8 +1,9 @@ ```javascript -import { Client, Manager } from "@appwrite.io/console"; +import { Client, Manager } from '@appwrite.io/console'; -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint +const client = new Client().setEndpoint( + 'https://.cloud.appwrite.io/v1', +); // Your API Endpoint const manager = new Manager(client); @@ -10,7 +11,7 @@ const result = await manager.updateUserStatus({ status: false, userId: '', // optional email: '', // optional - reason: '' // optional + reason: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index a361f0d4..5a9f66ee 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await messaging.createAPNSProvider({ teamId: '', // optional bundleId: '', // optional sandbox: false, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 6c6fa02f..a6da1435 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -19,7 +19,7 @@ const result = await messaging.createEmail({ attachments: [], // optional draft: false, // optional html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index 382ffe1d..74b9c95a 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await messaging.createFCMProvider({ providerId: '', name: '', serviceAccountJSON: {}, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index 956f9138..0338191d 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,13 +11,13 @@ const result = await messaging.createMailgunProvider({ providerId: '', name: '', apiKey: '', // optional - domain: '', // optional + domain: 'example.com', // optional isEuRegion: false, // optional fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-msg-91-provider.md b/docs/examples/messaging/create-msg-91-provider.md index 79135cb5..2f5462df 100644 --- a/docs/examples/messaging/create-msg-91-provider.md +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.createMsg91Provider({ templateId: '', // optional senderId: '', // optional authKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 24385f72..7235c19d 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging, MessagePriority } from "@appwrite.io/console"; +import { Client, Messaging, MessagePriority } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -21,12 +21,12 @@ const result = await messaging.createPush({ sound: '', // optional color: '', // optional tag: '', // optional - badge: null, // optional + badge: 1, // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional contentAvailable: false, // optional critical: false, // optional - priority: MessagePriority.Normal // optional + priority: MessagePriority.Normal, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md index 5de02136..bac27462 100644 --- a/docs/examples/messaging/create-resend-provider.md +++ b/docs/examples/messaging/create-resend-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await messaging.createResendProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index c03cdc80..d2cbe270 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await messaging.createSendgridProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-ses-provider.md b/docs/examples/messaging/create-ses-provider.md index 2021d442..f039f45c 100644 --- a/docs/examples/messaging/create-ses-provider.md +++ b/docs/examples/messaging/create-ses-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await messaging.createSesProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index a6e0e0ec..9dbafdd4 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await messaging.createSMS({ users: [], // optional targets: [], // optional draft: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index aa0b8bcc..3911e73d 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging, SmtpEncryption } from "@appwrite.io/console"; +import { Client, Messaging, SmtpEncryption } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await messaging.createSMTPProvider({ providerId: '', name: '', host: '', - port: 1, // optional + port: 587, // optional username: '', // optional password: 'password', // optional encryption: SmtpEncryption.None, // optional @@ -21,7 +21,7 @@ const result = await messaging.createSMTPProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index d5abed7a..1a87cce5 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.createSubscriber({ topicId: '', subscriberId: '', - targetId: '' + targetId: '', }); console.log(result); diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md index fecf2bbd..546b7957 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.createTelesignProvider({ from: '+12065550100', // optional customerId: '', // optional apiKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md index dce3a211..3501221a 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.createTextmagicProvider({ from: '+12065550100', // optional username: '', // optional apiKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 9a86f78b..1757fa6f 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.createTopic({ topicId: '', name: '', - subscribe: ["any"] // optional + subscribe: ['any'], // optional }); console.log(result); diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 53d00487..75a41f89 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.createTwilioProvider({ from: '+12065550100', // optional accountSid: '', // optional authToken: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md index 8e970d6f..d3e46c87 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.createVonageProvider({ from: '+12065550100', // optional apiKey: '', // optional apiSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md index e4f0b6a8..60d6a78f 100644 --- a/docs/examples/messaging/delete-provider.md +++ b/docs/examples/messaging/delete-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const messaging = new Messaging(client); const result = await messaging.deleteProvider({ - providerId: '' + providerId: '', }); console.log(result); diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index 9dea15eb..1c182f9d 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const messaging = new Messaging(client); const result = await messaging.deleteSubscriber({ topicId: '', - subscriberId: '' + subscriberId: '', }); console.log(result); diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md index fb07baf0..485e0f0b 100644 --- a/docs/examples/messaging/delete-topic.md +++ b/docs/examples/messaging/delete-topic.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const messaging = new Messaging(client); const result = await messaging.deleteTopic({ - topicId: '' + topicId: '', }); console.log(result); diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md index e8702e57..cf354e28 100644 --- a/docs/examples/messaging/delete.md +++ b/docs/examples/messaging/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const messaging = new Messaging(client); const result = await messaging.delete({ - messageId: '' + messageId: '', }); console.log(result); diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index d5e777b3..2b9c46c5 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const messaging = new Messaging(client); const result = await messaging.getMessage({ - messageId: '' + messageId: '', }); console.log(result); diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index d2adcc1e..8eb52b00 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const messaging = new Messaging(client); const result = await messaging.getProvider({ - providerId: '' + providerId: '', }); console.log(result); diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index 3a6b0c4e..59b51203 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const messaging = new Messaging(client); const result = await messaging.getSubscriber({ topicId: '', - subscriberId: '' + subscriberId: '', }); console.log(result); diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md index 6efb434b..92fce949 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const messaging = new Messaging(client); const result = await messaging.getTopic({ - topicId: '' + topicId: '', }); console.log(result); diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index 86d2a6b1..444c4aba 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.listMessages({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index ab3cf343..d21b7b0b 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.listProviders({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index c7aabf9c..2b7c7fe0 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await messaging.listSubscribers({ topicId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 613be120..a23399e8 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.listTargets({ messageId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index c2af07ed..63a2fbca 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.listTopics({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index dd06d118..b1eade77 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await messaging.updateAPNSProvider({ authKeyId: '', // optional teamId: '', // optional bundleId: '', // optional - sandbox: false // optional + sandbox: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 819b9f13..77f765a4 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -19,7 +19,7 @@ const result = await messaging.updateEmail({ cc: [], // optional bcc: [], // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional - attachments: [] // optional + attachments: [], // optional }); console.log(result); diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index c16475be..6d961eaa 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await messaging.updateFCMProvider({ providerId: '', name: '', // optional enabled: false, // optional - serviceAccountJSON: {} // optional + serviceAccountJSON: {}, // optional }); console.log(result); diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index e78d7027..5dd79687 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,13 +11,13 @@ const result = await messaging.updateMailgunProvider({ providerId: '', name: '', // optional apiKey: '', // optional - domain: '', // optional + domain: 'example.com', // optional isEuRegion: false, // optional enabled: false, // optional fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-msg-91-provider.md b/docs/examples/messaging/update-msg-91-provider.md index 7aa3ec3f..40aab69d 100644 --- a/docs/examples/messaging/update-msg-91-provider.md +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.updateMsg91Provider({ enabled: false, // optional templateId: '', // optional senderId: '', // optional - authKey: '' // optional + authKey: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index bb0448b4..f7c46bcf 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging, MessagePriority } from "@appwrite.io/console"; +import { Client, Messaging, MessagePriority } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -21,12 +21,12 @@ const result = await messaging.updatePush({ sound: '', // optional color: '', // optional tag: '', // optional - badge: null, // optional + badge: 1, // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional contentAvailable: false, // optional critical: false, // optional - priority: MessagePriority.Normal // optional + priority: MessagePriority.Normal, // optional }); console.log(result); diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md index cfbc37d0..c9ec7c93 100644 --- a/docs/examples/messaging/update-resend-provider.md +++ b/docs/examples/messaging/update-resend-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await messaging.updateResendProvider({ fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index 28660a7a..1ec4f54d 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await messaging.updateSendgridProvider({ fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-ses-provider.md b/docs/examples/messaging/update-ses-provider.md index 63d572f3..873c4256 100644 --- a/docs/examples/messaging/update-ses-provider.md +++ b/docs/examples/messaging/update-ses-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await messaging.updateSesProvider({ fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 593445a6..a41f3226 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await messaging.updateSMS({ targets: [], // optional content: '', // optional draft: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 353ad3c9..fc8521f8 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging, SmtpEncryption } from "@appwrite.io/console"; +import { Client, Messaging, SmtpEncryption } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -21,7 +21,7 @@ const result = await messaging.updateSMTPProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md index c95ff208..468419c3 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.updateTelesignProvider({ enabled: false, // optional customerId: '', // optional apiKey: '', // optional - from: '' // optional + from: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md index 86fc6ef1..3f72f7c6 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.updateTextmagicProvider({ enabled: false, // optional username: '', // optional apiKey: '', // optional - from: '' // optional + from: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index ac03014e..633728c6 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.updateTopic({ topicId: '', name: '', // optional - subscribe: ["any"] // optional + subscribe: ['any'], // optional }); console.log(result); diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md index 8d448fa0..e8c0b08a 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.updateTwilioProvider({ enabled: false, // optional accountSid: '', // optional authToken: '', // optional - from: '' // optional + from: '', // optional }); console.log(result); diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md index 3f917555..cfe3ea50 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Messaging } from "@appwrite.io/console"; +import { Client, Messaging } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await messaging.updateVonageProvider({ enabled: false, // optional apiKey: '', // optional apiSecret: '', // optional - from: '' // optional + from: '', // optional }); console.log(result); diff --git a/docs/examples/migrations/create-appwrite-migration.md b/docs/examples/migrations/create-appwrite-migration.md index 9729806f..af8341f9 100644 --- a/docs/examples/migrations/create-appwrite-migration.md +++ b/docs/examples/migrations/create-appwrite-migration.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Migrations, AppwriteMigrationResource, OnDuplicate } from "@appwrite.io/console"; +import { + Client, + Migrations, + AppwriteMigrationResource, + OnDuplicate, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +17,7 @@ const result = await migrations.createAppwriteMigration({ endpoint: 'https://example.com', projectId: '', apiKey: '', - onDuplicate: OnDuplicate.Fail // optional + onDuplicate: OnDuplicate.Fail, // optional }); console.log(result); diff --git a/docs/examples/migrations/create-csv-export.md b/docs/examples/migrations/create-csv-export.md index ee998df8..e357eb17 100644 --- a/docs/examples/migrations/create-csv-export.md +++ b/docs/examples/migrations/create-csv-export.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations } from "@appwrite.io/console"; +import { Client, Migrations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await migrations.createCSVExport({ enclosure: '', // optional escape: '', // optional header: false, // optional - notify: false // optional + notify: false, // optional }); console.log(result); diff --git a/docs/examples/migrations/create-csv-import.md b/docs/examples/migrations/create-csv-import.md index e86c4383..12d62cf6 100644 --- a/docs/examples/migrations/create-csv-import.md +++ b/docs/examples/migrations/create-csv-import.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations, OnDuplicate } from "@appwrite.io/console"; +import { Client, Migrations, OnDuplicate } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await migrations.createCSVImport({ databaseId: '', collectionId: '', internalFile: false, // optional - onDuplicate: OnDuplicate.Fail // optional + onDuplicate: OnDuplicate.Fail, // optional }); console.log(result); diff --git a/docs/examples/migrations/create-firebase-migration.md b/docs/examples/migrations/create-firebase-migration.md index 775df556..521363f1 100644 --- a/docs/examples/migrations/create-firebase-migration.md +++ b/docs/examples/migrations/create-firebase-migration.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, FirebaseMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + FirebaseMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +13,7 @@ const migrations = new Migrations(client); const result = await migrations.createFirebaseMigration({ resources: [FirebaseMigrationResource.User], - serviceAccount: '' + serviceAccount: '', }); console.log(result); diff --git a/docs/examples/migrations/create-json-export.md b/docs/examples/migrations/create-json-export.md index 90ef89a6..29da496e 100644 --- a/docs/examples/migrations/create-json-export.md +++ b/docs/examples/migrations/create-json-export.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations } from "@appwrite.io/console"; +import { Client, Migrations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await migrations.createJSONExport({ filename: '', columns: [], // optional queries: [], // optional - notify: false // optional + notify: false, // optional }); console.log(result); diff --git a/docs/examples/migrations/create-json-import.md b/docs/examples/migrations/create-json-import.md index 63dec013..f8decc0d 100644 --- a/docs/examples/migrations/create-json-import.md +++ b/docs/examples/migrations/create-json-import.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations, OnDuplicate } from "@appwrite.io/console"; +import { Client, Migrations, OnDuplicate } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await migrations.createJSONImport({ databaseId: '', collectionId: '', internalFile: false, // optional - onDuplicate: OnDuplicate.Fail // optional + onDuplicate: OnDuplicate.Fail, // optional }); console.log(result); diff --git a/docs/examples/migrations/create-n-host-migration.md b/docs/examples/migrations/create-n-host-migration.md index 1b7faec8..ef7b1ad2 100644 --- a/docs/examples/migrations/create-n-host-migration.md +++ b/docs/examples/migrations/create-n-host-migration.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, NHostMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + NHostMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +19,7 @@ const result = await migrations.createNHostMigration({ database: '', username: '', password: 'password', - port: null // optional + port: 5432, // optional }); console.log(result); diff --git a/docs/examples/migrations/create-supabase-migration.md b/docs/examples/migrations/create-supabase-migration.md index 35940039..8289cd25 100644 --- a/docs/examples/migrations/create-supabase-migration.md +++ b/docs/examples/migrations/create-supabase-migration.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, SupabaseMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + SupabaseMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +18,7 @@ const result = await migrations.createSupabaseMigration({ databaseHost: '', username: '', password: 'password', - port: null // optional + port: 5432, // optional }); console.log(result); diff --git a/docs/examples/migrations/delete.md b/docs/examples/migrations/delete.md index 4eaebdb2..22dd6a51 100644 --- a/docs/examples/migrations/delete.md +++ b/docs/examples/migrations/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations } from "@appwrite.io/console"; +import { Client, Migrations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const migrations = new Migrations(client); const result = await migrations.delete({ - migrationId: '' + migrationId: '', }); console.log(result); diff --git a/docs/examples/migrations/get-appwrite-report.md b/docs/examples/migrations/get-appwrite-report.md index d5417c9f..bc7e0228 100644 --- a/docs/examples/migrations/get-appwrite-report.md +++ b/docs/examples/migrations/get-appwrite-report.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, AppwriteMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + AppwriteMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +15,7 @@ const result = await migrations.getAppwriteReport({ resources: [AppwriteMigrationResource.User], endpoint: 'https://example.com', projectID: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/migrations/get-firebase-report.md b/docs/examples/migrations/get-firebase-report.md index 46b9d859..dbced0f8 100644 --- a/docs/examples/migrations/get-firebase-report.md +++ b/docs/examples/migrations/get-firebase-report.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, FirebaseMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + FirebaseMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +13,7 @@ const migrations = new Migrations(client); const result = await migrations.getFirebaseReport({ resources: [FirebaseMigrationResource.User], - serviceAccount: '' + serviceAccount: '', }); console.log(result); diff --git a/docs/examples/migrations/get-n-host-report.md b/docs/examples/migrations/get-n-host-report.md index c4f5285a..6a0e05fe 100644 --- a/docs/examples/migrations/get-n-host-report.md +++ b/docs/examples/migrations/get-n-host-report.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, NHostMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + NHostMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +19,7 @@ const result = await migrations.getNHostReport({ database: '', username: '', password: 'password', - port: null // optional + port: 5432, // optional }); console.log(result); diff --git a/docs/examples/migrations/get-supabase-report.md b/docs/examples/migrations/get-supabase-report.md index 9beeeceb..03db239d 100644 --- a/docs/examples/migrations/get-supabase-report.md +++ b/docs/examples/migrations/get-supabase-report.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Migrations, SupabaseMigrationResource } from "@appwrite.io/console"; +import { + Client, + Migrations, + SupabaseMigrationResource, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +18,7 @@ const result = await migrations.getSupabaseReport({ databaseHost: '', username: '', password: 'password', - port: null // optional + port: 5432, // optional }); console.log(result); diff --git a/docs/examples/migrations/get.md b/docs/examples/migrations/get.md index 7e9a6dd7..86e25faa 100644 --- a/docs/examples/migrations/get.md +++ b/docs/examples/migrations/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations } from "@appwrite.io/console"; +import { Client, Migrations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const migrations = new Migrations(client); const result = await migrations.get({ - migrationId: '' + migrationId: '', }); console.log(result); diff --git a/docs/examples/migrations/list.md b/docs/examples/migrations/list.md index 3bd32ec0..66778759 100644 --- a/docs/examples/migrations/list.md +++ b/docs/examples/migrations/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations } from "@appwrite.io/console"; +import { Client, Migrations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const migrations = new Migrations(client); const result = await migrations.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/migrations/retry.md b/docs/examples/migrations/retry.md index 25707507..315a19cd 100644 --- a/docs/examples/migrations/retry.md +++ b/docs/examples/migrations/retry.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations } from "@appwrite.io/console"; +import { Client, Migrations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const migrations = new Migrations(client); const result = await migrations.retry({ - migrationId: '' + migrationId: '', }); console.log(result); diff --git a/docs/examples/mongo/create-backup-policy.md b/docs/examples/mongo/create-backup-policy.md index feeb147c..1758cdb4 100644 --- a/docs/examples/mongo/create-backup-policy.md +++ b/docs/examples/mongo/create-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await mongo.createBackupPolicy({ schedule: '', retention: 1, type: 'full', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/mongo/create-backup.md b/docs/examples/mongo/create-backup.md index 4fd4a7cc..c175b1c0 100644 --- a/docs/examples/mongo/create-backup.md +++ b/docs/examples/mongo/create-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.createBackup({ databaseId: '', - type: 'full' // optional + type: 'full', // optional }); console.log(result); diff --git a/docs/examples/mongo/create-branch.md b/docs/examples/mongo/create-branch.md index bd34482b..777ac984 100644 --- a/docs/examples/mongo/create-branch.md +++ b/docs/examples/mongo/create-branch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const mongo = new Mongo(client); const result = await mongo.createBranch({ databaseId: '', branchId: '', // optional - ttl: 300 // optional + ttl: 300, // optional }); console.log(result); diff --git a/docs/examples/mongo/create-failover.md b/docs/examples/mongo/create-failover.md index b8afae98..e4dc58a1 100644 --- a/docs/examples/mongo/create-failover.md +++ b/docs/examples/mongo/create-failover.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); console.log(result); diff --git a/docs/examples/mongo/create-migration.md b/docs/examples/mongo/create-migration.md index 59842bf0..169546c9 100644 --- a/docs/examples/mongo/create-migration.md +++ b/docs/examples/mongo/create-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const mongo = new Mongo(client); const result = await mongo.createMigration({ databaseId: '', targetType: 'shared', - specification: '' // optional + specification: '', // optional }); console.log(result); diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 06f23ec2..e84ed883 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,8 @@ const result = await mongo.createRestoration({ databaseId: '', type: 'backup', // optional backupId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetDatabaseId: '', // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/mongo/create-upgrade.md b/docs/examples/mongo/create-upgrade.md index 686600e1..2d70ad4a 100644 --- a/docs/examples/mongo/create-upgrade.md +++ b/docs/examples/mongo/create-upgrade.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.createUpgrade({ databaseId: '', - targetVersion: '' + targetVersion: '', }); console.log(result); diff --git a/docs/examples/mongo/create.md b/docs/examples/mongo/create.md index 7863da83..2a12fa54 100644 --- a/docs/examples/mongo/create.md +++ b/docs/examples/mongo/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,6 @@ const result = await mongo.create({ specification: '', // optional replicas: 0, // optional syncMode: 'async', // optional - standbyRegion: '', // optional networkIdleTimeoutSeconds: 60, // optional networkIPAllowlist: [], // optional idleTimeoutMinutes: 5, // optional @@ -22,7 +21,7 @@ const result = await mongo.create({ pitrRetentionDays: 1, // optional storageAutoscaling: false, // optional storageAutoscalingThresholdPercent: 50, // optional - storageAutoscalingMaxGb: 0 // optional + storageAutoscalingMaxGb: 0, // optional }); console.log(result); diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md index cbd06af3..cc336d45 100644 --- a/docs/examples/mongo/delete-backup-policy.md +++ b/docs/examples/mongo/delete-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.deleteBackupPolicy({ databaseId: '', - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md index c5307add..18393a45 100644 --- a/docs/examples/mongo/delete-backup.md +++ b/docs/examples/mongo/delete-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.deleteBackup({ databaseId: '', - backupId: '' + backupId: '', }); console.log(result); diff --git a/docs/examples/mongo/delete-branch.md b/docs/examples/mongo/delete-branch.md index 67d1f41a..bea4b5b4 100644 --- a/docs/examples/mongo/delete-branch.md +++ b/docs/examples/mongo/delete-branch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.deleteBranch({ databaseId: '', - branchId: '' + branchId: '', }); console.log(result); diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md index 47a59158..37ae4b38 100644 --- a/docs/examples/mongo/delete.md +++ b/docs/examples/mongo/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/get-backup-policy.md b/docs/examples/mongo/get-backup-policy.md index 2eb76a49..3bd2083e 100644 --- a/docs/examples/mongo/get-backup-policy.md +++ b/docs/examples/mongo/get-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.getBackupPolicy({ databaseId: '', - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/mongo/get-backup.md b/docs/examples/mongo/get-backup.md index f05bbd6d..bb7c95dc 100644 --- a/docs/examples/mongo/get-backup.md +++ b/docs/examples/mongo/get-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.getBackup({ databaseId: '', - backupId: '' + backupId: '', }); console.log(result); diff --git a/docs/examples/mongo/get-pitr.md b/docs/examples/mongo/get-pitr.md index fa1f7b7c..35d46e2e 100644 --- a/docs/examples/mongo/get-pitr.md +++ b/docs/examples/mongo/get-pitr.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.getPitr({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/get-replicas.md b/docs/examples/mongo/get-replicas.md index abfb1e18..f730f56a 100644 --- a/docs/examples/mongo/get-replicas.md +++ b/docs/examples/mongo/get-replicas.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.getReplicas({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/get-restoration.md b/docs/examples/mongo/get-restoration.md index 2d0e4643..0220eeed 100644 --- a/docs/examples/mongo/get-restoration.md +++ b/docs/examples/mongo/get-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.getRestoration({ databaseId: '', - restorationId: '' + restorationId: '', }); console.log(result); diff --git a/docs/examples/mongo/get-status.md b/docs/examples/mongo/get-status.md index d0c08ffd..721dfe67 100644 --- a/docs/examples/mongo/get-status.md +++ b/docs/examples/mongo/get-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.getStatus({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/get.md b/docs/examples/mongo/get.md index a95d9ab1..d891b6c6 100644 --- a/docs/examples/mongo/get.md +++ b/docs/examples/mongo/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/list-backup-policies.md b/docs/examples/mongo/list-backup-policies.md index ebb1edc8..049af2ad 100644 --- a/docs/examples/mongo/list-backup-policies.md +++ b/docs/examples/mongo/list-backup-policies.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.listBackupPolicies({ databaseId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/mongo/list-backups.md b/docs/examples/mongo/list-backups.md index 2d559d0d..d2fd432f 100644 --- a/docs/examples/mongo/list-backups.md +++ b/docs/examples/mongo/list-backups.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mongo = new Mongo(client); const result = await mongo.listBackups({ databaseId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/mongo/list-branches.md b/docs/examples/mongo/list-branches.md index d1f5508e..3187073c 100644 --- a/docs/examples/mongo/list-branches.md +++ b/docs/examples/mongo/list-branches.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.listBranches({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/list-operations.md b/docs/examples/mongo/list-operations.md index edd1a7c9..9201a890 100644 --- a/docs/examples/mongo/list-operations.md +++ b/docs/examples/mongo/list-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,9 +9,9 @@ const mongo = new Mongo(client); const result = await mongo.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/mongo/list-restorations.md b/docs/examples/mongo/list-restorations.md index d144d262..9b058896 100644 --- a/docs/examples/mongo/list-restorations.md +++ b/docs/examples/mongo/list-restorations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await mongo.listRestorations({ status: 'pending', // optional type: 'backup', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/mongo/list-specifications.md b/docs/examples/mongo/list-specifications.md index b9084ef2..f50afa0f 100644 --- a/docs/examples/mongo/list-specifications.md +++ b/docs/examples/mongo/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/mongo/list.md b/docs/examples/mongo/list.md index eadf9946..a0579d43 100644 --- a/docs/examples/mongo/list.md +++ b/docs/examples/mongo/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.list({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/mongo/update-backup-policy.md b/docs/examples/mongo/update-backup-policy.md index 9651467e..a9eb1a2d 100644 --- a/docs/examples/mongo/update-backup-policy.md +++ b/docs/examples/mongo/update-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await mongo.updateBackupPolicy({ name: '', // optional schedule: '', // optional retention: 1, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/mongo/update-backup-storage.md b/docs/examples/mongo/update-backup-storage.md index e7d40306..e00fcad6 100644 --- a/docs/examples/mongo/update-backup-storage.md +++ b/docs/examples/mongo/update-backup-storage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await mongo.updateBackupStorage({ secretKey: '', region: '', // optional prefix: '', // optional - endpoint: '' // optional + endpoint: '', // optional }); console.log(result); diff --git a/docs/examples/mongo/update-credentials.md b/docs/examples/mongo/update-credentials.md index b3b59690..24962c3d 100644 --- a/docs/examples/mongo/update-credentials.md +++ b/docs/examples/mongo/update-credentials.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mongo = new Mongo(client); const result = await mongo.updateCredentials({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mongo/update-maintenance.md b/docs/examples/mongo/update-maintenance.md index 42685841..8cdc3328 100644 --- a/docs/examples/mongo/update-maintenance.md +++ b/docs/examples/mongo/update-maintenance.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const mongo = new Mongo(client); const result = await mongo.updateMaintenance({ databaseId: '', day: 'sun', - hourUtc: 0 + hourUtc: 0, }); console.log(result); diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md index ca585365..34cc95f7 100644 --- a/docs/examples/mongo/update.md +++ b/docs/examples/mongo/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mongo } from "@appwrite.io/console"; +import { Client, Mongo } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,8 +14,6 @@ const result = await mongo.update({ specification: '', // optional replicas: 0, // optional syncMode: 'async', // optional - crossRegionReplicas: 0, // optional - standbyRegion: '', // optional networkIdleTimeoutSeconds: 60, // optional networkIPAllowlist: [], // optional idleTimeoutMinutes: 5, // optional @@ -30,7 +28,7 @@ const result = await mongo.update({ sqlApiAllowedStatements: [], // optional sqlApiMaxRows: 1, // optional sqlApiMaxBytes: 1024, // optional - sqlApiTimeoutSeconds: 1 // optional + sqlApiTimeoutSeconds: 1, // optional }); console.log(result); diff --git a/docs/examples/mysql/create-backup-policy.md b/docs/examples/mysql/create-backup-policy.md index 842ae41b..f04fa04b 100644 --- a/docs/examples/mysql/create-backup-policy.md +++ b/docs/examples/mysql/create-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await mysql.createBackupPolicy({ schedule: '', retention: 1, type: 'full', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/mysql/create-backup.md b/docs/examples/mysql/create-backup.md index bf1db85e..33722ff4 100644 --- a/docs/examples/mysql/create-backup.md +++ b/docs/examples/mysql/create-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.createBackup({ databaseId: '', - type: 'full' // optional + type: 'full', // optional }); console.log(result); diff --git a/docs/examples/mysql/create-branch.md b/docs/examples/mysql/create-branch.md index 6d191b3b..e9fc3484 100644 --- a/docs/examples/mysql/create-branch.md +++ b/docs/examples/mysql/create-branch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const mysql = new Mysql(client); const result = await mysql.createBranch({ databaseId: '', branchId: '', // optional - ttl: 300 // optional + ttl: 300, // optional }); console.log(result); diff --git a/docs/examples/mysql/create-execution.md b/docs/examples/mysql/create-execution.md index 3e645bed..dbc3d3e2 100644 --- a/docs/examples/mysql/create-execution.md +++ b/docs/examples/mysql/create-execution.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await mysql.createExecution({ databaseId: '', sql: '', bindings: {}, // optional - timeoutSeconds: 1 // optional + timeoutSeconds: 1, // optional }); console.log(result); diff --git a/docs/examples/mysql/create-failover.md b/docs/examples/mysql/create-failover.md index e2a36bd4..6b1ca7c2 100644 --- a/docs/examples/mysql/create-failover.md +++ b/docs/examples/mysql/create-failover.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); console.log(result); diff --git a/docs/examples/mysql/create-migration.md b/docs/examples/mysql/create-migration.md index 4292a442..00490028 100644 --- a/docs/examples/mysql/create-migration.md +++ b/docs/examples/mysql/create-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const mysql = new Mysql(client); const result = await mysql.createMigration({ databaseId: '', targetType: 'shared', - specification: '' // optional + specification: '', // optional }); console.log(result); diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index 9f94cbef..34bd9363 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,8 @@ const result = await mysql.createRestoration({ databaseId: '', type: 'backup', // optional backupId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetDatabaseId: '', // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/mysql/create-upgrade.md b/docs/examples/mysql/create-upgrade.md index 365efba6..1b4825a0 100644 --- a/docs/examples/mysql/create-upgrade.md +++ b/docs/examples/mysql/create-upgrade.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.createUpgrade({ databaseId: '', - targetVersion: '' + targetVersion: '', }); console.log(result); diff --git a/docs/examples/mysql/create.md b/docs/examples/mysql/create.md index 9a7e5afb..6c3cc98e 100644 --- a/docs/examples/mysql/create.md +++ b/docs/examples/mysql/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,6 @@ const result = await mysql.create({ specification: '', // optional replicas: 0, // optional syncMode: 'async', // optional - standbyRegion: '', // optional networkIdleTimeoutSeconds: 60, // optional networkIPAllowlist: [], // optional idleTimeoutMinutes: 5, // optional @@ -22,7 +21,7 @@ const result = await mysql.create({ pitrRetentionDays: 1, // optional storageAutoscaling: false, // optional storageAutoscalingThresholdPercent: 50, // optional - storageAutoscalingMaxGb: 0 // optional + storageAutoscalingMaxGb: 0, // optional }); console.log(result); diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md index e847d0ea..ceeb6532 100644 --- a/docs/examples/mysql/delete-backup-policy.md +++ b/docs/examples/mysql/delete-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.deleteBackupPolicy({ databaseId: '', - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md index 7d64fa2e..1e3b8615 100644 --- a/docs/examples/mysql/delete-backup.md +++ b/docs/examples/mysql/delete-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.deleteBackup({ databaseId: '', - backupId: '' + backupId: '', }); console.log(result); diff --git a/docs/examples/mysql/delete-branch.md b/docs/examples/mysql/delete-branch.md index 62a46733..0d77f50e 100644 --- a/docs/examples/mysql/delete-branch.md +++ b/docs/examples/mysql/delete-branch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.deleteBranch({ databaseId: '', - branchId: '' + branchId: '', }); console.log(result); diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md index 88357894..657f56b3 100644 --- a/docs/examples/mysql/delete.md +++ b/docs/examples/mysql/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-backup-policy.md b/docs/examples/mysql/get-backup-policy.md index 0df26df7..e0ffdd20 100644 --- a/docs/examples/mysql/get-backup-policy.md +++ b/docs/examples/mysql/get-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.getBackupPolicy({ databaseId: '', - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-backup.md b/docs/examples/mysql/get-backup.md index 2201dd43..52954cfd 100644 --- a/docs/examples/mysql/get-backup.md +++ b/docs/examples/mysql/get-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.getBackup({ databaseId: '', - backupId: '' + backupId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-pitr.md b/docs/examples/mysql/get-pitr.md index 013cfd37..7c852290 100644 --- a/docs/examples/mysql/get-pitr.md +++ b/docs/examples/mysql/get-pitr.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.getPitr({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-pooler.md b/docs/examples/mysql/get-pooler.md index a9fcb1b5..02cc663d 100644 --- a/docs/examples/mysql/get-pooler.md +++ b/docs/examples/mysql/get-pooler.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.getPooler({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-replicas.md b/docs/examples/mysql/get-replicas.md index 01043979..cce37221 100644 --- a/docs/examples/mysql/get-replicas.md +++ b/docs/examples/mysql/get-replicas.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.getReplicas({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-restoration.md b/docs/examples/mysql/get-restoration.md index dfba8046..87a64ee7 100644 --- a/docs/examples/mysql/get-restoration.md +++ b/docs/examples/mysql/get-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.getRestoration({ databaseId: '', - restorationId: '' + restorationId: '', }); console.log(result); diff --git a/docs/examples/mysql/get-status.md b/docs/examples/mysql/get-status.md index 27e8c16c..60d3ab1b 100644 --- a/docs/examples/mysql/get-status.md +++ b/docs/examples/mysql/get-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.getStatus({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/get.md b/docs/examples/mysql/get.md index 2406c809..6a94ac4a 100644 --- a/docs/examples/mysql/get.md +++ b/docs/examples/mysql/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/list-backup-policies.md b/docs/examples/mysql/list-backup-policies.md index 494fc6a5..8c7ce7c3 100644 --- a/docs/examples/mysql/list-backup-policies.md +++ b/docs/examples/mysql/list-backup-policies.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.listBackupPolicies({ databaseId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/mysql/list-backups.md b/docs/examples/mysql/list-backups.md index a6189de9..8527d0fa 100644 --- a/docs/examples/mysql/list-backups.md +++ b/docs/examples/mysql/list-backups.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const mysql = new Mysql(client); const result = await mysql.listBackups({ databaseId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/mysql/list-branches.md b/docs/examples/mysql/list-branches.md index 3d4bb809..b48cf1a4 100644 --- a/docs/examples/mysql/list-branches.md +++ b/docs/examples/mysql/list-branches.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.listBranches({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/list-operations.md b/docs/examples/mysql/list-operations.md index bcb3765b..c586dd9e 100644 --- a/docs/examples/mysql/list-operations.md +++ b/docs/examples/mysql/list-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,9 +9,9 @@ const mysql = new Mysql(client); const result = await mysql.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/mysql/list-restorations.md b/docs/examples/mysql/list-restorations.md index 49c2bcc3..d3c67077 100644 --- a/docs/examples/mysql/list-restorations.md +++ b/docs/examples/mysql/list-restorations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await mysql.listRestorations({ status: 'pending', // optional type: 'backup', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/mysql/list-specifications.md b/docs/examples/mysql/list-specifications.md index 265de32b..dc7f4065 100644 --- a/docs/examples/mysql/list-specifications.md +++ b/docs/examples/mysql/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/mysql/list.md b/docs/examples/mysql/list.md index 63bfaac5..6df74d0e 100644 --- a/docs/examples/mysql/list.md +++ b/docs/examples/mysql/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.list({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/mysql/update-backup-policy.md b/docs/examples/mysql/update-backup-policy.md index 9fba8065..9bd36ccb 100644 --- a/docs/examples/mysql/update-backup-policy.md +++ b/docs/examples/mysql/update-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await mysql.updateBackupPolicy({ name: '', // optional schedule: '', // optional retention: 1, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/mysql/update-backup-storage.md b/docs/examples/mysql/update-backup-storage.md index ff3e63fe..6d02cfd8 100644 --- a/docs/examples/mysql/update-backup-storage.md +++ b/docs/examples/mysql/update-backup-storage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await mysql.updateBackupStorage({ secretKey: '', region: '', // optional prefix: '', // optional - endpoint: '' // optional + endpoint: '', // optional }); console.log(result); diff --git a/docs/examples/mysql/update-credentials.md b/docs/examples/mysql/update-credentials.md index dae6b201..55d468fc 100644 --- a/docs/examples/mysql/update-credentials.md +++ b/docs/examples/mysql/update-credentials.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const mysql = new Mysql(client); const result = await mysql.updateCredentials({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/mysql/update-maintenance.md b/docs/examples/mysql/update-maintenance.md index 1e53f6b2..fa4b9c25 100644 --- a/docs/examples/mysql/update-maintenance.md +++ b/docs/examples/mysql/update-maintenance.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const mysql = new Mysql(client); const result = await mysql.updateMaintenance({ databaseId: '', day: 'sun', - hourUtc: 0 + hourUtc: 0, }); console.log(result); diff --git a/docs/examples/mysql/update-pooler.md b/docs/examples/mysql/update-pooler.md index 6aa2736b..86a3a4c2 100644 --- a/docs/examples/mysql/update-pooler.md +++ b/docs/examples/mysql/update-pooler.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,7 +16,7 @@ const result = await mysql.updatePooler({ poolerCpuRequest: '', // optional poolerCpuLimit: '', // optional poolerMemoryRequest: '', // optional - poolerMemoryLimit: '' // optional + poolerMemoryLimit: '', // optional }); console.log(result); diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md index ce5e77fb..68fc9852 100644 --- a/docs/examples/mysql/update.md +++ b/docs/examples/mysql/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Mysql } from "@appwrite.io/console"; +import { Client, Mysql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,8 +14,6 @@ const result = await mysql.update({ specification: '', // optional replicas: 0, // optional syncMode: 'async', // optional - crossRegionReplicas: 0, // optional - standbyRegion: '', // optional networkIdleTimeoutSeconds: 60, // optional networkIPAllowlist: [], // optional idleTimeoutMinutes: 5, // optional @@ -30,7 +28,7 @@ const result = await mysql.update({ sqlApiAllowedStatements: [], // optional sqlApiMaxRows: 1, // optional sqlApiMaxBytes: 1024, // optional - sqlApiTimeoutSeconds: 1 // optional + sqlApiTimeoutSeconds: 1, // optional }); console.log(result); diff --git a/docs/examples/notifications/list.md b/docs/examples/notifications/list.md index 92c60d9d..3c657581 100644 --- a/docs/examples/notifications/list.md +++ b/docs/examples/notifications/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Notifications } from "@appwrite.io/console"; +import { Client, Notifications } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const notifications = new Notifications(client); const result = await notifications.list({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/notifications/update.md b/docs/examples/notifications/update.md index 8bea7057..5753d927 100644 --- a/docs/examples/notifications/update.md +++ b/docs/examples/notifications/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Notifications } from "@appwrite.io/console"; +import { Client, Notifications } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const notifications = new Notifications(client); const result = await notifications.update({ notificationId: '', - read: false + read: false, }); console.log(result); diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 93b6755c..d11b5dd8 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const oauth2 = new Oauth2(client); const result = await oauth2.approve({ grantId: '', authorizationDetails: '', // optional - scope: '' // optional + scope: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 78caf7e5..acb7116d 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -21,7 +21,7 @@ const result = await oauth2.authorizePost({ authorizationDetails: '', // optional resource: '', // optional audience: '', // optional - requestUri: '' // optional + requestUri: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index 936bd711..0a02731b 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -21,7 +21,7 @@ const result = await oauth2.authorize({ authorizationDetails: '', // optional resource: '', // optional audience: '', // optional - requestUri: '' // optional + requestUri: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e45f4332..3203b84d 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ scope: '', // optional authorizationDetails: '', // optional resource: '', // optional - audience: '' // optional + audience: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 0bee9711..31cbbbe3 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const oauth2 = new Oauth2(client); const result = await oauth2.createGrant({ - userCode: '' + userCode: '', }); console.log(result); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 15c75bc7..3c503287 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ maxAge: 0, // optional authorizationDetails: '', // optional resource: '', // optional - audience: '' // optional + audience: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index cfd8f328..900352e9 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ codeVerifier: '', // optional redirectUri: 'https://example.com', // optional resource: '', // optional - audience: '' // optional + audience: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index 9ad1cd4e..aa93997e 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const oauth2 = new Oauth2(client); const result = await oauth2.getGrant({ - grantId: '' + grantId: '', }); console.log(result); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index d5f8bc6e..a6e09e62 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const oauth2 = new Oauth2(client); const result = await oauth2.listOrganizations({ limit: 1, // optional offset: 0, // optional - search: '' // optional + search: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index fd40c0ad..71e20bbe 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const oauth2 = new Oauth2(client); const result = await oauth2.listProjects({ limit: 1, // optional offset: 0, // optional - search: '' // optional + search: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/logout-post.md b/docs/examples/oauth2/logout-post.md index 478c7f28..5a818a11 100644 --- a/docs/examples/oauth2/logout-post.md +++ b/docs/examples/oauth2/logout-post.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await oauth2.logoutPost({ clientId: '', // optional postLogoutRedirectUri: 'https://example.com', // optional state: '', // optional - uiLocales: '' // optional + uiLocales: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/logout.md b/docs/examples/oauth2/logout.md index c7197fb7..73a93b87 100644 --- a/docs/examples/oauth2/logout.md +++ b/docs/examples/oauth2/logout.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await oauth2.logout({ clientId: '', // optional postLogoutRedirectUri: 'https://example.com', // optional state: '', // optional - uiLocales: '' // optional + uiLocales: '', // optional }); console.log(result); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index 69868561..f9a1e4d0 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const oauth2 = new Oauth2(client); const result = await oauth2.reject({ - grantId: '' + grantId: '', }); console.log(result); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index ee733b14..e6d1fd6d 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Oauth2 } from "@appwrite.io/console"; +import { Client, Oauth2 } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await oauth2.revoke({ token: '', tokenTypeHint: 'access_token', // optional clientId: '', // optional - clientSecret: '' // optional + clientSecret: '', // optional }); console.log(result); diff --git a/docs/examples/organization/create-installation.md b/docs/examples/organization/create-installation.md index b47ebeb3..67bae315 100644 --- a/docs/examples/organization/create-installation.md +++ b/docs/examples/organization/create-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.createInstallation({ appId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); console.log(result); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md index 3989d829..4c1622c2 100644 --- a/docs/examples/organization/create-key.md +++ b/docs/examples/organization/create-key.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Organization, OrganizationKeyScopes } from "@appwrite.io/console"; +import { + Client, + Organization, + OrganizationKeyScopes, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +15,7 @@ const result = await organization.createKey({ keyId: '', name: '', scopes: [OrganizationKeyScopes.ProjectsRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/organization/create-membership.md b/docs/examples/organization/create-membership.md index e27bb219..953a5409 100644 --- a/docs/examples/organization/create-membership.md +++ b/docs/examples/organization/create-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await organization.createMembership({ userId: '', // optional phone: '+12065550100', // optional url: 'https://example.com', // optional - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/organization/create-project.md b/docs/examples/organization/create-project.md index aba71929..d3bb4b6f 100644 --- a/docs/examples/organization/create-project.md +++ b/docs/examples/organization/create-project.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization, Region } from "@appwrite.io/console"; +import { Client, Organization, Region } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,9 +8,9 @@ const client = new Client() const organization = new Organization(client); const result = await organization.createProject({ - projectId: '', + projectId: '', name: '', - region: Region.Fra // optional + region: Region.Fra, // optional }); console.log(result); diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index 54a87374..fdf16b5c 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.deleteInstallation({ - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md index 7b167db8..378a78b8 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/organization/delete-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.deleteKey({ - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/organization/delete-membership.md b/docs/examples/organization/delete-membership.md index ffa6fa6e..9769d387 100644 --- a/docs/examples/organization/delete-membership.md +++ b/docs/examples/organization/delete-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.deleteMembership({ - membershipId: '' + membershipId: '', }); console.log(result); diff --git a/docs/examples/organization/delete-project.md b/docs/examples/organization/delete-project.md index db62d68c..da0b09d7 100644 --- a/docs/examples/organization/delete-project.md +++ b/docs/examples/organization/delete-project.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.deleteProject({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/organization/delete.md b/docs/examples/organization/delete.md index b35fd2e5..e7bc22f6 100644 --- a/docs/examples/organization/delete.md +++ b/docs/examples/organization/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/organization/get-installation.md b/docs/examples/organization/get-installation.md index 051a7b7b..36acac2c 100644 --- a/docs/examples/organization/get-installation.md +++ b/docs/examples/organization/get-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.getInstallation({ - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md index d962bcae..512a64e1 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/organization/get-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.getKey({ - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/organization/get-membership.md b/docs/examples/organization/get-membership.md index 7edd314a..7540eb38 100644 --- a/docs/examples/organization/get-membership.md +++ b/docs/examples/organization/get-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.getMembership({ - membershipId: '' + membershipId: '', }); console.log(result); diff --git a/docs/examples/organization/get-project.md b/docs/examples/organization/get-project.md index a338b024..2f985e35 100644 --- a/docs/examples/organization/get-project.md +++ b/docs/examples/organization/get-project.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.getProject({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/organization/get.md b/docs/examples/organization/get.md index 8be6a692..640a7f3f 100644 --- a/docs/examples/organization/get.md +++ b/docs/examples/organization/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/organization/list-installations.md b/docs/examples/organization/list-installations.md index bc824db3..655f8db0 100644 --- a/docs/examples/organization/list-installations.md +++ b/docs/examples/organization/list-installations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.listInstallations({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md index d52ac31f..444eb1b5 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/organization/list-keys.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.listKeys({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/organization/list-memberships.md b/docs/examples/organization/list-memberships.md index 5f745d7e..a5c374ab 100644 --- a/docs/examples/organization/list-memberships.md +++ b/docs/examples/organization/list-memberships.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const organization = new Organization(client); const result = await organization.listMemberships({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/organization/list-projects.md b/docs/examples/organization/list-projects.md index 3e4b7588..3f7a1c78 100644 --- a/docs/examples/organization/list-projects.md +++ b/docs/examples/organization/list-projects.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const organization = new Organization(client); const result = await organization.listProjects({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/organization/update-installation.md b/docs/examples/organization/update-installation.md index a8d86d29..423fb5c5 100644 --- a/docs/examples/organization/update-installation.md +++ b/docs/examples/organization/update-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.updateInstallation({ installationId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); console.log(result); diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md index bb97a272..7ada58b4 100644 --- a/docs/examples/organization/update-key.md +++ b/docs/examples/organization/update-key.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Organization, OrganizationKeyScopes } from "@appwrite.io/console"; +import { + Client, + Organization, + OrganizationKeyScopes, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +15,7 @@ const result = await organization.updateKey({ keyId: '', name: '', scopes: [OrganizationKeyScopes.ProjectsRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/organization/update-membership.md b/docs/examples/organization/update-membership.md index 09e2a543..f94ae712 100644 --- a/docs/examples/organization/update-membership.md +++ b/docs/examples/organization/update-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.updateMembership({ membershipId: '', - roles: [] + roles: [], }); console.log(result); diff --git a/docs/examples/organization/update-project.md b/docs/examples/organization/update-project.md index ecf77403..7ae1ef33 100644 --- a/docs/examples/organization/update-project.md +++ b/docs/examples/organization/update-project.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.updateProject({ projectId: '', - name: '' + name: '', }); console.log(result); diff --git a/docs/examples/organization/update.md b/docs/examples/organization/update.md index 3aa67f9b..39b42141 100644 --- a/docs/examples/organization/update.md +++ b/docs/examples/organization/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organization } from "@appwrite.io/console"; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organization = new Organization(client); const result = await organization.update({ - name: '' + name: '', }); console.log(result); diff --git a/docs/examples/organizations/add-credit.md b/docs/examples/organizations/add-credit.md index 0fda043a..c29574b7 100644 --- a/docs/examples/organizations/add-credit.md +++ b/docs/examples/organizations/add-credit.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.addCredit({ organizationId: '', - couponId: '' + couponId: '', }); console.log(result); diff --git a/docs/examples/organizations/cancel-downgrade.md b/docs/examples/organizations/cancel-downgrade.md index 3cdc4614..fd3a61de 100644 --- a/docs/examples/organizations/cancel-downgrade.md +++ b/docs/examples/organizations/cancel-downgrade.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.cancelDowngrade({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/confirm-addon-payment.md b/docs/examples/organizations/confirm-addon-payment.md index 7c619783..b021f210 100644 --- a/docs/examples/organizations/confirm-addon-payment.md +++ b/docs/examples/organizations/confirm-addon-payment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.confirmAddonPayment({ organizationId: '', - addonId: '' + addonId: '', }); console.log(result); diff --git a/docs/examples/organizations/create-baa-addon.md b/docs/examples/organizations/create-baa-addon.md index 02b1e527..dd3b0571 100644 --- a/docs/examples/organizations/create-baa-addon.md +++ b/docs/examples/organizations/create-baa-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.createBaaAddon({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/create-downgrade-feedback.md b/docs/examples/organizations/create-downgrade-feedback.md index 8b025e08..126f3791 100644 --- a/docs/examples/organizations/create-downgrade-feedback.md +++ b/docs/examples/organizations/create-downgrade-feedback.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await organizations.createDowngradeFeedback({ reason: '', message: '', fromPlanId: '', - toPlanId: '' + toPlanId: '', }); console.log(result); diff --git a/docs/examples/organizations/create-invoice-payment.md b/docs/examples/organizations/create-invoice-payment.md index 286d8555..5abe8614 100644 --- a/docs/examples/organizations/create-invoice-payment.md +++ b/docs/examples/organizations/create-invoice-payment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const organizations = new Organizations(client); const result = await organizations.createInvoicePayment({ organizationId: '', invoiceId: '', - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/organizations/create-plan-estimation.md b/docs/examples/organizations/create-plan-estimation.md index ee143ecc..e029d750 100644 --- a/docs/examples/organizations/create-plan-estimation.md +++ b/docs/examples/organizations/create-plan-estimation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await organizations.createPlanEstimation({ organizationId: '', billingPlan: 'tier-0', invites: [], // optional - couponId: '' // optional + couponId: '', // optional }); console.log(result); diff --git a/docs/examples/organizations/create-premium-geo-db-addon.md b/docs/examples/organizations/create-premium-geo-db-addon.md index cad59c65..0e4af1ae 100644 --- a/docs/examples/organizations/create-premium-geo-db-addon.md +++ b/docs/examples/organizations/create-premium-geo-db-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.createPremiumGeoDBAddon({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/create.md b/docs/examples/organizations/create.md index 109bf6e8..2f3d99c1 100644 --- a/docs/examples/organizations/create.md +++ b/docs/examples/organizations/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations, Platform } from "@appwrite.io/console"; +import { Client, Organizations, Platform } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await organizations.create({ couponId: '', // optional taxId: '', // optional budget: 0, // optional - platform: Platform.Appwrite // optional + platform: Platform.Appwrite, // optional }); console.log(result); diff --git a/docs/examples/organizations/delete-addon.md b/docs/examples/organizations/delete-addon.md index 98c64eac..79cbb51e 100644 --- a/docs/examples/organizations/delete-addon.md +++ b/docs/examples/organizations/delete-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.deleteAddon({ organizationId: '', - addonId: '' + addonId: '', }); console.log(result); diff --git a/docs/examples/organizations/delete-backup-payment-method.md b/docs/examples/organizations/delete-backup-payment-method.md index d16cdffc..afafd142 100644 --- a/docs/examples/organizations/delete-backup-payment-method.md +++ b/docs/examples/organizations/delete-backup-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.deleteBackupPaymentMethod({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/delete-billing-address.md b/docs/examples/organizations/delete-billing-address.md index c39188db..ecb089c2 100644 --- a/docs/examples/organizations/delete-billing-address.md +++ b/docs/examples/organizations/delete-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.deleteBillingAddress({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/delete-default-payment-method.md b/docs/examples/organizations/delete-default-payment-method.md index b998b4d0..d332429a 100644 --- a/docs/examples/organizations/delete-default-payment-method.md +++ b/docs/examples/organizations/delete-default-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.deleteDefaultPaymentMethod({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md index f0871e64..6c7bc82c 100644 --- a/docs/examples/organizations/delete.md +++ b/docs/examples/organizations/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.delete({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/estimation-create-organization.md b/docs/examples/organizations/estimation-create-organization.md index e98b3031..94f7d14e 100644 --- a/docs/examples/organizations/estimation-create-organization.md +++ b/docs/examples/organizations/estimation-create-organization.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations, Platform } from "@appwrite.io/console"; +import { Client, Organizations, Platform } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await organizations.estimationCreateOrganization({ paymentMethodId: '', // optional invites: [], // optional couponId: '', // optional - platform: Platform.Appwrite // optional + platform: Platform.Appwrite, // optional }); console.log(result); diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md index 8049bb99..2f3000c6 100644 --- a/docs/examples/organizations/estimation-delete-organization.md +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.estimationDeleteOrganization({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/estimation-update-plan.md b/docs/examples/organizations/estimation-update-plan.md index 0a5b40aa..8bdf3d6f 100644 --- a/docs/examples/organizations/estimation-update-plan.md +++ b/docs/examples/organizations/estimation-update-plan.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await organizations.estimationUpdatePlan({ organizationId: '', billingPlan: 'tier-0', invites: [], // optional - couponId: '' // optional + couponId: '', // optional }); console.log(result); diff --git a/docs/examples/organizations/get-addon-price.md b/docs/examples/organizations/get-addon-price.md index 1f96ba39..12d6cb5e 100644 --- a/docs/examples/organizations/get-addon-price.md +++ b/docs/examples/organizations/get-addon-price.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations, Addon } from "@appwrite.io/console"; +import { Client, Organizations, AddonKey } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getAddonPrice({ organizationId: '', - addon: Addon.Baa + addon: AddonKey.Baa, }); console.log(result); diff --git a/docs/examples/organizations/get-addon.md b/docs/examples/organizations/get-addon.md index ea67f7a2..e59522e6 100644 --- a/docs/examples/organizations/get-addon.md +++ b/docs/examples/organizations/get-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getAddon({ organizationId: '', - addonId: '' + addonId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-aggregation.md b/docs/examples/organizations/get-aggregation.md index c512261f..aa06495d 100644 --- a/docs/examples/organizations/get-aggregation.md +++ b/docs/examples/organizations/get-aggregation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await organizations.getAggregation({ organizationId: '', aggregationId: '', limit: 0, // optional - offset: null // optional + offset: null, // optional }); console.log(result); diff --git a/docs/examples/organizations/get-available-credits.md b/docs/examples/organizations/get-available-credits.md index 832ba412..75cedc35 100644 --- a/docs/examples/organizations/get-available-credits.md +++ b/docs/examples/organizations/get-available-credits.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.getAvailableCredits({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-billing-address.md b/docs/examples/organizations/get-billing-address.md index 054f9c47..c8fad01a 100644 --- a/docs/examples/organizations/get-billing-address.md +++ b/docs/examples/organizations/get-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getBillingAddress({ organizationId: '', - billingAddressId: '' + billingAddressId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-credit.md b/docs/examples/organizations/get-credit.md index 89f352ad..ed8c8760 100644 --- a/docs/examples/organizations/get-credit.md +++ b/docs/examples/organizations/get-credit.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getCredit({ organizationId: '', - creditId: '' + creditId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-invoice-download.md b/docs/examples/organizations/get-invoice-download.md index 06f07463..0ace4a0d 100644 --- a/docs/examples/organizations/get-invoice-download.md +++ b/docs/examples/organizations/get-invoice-download.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = organizations.getInvoiceDownload({ organizationId: '', - invoiceId: '' + invoiceId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-invoice-view.md b/docs/examples/organizations/get-invoice-view.md index 454dedaf..b499a545 100644 --- a/docs/examples/organizations/get-invoice-view.md +++ b/docs/examples/organizations/get-invoice-view.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = organizations.getInvoiceView({ organizationId: '', - invoiceId: '' + invoiceId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-invoice.md b/docs/examples/organizations/get-invoice.md index 94f39185..00765077 100644 --- a/docs/examples/organizations/get-invoice.md +++ b/docs/examples/organizations/get-invoice.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getInvoice({ organizationId: '', - invoiceId: '' + invoiceId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-payment-method.md b/docs/examples/organizations/get-payment-method.md index 8eb8a205..80d2243e 100644 --- a/docs/examples/organizations/get-payment-method.md +++ b/docs/examples/organizations/get-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getPaymentMethod({ organizationId: '', - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-plan.md b/docs/examples/organizations/get-plan.md index a803a967..1c2adacf 100644 --- a/docs/examples/organizations/get-plan.md +++ b/docs/examples/organizations/get-plan.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.getPlan({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/get-scopes.md b/docs/examples/organizations/get-scopes.md index dfc1d214..e7ed2fed 100644 --- a/docs/examples/organizations/get-scopes.md +++ b/docs/examples/organizations/get-scopes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getScopes({ organizationId: '', - projectId: '' // optional + projectId: '', // optional }); console.log(result); diff --git a/docs/examples/organizations/get-usage.md b/docs/examples/organizations/get-usage.md index c637eb27..8ab35fdf 100644 --- a/docs/examples/organizations/get-usage.md +++ b/docs/examples/organizations/get-usage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const organizations = new Organizations(client); const result = await organizations.getUsage({ organizationId: '', startDate: '2020-10-15T06:38:00.000+00:00', // optional - endDate: '2020-10-15T06:38:00.000+00:00' // optional + endDate: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/organizations/list-addons.md b/docs/examples/organizations/list-addons.md index 57995752..2bde1c4f 100644 --- a/docs/examples/organizations/list-addons.md +++ b/docs/examples/organizations/list-addons.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.listAddons({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/list-aggregations.md b/docs/examples/organizations/list-aggregations.md index 6afefb72..db0a274b 100644 --- a/docs/examples/organizations/list-aggregations.md +++ b/docs/examples/organizations/list-aggregations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.listAggregations({ organizationId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/organizations/list-credits.md b/docs/examples/organizations/list-credits.md index bde215ab..9475df72 100644 --- a/docs/examples/organizations/list-credits.md +++ b/docs/examples/organizations/list-credits.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.listCredits({ organizationId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/organizations/list-invoices.md b/docs/examples/organizations/list-invoices.md index 91befb1a..878795f9 100644 --- a/docs/examples/organizations/list-invoices.md +++ b/docs/examples/organizations/list-invoices.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.listInvoices({ organizationId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/organizations/list-regions.md b/docs/examples/organizations/list-regions.md index 851995cd..4390f275 100644 --- a/docs/examples/organizations/list-regions.md +++ b/docs/examples/organizations/list-regions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const organizations = new Organizations(client); const result = await organizations.listRegions({ - organizationId: '' + organizationId: '', }); console.log(result); diff --git a/docs/examples/organizations/list.md b/docs/examples/organizations/list.md index 27794c99..974dcf0b 100644 --- a/docs/examples/organizations/list.md +++ b/docs/examples/organizations/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.list({ queries: [], // optional - search: '' // optional + search: '', // optional }); console.log(result); diff --git a/docs/examples/organizations/set-backup-payment-method.md b/docs/examples/organizations/set-backup-payment-method.md index 3db0dffe..7a5aeda4 100644 --- a/docs/examples/organizations/set-backup-payment-method.md +++ b/docs/examples/organizations/set-backup-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.setBackupPaymentMethod({ organizationId: '', - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/organizations/set-billing-address.md b/docs/examples/organizations/set-billing-address.md index 1c1c5b19..472f511f 100644 --- a/docs/examples/organizations/set-billing-address.md +++ b/docs/examples/organizations/set-billing-address.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.setBillingAddress({ organizationId: '', - billingAddressId: '' + billingAddressId: '', }); console.log(result); diff --git a/docs/examples/organizations/set-billing-email.md b/docs/examples/organizations/set-billing-email.md index 61cd3b88..4159945e 100644 --- a/docs/examples/organizations/set-billing-email.md +++ b/docs/examples/organizations/set-billing-email.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.setBillingEmail({ organizationId: '', - billingEmail: 'email@example.com' + billingEmail: 'email@example.com', }); console.log(result); diff --git a/docs/examples/organizations/set-billing-tax-id.md b/docs/examples/organizations/set-billing-tax-id.md index f5b66007..2b2b42e2 100644 --- a/docs/examples/organizations/set-billing-tax-id.md +++ b/docs/examples/organizations/set-billing-tax-id.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.setBillingTaxId({ organizationId: '', - taxId: '' + taxId: '', }); console.log(result); diff --git a/docs/examples/organizations/set-default-payment-method.md b/docs/examples/organizations/set-default-payment-method.md index b6d465f6..0c3e128d 100644 --- a/docs/examples/organizations/set-default-payment-method.md +++ b/docs/examples/organizations/set-default-payment-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.setDefaultPaymentMethod({ organizationId: '', - paymentMethodId: '' + paymentMethodId: '', }); console.log(result); diff --git a/docs/examples/organizations/update-budget.md b/docs/examples/organizations/update-budget.md index a923b5f9..020ce6d0 100644 --- a/docs/examples/organizations/update-budget.md +++ b/docs/examples/organizations/update-budget.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const organizations = new Organizations(client); const result = await organizations.updateBudget({ organizationId: '', budget: 0, - alerts: [] // optional + alerts: [], // optional }); console.log(result); diff --git a/docs/examples/organizations/update-plan.md b/docs/examples/organizations/update-plan.md index 7ca08da6..780422ef 100644 --- a/docs/examples/organizations/update-plan.md +++ b/docs/examples/organizations/update-plan.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await organizations.updatePlan({ invites: [], // optional couponId: '', // optional taxId: '', // optional - budget: 0 // optional + budget: 0, // optional }); console.log(result); diff --git a/docs/examples/organizations/validate-invoice.md b/docs/examples/organizations/validate-invoice.md index 2b1c078f..565b0a0d 100644 --- a/docs/examples/organizations/validate-invoice.md +++ b/docs/examples/organizations/validate-invoice.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.validateInvoice({ organizationId: '', - invoiceId: '' + invoiceId: '', }); console.log(result); diff --git a/docs/examples/organizations/validate-payment.md b/docs/examples/organizations/validate-payment.md index 9e999952..1fad9612 100644 --- a/docs/examples/organizations/validate-payment.md +++ b/docs/examples/organizations/validate-payment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations } from "@appwrite.io/console"; +import { Client, Organizations } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.validatePayment({ organizationId: '', - invites: [] // optional + invites: [], // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-backup-policy.md b/docs/examples/postgresql/create-backup-policy.md index 90f1ff02..4d3e237a 100644 --- a/docs/examples/postgresql/create-backup-policy.md +++ b/docs/examples/postgresql/create-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await postgresql.createBackupPolicy({ schedule: '', retention: 1, type: 'full', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-backup.md b/docs/examples/postgresql/create-backup.md index 766555cf..5af116dc 100644 --- a/docs/examples/postgresql/create-backup.md +++ b/docs/examples/postgresql/create-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.createBackup({ databaseId: '', - type: 'full' // optional + type: 'full', // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-branch.md b/docs/examples/postgresql/create-branch.md index 6e82f64a..d2b51ec4 100644 --- a/docs/examples/postgresql/create-branch.md +++ b/docs/examples/postgresql/create-branch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.createBranch({ databaseId: '', branchId: '', // optional - ttl: 300 // optional + ttl: 300, // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-execution.md b/docs/examples/postgresql/create-execution.md index 1e4c9eaf..deb26bc2 100644 --- a/docs/examples/postgresql/create-execution.md +++ b/docs/examples/postgresql/create-execution.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await postgresql.createExecution({ databaseId: '', sql: '', bindings: {}, // optional - timeoutSeconds: 1 // optional + timeoutSeconds: 1, // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-extension.md b/docs/examples/postgresql/create-extension.md index 0c6e512d..4bb11394 100644 --- a/docs/examples/postgresql/create-extension.md +++ b/docs/examples/postgresql/create-extension.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.createExtension({ databaseId: '', - name: '' + name: '', }); console.log(result); diff --git a/docs/examples/postgresql/create-failover.md b/docs/examples/postgresql/create-failover.md index 77bfe691..82b3ef3a 100644 --- a/docs/examples/postgresql/create-failover.md +++ b/docs/examples/postgresql/create-failover.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-migration.md b/docs/examples/postgresql/create-migration.md index 703ec022..fceba090 100644 --- a/docs/examples/postgresql/create-migration.md +++ b/docs/examples/postgresql/create-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.createMigration({ databaseId: '', targetType: 'shared', - specification: '' // optional + specification: '', // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index 93b76b46..c0695106 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,8 @@ const result = await postgresql.createRestoration({ databaseId: '', type: 'backup', // optional backupId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetDatabaseId: '', // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/postgresql/create-upgrade.md b/docs/examples/postgresql/create-upgrade.md index 68496dec..f18110f3 100644 --- a/docs/examples/postgresql/create-upgrade.md +++ b/docs/examples/postgresql/create-upgrade.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.createUpgrade({ databaseId: '', - targetVersion: '' + targetVersion: '', }); console.log(result); diff --git a/docs/examples/postgresql/create.md b/docs/examples/postgresql/create.md index 45e36030..108b9621 100644 --- a/docs/examples/postgresql/create.md +++ b/docs/examples/postgresql/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,6 @@ const result = await postgresql.create({ specification: '', // optional replicas: 0, // optional syncMode: 'async', // optional - standbyRegion: '', // optional networkIdleTimeoutSeconds: 60, // optional networkIPAllowlist: [], // optional idleTimeoutMinutes: 5, // optional @@ -22,7 +21,7 @@ const result = await postgresql.create({ pitrRetentionDays: 1, // optional storageAutoscaling: false, // optional storageAutoscalingThresholdPercent: 50, // optional - storageAutoscalingMaxGb: 0 // optional + storageAutoscalingMaxGb: 0, // optional }); console.log(result); diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md index 15dafdbc..15b133fe 100644 --- a/docs/examples/postgresql/delete-backup-policy.md +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.deleteBackupPolicy({ databaseId: '', - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md index 2cb95e6c..2f6eacc6 100644 --- a/docs/examples/postgresql/delete-backup.md +++ b/docs/examples/postgresql/delete-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.deleteBackup({ databaseId: '', - backupId: '' + backupId: '', }); console.log(result); diff --git a/docs/examples/postgresql/delete-branch.md b/docs/examples/postgresql/delete-branch.md index a2544863..244320b9 100644 --- a/docs/examples/postgresql/delete-branch.md +++ b/docs/examples/postgresql/delete-branch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.deleteBranch({ databaseId: '', - branchId: '' + branchId: '', }); console.log(result); diff --git a/docs/examples/postgresql/delete-extension.md b/docs/examples/postgresql/delete-extension.md index 64adab49..02cd7884 100644 --- a/docs/examples/postgresql/delete-extension.md +++ b/docs/examples/postgresql/delete-extension.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.deleteExtension({ databaseId: '', - extensionName: '' + extensionName: '', }); console.log(result); diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md index 3c91f9fb..213911d9 100644 --- a/docs/examples/postgresql/delete.md +++ b/docs/examples/postgresql/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-backup-policy.md b/docs/examples/postgresql/get-backup-policy.md index 0c65a1ee..4db5bffa 100644 --- a/docs/examples/postgresql/get-backup-policy.md +++ b/docs/examples/postgresql/get-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.getBackupPolicy({ databaseId: '', - policyId: '' + policyId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-backup.md b/docs/examples/postgresql/get-backup.md index bd5b1675..f5ab5022 100644 --- a/docs/examples/postgresql/get-backup.md +++ b/docs/examples/postgresql/get-backup.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.getBackup({ databaseId: '', - backupId: '' + backupId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-pitr.md b/docs/examples/postgresql/get-pitr.md index 0cb36b6f..0a522e7b 100644 --- a/docs/examples/postgresql/get-pitr.md +++ b/docs/examples/postgresql/get-pitr.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.getPitr({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-pooler.md b/docs/examples/postgresql/get-pooler.md index 1140db7b..fec0be0b 100644 --- a/docs/examples/postgresql/get-pooler.md +++ b/docs/examples/postgresql/get-pooler.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.getPooler({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-replicas.md b/docs/examples/postgresql/get-replicas.md index 0b49ccff..d15ba47d 100644 --- a/docs/examples/postgresql/get-replicas.md +++ b/docs/examples/postgresql/get-replicas.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.getReplicas({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-restoration.md b/docs/examples/postgresql/get-restoration.md index 2e203f21..566abc46 100644 --- a/docs/examples/postgresql/get-restoration.md +++ b/docs/examples/postgresql/get-restoration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.getRestoration({ databaseId: '', - restorationId: '' + restorationId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get-status.md b/docs/examples/postgresql/get-status.md index fc42e980..4e9a9ee9 100644 --- a/docs/examples/postgresql/get-status.md +++ b/docs/examples/postgresql/get-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.getStatus({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/get.md b/docs/examples/postgresql/get.md index 972bde1c..c0b303cb 100644 --- a/docs/examples/postgresql/get.md +++ b/docs/examples/postgresql/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/list-backup-policies.md b/docs/examples/postgresql/list-backup-policies.md index 39f7de9d..10558558 100644 --- a/docs/examples/postgresql/list-backup-policies.md +++ b/docs/examples/postgresql/list-backup-policies.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.listBackupPolicies({ databaseId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/postgresql/list-backups.md b/docs/examples/postgresql/list-backups.md index e2361862..9911422b 100644 --- a/docs/examples/postgresql/list-backups.md +++ b/docs/examples/postgresql/list-backups.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.listBackups({ databaseId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/postgresql/list-branches.md b/docs/examples/postgresql/list-branches.md index 58a21999..95bffd10 100644 --- a/docs/examples/postgresql/list-branches.md +++ b/docs/examples/postgresql/list-branches.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.listBranches({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/list-extensions.md b/docs/examples/postgresql/list-extensions.md index 0f498631..fd8334e9 100644 --- a/docs/examples/postgresql/list-extensions.md +++ b/docs/examples/postgresql/list-extensions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.listExtensions({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/list-operations.md b/docs/examples/postgresql/list-operations.md index e6840e4f..b762cdd7 100644 --- a/docs/examples/postgresql/list-operations.md +++ b/docs/examples/postgresql/list-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,9 +9,9 @@ const postgresql = new Postgresql(client); const result = await postgresql.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/postgresql/list-restorations.md b/docs/examples/postgresql/list-restorations.md index 734acefa..33fc97ec 100644 --- a/docs/examples/postgresql/list-restorations.md +++ b/docs/examples/postgresql/list-restorations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await postgresql.listRestorations({ status: 'pending', // optional type: 'backup', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/postgresql/list-specifications.md b/docs/examples/postgresql/list-specifications.md index 3af2dd66..9f5730ea 100644 --- a/docs/examples/postgresql/list-specifications.md +++ b/docs/examples/postgresql/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/postgresql/list.md b/docs/examples/postgresql/list.md index 01c8ff24..9bcdd747 100644 --- a/docs/examples/postgresql/list.md +++ b/docs/examples/postgresql/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.list({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/postgresql/update-backup-policy.md b/docs/examples/postgresql/update-backup-policy.md index 2937583f..7d763686 100644 --- a/docs/examples/postgresql/update-backup-policy.md +++ b/docs/examples/postgresql/update-backup-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await postgresql.updateBackupPolicy({ name: '', // optional schedule: '', // optional retention: 1, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/postgresql/update-backup-storage.md b/docs/examples/postgresql/update-backup-storage.md index 6939a1c0..1a803a12 100644 --- a/docs/examples/postgresql/update-backup-storage.md +++ b/docs/examples/postgresql/update-backup-storage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await postgresql.updateBackupStorage({ secretKey: '', region: '', // optional prefix: '', // optional - endpoint: '' // optional + endpoint: '', // optional }); console.log(result); diff --git a/docs/examples/postgresql/update-credentials.md b/docs/examples/postgresql/update-credentials.md index 1b32d41e..4290d623 100644 --- a/docs/examples/postgresql/update-credentials.md +++ b/docs/examples/postgresql/update-credentials.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const postgresql = new Postgresql(client); const result = await postgresql.updateCredentials({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/postgresql/update-maintenance.md b/docs/examples/postgresql/update-maintenance.md index 0b243aba..6e1e5ec9 100644 --- a/docs/examples/postgresql/update-maintenance.md +++ b/docs/examples/postgresql/update-maintenance.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const postgresql = new Postgresql(client); const result = await postgresql.updateMaintenance({ databaseId: '', day: 'sun', - hourUtc: 0 + hourUtc: 0, }); console.log(result); diff --git a/docs/examples/postgresql/update-pooler.md b/docs/examples/postgresql/update-pooler.md index 6b31331f..7f3f5e6d 100644 --- a/docs/examples/postgresql/update-pooler.md +++ b/docs/examples/postgresql/update-pooler.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,7 +16,7 @@ const result = await postgresql.updatePooler({ poolerCpuRequest: '', // optional poolerCpuLimit: '', // optional poolerMemoryRequest: '', // optional - poolerMemoryLimit: '' // optional + poolerMemoryLimit: '', // optional }); console.log(result); diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md index 35e4a645..874e4a60 100644 --- a/docs/examples/postgresql/update.md +++ b/docs/examples/postgresql/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Postgresql } from "@appwrite.io/console"; +import { Client, Postgresql } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,8 +14,6 @@ const result = await postgresql.update({ specification: '', // optional replicas: 0, // optional syncMode: 'async', // optional - crossRegionReplicas: 0, // optional - standbyRegion: '', // optional networkIdleTimeoutSeconds: 60, // optional networkIPAllowlist: [], // optional idleTimeoutMinutes: 5, // optional @@ -30,7 +28,7 @@ const result = await postgresql.update({ sqlApiAllowedStatements: [], // optional sqlApiMaxRows: 1, // optional sqlApiMaxBytes: 1024, // optional - sqlApiTimeoutSeconds: 1 // optional + sqlApiTimeoutSeconds: 1, // optional }); console.log(result); diff --git a/docs/examples/presences/delete.md b/docs/examples/presences/delete.md index 7773d3a2..4f5f4054 100644 --- a/docs/examples/presences/delete.md +++ b/docs/examples/presences/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Presences } from "@appwrite.io/console"; +import { Client, Presences } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const presences = new Presences(client); const result = await presences.delete({ - presenceId: '' + presenceId: '', }); console.log(result); diff --git a/docs/examples/presences/get-usage.md b/docs/examples/presences/get-usage.md index 338e339a..723b076b 100644 --- a/docs/examples/presences/get-usage.md +++ b/docs/examples/presences/get-usage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Presences, UsageRange } from "@appwrite.io/console"; +import { Client, Presences, UsageRange } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const presences = new Presences(client); const result = await presences.getUsage({ - range: UsageRange.TwentyFourHours // optional + range: UsageRange.TwentyFourHours, // optional }); console.log(result); diff --git a/docs/examples/presences/get.md b/docs/examples/presences/get.md index c2d4ca0d..e1eba61d 100644 --- a/docs/examples/presences/get.md +++ b/docs/examples/presences/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Presences } from "@appwrite.io/console"; +import { Client, Presences } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const presences = new Presences(client); const result = await presences.get({ - presenceId: '' + presenceId: '', }); console.log(result); diff --git a/docs/examples/presences/list.md b/docs/examples/presences/list.md index 5cd70b44..3ffeb14e 100644 --- a/docs/examples/presences/list.md +++ b/docs/examples/presences/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Presences } from "@appwrite.io/console"; +import { Client, Presences } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const presences = new Presences(client); const result = await presences.list({ queries: [], // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); console.log(result); diff --git a/docs/examples/presences/update.md b/docs/examples/presences/update.md index ce1280b0..a75cb2e7 100644 --- a/docs/examples/presences/update.md +++ b/docs/examples/presences/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Presences, Permission, Role } from "@appwrite.io/console"; +import { Client, Presences, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await presences.update({ expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {}, // optional permissions: [Permission.read(Role.any())], // optional - purge: false // optional + purge: false, // optional }); console.log(result); diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md index 8c77a0ce..ef3d2dea 100644 --- a/docs/examples/presences/upsert.md +++ b/docs/examples/presences/upsert.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Presences, Permission, Role } from "@appwrite.io/console"; +import { Client, Presences, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await presences.upsert({ status: '', permissions: [Permission.read(Role.any())], // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional - metadata: {} // optional + metadata: {}, // optional }); console.log(result); diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 7a553d5d..df927932 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createAndroidPlatform({ platformId: '', name: '', - applicationId: '' + applicationId: '', }); console.log(result); diff --git a/docs/examples/project/create-apple-platform.md b/docs/examples/project/create-apple-platform.md index 313f7705..28bb0793 100644 --- a/docs/examples/project/create-apple-platform.md +++ b/docs/examples/project/create-apple-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createApplePlatform({ platformId: '', name: '', - bundleIdentifier: '' + bundleIdentifier: '', }); console.log(result); diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 233f3b8e..f5f76a42 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectKeyScopes } from "@appwrite.io/console"; +import { Client, Project, ProjectKeyScopes } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.createEphemeralKey({ scopes: [ProjectKeyScopes.ProjectRead], - duration: 600 + duration: 600, }); console.log(result); diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md index b0feb14f..5354d732 100644 --- a/docs/examples/project/create-key.md +++ b/docs/examples/project/create-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectKeyScopes } from "@appwrite.io/console"; +import { Client, Project, ProjectKeyScopes } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.createKey({ keyId: '', name: '', scopes: [ProjectKeyScopes.ProjectRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/project/create-linux-platform.md b/docs/examples/project/create-linux-platform.md index f7c54062..cd527e37 100644 --- a/docs/examples/project/create-linux-platform.md +++ b/docs/examples/project/create-linux-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createLinuxPlatform({ platformId: '', name: '', - packageName: '' + packageName: '', }); console.log(result); diff --git a/docs/examples/project/create-mock-phone.md b/docs/examples/project/create-mock-phone.md index eaf3dad6..452362d1 100644 --- a/docs/examples/project/create-mock-phone.md +++ b/docs/examples/project/create-mock-phone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.createMockPhone({ number: '+12065550100', - otp: '' + otp: '', }); console.log(result); diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 85a11949..300e972c 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.createSMTPTest({ - emails: [] + emails: [], }); console.log(result); diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md index c27a58dd..2ad86e66 100644 --- a/docs/examples/project/create-variable.md +++ b/docs/examples/project/create-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.createVariable({ variableId: '', key: '', value: '', - secret: false // optional + secret: false, // optional }); console.log(result); diff --git a/docs/examples/project/create-web-platform.md b/docs/examples/project/create-web-platform.md index 1349d26d..cc27e4cd 100644 --- a/docs/examples/project/create-web-platform.md +++ b/docs/examples/project/create-web-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createWebPlatform({ platformId: '', name: '', - hostname: 'app.example.com' + hostname: 'app.example.com', }); console.log(result); diff --git a/docs/examples/project/create-windows-platform.md b/docs/examples/project/create-windows-platform.md index a099d910..55b53417 100644 --- a/docs/examples/project/create-windows-platform.md +++ b/docs/examples/project/create-windows-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createWindowsPlatform({ platformId: '', name: '', - packageIdentifierName: '' + packageIdentifierName: '', }); console.log(result); diff --git a/docs/examples/project/delete-key.md b/docs/examples/project/delete-key.md index b97331d0..05d10730 100644 --- a/docs/examples/project/delete-key.md +++ b/docs/examples/project/delete-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.deleteKey({ - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/project/delete-mock-phone.md b/docs/examples/project/delete-mock-phone.md index 598c56aa..4db6d3ce 100644 --- a/docs/examples/project/delete-mock-phone.md +++ b/docs/examples/project/delete-mock-phone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.deleteMockPhone({ - number: '+12065550100' + number: '+12065550100', }); console.log(result); diff --git a/docs/examples/project/delete-platform.md b/docs/examples/project/delete-platform.md index 54092d78..2e939098 100644 --- a/docs/examples/project/delete-platform.md +++ b/docs/examples/project/delete-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.deletePlatform({ - platformId: '' + platformId: '', }); console.log(result); diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md index 1435d112..8fcb3cd8 100644 --- a/docs/examples/project/delete-variable.md +++ b/docs/examples/project/delete-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.deleteVariable({ - variableId: '' + variableId: '', }); console.log(result); diff --git a/docs/examples/project/delete.md b/docs/examples/project/delete.md index 7e38d433..bb937691 100644 --- a/docs/examples/project/delete.md +++ b/docs/examples/project/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md index 48e3b230..edcd55fc 100644 --- a/docs/examples/project/get-email-template.md +++ b/docs/examples/project/get-email-template.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Project, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "@appwrite.io/console"; +import { + Client, + Project, + ProjectEmailTemplateId, + ProjectEmailTemplateLocale, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +14,7 @@ const project = new Project(client); const result = await project.getEmailTemplate({ templateId: ProjectEmailTemplateId.Verification, - locale: ProjectEmailTemplateLocale.Af // optional + locale: ProjectEmailTemplateLocale.Af, // optional }); console.log(result); diff --git a/docs/examples/project/get-key.md b/docs/examples/project/get-key.md index f2454e21..797a1101 100644 --- a/docs/examples/project/get-key.md +++ b/docs/examples/project/get-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getKey({ - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/project/get-mock-phone.md b/docs/examples/project/get-mock-phone.md index 938b5915..c2b7c61d 100644 --- a/docs/examples/project/get-mock-phone.md +++ b/docs/examples/project/get-mock-phone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getMockPhone({ - number: '+12065550100' + number: '+12065550100', }); console.log(result); diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md index ed4d8092..449a282c 100644 --- a/docs/examples/project/get-o-auth-2-provider.md +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectOAuthProviderId } from "@appwrite.io/console"; +import { Client, Project, ProjectOAuthProviderId } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getOAuth2Provider({ - providerId: ProjectOAuthProviderId.Amazon + providerId: ProjectOAuthProviderId.Amazon, }); console.log(result); diff --git a/docs/examples/project/get-platform.md b/docs/examples/project/get-platform.md index 1ae14878..d896e5f4 100644 --- a/docs/examples/project/get-platform.md +++ b/docs/examples/project/get-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getPlatform({ - platformId: '' + platformId: '', }); console.log(result); diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md index be06807f..a1e4d746 100644 --- a/docs/examples/project/get-policy.md +++ b/docs/examples/project/get-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectPolicyId } from "@appwrite.io/console"; +import { Client, Project, ProjectPolicyId } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getPolicy({ - policyId: ProjectPolicyId.PasswordDictionary + policyId: ProjectPolicyId.PasswordDictionary, }); console.log(result); diff --git a/docs/examples/project/get-usage.md b/docs/examples/project/get-usage.md index 79bf3af9..195c46b4 100644 --- a/docs/examples/project/get-usage.md +++ b/docs/examples/project/get-usage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectUsageRange } from "@appwrite.io/console"; +import { Client, Project, ProjectUsageRange } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.getUsage({ startDate: '2020-10-15T06:38:00.000+00:00', endDate: '2020-10-15T06:38:00.000+00:00', - period: ProjectUsageRange.OneHour // optional + period: ProjectUsageRange.OneHour, // optional }); console.log(result); diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md index bf5de97b..2291de26 100644 --- a/docs/examples/project/get-variable.md +++ b/docs/examples/project/get-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getVariable({ - variableId: '' + variableId: '', }); console.log(result); diff --git a/docs/examples/project/get.md b/docs/examples/project/get.md index 2d4d9f94..8efa7685 100644 --- a/docs/examples/project/get.md +++ b/docs/examples/project/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/project/list-email-templates.md b/docs/examples/project/list-email-templates.md index ec206bf3..4bffe603 100644 --- a/docs/examples/project/list-email-templates.md +++ b/docs/examples/project/list-email-templates.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listEmailTemplates({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/list-keys.md b/docs/examples/project/list-keys.md index c91def36..b0d493ec 100644 --- a/docs/examples/project/list-keys.md +++ b/docs/examples/project/list-keys.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listKeys({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/list-mock-phones.md b/docs/examples/project/list-mock-phones.md index d60a0570..a0f5f651 100644 --- a/docs/examples/project/list-mock-phones.md +++ b/docs/examples/project/list-mock-phones.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listMockPhones({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/list-o-auth-2-providers.md b/docs/examples/project/list-o-auth-2-providers.md index 3c8d5ea6..197a26fe 100644 --- a/docs/examples/project/list-o-auth-2-providers.md +++ b/docs/examples/project/list-o-auth-2-providers.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listOAuth2Providers({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/list-platforms.md b/docs/examples/project/list-platforms.md index fe3bb74c..695e1cd6 100644 --- a/docs/examples/project/list-platforms.md +++ b/docs/examples/project/list-platforms.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listPlatforms({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/list-policies.md b/docs/examples/project/list-policies.md index d1d84241..9c64c58e 100644 --- a/docs/examples/project/list-policies.md +++ b/docs/examples/project/list-policies.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listPolicies({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md index 52cdb733..a397b904 100644 --- a/docs/examples/project/list-variables.md +++ b/docs/examples/project/list-variables.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.listVariables({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index 7842a6d6..e736fb56 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateAndroidPlatform({ platformId: '', name: '', - applicationId: '' + applicationId: '', }); console.log(result); diff --git a/docs/examples/project/update-apple-platform.md b/docs/examples/project/update-apple-platform.md index 3788edfc..315e6903 100644 --- a/docs/examples/project/update-apple-platform.md +++ b/docs/examples/project/update-apple-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateApplePlatform({ platformId: '', name: '', - bundleIdentifier: '' + bundleIdentifier: '', }); console.log(result); diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md index e92f1245..c1a846a1 100644 --- a/docs/examples/project/update-auth-method.md +++ b/docs/examples/project/update-auth-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectAuthMethodId } from "@appwrite.io/console"; +import { Client, Project, ProjectAuthMethodId } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.updateAuthMethod({ methodId: ProjectAuthMethodId.EmailPassword, - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-deny-aliased-email-policy.md b/docs/examples/project/update-deny-aliased-email-policy.md index f9a253de..f32ddfa5 100644 --- a/docs/examples/project/update-deny-aliased-email-policy.md +++ b/docs/examples/project/update-deny-aliased-email-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateDenyAliasedEmailPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-deny-corporate-email-policy.md b/docs/examples/project/update-deny-corporate-email-policy.md index f9daed3d..c2323abb 100644 --- a/docs/examples/project/update-deny-corporate-email-policy.md +++ b/docs/examples/project/update-deny-corporate-email-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateDenyCorporateEmailPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-deny-disposable-email-policy.md b/docs/examples/project/update-deny-disposable-email-policy.md index 498ad335..8146a09a 100644 --- a/docs/examples/project/update-deny-disposable-email-policy.md +++ b/docs/examples/project/update-deny-disposable-email-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateDenyDisposableEmailPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-deny-free-email-policy.md b/docs/examples/project/update-deny-free-email-policy.md index 0356a798..626fffb6 100644 --- a/docs/examples/project/update-deny-free-email-policy.md +++ b/docs/examples/project/update-deny-free-email-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateDenyFreeEmailPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md index 7b2951f9..24aa3fba 100644 --- a/docs/examples/project/update-email-template.md +++ b/docs/examples/project/update-email-template.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Project, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "@appwrite.io/console"; +import { + Client, + Project, + ProjectEmailTemplateId, + ProjectEmailTemplateLocale, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +20,7 @@ const result = await project.updateEmailTemplate({ senderName: '', // optional senderEmail: 'email@example.com', // optional replyToEmail: 'email@example.com', // optional - replyToName: '' // optional + replyToName: '', // optional }); console.log(result); diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 636419e0..3bba96a0 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectKeyScopes } from "@appwrite.io/console"; +import { Client, Project, ProjectKeyScopes } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateKey({ keyId: '', name: '', scopes: [ProjectKeyScopes.ProjectRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index acf873ad..8df4ffb4 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateLabels({ - labels: [] + labels: [], }); console.log(result); diff --git a/docs/examples/project/update-linux-platform.md b/docs/examples/project/update-linux-platform.md index 9e1d680c..5bf1ae98 100644 --- a/docs/examples/project/update-linux-platform.md +++ b/docs/examples/project/update-linux-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateLinuxPlatform({ platformId: '', name: '', - packageName: '' + packageName: '', }); console.log(result); diff --git a/docs/examples/project/update-membership-privacy-policy.md b/docs/examples/project/update-membership-privacy-policy.md index ae8ef978..1e14ffa0 100644 --- a/docs/examples/project/update-membership-privacy-policy.md +++ b/docs/examples/project/update-membership-privacy-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await project.updateMembershipPrivacyPolicy({ userPhone: false, // optional userName: false, // optional userMFA: false, // optional - userAccessedAt: false // optional + userAccessedAt: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-mfa-factors-policy.md b/docs/examples/project/update-mfa-factors-policy.md new file mode 100644 index 00000000..e2663bde --- /dev/null +++ b/docs/examples/project/update-mfa-factors-policy.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updateMFAFactorsPolicy({ + totp: false, // optional + email: false, // optional + phone: false, // optional + custom: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-mock-phone.md b/docs/examples/project/update-mock-phone.md index 88204665..bf3d4092 100644 --- a/docs/examples/project/update-mock-phone.md +++ b/docs/examples/project/update-mock-phone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.updateMockPhone({ number: '+12065550100', - otp: '' + otp: '', }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-amazon.md b/docs/examples/project/update-o-auth-2-amazon.md index 41505151..2f98d091 100644 --- a/docs/examples/project/update-o-auth-2-amazon.md +++ b/docs/examples/project/update-o-auth-2-amazon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Amazon({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 088f42fa..ea8fef83 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Apple({ keyId: '', // optional teamId: '', // optional p8File: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-appwrite.md b/docs/examples/project/update-o-auth-2-appwrite.md index be9b975e..669b14e3 100644 --- a/docs/examples/project/update-o-auth-2-appwrite.md +++ b/docs/examples/project/update-o-auth-2-appwrite.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Appwrite({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index aae061ce..7c2898e4 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-authentik.md b/docs/examples/project/update-o-auth-2-authentik.md index b59b7ced..796368a0 100644 --- a/docs/examples/project/update-o-auth-2-authentik.md +++ b/docs/examples/project/update-o-auth-2-authentik.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateOAuth2Authentik({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-autodesk.md b/docs/examples/project/update-o-auth-2-autodesk.md index 675caa2a..819d6fa4 100644 --- a/docs/examples/project/update-o-auth-2-autodesk.md +++ b/docs/examples/project/update-o-auth-2-autodesk.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Autodesk({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-bitbucket.md b/docs/examples/project/update-o-auth-2-bitbucket.md index 98b39d67..14e5d86c 100644 --- a/docs/examples/project/update-o-auth-2-bitbucket.md +++ b/docs/examples/project/update-o-auth-2-bitbucket.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Bitbucket({ key: '', // optional secret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-bitly.md b/docs/examples/project/update-o-auth-2-bitly.md index 572d6dcf..66865768 100644 --- a/docs/examples/project/update-o-auth-2-bitly.md +++ b/docs/examples/project/update-o-auth-2-bitly.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Bitly({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-box.md b/docs/examples/project/update-o-auth-2-box.md index a3010c05..7dd3605a 100644 --- a/docs/examples/project/update-o-auth-2-box.md +++ b/docs/examples/project/update-o-auth-2-box.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Box({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-cloudflare.md b/docs/examples/project/update-o-auth-2-cloudflare.md new file mode 100644 index 00000000..b961a091 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-cloudflare.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Cloudflare({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-dailymotion.md b/docs/examples/project/update-o-auth-2-dailymotion.md index 40912058..fd63c401 100644 --- a/docs/examples/project/update-o-auth-2-dailymotion.md +++ b/docs/examples/project/update-o-auth-2-dailymotion.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Dailymotion({ apiKey: '', // optional apiSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index c289e4b4..1116db06 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Discord({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-disqus.md b/docs/examples/project/update-o-auth-2-disqus.md index b356ce7f..fba11c6a 100644 --- a/docs/examples/project/update-o-auth-2-disqus.md +++ b/docs/examples/project/update-o-auth-2-disqus.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Disqus({ publicKey: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-dropbox.md b/docs/examples/project/update-o-auth-2-dropbox.md index f088118a..6bb803e2 100644 --- a/docs/examples/project/update-o-auth-2-dropbox.md +++ b/docs/examples/project/update-o-auth-2-dropbox.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Dropbox({ appKey: '', // optional appSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-etsy.md b/docs/examples/project/update-o-auth-2-etsy.md index 469c0a08..d05f9050 100644 --- a/docs/examples/project/update-o-auth-2-etsy.md +++ b/docs/examples/project/update-o-auth-2-etsy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Etsy({ keyString: '', // optional sharedSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-facebook.md b/docs/examples/project/update-o-auth-2-facebook.md index 1af18fbd..deae89b2 100644 --- a/docs/examples/project/update-o-auth-2-facebook.md +++ b/docs/examples/project/update-o-auth-2-facebook.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Facebook({ appId: '', // optional appSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-figma.md b/docs/examples/project/update-o-auth-2-figma.md index e1b35875..7414b4c1 100644 --- a/docs/examples/project/update-o-auth-2-figma.md +++ b/docs/examples/project/update-o-auth-2-figma.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Figma({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-fusion-auth.md b/docs/examples/project/update-o-auth-2-fusion-auth.md index da29e909..4881811e 100644 --- a/docs/examples/project/update-o-auth-2-fusion-auth.md +++ b/docs/examples/project/update-o-auth-2-fusion-auth.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateOAuth2FusionAuth({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index f1dbb617..f3cc3b13 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2GitHub({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-gitlab.md b/docs/examples/project/update-o-auth-2-gitlab.md index 5191d013..1bfb3d7e 100644 --- a/docs/examples/project/update-o-auth-2-gitlab.md +++ b/docs/examples/project/update-o-auth-2-gitlab.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateOAuth2Gitlab({ applicationId: '', // optional secret: '', // optional endpoint: 'https://example.com', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index c84567de..2780c0ca 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project, ProjectOAuth2GooglePrompt } from "@appwrite.io/console"; +import { + Client, + Project, + ProjectOAuth2GooglePrompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +15,7 @@ const result = await project.updateOAuth2Google({ clientId: '', // optional clientSecret: '', // optional prompt: [ProjectOAuth2GooglePrompt.None], // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-hugging-face.md b/docs/examples/project/update-o-auth-2-hugging-face.md new file mode 100644 index 00000000..4917ae7a --- /dev/null +++ b/docs/examples/project/update-o-auth-2-hugging-face.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2HuggingFace({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md new file mode 100644 index 00000000..b92e049d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Kakao({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-keycloak.md b/docs/examples/project/update-o-auth-2-keycloak.md index 7121691d..34653307 100644 --- a/docs/examples/project/update-o-auth-2-keycloak.md +++ b/docs/examples/project/update-o-auth-2-keycloak.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Keycloak({ clientSecret: '', // optional endpoint: '', // optional realmName: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-kick.md b/docs/examples/project/update-o-auth-2-kick.md index 1bf99d6b..e29b1a75 100644 --- a/docs/examples/project/update-o-auth-2-kick.md +++ b/docs/examples/project/update-o-auth-2-kick.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Kick({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-linkedin.md b/docs/examples/project/update-o-auth-2-linkedin.md index 2ba49a51..97f465f0 100644 --- a/docs/examples/project/update-o-auth-2-linkedin.md +++ b/docs/examples/project/update-o-auth-2-linkedin.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Linkedin({ clientId: '', // optional primaryClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 3e10286a..18f21fe9 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '', // optional applicationSecret: '', // optional tenant: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-notion.md b/docs/examples/project/update-o-auth-2-notion.md index 7c9c0f09..66060594 100644 --- a/docs/examples/project/update-o-auth-2-notion.md +++ b/docs/examples/project/update-o-auth-2-notion.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Notion({ oauthClientId: '', // optional oauthClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md index fe8e74b7..2d979ee8 100644 --- a/docs/examples/project/update-o-auth-2-oidc.md +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectOAuth2OidcPrompt } from "@appwrite.io/console"; +import { Client, Project, ProjectOAuth2OidcPrompt } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,7 +16,7 @@ const result = await project.updateOAuth2Oidc({ userInfoURL: 'https://example.com', // optional prompt: [ProjectOAuth2OidcPrompt.None], // optional maxAge: 0, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 6621728e..a94ad691 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,9 @@ const project = new Project(client); const result = await project.updateOAuth2Okta({ clientId: '', // optional clientSecret: '', // optional - domain: '', // optional + domain: 'example.com', // optional authorizationServerId: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-paypal-sandbox.md b/docs/examples/project/update-o-auth-2-paypal-sandbox.md index d69e3e05..2b689e8e 100644 --- a/docs/examples/project/update-o-auth-2-paypal-sandbox.md +++ b/docs/examples/project/update-o-auth-2-paypal-sandbox.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2PaypalSandbox({ clientId: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-paypal.md b/docs/examples/project/update-o-auth-2-paypal.md index 4e41a324..3477c76e 100644 --- a/docs/examples/project/update-o-auth-2-paypal.md +++ b/docs/examples/project/update-o-auth-2-paypal.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Paypal({ clientId: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-podio.md b/docs/examples/project/update-o-auth-2-podio.md index 247b96cc..b930d433 100644 --- a/docs/examples/project/update-o-auth-2-podio.md +++ b/docs/examples/project/update-o-auth-2-podio.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Podio({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-resend.md b/docs/examples/project/update-o-auth-2-resend.md new file mode 100644 index 00000000..99fef956 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-resend.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Resend({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 8472e309..04c3da12 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '', // optional customerSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index 7eae488d..e765f974 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -22,7 +22,8 @@ const result = await project.updateOAuth2Server({ userCodeLength: 6, // optional userCodeFormat: 'numeric', // optional deviceCodeDuration: 60, // optional - defaultScopes: [] // optional + defaultScopes: [], // optional + installationScopes: [], // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-slack.md b/docs/examples/project/update-o-auth-2-slack.md index 7258f278..fe04c9b3 100644 --- a/docs/examples/project/update-o-auth-2-slack.md +++ b/docs/examples/project/update-o-auth-2-slack.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Slack({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-spotify.md b/docs/examples/project/update-o-auth-2-spotify.md index 796fd5cb..4e88f833 100644 --- a/docs/examples/project/update-o-auth-2-spotify.md +++ b/docs/examples/project/update-o-auth-2-spotify.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Spotify({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-stripe.md b/docs/examples/project/update-o-auth-2-stripe.md index 6faf6dc1..311b1b1a 100644 --- a/docs/examples/project/update-o-auth-2-stripe.md +++ b/docs/examples/project/update-o-auth-2-stripe.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Stripe({ clientId: '', // optional apiSecretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md new file mode 100644 index 00000000..c840831d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tik-tok.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2TikTok({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md index d7eabe6e..3a54d0c2 100644 --- a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md +++ b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2TradeshiftSandbox({ oauth2ClientId: '', // optional oauth2ClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-tradeshift.md b/docs/examples/project/update-o-auth-2-tradeshift.md index 90a18465..601a8452 100644 --- a/docs/examples/project/update-o-auth-2-tradeshift.md +++ b/docs/examples/project/update-o-auth-2-tradeshift.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Tradeshift({ oauth2ClientId: '', // optional oauth2ClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-twitch.md b/docs/examples/project/update-o-auth-2-twitch.md index 0fc86b17..dec6da05 100644 --- a/docs/examples/project/update-o-auth-2-twitch.md +++ b/docs/examples/project/update-o-auth-2-twitch.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Twitch({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-word-press.md b/docs/examples/project/update-o-auth-2-word-press.md index 1925bdd2..04119dca 100644 --- a/docs/examples/project/update-o-auth-2-word-press.md +++ b/docs/examples/project/update-o-auth-2-word-press.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2WordPress({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-yahoo.md b/docs/examples/project/update-o-auth-2-yahoo.md index 07af9e12..9ce30859 100644 --- a/docs/examples/project/update-o-auth-2-yahoo.md +++ b/docs/examples/project/update-o-auth-2-yahoo.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Yahoo({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-yandex.md b/docs/examples/project/update-o-auth-2-yandex.md index b43566b7..9cda2ed2 100644 --- a/docs/examples/project/update-o-auth-2-yandex.md +++ b/docs/examples/project/update-o-auth-2-yandex.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Yandex({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index f0113d05..0a1ff861 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Zoho({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-zoom.md b/docs/examples/project/update-o-auth-2-zoom.md index 531a66a6..a6f3f87a 100644 --- a/docs/examples/project/update-o-auth-2-zoom.md +++ b/docs/examples/project/update-o-auth-2-zoom.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Zoom({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2x.md b/docs/examples/project/update-o-auth-2x.md index 8510e6e5..05162dc8 100644 --- a/docs/examples/project/update-o-auth-2x.md +++ b/docs/examples/project/update-o-auth-2x.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2X({ customerKey: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-password-dictionary-policy.md b/docs/examples/project/update-password-dictionary-policy.md index 1c37ab28..b89a5885 100644 --- a/docs/examples/project/update-password-dictionary-policy.md +++ b/docs/examples/project/update-password-dictionary-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updatePasswordDictionaryPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-password-history-policy.md b/docs/examples/project/update-password-history-policy.md index a038012a..ac019894 100644 --- a/docs/examples/project/update-password-history-policy.md +++ b/docs/examples/project/update-password-history-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updatePasswordHistoryPolicy({ - total: 1 + total: 1, }); console.log(result); diff --git a/docs/examples/project/update-password-personal-data-policy.md b/docs/examples/project/update-password-personal-data-policy.md index d7de7f17..ac5aad7c 100644 --- a/docs/examples/project/update-password-personal-data-policy.md +++ b/docs/examples/project/update-password-personal-data-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updatePasswordPersonalDataPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-password-strength-policy.md b/docs/examples/project/update-password-strength-policy.md index 88913c74..38ee398d 100644 --- a/docs/examples/project/update-password-strength-policy.md +++ b/docs/examples/project/update-password-strength-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await project.updatePasswordStrengthPolicy({ uppercase: false, // optional lowercase: false, // optional number: false, // optional - symbols: false // optional + symbols: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-protocol.md b/docs/examples/project/update-protocol.md index e966ad7c..fe131589 100644 --- a/docs/examples/project/update-protocol.md +++ b/docs/examples/project/update-protocol.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectProtocolId } from "@appwrite.io/console"; +import { Client, Project, ProjectProtocolId } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.updateProtocol({ protocolId: ProjectProtocolId.Rest, - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-service.md b/docs/examples/project/update-service.md index b3b1ffd3..a44657f7 100644 --- a/docs/examples/project/update-service.md +++ b/docs/examples/project/update-service.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectServiceId } from "@appwrite.io/console"; +import { Client, Project, ProjectServiceId } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.updateService({ serviceId: ProjectServiceId.Account, - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-session-alert-policy.md b/docs/examples/project/update-session-alert-policy.md index 96d6a489..b264005f 100644 --- a/docs/examples/project/update-session-alert-policy.md +++ b/docs/examples/project/update-session-alert-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateSessionAlertPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md index b6a71ae8..6dcf3d3f 100644 --- a/docs/examples/project/update-session-duration-policy.md +++ b/docs/examples/project/update-session-duration-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateSessionDurationPolicy({ - duration: 60 + duration: 60, }); console.log(result); diff --git a/docs/examples/project/update-session-invalidation-policy.md b/docs/examples/project/update-session-invalidation-policy.md index 448eb6e7..ea2dc38f 100644 --- a/docs/examples/project/update-session-invalidation-policy.md +++ b/docs/examples/project/update-session-invalidation-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateSessionInvalidationPolicy({ - enabled: false + enabled: false, }); console.log(result); diff --git a/docs/examples/project/update-session-limit-policy.md b/docs/examples/project/update-session-limit-policy.md index 5dc94994..6f4726c8 100644 --- a/docs/examples/project/update-session-limit-policy.md +++ b/docs/examples/project/update-session-limit-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateSessionLimitPolicy({ - total: 1 + total: 1, }); console.log(result); diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md index 0dda510a..e7bb461b 100644 --- a/docs/examples/project/update-smtp.md +++ b/docs/examples/project/update-smtp.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectSMTPSecure } from "@appwrite.io/console"; +import { Client, Project, ProjectSMTPSecure } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,8 +8,8 @@ const client = new Client() const project = new Project(client); const result = await project.updateSMTP({ - host: '', // optional - port: null, // optional + host: 'example.com', // optional + port: 587, // optional username: '', // optional password: 'password', // optional senderEmail: 'email@example.com', // optional @@ -17,7 +17,7 @@ const result = await project.updateSMTP({ replyToEmail: 'email@example.com', // optional replyToName: '', // optional secure: ProjectSMTPSecure.Tls, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md index ed8769eb..1b6c3155 100644 --- a/docs/examples/project/update-user-limit-policy.md +++ b/docs/examples/project/update-user-limit-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateUserLimitPolicy({ - total: 0 + total: 0, }); console.log(result); diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md index 2eedd902..32668c6b 100644 --- a/docs/examples/project/update-variable.md +++ b/docs/examples/project/update-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await project.updateVariable({ variableId: '', key: '', // optional value: '', // optional - secret: false // optional + secret: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-web-platform.md b/docs/examples/project/update-web-platform.md index 13ece6e7..3594a739 100644 --- a/docs/examples/project/update-web-platform.md +++ b/docs/examples/project/update-web-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateWebPlatform({ platformId: '', name: '', - hostname: 'app.example.com' + hostname: 'app.example.com', }); console.log(result); diff --git a/docs/examples/project/update-windows-platform.md b/docs/examples/project/update-windows-platform.md index c49a4284..273c2507 100644 --- a/docs/examples/project/update-windows-platform.md +++ b/docs/examples/project/update-windows-platform.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from "@appwrite.io/console"; +import { Client, Project } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateWindowsPlatform({ platformId: '', name: '', - packageIdentifierName: '' + packageIdentifierName: '', }); console.log(result); diff --git a/docs/examples/projects/confirm-addon-payment.md b/docs/examples/projects/confirm-addon-payment.md index 3da9da95..cfef92e7 100644 --- a/docs/examples/projects/confirm-addon-payment.md +++ b/docs/examples/projects/confirm-addon-payment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.confirmAddonPayment({ projectId: '', - addonId: '' + addonId: '', }); console.log(result); diff --git a/docs/examples/projects/create-premium-geo-db-addon.md b/docs/examples/projects/create-premium-geo-db-addon.md index a627ec9a..f2bb7c70 100644 --- a/docs/examples/projects/create-premium-geo-db-addon.md +++ b/docs/examples/projects/create-premium-geo-db-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const projects = new Projects(client); const result = await projects.createPremiumGeoDBAddon({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/projects/create-schedule.md b/docs/examples/projects/create-schedule.md index 52c5e7c6..4ad15f22 100644 --- a/docs/examples/projects/create-schedule.md +++ b/docs/examples/projects/create-schedule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects, ScheduleResourceType } from "@appwrite.io/console"; +import { Client, Projects, ScheduleResourceType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,9 +11,9 @@ const result = await projects.createSchedule({ projectId: '', resourceType: ScheduleResourceType.Function, resourceId: '', - schedule: '', + schedule: '0 0 * * *', active: false, // optional - data: {} // optional + data: {}, // optional }); console.log(result); diff --git a/docs/examples/projects/delete-addon.md b/docs/examples/projects/delete-addon.md index 21edcc6e..e9597d7f 100644 --- a/docs/examples/projects/delete-addon.md +++ b/docs/examples/projects/delete-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.deleteAddon({ projectId: '', - addonId: '' + addonId: '', }); console.log(result); diff --git a/docs/examples/projects/delete-dev-key.md b/docs/examples/projects/delete-dev-key.md index 8130044a..c0940dec 100644 --- a/docs/examples/projects/delete-dev-key.md +++ b/docs/examples/projects/delete-dev-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.deleteDevKey({ projectId: '', - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/projects/get-addon-price.md b/docs/examples/projects/get-addon-price.md index d51f477b..f9804aa0 100644 --- a/docs/examples/projects/get-addon-price.md +++ b/docs/examples/projects/get-addon-price.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.getAddonPrice({ projectId: '', - addon: 'baa' + addon: 'baa', }); console.log(result); diff --git a/docs/examples/projects/get-addon.md b/docs/examples/projects/get-addon.md index 5ec8ce39..cd8d2cd0 100644 --- a/docs/examples/projects/get-addon.md +++ b/docs/examples/projects/get-addon.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.getAddon({ projectId: '', - addonId: '' + addonId: '', }); console.log(result); diff --git a/docs/examples/projects/get-dev-key.md b/docs/examples/projects/get-dev-key.md index 3262240a..265b6401 100644 --- a/docs/examples/projects/get-dev-key.md +++ b/docs/examples/projects/get-dev-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.getDevKey({ projectId: '', - keyId: '' + keyId: '', }); console.log(result); diff --git a/docs/examples/projects/get-schedule.md b/docs/examples/projects/get-schedule.md index 356c0f0c..86812d5f 100644 --- a/docs/examples/projects/get-schedule.md +++ b/docs/examples/projects/get-schedule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.getSchedule({ projectId: '', - scheduleId: '' + scheduleId: '', }); console.log(result); diff --git a/docs/examples/projects/list-addons.md b/docs/examples/projects/list-addons.md index 30a4d9af..6f33e9b6 100644 --- a/docs/examples/projects/list-addons.md +++ b/docs/examples/projects/list-addons.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const projects = new Projects(client); const result = await projects.listAddons({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/projects/list-dev-keys.md b/docs/examples/projects/list-dev-keys.md index 02ff4962..46a0307e 100644 --- a/docs/examples/projects/list-dev-keys.md +++ b/docs/examples/projects/list-dev-keys.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.listDevKeys({ projectId: '', - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/projects/list-schedules.md b/docs/examples/projects/list-schedules.md index 64f030a2..d28d3dcf 100644 --- a/docs/examples/projects/list-schedules.md +++ b/docs/examples/projects/list-schedules.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const projects = new Projects(client); const result = await projects.listSchedules({ projectId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/projects/list-stages.md b/docs/examples/projects/list-stages.md index 3a0783b4..e01d3468 100644 --- a/docs/examples/projects/list-stages.md +++ b/docs/examples/projects/list-stages.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const projects = new Projects(client); const result = await projects.listStages({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/projects/update-console-access.md b/docs/examples/projects/update-console-access.md index c861c6df..92c85ca5 100644 --- a/docs/examples/projects/update-console-access.md +++ b/docs/examples/projects/update-console-access.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const projects = new Projects(client); const result = await projects.updateConsoleAccess({ - projectId: '' + projectId: '', }); console.log(result); diff --git a/docs/examples/projects/update-dev-key.md b/docs/examples/projects/update-dev-key.md index aa667ca7..424f7be1 100644 --- a/docs/examples/projects/update-dev-key.md +++ b/docs/examples/projects/update-dev-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await projects.updateDevKey({ projectId: '', keyId: '', name: '', - expire: '2020-10-15T06:38:00.000+00:00' + expire: '2020-10-15T06:38:00.000+00:00', }); console.log(result); diff --git a/docs/examples/projects/update-stage.md b/docs/examples/projects/update-stage.md index 00dec410..a8e53242 100644 --- a/docs/examples/projects/update-stage.md +++ b/docs/examples/projects/update-stage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const projects = new Projects(client); const result = await projects.updateStage({ projectId: '', stageId: '', - skip: false // optional + skip: false, // optional }); console.log(result); diff --git a/docs/examples/projects/update-status.md b/docs/examples/projects/update-status.md index d795d87e..1fe624c4 100644 --- a/docs/examples/projects/update-status.md +++ b/docs/examples/projects/update-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects, Status } from "@appwrite.io/console"; +import { Client, Projects, Status } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.updateStatus({ projectId: '', - status: Status.Active + status: Status.Active, }); console.log(result); diff --git a/docs/examples/projects/update-team.md b/docs/examples/projects/update-team.md index 4062f8fa..4316ec58 100644 --- a/docs/examples/projects/update-team.md +++ b/docs/examples/projects/update-team.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Projects } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.updateTeam({ projectId: '', - teamId: '' + teamId: '', }); console.log(result); diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md index 8fb6d238..4f042137 100644 --- a/docs/examples/proxy/create-api-rule.md +++ b/docs/examples/proxy/create-api-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.createAPIRule({ - domain: '' + domain: 'example.com', }); console.log(result); diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md index a7d9ae63..b1b9bb11 100644 --- a/docs/examples/proxy/create-function-rule.md +++ b/docs/examples/proxy/create-function-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,9 +8,9 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.createFunctionRule({ - domain: '', + domain: 'example.com', functionId: '', - branch: '' // optional + branch: '', // optional }); console.log(result); diff --git a/docs/examples/proxy/create-invalidation.md b/docs/examples/proxy/create-invalidation.md index 9005b367..f15adbfc 100644 --- a/docs/examples/proxy/create-invalidation.md +++ b/docs/examples/proxy/create-invalidation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy, InvalidationType } from "@appwrite.io/console"; +import { Client, Proxy, InvalidationType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,9 +8,9 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.createInvalidation({ - domain: '', + domain: 'example.com', type: InvalidationType.Tag, - reference: '' // optional + reference: '', // optional }); console.log(result); diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md index 0ab36157..eb1d97ce 100644 --- a/docs/examples/proxy/create-redirect-rule.md +++ b/docs/examples/proxy/create-redirect-rule.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Proxy, StatusCode, ProxyResourceType } from "@appwrite.io/console"; +import { + Client, + Proxy, + StatusCode, + ProxyResourceType, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,11 +13,11 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.createRedirectRule({ - domain: '', + domain: 'example.com', url: 'https://example.com', statusCode: StatusCode.MovedPermanently, resourceId: '', - resourceType: ProxyResourceType.Site + resourceType: ProxyResourceType.Site, }); console.log(result); diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md index 9f30b180..7d0fb0db 100644 --- a/docs/examples/proxy/create-site-rule.md +++ b/docs/examples/proxy/create-site-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,9 +8,9 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.createSiteRule({ - domain: '', + domain: 'example.com', siteId: '', - branch: '' // optional + branch: '', // optional }); console.log(result); diff --git a/docs/examples/proxy/delete-rule.md b/docs/examples/proxy/delete-rule.md index 96bd5b2f..858dca18 100644 --- a/docs/examples/proxy/delete-rule.md +++ b/docs/examples/proxy/delete-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.deleteRule({ - ruleId: '' + ruleId: '', }); console.log(result); diff --git a/docs/examples/proxy/get-rule.md b/docs/examples/proxy/get-rule.md index 2cb890fb..8b77d394 100644 --- a/docs/examples/proxy/get-rule.md +++ b/docs/examples/proxy/get-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.getRule({ - ruleId: '' + ruleId: '', }); console.log(result); diff --git a/docs/examples/proxy/list-rules.md b/docs/examples/proxy/list-rules.md index b4bd8701..40baf3d6 100644 --- a/docs/examples/proxy/list-rules.md +++ b/docs/examples/proxy/list-rules.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const proxy = new Proxy(client); const result = await proxy.listRules({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/proxy/update-rule-status.md b/docs/examples/proxy/update-rule-status.md index 39310888..1309d915 100644 --- a/docs/examples/proxy/update-rule-status.md +++ b/docs/examples/proxy/update-rule-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy } from "@appwrite.io/console"; +import { Client, Proxy } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const proxy = new Proxy(client); const result = await proxy.updateRuleStatus({ - ruleId: '' + ruleId: '', }); console.log(result); diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index ce2f439e..e9c3a8ac 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await sites.createDeployment({ installCommand: '', // optional buildCommand: '', // optional outputDirectory: '', // optional - activate: false // optional + activate: false, // optional }); console.log(result); diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md index e202b7e3..4dfa825a 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.createDuplicateDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index 1a9584cf..d29a5e81 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites, TemplateReferenceType } from "@appwrite.io/console"; +import { Client, Sites, TemplateReferenceType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await sites.createTemplateDeployment({ rootDirectory: '', type: TemplateReferenceType.Branch, reference: '', - activate: false // optional + activate: false, // optional }); console.log(result); diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index 73f2f2d9..05afb1ff 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await sites.createVariable({ variableId: '', key: '', value: '', - secret: false // optional + secret: false, // optional }); console.log(result); diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index c4313ec8..79a3bd12 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites, VCSReferenceType } from "@appwrite.io/console"; +import { Client, Sites, VCSReferenceType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await sites.createVcsDeployment({ siteId: '', type: VCSReferenceType.Branch, reference: '', - activate: false // optional + activate: false, // optional }); console.log(result); diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index b6d0c8b6..724ea523 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -1,5 +1,12 @@ ```javascript -import { Client, Sites, Framework, BuildRuntime, Adapter } from "@appwrite.io/console"; +import { + Client, + Sites, + Framework, + BuildRuntime, + Adapter, + ProjectKeyScopes, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -28,9 +35,10 @@ const result = await sites.create({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional + scopes: [ProjectKeyScopes.ProjectRead], // optional }); console.log(result); diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md index 6dcaaf7e..cfdbd694 100644 --- a/docs/examples/sites/delete-deployment.md +++ b/docs/examples/sites/delete-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.deleteDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 6e22e9be..3507f656 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.deleteLog({ siteId: '', - logId: '' + logId: '', }); console.log(result); diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md index 753080a2..4c1139ad 100644 --- a/docs/examples/sites/delete-variable.md +++ b/docs/examples/sites/delete-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.deleteVariable({ siteId: '', - variableId: '' + variableId: '', }); console.log(result); diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md index 13b944ce..4e3d7c78 100644 --- a/docs/examples/sites/delete.md +++ b/docs/examples/sites/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const sites = new Sites(client); const result = await sites.delete({ - siteId: '' + siteId: '', }); console.log(result); diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index acbbadd1..30870787 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites, DeploymentDownloadType } from "@appwrite.io/console"; +import { Client, Sites, DeploymentDownloadType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = sites.getDeploymentDownload({ siteId: '', deploymentId: '', type: DeploymentDownloadType.Source, // optional - token: '' // optional + token: '', // optional }); console.log(result); diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index 86e84fc0..9ed95bfc 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.getDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md index ba6f399a..ead132bc 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.getLog({ siteId: '', - logId: '' + logId: '', }); console.log(result); diff --git a/docs/examples/sites/get-template.md b/docs/examples/sites/get-template.md index 94b74043..88f30638 100644 --- a/docs/examples/sites/get-template.md +++ b/docs/examples/sites/get-template.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const sites = new Sites(client); const result = await sites.getTemplate({ - templateId: '' + templateId: '', }); console.log(result); diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md index dd087144..17a044bc 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.getVariable({ siteId: '', - variableId: '' + variableId: '', }); console.log(result); diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index c49df69f..c8d26fc7 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const sites = new Sites(client); const result = await sites.get({ - siteId: '' + siteId: '', }); console.log(result); diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index d7fb2766..484bf5b1 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await sites.listDeployments({ siteId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index 2d4daa8e..26d0e532 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 3a57a8d4..8fb3d851 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const sites = new Sites(client); const result = await sites.listLogs({ siteId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 623e0eed..1d77721c 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const sites = new Sites(client); const result = await sites.listSpecifications({ - type: 'runtimes' // optional + type: 'runtimes', // optional }); console.log(result); diff --git a/docs/examples/sites/list-templates.md b/docs/examples/sites/list-templates.md index bf6db4d1..4832803a 100644 --- a/docs/examples/sites/list-templates.md +++ b/docs/examples/sites/list-templates.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Sites, Framework, SiteTemplateUseCase } from "@appwrite.io/console"; +import { + Client, + Sites, + Framework, + SiteTemplateUseCase, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +16,7 @@ const result = await sites.listTemplates({ frameworks: [Framework.Analog], // optional useCases: [SiteTemplateUseCase.Portfolio], // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index ae7626c1..75075e8f 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const sites = new Sites(client); const result = await sites.listVariables({ siteId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index 316553fe..425011a2 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const sites = new Sites(client); const result = await sites.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md index 960718d5..470bde6c 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.updateDeploymentStatus({ siteId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md index 20558fca..0c857e5c 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const sites = new Sites(client); const result = await sites.updateSiteDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); console.log(result); diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index df1aeaf7..acf0bcf0 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites } from "@appwrite.io/console"; +import { Client, Sites } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await sites.updateVariable({ variableId: '', key: '', // optional value: '', // optional - secret: false // optional + secret: false, // optional }); console.log(result); diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index e635761d..36e66d82 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -1,5 +1,12 @@ ```javascript -import { Client, Sites, Framework, BuildRuntime, Adapter } from "@appwrite.io/console"; +import { + Client, + Sites, + Framework, + BuildRuntime, + Adapter, + ProjectKeyScopes, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -28,9 +35,10 @@ const result = await sites.update({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional + scopes: [ProjectKeyScopes.ProjectRead], // optional }); console.log(result); diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index fa8f9d49..e55136f3 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -1,5 +1,11 @@ ```javascript -import { Client, Storage, Compression, Permission, Role } from "@appwrite.io/console"; +import { + Client, + Storage, + Compression, + Permission, + Role, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -18,7 +24,7 @@ const result = await storage.createBucket({ compression: Compression.None, // optional encryption: false, // optional antivirus: false, // optional - transformations: false // optional + transformations: false, // optional }); console.log(result); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index ad7814a6..71b4a5f1 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage, Permission, Role } from "@appwrite.io/console"; +import { Client, Storage, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await storage.createFile({ fileId: '', file: document.getElementById('uploader').files[0], permissions: [Permission.read(Role.any())], // optional - folder: '' // optional + folder: 'photos/2026', // optional }); console.log(result); diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index 1d2aa69c..a7147bcb 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const storage = new Storage(client); const result = await storage.deleteBucket({ - bucketId: '' + bucketId: '', }); console.log(result); diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index e40590c1..1a2d9eb8 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const storage = new Storage(client); const result = await storage.deleteFile({ bucketId: '', - fileId: '' + fileId: '', }); console.log(result); diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index a710bc7f..eff67a03 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const storage = new Storage(client); const result = await storage.getBucket({ - bucketId: '' + bucketId: '', }); console.log(result); diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 1e940d16..6feab6e0 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const storage = new Storage(client); const result = storage.getFileDownload({ bucketId: '', fileId: '', - token: '' // optional + token: '', // optional }); console.log(result); diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 781c5cc4..b5d8f2db 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -1,5 +1,10 @@ ```javascript -import { Client, Storage, ImageGravity, ImageFormat } from "@appwrite.io/console"; +import { + Client, + Storage, + ImageGravity, + ImageFormat, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,16 +17,16 @@ const result = storage.getFilePreview({ fileId: '', width: 0, // optional height: 0, // optional - gravity: ImageGravity.Center, // optional + gravity: ImageGravity.Auto, // optional quality: -1, // optional borderWidth: 0, // optional - borderColor: '', // optional + borderColor: 'FFFFFF', // optional borderRadius: 0, // optional opacity: 0, // optional rotation: -360, // optional - background: '', // optional + background: 'FFFFFF', // optional output: ImageFormat.Jpg, // optional - token: '' // optional + token: '', // optional }); console.log(result); diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 800f3f93..7dea7751 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const storage = new Storage(client); const result = storage.getFileView({ bucketId: '', fileId: '', - token: '' // optional + token: '', // optional }); console.log(result); diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index a48d4dfe..317c090d 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const storage = new Storage(client); const result = await storage.getFile({ bucketId: '', - fileId: '' + fileId: '', }); console.log(result); diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index bad2cd17..cb162c51 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const storage = new Storage(client); const result = await storage.listBuckets({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 4085f392..d69ec2e0 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage } from "@appwrite.io/console"; +import { Client, Storage } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await storage.listFiles({ bucketId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index cca106f0..6816d592 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -1,5 +1,11 @@ ```javascript -import { Client, Storage, Compression, Permission, Role } from "@appwrite.io/console"; +import { + Client, + Storage, + Compression, + Permission, + Role, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -18,7 +24,7 @@ const result = await storage.updateBucket({ compression: Compression.None, // optional encryption: false, // optional antivirus: false, // optional - transformations: false // optional + transformations: false, // optional }); console.log(result); diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index b24ff730..88155611 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Storage, Permission, Role } from "@appwrite.io/console"; +import { Client, Storage, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await storage.updateFile({ bucketId: '', fileId: '', name: '', // optional - permissions: [Permission.read(Role.any())] // optional + permissions: [Permission.read(Role.any())], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md index c00adcc4..ff6fa989 100644 --- a/docs/examples/tablesdb/create-big-int-column.md +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createBigIntColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 1000000, // optional + xdefault: 0, // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md index 9945d4c1..bff59103 100644 --- a/docs/examples/tablesdb/create-boolean-column.md +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createBooleanColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: false, // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-cutover.md b/docs/examples/tablesdb/create-cutover.md new file mode 100644 index 00000000..f004aa72 --- /dev/null +++ b/docs/examples/tablesdb/create-cutover.md @@ -0,0 +1,16 @@ +```javascript +import { Client, TablesDB } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createCutover({ + databaseId: '', + migrationId: '', +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index 2c71780b..cc9e87f3 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createDatetimeColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md index 4a10aeb8..53c7430b 100644 --- a/docs/examples/tablesdb/create-email-column.md +++ b/docs/examples/tablesdb/create-email-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createEmailColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index 38aa95a6..520a828e 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createEnumColumn({ databaseId: '', tableId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', // optional - array: false // optional + xdefault: 'active', // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-failover.md b/docs/examples/tablesdb/create-failover.md index 801f32a9..1229b8aa 100644 --- a/docs/examples/tablesdb/create-failover.md +++ b/docs/examples/tablesdb/create-failover.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md index bae50920..3852dfbe 100644 --- a/docs/examples/tablesdb/create-float-column.md +++ b/docs/examples/tablesdb/create-float-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createFloatColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10.5, // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index aa5aa3e4..1b4f0aba 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -1,5 +1,10 @@ ```javascript -import { Client, TablesDB, TablesDBIndexType, OrderBy } from "@appwrite.io/console"; +import { + Client, + TablesDB, + TablesDBIndexType, + OrderBy, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +15,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createIndex({ databaseId: '', tableId: '', - key: '', + key: '', type: TablesDBIndexType.Key, columns: [], orders: [OrderBy.Asc], // optional - lengths: [] // optional + lengths: [], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md index f8104508..c2c1c243 100644 --- a/docs/examples/tablesdb/create-integer-column.md +++ b/docs/examples/tablesdb/create-integer-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createIntegerColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10, // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md index 71810e88..bc09d737 100644 --- a/docs/examples/tablesdb/create-ip-column.md +++ b/docs/examples/tablesdb/create-ip-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createIpColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional - array: false // optional + xdefault: '192.0.2.0', // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index 75136874..f82ce197 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,13 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createLineColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]] // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md index adc47e70..5bc3c7bf 100644 --- a/docs/examples/tablesdb/create-longtext-column.md +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createLongtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md index 416cb048..474fd9b2 100644 --- a/docs/examples/tablesdb/create-mediumtext-column.md +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createMediumtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-migration.md b/docs/examples/tablesdb/create-migration.md index 199ef50a..8237d8cb 100644 --- a/docs/examples/tablesdb/create-migration.md +++ b/docs/examples/tablesdb/create-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createMigration({ databaseId: '', - specification: 's-1vcpu-1gb' + specification: 's-1vcpu-1gb', + autoCutover: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md index 60a68135..a63c6d59 100644 --- a/docs/examples/tablesdb/create-operations.md +++ b/docs/examples/tablesdb/create-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,16 +10,16 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createOperations({ transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "tableId": "", - "rowId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + { + action: 'create', + databaseId: '', + tableId: '', + rowId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 40ab6a44..1e159139 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,9 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createPointColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [1, 2] // optional + xdefault: [1, 2], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 5ad3723b..ad5a21ba 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,16 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createPolygonColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md index 851f8c3e..92d4fcda 100644 --- a/docs/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -1,5 +1,10 @@ ```javascript -import { Client, TablesDB, RelationshipType, RelationMutate } from "@appwrite.io/console"; +import { + Client, + TablesDB, + RelationshipType, + RelationMutate, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,9 +18,9 @@ const result = await tablesDB.createRelationshipColumn({ relatedTableId: '', type: RelationshipType.OneToOne, twoWay: false, // optional - key: '', // optional - twoWayKey: '', // optional - onDelete: RelationMutate.Cascade // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate.Cascade, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 1d24f787..820637a2 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, Permission, Role } from "@appwrite.io/console"; +import { Client, TablesDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,14 +12,14 @@ const result = await tablesDB.createRow({ tableId: '', rowId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index b57175c8..2c046135 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.createRows({ databaseId: '', tableId: '', rows: [], - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md index 1e1c7710..be030ae1 100644 --- a/docs/examples/tablesdb/create-string-column.md +++ b/docs/examples/tablesdb/create-string-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createStringColumn({ databaseId: '', tableId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index 78fde6c6..9d213ce4 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, Permission, Role } from "@appwrite.io/console"; +import { Client, TablesDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await tablesDB.createTable({ rowSecurity: false, // optional enabled: false, // optional columns: [], // optional - indexes: [] // optional + indexes: [], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md index 0ca82673..71febf91 100644 --- a/docs/examples/tablesdb/create-text-column.md +++ b/docs/examples/tablesdb/create-text-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createTextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md index 29c1af68..c9c05586 100644 --- a/docs/examples/tablesdb/create-transaction.md +++ b/docs/examples/tablesdb/create-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.createTransaction({ - ttl: 60 // optional + ttl: 60, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md index ffdb6e4f..93b4ef88 100644 --- a/docs/examples/tablesdb/create-url-column.md +++ b/docs/examples/tablesdb/create-url-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createUrlColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', // optional - array: false // optional + array: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md index e143cc82..039cc055 100644 --- a/docs/examples/tablesdb/create-varchar-column.md +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createVarcharColumn({ databaseId: '', tableId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index e7faf04a..5ed38dcd 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await tablesDB.create({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 50477de1..de32d864 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,10 +11,10 @@ const result = await tablesDB.decrementRowColumn({ databaseId: '', tableId: '', rowId: '', - column: '', - value: null, // optional - min: null, // optional - transactionId: '' // optional + column: '', + value: 1, // optional + min: 0, // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md index 73d092a6..b8232ca3 100644 --- a/docs/examples/tablesdb/delete-column.md +++ b/docs/examples/tablesdb/delete-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.deleteColumn({ databaseId: '', tableId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md index 0287aa5b..01b603ad 100644 --- a/docs/examples/tablesdb/delete-index.md +++ b/docs/examples/tablesdb/delete-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.deleteIndex({ databaseId: '', tableId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 66a4af33..53b28f5a 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.deleteMigration({ databaseId: '', - migrationId: '' + migrationId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index bb2f7edd..3022c5b2 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.deleteRow({ databaseId: '', tableId: '', rowId: '', - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 4c575781..58df6f19 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.deleteRows({ databaseId: '', tableId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md index 22548e34..3d20915d 100644 --- a/docs/examples/tablesdb/delete-table.md +++ b/docs/examples/tablesdb/delete-table.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.deleteTable({ databaseId: '', - tableId: '' + tableId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md index be5edcc0..a5511512 100644 --- a/docs/examples/tablesdb/delete-transaction.md +++ b/docs/examples/tablesdb/delete-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.deleteTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md index 4906f844..70fc1f45 100644 --- a/docs/examples/tablesdb/delete.md +++ b/docs/examples/tablesdb/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 75425492..2c50bd67 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.getColumn({ databaseId: '', tableId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md index 8f8b0c82..b00f7336 100644 --- a/docs/examples/tablesdb/get-index.md +++ b/docs/examples/tablesdb/get-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.getIndex({ databaseId: '', tableId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-migration.md b/docs/examples/tablesdb/get-migration.md index 2b88ff50..9858a1f0 100644 --- a/docs/examples/tablesdb/get-migration.md +++ b/docs/examples/tablesdb/get-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.getMigration({ databaseId: '', - migrationId: '' + migrationId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-replicas.md b/docs/examples/tablesdb/get-replicas.md index 9a0c582e..31fbfa6c 100644 --- a/docs/examples/tablesdb/get-replicas.md +++ b/docs/examples/tablesdb/get-replicas.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.getReplicas({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 717e9720..c59483e3 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await tablesDB.getRow({ tableId: '', rowId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/get-status.md b/docs/examples/tablesdb/get-status.md index b96d875f..ac06cecd 100644 --- a/docs/examples/tablesdb/get-status.md +++ b/docs/examples/tablesdb/get-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.getStatus({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md index 6de4b809..6b5b5a3a 100644 --- a/docs/examples/tablesdb/get-table.md +++ b/docs/examples/tablesdb/get-table.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.getTable({ databaseId: '', - tableId: '' + tableId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md index 511c6029..b49fe1b7 100644 --- a/docs/examples/tablesdb/get-transaction.md +++ b/docs/examples/tablesdb/get-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.getTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md index 275d646b..78fac325 100644 --- a/docs/examples/tablesdb/get.md +++ b/docs/examples/tablesdb/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index 60fad4d8..efcc2f5f 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,10 +11,10 @@ const result = await tablesDB.incrementRowColumn({ databaseId: '', tableId: '', rowId: '', - column: '', - value: null, // optional - max: null, // optional - transactionId: '' // optional + column: '', + value: 1, // optional + max: 100, // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index 831c4675..c3e11bd7 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.listColumns({ databaseId: '', tableId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index ea4a541c..7044d880 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.listIndexes({ databaseId: '', tableId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list-migrations.md b/docs/examples/tablesdb/list-migrations.md index ff09eb63..86528dae 100644 --- a/docs/examples/tablesdb/list-migrations.md +++ b/docs/examples/tablesdb/list-migrations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.listMigrations({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/tablesdb/list-operations.md b/docs/examples/tablesdb/list-operations.md index 20e282d2..4bbf1de2 100644 --- a/docs/examples/tablesdb/list-operations.md +++ b/docs/examples/tablesdb/list-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,9 +9,9 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 95df1e02..fe4fca36 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await tablesDB.listRows({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list-specifications.md b/docs/examples/tablesdb/list-specifications.md index 250a8402..4fc1c217 100644 --- a/docs/examples/tablesdb/list-specifications.md +++ b/docs/examples/tablesdb/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index c9a182df..adf12b92 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.listTables({ databaseId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index c2f6b3cf..2d616198 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tablesDB = new TablesDB(client); const result = await tablesDB.listTransactions({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index a487fabe..e6e647b0 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md index 578e813c..a8dcfb24 100644 --- a/docs/examples/tablesdb/update-big-int-column.md +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateBigIntColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 0, + min: 0, // optional + max: 1000000, // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md index 67380638..3f1f2904 100644 --- a/docs/examples/tablesdb/update-boolean-column.md +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateBooleanColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: false, - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index 89ec138f..218744e0 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateDatetimeColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md index 981e5dd5..c5529460 100644 --- a/docs/examples/tablesdb/update-email-column.md +++ b/docs/examples/tablesdb/update-email-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateEmailColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index 493e9f3a..c85d5002 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateEnumColumn({ databaseId: '', tableId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'active', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md index 0f655fd8..ec3da21c 100644 --- a/docs/examples/tablesdb/update-float-column.md +++ b/docs/examples/tablesdb/update-float-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateFloatColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10.5, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md index e42a7142..a24c4e32 100644 --- a/docs/examples/tablesdb/update-integer-column.md +++ b/docs/examples/tablesdb/update-integer-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateIntegerColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md index d96b0121..74aa61f4 100644 --- a/docs/examples/tablesdb/update-ip-column.md +++ b/docs/examples/tablesdb/update-ip-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateIpColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: '192.0.2.0', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index ffc3813b..79385a3a 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,14 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateLineColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]], // optional - newKey: '' // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md index 6e3fda80..4d862abf 100644 --- a/docs/examples/tablesdb/update-longtext-column.md +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateLongtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md index dc994757..040d78c2 100644 --- a/docs/examples/tablesdb/update-mediumtext-column.md +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateMediumtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index eac241e8..636e5667 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updatePointColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: [1, 2], // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 854db0bd..8ed64623 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,17 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updatePolygonColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional - newKey: '' // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md index adc6e16d..77d2035d 100644 --- a/docs/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, RelationMutate } from "@appwrite.io/console"; +import { Client, TablesDB, RelationMutate } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,9 +10,9 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateRelationshipColumn({ databaseId: '', tableId: '', - key: '', + key: '', onDelete: RelationMutate.Cascade, // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index e516e012..116fb222 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, Permission, Role } from "@appwrite.io/console"; +import { Client, TablesDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,14 +12,14 @@ const result = await tablesDB.updateRow({ tableId: '', rowId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 1ef873da..32c0156c 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,14 +11,14 @@ const result = await tablesDB.updateRows({ databaseId: '', tableId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md index 3be9e866..817ca449 100644 --- a/docs/examples/tablesdb/update-string-column.md +++ b/docs/examples/tablesdb/update-string-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateStringColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index 943657d6..7d382d43 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, Permission, Role } from "@appwrite.io/console"; +import { Client, TablesDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await tablesDB.updateTable({ permissions: [Permission.read(Role.any())], // optional rowSecurity: false, // optional enabled: false, // optional - purge: false // optional + purge: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md index f5bd5abd..ac46a962 100644 --- a/docs/examples/tablesdb/update-text-column.md +++ b/docs/examples/tablesdb/update-text-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateTextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md index ab7e6498..01ccbd15 100644 --- a/docs/examples/tablesdb/update-transaction.md +++ b/docs/examples/tablesdb/update-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateTransaction({ transactionId: '', commit: false, // optional - rollback: false // optional + rollback: false, // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md index 6af45cd0..14fbf3df 100644 --- a/docs/examples/tablesdb/update-url-column.md +++ b/docs/examples/tablesdb/update-url-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,10 +10,10 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateUrlColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md index 0b46befe..ec04fb45 100644 --- a/docs/examples/tablesdb/update-varchar-column.md +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +10,11 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.updateVarcharColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index f7467075..55a7959e 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await tablesDB.update({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 20d39e6c..2e58b52e 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, Permission, Role } from "@appwrite.io/console"; +import { Client, TablesDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,14 +12,14 @@ const result = await tablesDB.upsertRow({ tableId: '', rowId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 510dc3e7..005f7b4e 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB } from "@appwrite.io/console"; +import { Client, TablesDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tablesDB.upsertRows({ databaseId: '', tableId: '', rows: [], - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/teams/create-installation.md b/docs/examples/teams/create-installation.md index e1670155..9be460a8 100644 --- a/docs/examples/teams/create-installation.md +++ b/docs/examples/teams/create-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.createInstallation({ teamId: '', appId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); console.log(result); diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index f7c83213..35581d30 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await teams.createMembership({ userId: '', // optional phone: '+12065550100', // optional url: 'https://example.com', // optional - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index a4dc3f2d..99694324 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.create({ teamId: '', name: '', - roles: [] // optional + roles: [], // optional }); console.log(result); diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index 13febb94..f6990ed9 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.deleteInstallation({ teamId: '', - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index a54c5a2f..d8a647e4 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.deleteMembership({ teamId: '', - membershipId: '' + membershipId: '', }); console.log(result); diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 655f7c79..ac4f95b7 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const teams = new Teams(client); const result = await teams.delete({ - teamId: '' + teamId: '', }); console.log(result); diff --git a/docs/examples/teams/get-installation.md b/docs/examples/teams/get-installation.md index e8200a91..572baa69 100644 --- a/docs/examples/teams/get-installation.md +++ b/docs/examples/teams/get-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.getInstallation({ teamId: '', - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 9f492255..4dce1944 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.getMembership({ teamId: '', - membershipId: '' + membershipId: '', }); console.log(result); diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 040ea35b..63ec4faa 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const teams = new Teams(client); const result = await teams.getPrefs({ - teamId: '' + teamId: '', }); console.log(result); diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 4192dac7..2afd1ab5 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const teams = new Teams(client); const result = await teams.get({ - teamId: '' + teamId: '', }); console.log(result); diff --git a/docs/examples/teams/list-installations.md b/docs/examples/teams/list-installations.md index 4bfa62bc..8085d466 100644 --- a/docs/examples/teams/list-installations.md +++ b/docs/examples/teams/list-installations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.listInstallations({ teamId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/teams/list-logs.md b/docs/examples/teams/list-logs.md index 769b7cec..889413dd 100644 --- a/docs/examples/teams/list-logs.md +++ b/docs/examples/teams/list-logs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.listLogs({ teamId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 656a46ca..5ea91817 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await teams.listMemberships({ teamId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 739a3040..15db3ca6 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/teams/update-installation.md b/docs/examples/teams/update-installation.md index 2c3a9ca4..cd762da2 100644 --- a/docs/examples/teams/update-installation.md +++ b/docs/examples/teams/update-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.updateInstallation({ teamId: '', installationId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); console.log(result); diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 94ae41f2..7ac6b105 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await teams.updateMembershipStatus({ teamId: '', membershipId: '', userId: '', - secret: '' + secret: '', }); console.log(result); diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index a7ac4a74..6ed36583 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.updateMembership({ teamId: '', membershipId: '', - roles: [] + roles: [], }); console.log(result); diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 5723ad17..1b11e6e8 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.updateName({ teamId: '', - name: '' + name: '', }); console.log(result); diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index e4e79044..e0cdfa49 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Teams } from "@appwrite.io/console"; +import { Client, Teams } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.updatePrefs({ teamId: '', - prefs: {} + prefs: {}, }); console.log(result); diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index 2b474eea..cd4d162c 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Tokens } from "@appwrite.io/console"; +import { Client, Tokens } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const tokens = new Tokens(client); const result = await tokens.createFileToken({ bucketId: '', fileId: '', - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md index 20c59410..f16e909d 100644 --- a/docs/examples/tokens/delete.md +++ b/docs/examples/tokens/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Tokens } from "@appwrite.io/console"; +import { Client, Tokens } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tokens = new Tokens(client); const result = await tokens.delete({ - tokenId: '' + tokenId: '', }); console.log(result); diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index f918dd22..e6082750 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Tokens } from "@appwrite.io/console"; +import { Client, Tokens } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const tokens = new Tokens(client); const result = await tokens.get({ - tokenId: '' + tokenId: '', }); console.log(result); diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 5b190cb6..2a1b164c 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Tokens } from "@appwrite.io/console"; +import { Client, Tokens } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await tokens.list({ bucketId: '', fileId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index 3374cced..28513f2c 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Tokens } from "@appwrite.io/console"; +import { Client, Tokens } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const tokens = new Tokens(client); const result = await tokens.update({ tokenId: '', - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/usage/list-events.md b/docs/examples/usage/list-events.md index 6647ed02..30b8d975 100644 --- a/docs/examples/usage/list-events.md +++ b/docs/examples/usage/list-events.md @@ -1,5 +1,13 @@ ```javascript -import { Client, Usage, UsageInterval, UsageEventDimension, UsageOrderBy, UsageOrderDirection } from "@appwrite.io/console"; +import { + Client, + Usage, + UsageEventMetric, + UsageInterval, + UsageEventDimension, + UsageOrderBy, + UsageOrderDirection, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +16,7 @@ const client = new Client() const usage = new Usage(client); const result = await usage.listEvents({ - metrics: [], + metrics: [UsageEventMetric.NetworkRequests], queries: [], // optional interval: UsageInterval.OneMinute, // optional dimensions: [UsageEventDimension.Path], // optional @@ -17,7 +25,7 @@ const result = await usage.listEvents({ orderBy: UsageOrderBy.Time, // optional orderDir: UsageOrderDirection.Asc, // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/usage/list-gauges.md b/docs/examples/usage/list-gauges.md index 2dd225ac..745ecf94 100644 --- a/docs/examples/usage/list-gauges.md +++ b/docs/examples/usage/list-gauges.md @@ -1,5 +1,13 @@ ```javascript -import { Client, Usage, UsageInterval, UsageGaugeDimension, UsageOrderBy, UsageOrderDirection } from "@appwrite.io/console"; +import { + Client, + Usage, + UsageGaugeMetric, + UsageInterval, + UsageGaugeDimension, + UsageOrderBy, + UsageOrderDirection, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +16,7 @@ const client = new Client() const usage = new Usage(client); const result = await usage.listGauges({ - metrics: [], + metrics: [UsageGaugeMetric.Teams], queries: [], // optional interval: UsageInterval.OneMinute, // optional dimensions: [UsageGaugeDimension.ResourceId], // optional @@ -17,7 +25,8 @@ const result = await usage.listGauges({ orderBy: UsageOrderBy.Time, // optional orderDir: UsageOrderDirection.Asc, // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional + aggregate: 'last', // optional }); console.log(result); diff --git a/docs/examples/users/create-argon-2-user.md b/docs/examples/users/create-argon-2-user.md index 8b92df0b..ba77aabd 100644 --- a/docs/examples/users/create-argon-2-user.md +++ b/docs/examples/users/create-argon-2-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await users.createArgon2User({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index 0d9a15fb..482eca33 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await users.createBcryptUser({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-jwt.md b/docs/examples/users/create-jwt.md index 01cbdc8b..922e2091 100644 --- a/docs/examples/users/create-jwt.md +++ b/docs/examples/users/create-jwt.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,8 +9,8 @@ const users = new Users(client); const result = await users.createJWT({ userId: '', - sessionId: '', // optional - duration: 0 // optional + sessionId: 'recent()', // optional + duration: 0, // optional }); console.log(result); diff --git a/docs/examples/users/create-md-5-user.md b/docs/examples/users/create-md-5-user.md index 239e1e52..b9f6c9f7 100644 --- a/docs/examples/users/create-md-5-user.md +++ b/docs/examples/users/create-md-5-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await users.createMD5User({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 431e4420..a95a1f56 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.createMFARecoveryCodes({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/create-ph-pass-user.md b/docs/examples/users/create-ph-pass-user.md index b237c307..9a5ed807 100644 --- a/docs/examples/users/create-ph-pass-user.md +++ b/docs/examples/users/create-ph-pass-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await users.createPHPassUser({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index 5d2909db..97102a19 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await users.createScryptModifiedUser({ passwordSalt: '', passwordSaltSeparator: '', passwordSignerKey: '', - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index 22749a80..e0343189 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,11 +12,11 @@ const result = await users.createScryptUser({ email: 'email@example.com', password: 'password', passwordSalt: '', - passwordCpu: null, - passwordMemory: null, - passwordParallel: null, - passwordLength: null, - name: '' // optional + passwordCpu: 8, + passwordMemory: 65536, + passwordParallel: 1, + passwordLength: 64, + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md index 785ec0e6..8a7e864f 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.createSession({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/create-sha-user.md b/docs/examples/users/create-sha-user.md index e57bd0fe..3a69e771 100644 --- a/docs/examples/users/create-sha-user.md +++ b/docs/examples/users/create-sha-user.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users, PasswordHash } from "@appwrite.io/console"; +import { Client, Users, PasswordHash } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await users.createSHAUser({ email: 'email@example.com', password: 'password', passwordVersion: PasswordHash.Sha1, // optional - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index 905adb7c..f6e985f9 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users, MessagingProviderType } from "@appwrite.io/console"; +import { Client, Users, MessagingProviderType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await users.createTarget({ providerType: MessagingProviderType.Email, identifier: '', providerId: '', // optional - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md index c6f43124..56e5fae7 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const users = new Users(client); const result = await users.createToken({ userId: '', length: 4, // optional - expire: 60 // optional + expire: 60, // optional }); console.log(result); diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 83fa0bd7..71db07aa 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await users.create({ email: 'email@example.com', // optional phone: '+12065550100', // optional password: 'password', // optional - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index 8a75f548..193e0e3a 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.deleteIdentity({ - identityId: '' + identityId: '', }); console.log(result); diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index fac8f2fe..520abf65 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users, AuthenticatorType } from "@appwrite.io/console"; +import { Client, Users, AuthenticatorType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.deleteMFAAuthenticator({ userId: '', - type: AuthenticatorType.Totp + type: AuthenticatorType.Totp, }); console.log(result); diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 0bea5626..193f6717 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.deleteSession({ userId: '', - sessionId: '' + sessionId: '', }); console.log(result); diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 0087096e..7d581298 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.deleteSessions({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md index d6b84512..639815a5 100644 --- a/docs/examples/users/delete-target.md +++ b/docs/examples/users/delete-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.deleteTarget({ userId: '', - targetId: '' + targetId: '', }); console.log(result); diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index fd7c6777..4cfdc4fa 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.delete({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/get-mfa-challenge.md b/docs/examples/users/get-mfa-challenge.md new file mode 100644 index 00000000..e31e1cec --- /dev/null +++ b/docs/examples/users/get-mfa-challenge.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const users = new Users(client); + +const result = await users.getMFAChallenge({ + userId: '', + challengeId: '', +}); + +console.log(result); +``` diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index f0acfe91..800fa2ed 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.getMFARecoveryCodes({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index b2b8fbbb..6ad35497 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.getPrefs({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index 3ab5afaa..17cd872c 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.getTarget({ userId: '', - targetId: '' + targetId: '', }); console.log(result); diff --git a/docs/examples/users/get-usage.md b/docs/examples/users/get-usage.md index b998877b..04ecef8a 100644 --- a/docs/examples/users/get-usage.md +++ b/docs/examples/users/get-usage.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users, UsageRange } from "@appwrite.io/console"; +import { Client, Users, UsageRange } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.getUsage({ - range: UsageRange.24h // optional + range: UsageRange.Value24h, // optional }); console.log(result); diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 151401f8..3da557d4 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.get({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 9afe716d..bfd63ef4 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const users = new Users(client); const result = await users.listIdentities({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 5b40db8e..6affdede 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const users = new Users(client); const result = await users.listLogs({ userId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index de0cc69d..a3dfd828 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await users.listMemberships({ userId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 7120c655..61c2b60b 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.listMFAFactors({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index d8db6a65..934efef2 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.listSessions({ userId: '', - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index 456b824b..b3f09b9f 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const users = new Users(client); const result = await users.listTargets({ userId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 47f3b201..40f351e0 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const users = new Users(client); const result = await users.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 88c24c6f..0131972f 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateEmailVerification({ userId: '', - emailVerification: false + emailVerification: false, }); console.log(result); diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index b764d525..2f3fffed 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateEmail({ userId: '', - email: 'email@example.com' + email: 'email@example.com', }); console.log(result); diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md index 955af032..819a857e 100644 --- a/docs/examples/users/update-impersonator.md +++ b/docs/examples/users/update-impersonator.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateImpersonator({ userId: '', - impersonator: false + impersonator: false, }); console.log(result); diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 14bb2ebb..bf287f36 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateLabels({ userId: '', - labels: [] + labels: [], }); console.log(result); diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index 8c4ead69..ed7a5706 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.updateMFARecoveryCodes({ - userId: '' + userId: '', }); console.log(result); diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 616ca30e..5152ce26 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateMFA({ userId: '', - mfa: false + mfa: false, }); console.log(result); diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 708733e8..1d7680e6 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateName({ userId: '', - name: '' + name: '', }); console.log(result); diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 48920f14..ff58b1da 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updatePassword({ userId: '', - password: 'password' + password: 'password', }); console.log(result); diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index 2666cd99..d30161f9 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updatePhoneVerification({ userId: '', - phoneVerification: false + phoneVerification: false, }); console.log(result); diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 3244d09d..a3c5868a 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updatePhone({ userId: '', - number: '+12065550100' + number: '+12065550100', }); console.log(result); diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index c2afe2ec..b306d59a 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updatePrefs({ userId: '', - prefs: {} + prefs: {}, }); console.log(result); diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 4a1d4c1a..fc95c6bb 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateStatus({ userId: '', - status: false + status: false, }); console.log(result); diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md index 2752bb78..50c9257b 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Users } from "@appwrite.io/console"; +import { Client, Users } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await users.updateTarget({ targetId: '', identifier: '', // optional providerId: '', // optional - name: '' // optional + name: '', // optional }); console.log(result); diff --git a/docs/examples/vcs/create-repository-detection.md b/docs/examples/vcs/create-repository-detection.md index 6666a9f3..99df3235 100644 --- a/docs/examples/vcs/create-repository-detection.md +++ b/docs/examples/vcs/create-repository-detection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs, VCSDetectionType } from "@appwrite.io/console"; +import { Client, Vcs, VCSDetectionType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vcs.createRepositoryDetection({ installationId: '', providerRepositoryId: '', type: VCSDetectionType.Runtime, - providerRootDirectory: '' // optional + providerRootDirectory: '', // optional }); console.log(result); diff --git a/docs/examples/vcs/create-repository.md b/docs/examples/vcs/create-repository.md index 8a02e522..9598870c 100644 --- a/docs/examples/vcs/create-repository.md +++ b/docs/examples/vcs/create-repository.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vcs.createRepository({ installationId: '', name: '', xprivate: false, - providerNamespace: '' // optional + providerNamespace: '', // optional }); console.log(result); diff --git a/docs/examples/vcs/delete-installation.md b/docs/examples/vcs/delete-installation.md index 8afd6e6d..73d4db52 100644 --- a/docs/examples/vcs/delete-installation.md +++ b/docs/examples/vcs/delete-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vcs = new Vcs(client); const result = await vcs.deleteInstallation({ - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/vcs/get-installation.md b/docs/examples/vcs/get-installation.md index 2852c4ab..35c17ccb 100644 --- a/docs/examples/vcs/get-installation.md +++ b/docs/examples/vcs/get-installation.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vcs = new Vcs(client); const result = await vcs.getInstallation({ - installationId: '' + installationId: '', }); console.log(result); diff --git a/docs/examples/vcs/get-repository-contents.md b/docs/examples/vcs/get-repository-contents.md index 5be6ef87..87caa407 100644 --- a/docs/examples/vcs/get-repository-contents.md +++ b/docs/examples/vcs/get-repository-contents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vcs.getRepositoryContents({ installationId: '', providerRepositoryId: '', providerRootDirectory: '', // optional - providerReference: '' // optional + providerReference: '', // optional }); console.log(result); diff --git a/docs/examples/vcs/get-repository.md b/docs/examples/vcs/get-repository.md index bff984b3..805fca4f 100644 --- a/docs/examples/vcs/get-repository.md +++ b/docs/examples/vcs/get-repository.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const vcs = new Vcs(client); const result = await vcs.getRepository({ installationId: '', - providerRepositoryId: '' + providerRepositoryId: '', }); console.log(result); diff --git a/docs/examples/vcs/list-installations.md b/docs/examples/vcs/list-installations.md index cda9fc9c..56f7fc4d 100644 --- a/docs/examples/vcs/list-installations.md +++ b/docs/examples/vcs/list-installations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const vcs = new Vcs(client); const result = await vcs.listInstallations({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/vcs/list-namespaces.md b/docs/examples/vcs/list-namespaces.md index 61a155d8..a66ffdd0 100644 --- a/docs/examples/vcs/list-namespaces.md +++ b/docs/examples/vcs/list-namespaces.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const vcs = new Vcs(client); const result = await vcs.listNamespaces({ installationId: '', search: '', // optional - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/vcs/list-repositories.md b/docs/examples/vcs/list-repositories.md index 0aad1f02..1661cd8c 100644 --- a/docs/examples/vcs/list-repositories.md +++ b/docs/examples/vcs/list-repositories.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs, VCSDetectionType } from "@appwrite.io/console"; +import { Client, Vcs, VCSDetectionType } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vcs.listRepositories({ installationId: '', type: VCSDetectionType.Runtime, search: '', // optional - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/vcs/list-repository-branches.md b/docs/examples/vcs/list-repository-branches.md index 2943996f..2efd905b 100644 --- a/docs/examples/vcs/list-repository-branches.md +++ b/docs/examples/vcs/list-repository-branches.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vcs.listRepositoryBranches({ installationId: '', providerRepositoryId: '', search: '', // optional - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/vcs/update-external-deployments.md b/docs/examples/vcs/update-external-deployments.md index 20a11e02..3975bc7f 100644 --- a/docs/examples/vcs/update-external-deployments.md +++ b/docs/examples/vcs/update-external-deployments.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Vcs } from "@appwrite.io/console"; +import { Client, Vcs } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const vcs = new Vcs(client); const result = await vcs.updateExternalDeployments({ installationId: '', repositoryId: '', - providerPullRequestId: '' + providerPullRequestId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index 43924d6b..b69be570 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, VectorsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await vectorsDB.createCollection({ dimension: 1, permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index 85067168..5995f070 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, VectorsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,17 +12,13 @@ const result = await vectorsDB.createDocument({ collectionId: '', documentId: '', data: { - "embeddings": [ - 0.12, - -0.55, - 0.88, - 1.02 - ], - "metadata": { - "key": "value" - } + embeddings: [0.12, -0.55, 0.88, 1.02], + metadata: { + key: 'value', + }, }, - permissions: [Permission.read(Role.any())] // optional + permissions: [Permission.read(Role.any())], // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 4f955e88..6bda5bf1 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,8 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createDocuments({ databaseId: '', collectionId: '', - documents: [] + documents: [], + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-failover.md b/docs/examples/vectorsdb/create-failover.md index 0c0509ca..42c70461 100644 --- a/docs/examples/vectorsdb/create-failover.md +++ b/docs/examples/vectorsdb/create-failover.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index 7bef86ed..1f8b422d 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -1,5 +1,10 @@ ```javascript -import { Client, VectorsDB, VectorsDBIndexType, OrderBy } from "@appwrite.io/console"; +import { + Client, + VectorsDB, + VectorsDBIndexType, + OrderBy, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,11 +15,11 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createIndex({ databaseId: '', collectionId: '', - key: '', + key: '', type: VectorsDBIndexType.HnswEuclidean, attributes: [], orders: [OrderBy.Asc], // optional - lengths: [] // optional + lengths: [], // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index 5ff5f687..fc90ed8b 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,16 +10,16 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createOperations({ transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + { + action: 'create', + databaseId: '', + collectionId: '', + documentId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-query.md b/docs/examples/vectorsdb/create-query.md index 5fc57209..5900362b 100644 --- a/docs/examples/vectorsdb/create-query.md +++ b/docs/examples/vectorsdb/create-query.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await vectorsDB.createQuery({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md index 99ee2ff6..713840a8 100644 --- a/docs/examples/vectorsdb/create-transaction.md +++ b/docs/examples/vectorsdb/create-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createTransaction({ - ttl: 60 // optional + ttl: 60, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md index e10365e8..1bc26e0c 100644 --- a/docs/examples/vectorsdb/create.md +++ b/docs/examples/vectorsdb/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await vectorsDB.create({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md index bc7997f9..9e0d2bf8 100644 --- a/docs/examples/vectorsdb/delete-collection.md +++ b/docs/examples/vectorsdb/delete-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.deleteCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md index a1db5dea..b7d5b7a7 100644 --- a/docs/examples/vectorsdb/delete-document.md +++ b/docs/examples/vectorsdb/delete-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vectorsDB.deleteDocument({ databaseId: '', collectionId: '', documentId: '', - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index 92d6c8a6..e699485b 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vectorsDB.deleteDocuments({ databaseId: '', collectionId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md index b592d682..b88a5dc2 100644 --- a/docs/examples/vectorsdb/delete-index.md +++ b/docs/examples/vectorsdb/delete-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.deleteIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md index 12a21357..8e936d1a 100644 --- a/docs/examples/vectorsdb/delete-transaction.md +++ b/docs/examples/vectorsdb/delete-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.deleteTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md index 768bf7bc..34ce8b6d 100644 --- a/docs/examples/vectorsdb/delete.md +++ b/docs/examples/vectorsdb/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.delete({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md index 440adca2..3d0eb6a9 100644 --- a/docs/examples/vectorsdb/get-collection.md +++ b/docs/examples/vectorsdb/get-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.getCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md index c3ecc577..0b16fca1 100644 --- a/docs/examples/vectorsdb/get-document.md +++ b/docs/examples/vectorsdb/get-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await vectorsDB.getDocument({ collectionId: '', documentId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md index 08930cfe..6a1ace93 100644 --- a/docs/examples/vectorsdb/get-index.md +++ b/docs/examples/vectorsdb/get-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.getIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/get-replicas.md b/docs/examples/vectorsdb/get-replicas.md index 33d1f405..976d6f51 100644 --- a/docs/examples/vectorsdb/get-replicas.md +++ b/docs/examples/vectorsdb/get-replicas.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.getReplicas({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/get-status.md b/docs/examples/vectorsdb/get-status.md index fbdeffa2..0976b3ab 100644 --- a/docs/examples/vectorsdb/get-status.md +++ b/docs/examples/vectorsdb/get-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.getStatus({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md index 80c1ab82..cd9e1e58 100644 --- a/docs/examples/vectorsdb/get-transaction.md +++ b/docs/examples/vectorsdb/get-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.getTransaction({ - transactionId: '' + transactionId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md index b7c5f5ac..e82e8f5d 100644 --- a/docs/examples/vectorsdb/get.md +++ b/docs/examples/vectorsdb/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.get({ - databaseId: '' + databaseId: '', }); console.log(result); diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md index dd4f27fb..10b68b11 100644 --- a/docs/examples/vectorsdb/list-collections.md +++ b/docs/examples/vectorsdb/list-collections.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vectorsDB.listCollections({ databaseId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md index 8b907aad..acdfdc88 100644 --- a/docs/examples/vectorsdb/list-documents.md +++ b/docs/examples/vectorsdb/list-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await vectorsDB.listDocuments({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md index eeeddb5c..dfc577c0 100644 --- a/docs/examples/vectorsdb/list-indexes.md +++ b/docs/examples/vectorsdb/list-indexes.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vectorsDB.listIndexes({ databaseId: '', collectionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/list-operations.md b/docs/examples/vectorsdb/list-operations.md index 9b1d628d..3fef1f3f 100644 --- a/docs/examples/vectorsdb/list-operations.md +++ b/docs/examples/vectorsdb/list-operations.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,9 +9,9 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/list-specifications.md b/docs/examples/vectorsdb/list-specifications.md index 583a2593..3197cf3c 100644 --- a/docs/examples/vectorsdb/list-specifications.md +++ b/docs/examples/vectorsdb/list-specifications.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index 21edf97c..02da7686 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const vectorsDB = new VectorsDB(client); const result = await vectorsDB.listTransactions({ - queries: [] // optional + queries: [], // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md index d09c6f98..c51ee26b 100644 --- a/docs/examples/vectorsdb/list.md +++ b/docs/examples/vectorsdb/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.list({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 2cbc7d5a..49102441 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, VectorsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ const result = await vectorsDB.updateCollection({ dimension: 1, // optional permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional - enabled: false // optional + enabled: false, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md index ce990ad6..f571d834 100644 --- a/docs/examples/vectorsdb/update-document.md +++ b/docs/examples/vectorsdb/update-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, VectorsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await vectorsDB.updateDocument({ documentId: '', data: {}, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md index 44c19fb4..e2446382 100644 --- a/docs/examples/vectorsdb/update-documents.md +++ b/docs/examples/vectorsdb/update-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await vectorsDB.updateDocuments({ collectionId: '', data: {}, // optional queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md index a7809df7..cec0535d 100644 --- a/docs/examples/vectorsdb/update-transaction.md +++ b/docs/examples/vectorsdb/update-transaction.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.updateTransaction({ transactionId: '', commit: false, // optional - rollback: false // optional + rollback: false, // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md index fd375177..ee930ec7 100644 --- a/docs/examples/vectorsdb/update.md +++ b/docs/examples/vectorsdb/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await vectorsDB.update({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md index 1221bad1..9d42d0d7 100644 --- a/docs/examples/vectorsdb/upsert-document.md +++ b/docs/examples/vectorsdb/upsert-document.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB, Permission, Role } from "@appwrite.io/console"; +import { Client, VectorsDB, Permission, Role } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +13,7 @@ const result = await vectorsDB.upsertDocument({ documentId: '', data: {}, // optional permissions: [Permission.read(Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index 74a03f92..af58d1d4 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB } from "@appwrite.io/console"; +import { Client, VectorsDB } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await vectorsDB.upsertDocuments({ databaseId: '', collectionId: '', documents: [], - transactionId: '' // optional + transactionId: '', // optional }); console.log(result); diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md index 17adacb6..9c494768 100644 --- a/docs/examples/waf/create-bypass-rule.md +++ b/docs/examples/waf/create-bypass-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await waf.createBypassRule({ description: '', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md index d183f84f..5b1689f8 100644 --- a/docs/examples/waf/create-challenge-rule.md +++ b/docs/examples/waf/create-challenge-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -18,7 +18,7 @@ const result = await waf.createChallengeRule({ enabled: false, // optional conditions: '', // optional difficulty: 1, // optional - ttl: 900 // optional + ttl: 900, // optional }); console.log(result); diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md index 204ce88a..87bfdbec 100644 --- a/docs/examples/waf/create-deny-rule.md +++ b/docs/examples/waf/create-deny-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await waf.createDenyRule({ description: '', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md index 53a50fcc..bb1d683f 100644 --- a/docs/examples/waf/create-rate-limit-rule.md +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,9 +16,11 @@ const result = await waf.createRateLimitRule({ resourceId: '', // optional description: '', // optional key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md index 66f67b92..37d9ed8f 100644 --- a/docs/examples/waf/create-redirect-rule.md +++ b/docs/examples/waf/create-redirect-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await waf.createRedirectRule({ description: '', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md index ebcd3e75..9b7cceec 100644 --- a/docs/examples/waf/delete-rule.md +++ b/docs/examples/waf/delete-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const waf = new Waf(client); const result = await waf.deleteRule({ - ruleId: '' + ruleId: '', }); console.log(result); diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md index 3b498b65..e9515d07 100644 --- a/docs/examples/waf/get-rule.md +++ b/docs/examples/waf/get-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const waf = new Waf(client); const result = await waf.getRule({ - ruleId: '' + ruleId: '', }); console.log(result); diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md index 4cbf7bb7..7b90f8fa 100644 --- a/docs/examples/waf/list-rules.md +++ b/docs/examples/waf/list-rules.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const waf = new Waf(client); const result = await waf.listRules({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md index 30cbca80..d0987aa2 100644 --- a/docs/examples/waf/update-bypass-rule.md +++ b/docs/examples/waf/update-bypass-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await waf.updateBypassRule({ description: '', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md index 07bb6867..210200fc 100644 --- a/docs/examples/waf/update-challenge-rule.md +++ b/docs/examples/waf/update-challenge-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -18,7 +18,7 @@ const result = await waf.updateChallengeRule({ enabled: false, // optional conditions: '', // optional difficulty: 1, // optional - ttl: 900 // optional + ttl: 900, // optional }); console.log(result); diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md index 473bdcaf..a46d5680 100644 --- a/docs/examples/waf/update-deny-rule.md +++ b/docs/examples/waf/update-deny-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,7 +15,7 @@ const result = await waf.updateDenyRule({ description: '', // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md index e979510a..24dfd934 100644 --- a/docs/examples/waf/update-rate-limit-rule.md +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,9 +16,10 @@ const result = await waf.updateRateLimitRule({ limit: 1, // optional interval: 1, // optional key: 'ip', // optional + maxBucketSize: 1, // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md index 907ebda8..00e5c3ef 100644 --- a/docs/examples/waf/update-redirect-rule.md +++ b/docs/examples/waf/update-redirect-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Waf } from "@appwrite.io/console"; +import { Client, Waf } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,7 +17,7 @@ const result = await waf.updateRedirectRule({ statusCode: 300, // optional priority: -100000, // optional enabled: false, // optional - conditions: '' // optional + conditions: '', // optional }); console.log(result); diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index e44da2bb..f5817fbe 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Webhooks } from "@appwrite.io/console"; +import { Client, Webhooks } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,14 +9,14 @@ const webhooks = new Webhooks(client); const result = await webhooks.create({ webhookId: '', - url: '', + url: 'https://example.com/webhook', name: '', events: [], enabled: false, // optional tls: false, // optional authUsername: '', // optional authPassword: 'password', // optional - secret: '' // optional + secret: '', // optional }); console.log(result); diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md index 1ba3b99d..e4fbd3d7 100644 --- a/docs/examples/webhooks/delete.md +++ b/docs/examples/webhooks/delete.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Webhooks } from "@appwrite.io/console"; +import { Client, Webhooks } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const webhooks = new Webhooks(client); const result = await webhooks.delete({ - webhookId: '' + webhookId: '', }); console.log(result); diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md index f8afc2f9..d7e40e52 100644 --- a/docs/examples/webhooks/get.md +++ b/docs/examples/webhooks/get.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Webhooks } from "@appwrite.io/console"; +import { Client, Webhooks } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const webhooks = new Webhooks(client); const result = await webhooks.get({ - webhookId: '' + webhookId: '', }); console.log(result); diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md index ebdd766a..6d4381cd 100644 --- a/docs/examples/webhooks/list.md +++ b/docs/examples/webhooks/list.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Webhooks } from "@appwrite.io/console"; +import { Client, Webhooks } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const webhooks = new Webhooks(client); const result = await webhooks.list({ queries: [], // optional - total: false // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/webhooks/update-secret.md b/docs/examples/webhooks/update-secret.md index d1c36274..bb7492ad 100644 --- a/docs/examples/webhooks/update-secret.md +++ b/docs/examples/webhooks/update-secret.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Webhooks } from "@appwrite.io/console"; +import { Client, Webhooks } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const webhooks = new Webhooks(client); const result = await webhooks.updateSecret({ webhookId: '', - secret: '' // optional + secret: '', // optional }); console.log(result); diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 6d3bf024..78071ef4 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Webhooks } from "@appwrite.io/console"; +import { Client, Webhooks } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,12 +10,12 @@ const webhooks = new Webhooks(client); const result = await webhooks.update({ webhookId: '', name: '', - url: '', + url: 'https://example.com/webhook', events: [], enabled: false, // optional tls: false, // optional authUsername: '', // optional - authPassword: 'password' // optional + authPassword: 'password', // optional }); console.log(result); diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..b8d79f5d --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,31 @@ +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + eslint.configs.recommended, + tseslint.configs.recommended, + { + ignores: ['dist/', 'types/', 'docs/', 'rollup.config.mjs'], + }, + { + rules: { + // The SDK deliberately exposes loosely-typed surfaces (payloads, + // model generics defaulting to open records), so `any` is part of + // its public contract rather than an oversight. + '@typescript-eslint/no-explicit-any': 'off', + // Empty responses are typed `Promise<{}>` and the models are + // published under the `Models` namespace; both are part of the + // SDK's public API and cannot change without a breaking release. + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + }, + ], + }, + }, +); diff --git a/package-lock.json b/package-lock.json index a84c7e23..cd6d2e33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,26 +1,30 @@ { "name": "@appwrite.io/console", - "version": "16.0.0", + "version": "16.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "16.0.0", + "version": "16.1.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" }, "devDependencies": { + "@eslint/js": "10.0.1", "@rollup/plugin-commonjs": "29.0.3", "@rollup/plugin-node-resolve": "16.0.3", "@rollup/plugin-typescript": "12.3.0", "@types/json-bigint": "1.0.4", + "eslint": "10.10.0", "playwright": "1.56.1", - "rollup": "4.62.4", + "prettier": "3.9.6", + "rollup": "4.63.1", "serve-handler": "6.1.7", "tslib": "2.8.1", - "typescript": "5.9.3" + "typescript": "5.9.3", + "typescript-eslint": "8.69.0" }, "engines": { "node": ">=18.0.0" @@ -29,10 +33,252 @@ "brace-expansion": "5.0.9" } }, + "node_modules/@cacheable/memory": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", + "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/utils": "^2.5.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@cacheable/utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.5.0.tgz", + "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.5.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.5", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", + "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^3.0.5", + "debug": "^4.3.1", + "minimatch": "^10.2.4" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz", + "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/js": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-10.0.1.tgz", + "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "eslint": "^10.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/@eslint/object-schema": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.5.tgz", + "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz", + "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@keyv/bigmap": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.4.0", + "hookified": "^1.15.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "keyv": "^5.6.0" + } + }, + "node_modules/@keyv/serialize": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.1.1.tgz", + "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==", "dev": true, "license": "MIT" }, @@ -159,9 +405,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.4.tgz", - "integrity": "sha512-RrPokAb7dmbxFoeO3TloqHyOjgye8RkBhSqmp4aJMIex4c9r46ZstPnleDQOq1t46VOVjwIuwNogIqbodV1Vvg==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.1.tgz", + "integrity": "sha512-UZ8sUxPTiHWYX9QNdJedb1kDZSpS1t/VPWBWGSgqHNi9w3Cu6IXvu2mzbhiTiPvtrqgTQJ+zqiAq2iPIPilpaQ==", "cpu": [ "arm" ], @@ -173,9 +419,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.4.tgz", - "integrity": "sha512-JKuJc+pnpks2pjy7L/N3v/cAkZxYlnmuZoD840ldbMI5KDbC4iO9NKwPKYdjYFCMAIIlBzYSFHxIJVYzRo2/8A==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.1.tgz", + "integrity": "sha512-cQ4nFQABN5cDvDpbvJ7bMStCpnaVxynZrRMfUJYgxcIk9Sh54FIO1vtfkg0B69REjER77ioZ/ov+eAApx/KmLQ==", "cpu": [ "arm64" ], @@ -187,9 +433,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.4.tgz", - "integrity": "sha512-krw5uS2STmvJ02x0uTXHbqQNuz+9eZ1iw+qXk9dmW2gvV4jV7O2hEoOnuhFrpOPiel1mBFtqbxYZZtC46hXLOw==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.1.tgz", + "integrity": "sha512-FQNqd1lRy/0QhDk3xeRIkSBiCpXCiDnZO3YLVdcDKN1UBiKToNftCzcXYNLshmPDUMlu2TdeS8tGcsU6f3YF1Q==", "cpu": [ "arm64" ], @@ -201,9 +447,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.4.tgz", - "integrity": "sha512-wsTxtgApb4PrOsNJIm0FZ1h3WvCC+k9uxLJ4ad75hgoS4NiRes2SoJFlDAyMwiUY8IssDqGcHbXuN0sx1tfF1A==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.1.tgz", + "integrity": "sha512-pvD16V939D3CloK0+qikpGaxiPrDUXTe7Y5cWOMkMSy7m1cawa8EGy/kXYi/G/cKAC4HDAbSnzCIk1WmsoOKXg==", "cpu": [ "x64" ], @@ -215,9 +461,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.4.tgz", - "integrity": "sha512-GUOnQlyZe3yAXhWOtOMsn5Qkrv5E5mZXa0thbARWi5Ei2szlVXJFQhddZ4HbAzh8q92w5twp+CQvs/eFanz9YQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.1.tgz", + "integrity": "sha512-pcFGeL2345VwdTnJhA6zLbew+YgWB0qBG2+dMtXjCicf6+rm6kO6cOoh5VnTe0ZMrMRgRyuHmCJxZWrIdzYuOw==", "cpu": [ "arm64" ], @@ -229,9 +475,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.4.tgz", - "integrity": "sha512-/Y7f3QuxjzPKsjA/rfEDa3+0vXqyjmJ50Ln8dPpCmWkKTrUoWHG1cWhTqaAMLob2m2nESWuC7yGrREz019Ztqg==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.1.tgz", + "integrity": "sha512-mRJlqSRulVzcKq/LKA6ICSIc3K/l4fzlVn/gePn2nXIHy8seRi5z/eeRE0d/XMBxcMldiXtQTSpRj0tkkC3g8Q==", "cpu": [ "x64" ], @@ -243,9 +489,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.4.tgz", - "integrity": "sha512-81wiiX3v7aqy+T+bT61TJ78yJjRquqFFTTbAPt08imfQQzkPIW8t6aJbkTagtCCrXMNc9D66+geqlK7ydLPNqA==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.1.tgz", + "integrity": "sha512-YDUNvVM85TI3g/1OpnqKP1h4NeW/j64DfWMf+G3M809xNk1bJSnpFp4sh83NpmVE5DXnkh8ULor4LTVZKoYLHw==", "cpu": [ "arm" ], @@ -260,9 +506,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.4.tgz", - "integrity": "sha512-9kmDIvNZqdoHOBZgNtpTBeLWYO/LVipM3H/j62P8848/l/VPEQL6N3uxU9pvP1oZAsXyC2MEnFP3ovRjo7WYNQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.1.tgz", + "integrity": "sha512-7Mcn71p9ZuQFAj+h+dhQXy/yeLePRS2yKRnmW1DijA9thKO5qap0GNOIQK4yQ6iP3SU0Mrb/yWo8h8vgRba8lw==", "cpu": [ "arm" ], @@ -277,9 +523,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.4.tgz", - "integrity": "sha512-CcnXHWnXg69g+DX5VWL3FHts3qMRN2uVEHX+BZvGLdd07/gXkn3ePjYtO1LDJvxkGKVHMclKBRa1QUTH+6toYQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.1.tgz", + "integrity": "sha512-4YiLQTX6U4CSl0L9cluep9A9W6UmTfqBDc2/CH6wlu54pl4E7Jn3cOD8oxzvBDEGk/JMKgJ47C8g+radF7mwvg==", "cpu": [ "arm64" ], @@ -294,9 +540,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.4.tgz", - "integrity": "sha512-iFOibiHnTRuhrWLlRsOQFdZJJIa7S8OwkneJr4ocALP16u5yk6lWLINFwhHaEqBFMsKDUZofLkGos7+CPzGB3g==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.1.tgz", + "integrity": "sha512-2ra8F7w8OquwZN9z2/fKFnli69wa8PLwaVzRMIPGb13ByMJwC28Fbp8YcVGoUhlYMTt7j5j9bNgpysrN2UM+vw==", "cpu": [ "arm64" ], @@ -311,9 +557,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.4.tgz", - "integrity": "sha512-XnWYMI7euHlb5a871xPja+Gm7DRCFU+FGRrtS2sMq9N8FvqtpagUy6gD4YOemC5MRk9xbh8+jYMEJbigFQwsgA==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.1.tgz", + "integrity": "sha512-Sy20ncyhjmBP0Ml+UvQbimjlk6VFgjW5uNP+qqwHB00mTE8Bl2C1TuHTlRwK2YoXeZbee5lP2XevBWVkAQAtSQ==", "cpu": [ "loong64" ], @@ -328,9 +574,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.4.tgz", - "integrity": "sha512-qGDAlO0U8xedCcsdRm9oaoQY8DAx/QT7uIxJWhCdx0ceIWX783UC9QSYkdpzAe29wNiVfp24+bZdQmn49o45SQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.1.tgz", + "integrity": "sha512-noITLp8oNjYliPnGWmLyelIHwULGqbHloQHGw1rtxbWhTuWooRpnZarZQJ1y9EUC4szuCusCc+HEpUtxpIwYvA==", "cpu": [ "loong64" ], @@ -345,9 +591,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.4.tgz", - "integrity": "sha512-ru4H6ezD7ysA5EiEK6qkkaEb4modH8CTej6kUy/gQi20u3kB3G7Zn8snXXkeJSCOFKG/rbPPtM/+9Wgas1961w==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.1.tgz", + "integrity": "sha512-hlxxXd+F1mWiAcaFR7Sv9ZQT6m6UfI8+Vy/kFJzztq2pDMU/0wZ9sish0iszNZvsQDo8Gc0i5yuFEOz5dDf6fA==", "cpu": [ "ppc64" ], @@ -362,9 +608,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.4.tgz", - "integrity": "sha512-2W4MO5WQVJnbJaZdvDb9rhBDuFU1nKIepPFpJUBsTh2k1YY2g+ODViaWuyOAjQ5cOP7NvrvLzt3wvHOoiAvc7w==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.1.tgz", + "integrity": "sha512-EF7OpqQTQ/BvGqLzUi4rEHuagCV9MugAUXSHemwPW5vxZ75RR+jxO/2j95Ph2dalMpFHSVECjRoioHZgA9zOYA==", "cpu": [ "ppc64" ], @@ -379,9 +625,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.4.tgz", - "integrity": "sha512-+fxjfuoAmVMCYV5QyjoIpu0cp5DOiOTeqYFk1AVaxGr+/ravWLX89XfQmptsoWcaVy/TGf2hexzbUOrCQIL1CQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.1.tgz", + "integrity": "sha512-wQO3JesW9PRkwlabQ27y7sPfVOOTLRG73I4F2UYHG5PXun3J9U3y+b7ezVKSYbsvSKGQ1k1cq8Qlun4C9kLt3w==", "cpu": [ "riscv64" ], @@ -396,9 +642,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.4.tgz", - "integrity": "sha512-jTn8JfHGL4djjFxPuM06LmNUJDsst2jeVlsd9OmIH6zc5sC9K6rIuO4YajXatLUpBmBKl6b35ro1QZocLi+tcA==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.1.tgz", + "integrity": "sha512-ouAGwhO6wHRXdnOVCOsB0tRFkA7nhNB2Nwax6oECXN0YiN8EYUTBAOudADOB1PI+yDL61TeNx/u7MVCzksNbkQ==", "cpu": [ "riscv64" ], @@ -413,9 +659,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.4.tgz", - "integrity": "sha512-oCJCJL4pXsoDcP2QZ+JVlPTIRc6266zsIaeJJsWImmF7HO0W8nb6HuSgZlMWxJwaPf8ehbSw8yo0EUw925hKsA==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.1.tgz", + "integrity": "sha512-q2R38Sn+1J8RxhfJ+T54wSWmyKXWec+9jgDfqO2AtArEqHO5R2aeayp5H5OYLr5UYDVGsVaZPEFUooMhYCdz5A==", "cpu": [ "s390x" ], @@ -430,9 +676,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.4.tgz", - "integrity": "sha512-W69hukhZ3KKNRCaMIEzKvcFye42hh0FE1+YoYaf5+Ikacuftoco6yO/xouz0hc5d5W/s3yBro5jRiuEE/Q5vUw==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.1.tgz", + "integrity": "sha512-gfI5T24WLLuFfSKw7Go/zDXjAAV0fny0swTaDv+WjK7vqcw4cRhFfdsyKL1n+ukI+ooBxn3bVQnyrn06WpI50w==", "cpu": [ "x64" ], @@ -447,9 +693,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.4.tgz", - "integrity": "sha512-qiXbGG2jkjXhzXpsFZSR2Xpb8DN/UaxYsbb/STbuR/6fpaDgRmmaq1B/LmtF2wQFOFOSsK2jdE0RZ3a0zHn4QA==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.1.tgz", + "integrity": "sha512-4h6XqthmB4Hspji84wvgk+ElodTsGj+dbZqHJHHtKxj4mYq0ANSEEPX9ys3moJueqsRjwpaJYH7874Itwnj2ow==", "cpu": [ "x64" ], @@ -464,9 +710,9 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.4.tgz", - "integrity": "sha512-nWeM//hxv8mIo6jD7Hu4o48DVmV9pbV6gsKaWU+4NFyqHoPKwrkRiZGLKUhOBk8qNmDmpwFtPKg80Bo/Tn4xiQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.1.tgz", + "integrity": "sha512-dlfCOa87o1VAYegLQ9EKilx2JCeRofiyPGhTCmqnuXZ6bMPiycO1rq1+sKoulAp7pGLIsTIw+1x5R+zgh5LhhA==", "cpu": [ "x64" ], @@ -478,9 +724,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.4.tgz", - "integrity": "sha512-s62SQ/vgsRSvMwDkOEfTqfgASF0f26ZNaQuTA6Aok5lrikf89yI2W0gFHvZb2Jpgc6N8JnOKZgCK2iciO3CsxQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.1.tgz", + "integrity": "sha512-cjkLbOlfcm3QGhMM1J5zaZjsw1GggbN6rw9UTSSRrPrR1KkcXnN7Uq9rPw34xImQ9VOY9GN+6u2Zj80B9ptkcw==", "cpu": [ "arm64" ], @@ -492,9 +738,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.4.tgz", - "integrity": "sha512-J6wGf8TVGbXJq+HH+ttTvrcfNKPbuZecV6KT1B8I18BC5IURUh5kl4Yl5OEP5eFIUoI5BWxCsyYMhFsDx8kekw==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.1.tgz", + "integrity": "sha512-Li1KdUnWGE4N3e1F/B4RTB1ms+nG4WBgjByO46pkeBVX/2UBsY53xf5vK9WygVmnH3RwncIST7lkSdLSY6P9lg==", "cpu": [ "arm64" ], @@ -506,9 +752,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.4.tgz", - "integrity": "sha512-zmfrQd/0wu6oJs8Vq8KwY/YtsKSsLtKe/HwAP4Wqy8LhWjeT55fHRAkOhYQ12wI3ayS4Tt12d5CDRD7N96SAYQ==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.1.tgz", + "integrity": "sha512-t4ZYOSoLTgwhuFMrmTMLx/+i1DQVK7HYqMc6kY46EApwi8X0nIVphzdNoThU3xt6n+N5urG1/gxBdCaKDLavfg==", "cpu": [ "ia32" ], @@ -520,9 +766,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.4.tgz", - "integrity": "sha512-qPzHqdj9rfUD+w79dtE07zi/kFwKyCJqplp5K5ygeLTp7jLpAoc16OAH39HSmRC9UpozaecsleI8uAdEj6v2yw==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.1.tgz", + "integrity": "sha512-RgroPfMmKlD1RzSDxvwgcPiy2HNQKoYV7OmwIXDsk73uKW5t6B/V8KIy27SMv/FNXFo/oSBtWc9J0X7t91ezZg==", "cpu": [ "x64" ], @@ -534,9 +780,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.4.tgz", - "integrity": "sha512-zD6NdeWEByGE9QF9vCrlJ5YQB4oq9q91kPZS37Jwj5hOkvR1lTBSpsKhKDw4IJtbQ35LsTS1HD9DZYGKIshU1Q==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.1.tgz", + "integrity": "sha512-at8QVep6S3h5Y6gSbdGU06bRY5WJkf6WUduM9YtvYMbYhB1MOFfUgc6kehitQXzOtMSaT70q7f9ydPhpqu821w==", "cpu": [ "x64" ], @@ -547,6 +793,13 @@ "win32" ] }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", @@ -561,6 +814,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/resolve": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", @@ -568,148 +828,760 @@ "dev": true, "license": "MIT" }, - "node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.69.0.tgz", + "integrity": "sha512-t5jQTKPIgVW1PE6dR6H6Qz5gm8zjMlX5/2gRaOGd9eO6V7J+tQc6iWKukEe7dY8u9HyYasQ0yfF0/FSSTEO2gA==", "dev": true, "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.69.0", + "@typescript-eslint/type-utils": "8.69.0", + "@typescript-eslint/utils": "8.69.0", + "@typescript-eslint/visitor-keys": "8.69.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, "engines": { - "node": "18 || 20 || >=22" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.69.0", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/bignumber.js": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", - "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.8.tgz", + "integrity": "sha512-YYNsSlXBjMk92SKnkwvB5LOVSa6OznlFUGcsvrFgNJbJCd0M1XKeFVRc8ZByeCqz32FivYNHJVooLmdqrmvp/Q==", + "dev": true, "license": "MIT", "engines": { - "node": "*" + "node": ">= 4" } }, - "node_modules/brace-expansion": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", - "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", + "node_modules/@typescript-eslint/parser": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.69.0.tgz", + "integrity": "sha512-l4b0DhWioGg6Gt2ebGlvfkFMOjRsauxtsnDRwUSRX1qHq3HdTfQHV8wW9zEXeciai6HfeaKOedQn2Zoofx3WBw==", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^4.0.2" + "@typescript-eslint/scope-manager": "8.69.0", + "@typescript-eslint/types": "8.69.0", + "@typescript-eslint/typescript-estree": "8.69.0", + "@typescript-eslint/visitor-keys": "8.69.0", + "debug": "^4.4.3" }, "engines": { - "node": "20 || >=22" - } - }, - "node_modules/bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true, - "license": "MIT" - }, - "node_modules/content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==", + "node_modules/@typescript-eslint/project-service": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.69.0.tgz", + "integrity": "sha512-yi4obFrHMmnsesWehHbkg9zMA7Jt8cXT+mKM08G999pH1yT6nqgsHx7MYm0uY1wAj8CqiBXYRJ7WAT0QdQHQXg==", "dev": true, "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.69.0", + "@typescript-eslint/types": "^8.69.0", + "debug": "^4.4.3" + }, "engines": { - "node": ">= 0.6" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/deepmerge": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.69.0.tgz", + "integrity": "sha512-ewfspqWvSxKSOaplqAUNbaSFO0eB6w1EtQ+esfYFRm3614Ty4uNtExkcbgd6nWsXphbqKyf9ZYdbZdv2xEoWEQ==", "dev": true, "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.69.0", + "@typescript-eslint/visitor-keys": "8.69.0" + }, "engines": { - "node": ">=0.10.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.69.0.tgz", + "integrity": "sha512-xNqK7YTDZsLniQMV/4rpFR8Z5JlqeRvVjuG1YgF/mdPVH84HSD19L8CczMA0qg2RfwEV231GHH3VnToJDo4MfQ==", "dev": true, "license": "MIT", "engines": { - "node": ">= 0.4" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true, - "license": "MIT" - }, - "node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "node_modules/@typescript-eslint/type-utils": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.69.0.tgz", + "integrity": "sha512-ZfoJAVg3JZndQEpEl9petVlxau3lRuElc4HRMuAlLCf8to04/iHz692RUSNmXKDjEuJmIL+KZ2/BsOcBc16dsA==", "dev": true, "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.69.0", + "@typescript-eslint/typescript-estree": "8.69.0", + "@typescript-eslint/utils": "8.69.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, "engines": { - "node": ">=12.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, - "peerDependencies": { - "picomatch": "^3 || ^4" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "node_modules/@typescript-eslint/types": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.69.0.tgz", + "integrity": "sha512-K3VrubUPhlo9VDBS6QdI8YB5j7ClpqLRdefcz6PFrhnwicehBweqQ9Evhl4l+FYz0HdDmMqIiSX0aldGRYtDCA==", "dev": true, - "hasInstallScript": true, "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.69.0.tgz", + "integrity": "sha512-AdFkgqck3Vudb/kWnxlyafU/4aBhHrbQ9locP2N4psXTy5mOBg0SHJumnLvx7r6g1gV4DKvUFwV2nJZBoqOD8w==", "dev": true, "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.69.0", + "@typescript-eslint/tsconfig-utils": "8.69.0", + "@typescript-eslint/types": "8.69.0", + "@typescript-eslint/visitor-keys": "8.69.0", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/hasown": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", - "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "node_modules/@typescript-eslint/utils": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.69.0.tgz", + "integrity": "sha512-tUbx60BBqQa31kXF5MCsOOLL5E/WzUuxIn7YpAvq+eaUlqvk8/NXnXMBNAdLCr0icjkzem7iUA5QqWHe/hJ1aw==", "dev": true, "license": "MIT", "dependencies": { - "function-bind": "^1.1.2" + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.69.0", + "@typescript-eslint/types": "8.69.0", + "@typescript-eslint/typescript-estree": "8.69.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.69.0.tgz", + "integrity": "sha512-+rmdgPA+EXkNgKYvHvFfhrs35utXbwaC5PGpDquSXcoXQDKUA5UjV0LmTucG/4JXkM31BTu4TilHtrN8IVBe8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.69.0", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/acorn": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz", + "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/bignumber.js": { + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", + "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", + "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cacheable": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.5.0.tgz", + "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/memory": "^2.2.0", + "@cacheable/utils": "^2.5.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.10.1" + } + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.10.0.tgz", + "integrity": "sha512-NPXn6r5zl4uET1DAVPaOwzX3rut4c0wcmw3dWJAfOsTM5+TogXo0DDjz8pwm/hL8cyVNpHqeK4JpN0NjnyFFNw==", + "dev": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.2", + "@eslint/config-array": "^0.23.5", + "@eslint/config-helpers": "^0.7.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.3", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^9.1.2", + "eslint-visitor-keys": "^5.0.1", + "espree": "^11.2.0", + "esquery": "^1.7.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "11.1.5 || >11.1.6 <12", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "minimatch": "^10.2.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", + "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@types/esrecurse": "^4.3.1", + "@types/estree": "^1.0.8", + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", + "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.16.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^5.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-entry-cache": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.5.tgz", + "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^6.1.23" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "6.1.23", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.23.tgz", + "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cacheable": "^2.5.0", + "flatted": "^3.4.2", + "hookified": "^1.15.0" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/hashery": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^1.15.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" }, "engines": { "node": ">= 0.4" } }, + "node_modules/hookified": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, "node_modules/is-core-module": { "version": "2.16.2", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", @@ -726,6 +1598,29 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", @@ -743,6 +1638,13 @@ "@types/estree": "*" } }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, "node_modules/json-bigint": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", @@ -752,6 +1654,60 @@ "bignumber.js": "^9.0.0" } }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@keyv/serialize": "^1.1.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -786,16 +1742,93 @@ } }, "node_modules/minimatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", - "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^5.0.8" }, "engines": { - "node": "*" + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" } }, "node_modules/path-is-inside": { @@ -805,6 +1838,16 @@ "dev": true, "license": "(WTFPL OR MIT)" }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -820,9 +1863,9 @@ "license": "MIT" }, "node_modules/picomatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", - "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", "engines": { @@ -864,6 +1907,62 @@ "node": ">=18" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.9.6", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz", + "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qified": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz", + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^2.1.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/qified/node_modules/hookified": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz", + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==", + "dev": true, + "license": "MIT" + }, "node_modules/range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -897,9 +1996,9 @@ } }, "node_modules/rollup": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz", - "integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==", + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.1.tgz", + "integrity": "sha512-3Df9jsstwhccuEfmAMi9l8XUh/GOkVObmFTU7CCVBysEbcOZLl84jCtaAZMcPiMz2EGKsATzQcU+Xr3n/wU6cg==", "dev": true, "license": "MIT", "dependencies": { @@ -914,34 +2013,47 @@ }, "optionalDependencies": { "@napi-rs/lzma-linux-x64-gnu": "1.5.1", - "@rollup/rollup-android-arm-eabi": "4.62.4", - "@rollup/rollup-android-arm64": "4.62.4", - "@rollup/rollup-darwin-arm64": "4.62.4", - "@rollup/rollup-darwin-x64": "4.62.4", - "@rollup/rollup-freebsd-arm64": "4.62.4", - "@rollup/rollup-freebsd-x64": "4.62.4", - "@rollup/rollup-linux-arm-gnueabihf": "4.62.4", - "@rollup/rollup-linux-arm-musleabihf": "4.62.4", - "@rollup/rollup-linux-arm64-gnu": "4.62.4", - "@rollup/rollup-linux-arm64-musl": "4.62.4", - "@rollup/rollup-linux-loong64-gnu": "4.62.4", - "@rollup/rollup-linux-loong64-musl": "4.62.4", - "@rollup/rollup-linux-ppc64-gnu": "4.62.4", - "@rollup/rollup-linux-ppc64-musl": "4.62.4", - "@rollup/rollup-linux-riscv64-gnu": "4.62.4", - "@rollup/rollup-linux-riscv64-musl": "4.62.4", - "@rollup/rollup-linux-s390x-gnu": "4.62.4", - "@rollup/rollup-linux-x64-gnu": "4.62.4", - "@rollup/rollup-linux-x64-musl": "4.62.4", - "@rollup/rollup-openbsd-x64": "4.62.4", - "@rollup/rollup-openharmony-arm64": "4.62.4", - "@rollup/rollup-win32-arm64-msvc": "4.62.4", - "@rollup/rollup-win32-ia32-msvc": "4.62.4", - "@rollup/rollup-win32-x64-gnu": "4.62.4", - "@rollup/rollup-win32-x64-msvc": "4.62.4", + "@rollup/rollup-android-arm-eabi": "4.63.1", + "@rollup/rollup-android-arm64": "4.63.1", + "@rollup/rollup-darwin-arm64": "4.63.1", + "@rollup/rollup-darwin-x64": "4.63.1", + "@rollup/rollup-freebsd-arm64": "4.63.1", + "@rollup/rollup-freebsd-x64": "4.63.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.1", + "@rollup/rollup-linux-arm-musleabihf": "4.63.1", + "@rollup/rollup-linux-arm64-gnu": "4.63.1", + "@rollup/rollup-linux-arm64-musl": "4.63.1", + "@rollup/rollup-linux-loong64-gnu": "4.63.1", + "@rollup/rollup-linux-loong64-musl": "4.63.1", + "@rollup/rollup-linux-ppc64-gnu": "4.63.1", + "@rollup/rollup-linux-ppc64-musl": "4.63.1", + "@rollup/rollup-linux-riscv64-gnu": "4.63.1", + "@rollup/rollup-linux-riscv64-musl": "4.63.1", + "@rollup/rollup-linux-s390x-gnu": "4.63.1", + "@rollup/rollup-linux-x64-gnu": "4.63.1", + "@rollup/rollup-linux-x64-musl": "4.63.1", + "@rollup/rollup-openbsd-x64": "4.63.1", + "@rollup/rollup-openharmony-arm64": "4.63.1", + "@rollup/rollup-win32-arm64-msvc": "4.63.1", + "@rollup/rollup-win32-ia32-msvc": "4.63.1", + "@rollup/rollup-win32-x64-gnu": "4.63.1", + "@rollup/rollup-win32-x64-msvc": "4.63.1", "fsevents": "~2.3.2" } }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/serve-handler": { "version": "6.1.7", "resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.7.tgz", @@ -958,6 +2070,42 @@ "range-parser": "1.2.0" } }, + "node_modules/serve-handler/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -971,6 +2119,36 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -978,6 +2156,19 @@ "dev": true, "license": "0BSD" }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -991,6 +2182,79 @@ "engines": { "node": ">=14.17" } + }, + "node_modules/typescript-eslint": { + "version": "8.69.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.69.0.tgz", + "integrity": "sha512-B3MltX0VqjUBNEe3b3sSuiRbfa6XrfHFtBiPamjT5AsW/dfq+y+bc0wyuS9DxAS1LyzCxRp2+rxzpLUvqM2BvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.69.0", + "@typescript-eslint/parser": "8.69.0", + "@typescript-eslint/typescript-estree": "8.69.0", + "@typescript-eslint/utils": "8.69.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index 80ea564c..c8c59602 100644 --- a/package.json +++ b/package.json @@ -1,53 +1,62 @@ { - "name": "@appwrite.io/console", - "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": "16.0.0", - "license": "BSD-3-Clause", - "main": "dist/cjs/sdk.js", - "exports": { - ".": { - "import": "./dist/esm/sdk.js", - "require": "./dist/cjs/sdk.js", - "types": "./types/index.d.ts" + "name": "@appwrite.io/console", + "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": "16.1.0", + "license": "BSD-3-Clause", + "main": "dist/cjs/sdk.js", + "exports": { + ".": { + "import": "./dist/esm/sdk.js", + "require": "./dist/cjs/sdk.js", + "types": "./types/index.d.ts" + }, + "./package.json": "./package.json" }, - "./package.json": "./package.json" - }, - "module": "dist/esm/sdk.js", - "types": "types/index.d.ts", - "files": [ - "dist", - "types" - ], - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-console" - }, - "scripts": { - "build": "npm run build:types && npm run build:libs", - "build:types": "tsc --declaration --emitDeclarationOnly --outDir types", - "build:libs": "rollup -c" - }, - "engines": { - "node": ">=18.0.0" - }, - "dependencies": { - "json-bigint": "1.0.0" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "29.0.3", - "@rollup/plugin-node-resolve": "16.0.3", - "@rollup/plugin-typescript": "12.3.0", - "@types/json-bigint": "1.0.4", - "playwright": "1.56.1", - "rollup": "4.62.4", - "serve-handler": "6.1.7", - "tslib": "2.8.1", - "typescript": "5.9.3" - }, - "overrides": { - "brace-expansion": "5.0.9" - }, - "jsdelivr": "dist/iife/sdk.js", - "unpkg": "dist/iife/sdk.js" + "module": "dist/esm/sdk.js", + "types": "types/index.d.ts", + "files": [ + "dist", + "types" + ], + "repository": { + "type": "git", + "url": "https://github.com/appwrite/sdk-for-console" + }, + "scripts": { + "build": "npm run build:types && npm run build:libs", + "build:types": "tsc --declaration --emitDeclarationOnly --outDir types", + "build:libs": "rollup -c", + "format": "prettier --write .", + "format:check": "prettier --check .", + "lint": "eslint .", + "lint:fix": "eslint --fix .", + "analyse": "tsc --noEmit" + }, + "engines": { + "node": ">=18.0.0" + }, + "dependencies": { + "json-bigint": "1.0.0" + }, + "devDependencies": { + "@eslint/js": "10.0.1", + "@rollup/plugin-commonjs": "29.0.3", + "@rollup/plugin-node-resolve": "16.0.3", + "@rollup/plugin-typescript": "12.3.0", + "@types/json-bigint": "1.0.4", + "eslint": "10.10.0", + "playwright": "1.56.1", + "prettier": "3.9.6", + "rollup": "4.63.1", + "serve-handler": "6.1.7", + "tslib": "2.8.1", + "typescript": "5.9.3", + "typescript-eslint": "8.69.0" + }, + "overrides": { + "brace-expansion": "5.0.9" + }, + "jsdelivr": "dist/iife/sdk.js", + "unpkg": "dist/iife/sdk.js" } diff --git a/rollup.config.mjs b/rollup.config.mjs index eabf435c..0d5864b6 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,44 +1,44 @@ -import { readFileSync } from "fs"; -const pkg = JSON.parse(readFileSync("./package.json", "utf8")); -import typescript from "@rollup/plugin-typescript"; -import resolve from "@rollup/plugin-node-resolve"; -import commonjs from "@rollup/plugin-commonjs"; +import { readFileSync } from 'fs'; +const pkg = JSON.parse(readFileSync('./package.json', 'utf8')); +import typescript from '@rollup/plugin-typescript'; +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; const external = Object.keys(pkg.dependencies ?? {}); export default [ { - input: "src/index.ts", + input: 'src/index.ts', external, - plugins: [typescript({ outDir: "dist" })], + plugins: [typescript({ outDir: 'dist' })], output: [ { - format: "cjs", + format: 'cjs', file: pkg.main, esModule: false, sourcemap: true, }, { - format: "es", + format: 'es', file: pkg.module, sourcemap: true, }, ], }, { - input: "src/index.ts", + input: 'src/index.ts', plugins: [ resolve({ browser: true }), commonjs(), - typescript({ outDir: "dist" }) + typescript({ outDir: 'dist' }), ], output: [ { - format: "iife", + format: 'iife', file: pkg.jsdelivr, - name: "Appwrite", + name: 'Appwrite', extend: true, }, ], - } + }, ]; diff --git a/src/channel.ts b/src/channel.ts index d4618a36..b4a55092 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -1,167 +1,201 @@ -interface Root {} -interface Database { _db: any } -interface Collection { _coll: any } -interface Document { _doc: any } -interface TablesDB { _tdb: any } -interface Table { _tbl: any } -interface Row { _row: any } -interface Bucket { _bkt: any } -interface File { _file: any } -interface Func { _fn: any } -interface Execution { _exec: any } -interface Team { _team: any } -interface Membership { _mem: any } -interface Presence { _presence: any } -interface Resolved { _res: any } +interface Database { + _db: any; +} +interface Collection { + _coll: any; +} +interface Document { + _doc: any; +} +interface TablesDB { + _tdb: any; +} +interface Table { + _tbl: any; +} +interface Row { + _row: any; +} +interface Bucket { + _bkt: any; +} +interface File { + _file: any; +} +interface Func { + _fn: any; +} +interface Execution { + _exec: any; +} +interface Team { + _team: any; +} +interface Membership { + _mem: any; +} +interface Presence { + _presence: any; +} +interface Resolved { + _res: any; +} type Actionable = Document | Row | File | Team | Membership | Presence; function normalize(id: string): string { - if (id === undefined || id === null) { - throw new Error("Channel ID is required"); - } - const trimmed = String(id).trim(); - if (trimmed === "") { - throw new Error("Channel ID is required"); - } - return trimmed; + if (id === undefined || id === null) { + throw new Error('Channel ID is required'); + } + const trimmed = String(id).trim(); + if (trimmed === '') { + throw new Error('Channel ID is required'); + } + return trimmed; } export class Channel { - declare _type: T; - - private constructor(private readonly segments: string[]) {} - - private next(segment: string, id?: string): Channel { - const segments = - id === undefined - ? [...this.segments, segment] - : [...this.segments, segment, normalize(id)]; - - return new Channel(segments) as any; - } - - private resolve(action: string): Channel { - return new Channel([...this.segments, action]) as any; - } - - toString(): string { - return this.segments.join("."); - } - - // --- DATABASE ROUTE --- - // Only available on Channel - collection(this: Channel, id: string): Channel { - return this.next("collections", id); - } - - // Only available on Channel - document(this: Channel, id?: string): Channel { - // Default: no document ID segment - return this.next("documents", id); - } - - // --- TABLESDB ROUTE --- - table(this: Channel, id: string): Channel { - return this.next
("tables", id); - } - - row(this: Channel
, id?: string): Channel { - // Default: no row ID segment - return this.next("rows", id); - } - - // --- BUCKET ROUTE --- - file(this: Channel, id?: string): Channel { - // Default: no file ID segment - return this.next("files", id); - } - - // --- TERMINAL ACTIONS --- - // Restricted to the Actionable union - create(this: Channel): Channel { - return this.resolve("create"); - } - - upsert(this: Channel): Channel { - return this.resolve("upsert"); - } - - update(this: Channel): Channel { - return this.resolve("update"); - } - - delete(this: Channel): Channel { - return this.resolve("delete"); - } - - // --- ROOT FACTORIES --- - static database(id: string) { - return new Channel(["databases", normalize(id)]); - } - - static execution(id: string) { - return new Channel(["executions", normalize(id)]); - } - - static tablesdb(id: string) { - return new Channel(["tablesdb", normalize(id)]); - } - - static bucket(id: string) { - return new Channel(["buckets", normalize(id)]); - } - - static function(id: string) { - return new Channel(["functions", normalize(id)]); - } - - static team(id: string) { - return new Channel(["teams", normalize(id)]); - } - - static membership(id: string) { - return new Channel(["memberships", normalize(id)]); - } - - static presence(id: string) { - return new Channel(["presences", normalize(id)]); - } - - static account(): string { - return "account"; - } - - // Global events - static documents(): string { - return "documents"; - } - - static rows(): string { - return "rows"; - } - - static files(): string { - return "files"; - } - - static executions(): string { - return "executions"; - } - - static teams(): string { - return "teams"; - } - - static memberships(): string { - return "memberships"; - } - - static presences(): string { - return "presences"; - } + declare _type: T; + + private constructor(private readonly segments: string[]) {} + + private next(segment: string, id?: string): Channel { + const segments = + id === undefined + ? [...this.segments, segment] + : [...this.segments, segment, normalize(id)]; + + return new Channel(segments) as any; + } + + private resolve(action: string): Channel { + return new Channel([...this.segments, action]) as any; + } + + toString(): string { + return this.segments.join('.'); + } + + // --- DATABASE ROUTE --- + // Only available on Channel + collection(this: Channel, id: string): Channel { + return this.next('collections', id); + } + + // Only available on Channel + document(this: Channel, id?: string): Channel { + // Default: no document ID segment + return this.next('documents', id); + } + + // --- TABLESDB ROUTE --- + table(this: Channel, id: string): Channel
{ + return this.next
('tables', id); + } + + row(this: Channel
, id?: string): Channel { + // Default: no row ID segment + return this.next('rows', id); + } + + // --- BUCKET ROUTE --- + file(this: Channel, id?: string): Channel { + // Default: no file ID segment + return this.next('files', id); + } + + // --- TERMINAL ACTIONS --- + // Restricted to the Actionable union + create(this: Channel): Channel { + return this.resolve('create'); + } + + upsert(this: Channel): Channel { + return this.resolve('upsert'); + } + + update(this: Channel): Channel { + return this.resolve('update'); + } + + delete(this: Channel): Channel { + return this.resolve('delete'); + } + + // --- ROOT FACTORIES --- + static database(id: string) { + return new Channel(['databases', normalize(id)]); + } + + static execution(id: string) { + return new Channel(['executions', normalize(id)]); + } + + static tablesdb(id: string) { + return new Channel(['tablesdb', normalize(id)]); + } + + static bucket(id: string) { + return new Channel(['buckets', normalize(id)]); + } + + static function(id: string) { + return new Channel(['functions', normalize(id)]); + } + + static team(id: string) { + return new Channel(['teams', normalize(id)]); + } + + static membership(id: string) { + return new Channel(['memberships', normalize(id)]); + } + + static presence(id: string) { + return new Channel(['presences', normalize(id)]); + } + + static account(): string { + return 'account'; + } + + // Global events + static documents(): string { + return 'documents'; + } + + static rows(): string { + return 'rows'; + } + + static files(): string { + return 'files'; + } + + static executions(): string { + return 'executions'; + } + + static teams(): string { + return 'teams'; + } + + static memberships(): string { + return 'memberships'; + } + + static presences(): string { + return 'presences'; + } } // Export types for backward compatibility with realtime -export type ActionableChannel = Channel | Channel | Channel | Channel | Channel | Channel | Channel; +export type ActionableChannel = + | Channel + | Channel + | Channel + | Channel + | Channel + | Channel + | Channel; export type ResolvedChannel = Channel; diff --git a/src/client.ts b/src/client.ts index 4e3ffb1d..7f973722 100644 --- a/src/client.ts +++ b/src/client.ts @@ -12,12 +12,14 @@ const MAX_INT64 = BigInt('9223372036854775807'); const MIN_INT64 = BigInt('-9223372036854775808'); function isBigNumber(value: any): boolean { - return value !== null - && typeof value === 'object' - && value._isBigNumber === true - && typeof value.isInteger === 'function' - && typeof value.toFixed === 'function' - && typeof value.toNumber === 'function'; + return ( + value !== null && + typeof value === 'object' && + value._isBigNumber === true && + typeof value.isInteger === 'function' && + typeof value.toFixed === 'function' && + typeof value.toNumber === 'function' + ); } function reviver(_key: string, value: any): any { @@ -40,7 +42,7 @@ function reviver(_key: string, value: any): any { export const JSONbig = { parse: (text: string) => JSONbigParser.parse(text, reviver), - stringify: JSONbigSerializer.stringify + stringify: JSONbigSerializer.stringify, }; /** @@ -48,14 +50,14 @@ export const JSONbig = { */ type Payload = { [key: string]: any; -} +}; /** * Headers type representing a key-value pair with string keys and string values. */ type Headers = { [key: string]: string; -} +}; /** * Realtime response structure with different types. @@ -69,8 +71,13 @@ type RealtimeResponse = { /** * Data associated with the response based on the response type. */ - data: RealtimeResponseAuthenticated | RealtimeResponseConnected | RealtimeResponseError | RealtimeResponseEvent | undefined; -} + data: + | RealtimeResponseAuthenticated + | RealtimeResponseConnected + | RealtimeResponseError + | RealtimeResponseEvent + | undefined; +}; /** * Realtime request structure for authentication. @@ -85,18 +92,18 @@ type RealtimeRequest = { * Data required for authentication. */ data: RealtimeRequestAuthenticate | RealtimeRequestSubscribe[]; -} +}; type RealtimeRequestSubscribe = { subscriptionId: string; channels: string[]; queries: string[]; -} +}; /** * Realtime event response structure with generic payload type. */ -type RealtimeResponseEvent = { +type RealtimeResponseEvent = { /** * List of event names associated with the response. */ @@ -121,7 +128,7 @@ type RealtimeResponseEvent = { * Subscription IDs this event matches (from backend, optional). */ subscriptions?: string[]; -} +}; /** * Realtime response structure for errors. @@ -136,7 +143,7 @@ type RealtimeResponseError = { * Error message describing the encountered error. */ message: string; -} +}; /** * Realtime response structure for a successful connection. @@ -151,7 +158,7 @@ type RealtimeResponseConnected = { * User object representing the connected user (optional). */ user?: object; -} +}; /** * Realtime response structure for authenticated connections. @@ -171,7 +178,7 @@ type RealtimeResponseAuthenticated = { * User object representing the authenticated user. */ user: object; -} +}; /** * Realtime request structure for authentication. @@ -181,7 +188,7 @@ type RealtimeRequestAuthenticate = { * Session identifier for authentication. */ session: string; -} +}; type TimeoutHandle = ReturnType | number; @@ -201,7 +208,7 @@ type Realtime = { /** * Heartbeat interval for the realtime connection. - */ + */ heartbeat?: TimeoutHandle; /** @@ -222,11 +229,14 @@ type Realtime = { /** * Map of subscriptions keyed by client-generated subscriptionId. */ - subscriptions: Map) => void - }>; + subscriptions: Map< + string, + { + channels: string[]; + queries: string[]; + callback: (payload: RealtimeResponseEvent) => void; + } + >; /** * Pending subscribe rows keyed by subscriptionId. Flushed and cleared on each send. @@ -271,7 +281,7 @@ type Realtime = { * @param {MessageEvent} event - Event containing the received message. */ onMessage: (event: MessageEvent) => void; -} +}; /** * Type representing upload progress information. @@ -301,7 +311,7 @@ type UploadProgress = { * Number of chunks that have been successfully uploaded. */ chunksUploaded: number; -} +}; /** * Exception thrown by the package @@ -331,7 +341,12 @@ class AppwriteException extends Error { * @param {string} type - The error type. Default is an empty string. * @param {string} response - The response string. Default is an empty string. */ - constructor(message: string, code: number = 0, type: string = '', response: string = '') { + constructor( + message: string, + code: number = 0, + type: string = '', + response: string = '', + ) { super(message); this.name = 'AppwriteException'; this.message = message; @@ -396,8 +411,8 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '16.0.0', - 'X-Appwrite-Response-Format': '1.9.6', + 'x-sdk-version': '16.1.0', + 'X-Appwrite-Response-Format': '2.0.0', }; /** @@ -426,12 +441,17 @@ class Client { throw new AppwriteException('Endpoint must be a valid string'); } - if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) { + if ( + !endpoint.startsWith('http://') && + !endpoint.startsWith('https://') + ) { throw new AppwriteException('Invalid endpoint URL: ' + endpoint); } this.config.endpoint = endpoint; - this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://'); + this.config.endpointRealtime = endpoint + .replace('https://', 'wss://') + .replace('http://', 'ws://'); return this; } @@ -448,8 +468,13 @@ class Client { throw new AppwriteException('Endpoint must be a valid string'); } - if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) { - throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime); + if ( + !endpointRealtime.startsWith('ws://') && + !endpointRealtime.startsWith('wss://') + ) { + throw new AppwriteException( + 'Invalid realtime endpoint URL: ' + endpointRealtime, + ); } this.config.endpointRealtime = endpointRealtime; @@ -487,15 +512,21 @@ class Client { case 'include': return true; case 'same-origin': { - if (typeof window === 'undefined' || typeof url === 'undefined') { + if ( + typeof window === 'undefined' || + typeof url === 'undefined' + ) { return false; } try { - const parsedUrl = typeof url === 'string' ? new URL(url) : url; - const normalizedOrigin = parsedUrl.protocol === 'wss:' || parsedUrl.protocol === 'ws:' - ? `${parsedUrl.protocol === 'wss:' ? 'https:' : 'http:'}//${parsedUrl.host}` - : parsedUrl.origin; + const parsedUrl = + typeof url === 'string' ? new URL(url) : url; + const normalizedOrigin = + parsedUrl.protocol === 'wss:' || + parsedUrl.protocol === 'ws:' + ? `${parsedUrl.protocol === 'wss:' ? 'https:' : 'http:'}//${parsedUrl.host}` + : parsedUrl.origin; return normalizedOrigin === window.location.origin; } catch { @@ -735,9 +766,11 @@ class Client { } this.realtime.heartbeat = window?.setInterval(() => { - this.realtime.socket?.send(JSONbig.stringify({ - type: 'ping' - })); + this.realtime.socket?.send( + JSONbig.stringify({ + type: 'ping', + }), + ); }, 20_000); }, createSocket: () => { @@ -747,15 +780,19 @@ class Client { return; } - const encodedProject = encodeURIComponent((this.config.project as string) ?? ''); + const encodedProject = encodeURIComponent( + (this.config.project as string) ?? '', + ); // URL carries only the project; channels/queries are sent via subscribe message. let queryParams = 'project=' + encodedProject; if (this.config.jwt) { - queryParams += '&jwt=' + encodeURIComponent(this.config.jwt as string); + queryParams += + '&jwt=' + encodeURIComponent(this.config.jwt as string); } - const url = this.config.endpointRealtime + '/realtime?' + queryParams; + const url = + this.config.endpointRealtime + '/realtime?' + queryParams; if ( url !== this.realtime.url || // Check if URL is present @@ -772,37 +809,46 @@ class Client { this.realtime.url = url; this.realtime.socket = new WebSocket(url); - this.realtime.socket.addEventListener('message', this.realtime.onMessage); - this.realtime.socket.addEventListener('open', _event => { + this.realtime.socket.addEventListener( + 'message', + this.realtime.onMessage, + ); + this.realtime.socket.addEventListener('open', (_event) => { this.realtime.reconnectAttempts = 0; this.realtime.createHeartbeat(); }); - this.realtime.socket.addEventListener('close', event => { + this.realtime.socket.addEventListener('close', (event) => { if ( !this.realtime.reconnect || - ( - this.realtime?.lastMessage?.type === 'error' && // Check if last message was of type error - (this.realtime?.lastMessage.data).code === 1008 // Check for policy violation 1008 - ) + (this.realtime?.lastMessage?.type === 'error' && // Check if last message was of type error + (( + this.realtime?.lastMessage.data + )).code === 1008) // Check for policy violation 1008 ) { this.realtime.reconnect = true; return; } const timeout = this.realtime.getTimeout(); - console.error(`Realtime got disconnected. Reconnect will be attempted in ${timeout / 1000} seconds.`, event.reason); + console.error( + `Realtime got disconnected. Reconnect will be attempted in ${timeout / 1000} seconds.`, + event.reason, + ); setTimeout(() => { this.realtime.reconnectAttempts++; this.realtime.createSocket(); }, timeout); - }) + }); } else if (this.realtime.socket?.readyState === WebSocket.OPEN) { this.realtime.sendPendingSubscribes(); } }, sendPendingSubscribes: () => { - if (!this.realtime.socket || this.realtime.socket.readyState !== WebSocket.OPEN) { + if ( + !this.realtime.socket || + this.realtime.socket.readyState !== WebSocket.OPEN + ) { return; } @@ -813,10 +859,12 @@ class Client { const rows = Array.from(this.realtime.pendingSubscribes.values()); this.realtime.pendingSubscribes.clear(); - this.realtime.socket.send(JSONbig.stringify({ - type: 'subscribe', - data: rows - })); + this.realtime.socket.send( + JSONbig.stringify({ + type: 'subscribe', + data: rows, + }), + ); }, onMessage: (event) => { try { @@ -824,31 +872,49 @@ class Client { this.realtime.lastMessage = message; switch (message.type) { case 'connected': { - const messageData = message.data; + const messageData = ( + message.data + ); - if (this.shouldUseFallbackCredentials(this.realtime.url)) { + if ( + this.shouldUseFallbackCredentials(this.realtime.url) + ) { let session = this.config.session; if (!session) { - const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}'); - session = cookie?.[`a_session_${this.config.project}`]; + const cookie = JSONbig.parse( + window.localStorage.getItem( + 'cookieFallback', + ) ?? '{}', + ); + session = + cookie?.[ + `a_session_${this.config.project}` + ]; } if (session && !messageData?.user) { - this.realtime.socket?.send(JSONbig.stringify({ - type: 'authentication', - data: { - session - } - })); + this.realtime.socket?.send( + JSONbig.stringify({ + type: 'authentication', + data: { + session, + }, + }), + ); } } - this.realtime.subscriptions.forEach((sub, subscriptionId) => { - this.realtime.pendingSubscribes.set(subscriptionId, { - subscriptionId, - channels: sub.channels, - queries: sub.queries ?? [] - }); - }); + this.realtime.subscriptions.forEach( + (sub, subscriptionId) => { + this.realtime.pendingSubscribes.set( + subscriptionId, + { + subscriptionId, + channels: sub.channels, + queries: sub.queries ?? [], + }, + ); + }, + ); this.realtime.sendPendingSubscribes(); break; } @@ -858,25 +924,44 @@ class Client { // the SDK needs to reconcile. break; case 'event': { - const data = >message.data; + const data = >( + message.data + ); if (!data?.channels) break; const eventSubIds = data.subscriptions; if (eventSubIds && eventSubIds.length > 0) { for (const subscriptionId of eventSubIds) { - const subscription = this.realtime.subscriptions.get(subscriptionId); + const subscription = + this.realtime.subscriptions.get( + subscriptionId, + ); if (subscription) { - setTimeout(() => subscription.callback(data)); + setTimeout(() => + subscription.callback(data), + ); } } } else { - const isSubscribed = data.channels.some(channel => this.realtime.channels.has(channel)); + const isSubscribed = data.channels.some((channel) => + this.realtime.channels.has(channel), + ); if (!isSubscribed) break; - this.realtime.subscriptions.forEach(subscription => { - if (data.channels.some(channel => subscription.channels.includes(channel))) { - setTimeout(() => subscription.callback(data)); - } - }); + this.realtime.subscriptions.forEach( + (subscription) => { + if ( + data.channels.some((channel) => + subscription.channels.includes( + channel, + ), + ) + ) { + setTimeout(() => + subscription.callback(data), + ); + } + }, + ); } break; } @@ -890,8 +975,8 @@ class Client { } catch (e) { console.error(e); } - } - } + }, + }; /** * Subscribes to Appwrite events and passes you the payload in realtime. @@ -918,7 +1003,7 @@ class Client { * - teams.[ID] * - memberships * - memberships.[ID] - * + * * You can also use Channel builders: * - Channel.database('db').collection('col').document('doc').create() * - Channel.bucket('bucket').file('file').update() @@ -928,14 +1013,20 @@ class Client { * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update. * @returns {() => void} Unsubscribes from events. */ - subscribe( - channels: string | string[] | Channel | ActionableChannel | ResolvedChannel | (Channel | ActionableChannel | ResolvedChannel)[], + subscribe( + channels: + | string + | string[] + | Channel + | ActionableChannel + | ResolvedChannel + | (Channel | ActionableChannel | ResolvedChannel)[], callback: (payload: RealtimeResponseEvent) => void, - queries: (string | Query)[] = [] + queries: (string | Query)[] = [], ): () => void { const channelArray = Array.isArray(channels) ? channels : [channels]; // Convert Channel instances to strings - const channelStrings = channelArray.map(ch => { + const channelStrings = channelArray.map((ch) => { if (typeof ch === 'string') { return ch; } @@ -946,9 +1037,13 @@ class Client { // Fallback to generic string conversion return String(ch); }); - channelStrings.forEach(channel => this.realtime.channels.add(channel)); + channelStrings.forEach((channel) => + this.realtime.channels.add(channel), + ); - const queryStrings = (queries ?? []).map(q => typeof q === 'string' ? q : q.toString()); + const queryStrings = (queries ?? []).map((q) => + typeof q === 'string' ? q : q.toString(), + ); let subscriptionId = ''; const attempts = this.realtime.subscriptions.size + 1; @@ -960,17 +1055,19 @@ class Client { } } if (subscriptionId === '') { - throw new AppwriteException('Failed to generate unique subscription id'); + throw new AppwriteException( + 'Failed to generate unique subscription id', + ); } this.realtime.subscriptions.set(subscriptionId, { channels: channelStrings, queries: queryStrings, - callback + callback, }); this.realtime.pendingSubscribes.set(subscriptionId, { subscriptionId, channels: channelStrings, - queries: queryStrings + queries: queryStrings, }); this.realtime.connect(); @@ -979,31 +1076,41 @@ class Client { this.realtime.subscriptions.delete(subscriptionId); this.realtime.pendingSubscribes.delete(subscriptionId); const stillUsed = new Set(); - this.realtime.subscriptions.forEach(sub => { - sub.channels.forEach(channel => stillUsed.add(channel)); + this.realtime.subscriptions.forEach((sub) => { + sub.channels.forEach((channel) => stillUsed.add(channel)); }); - this.realtime.channels.forEach(channel => { + this.realtime.channels.forEach((channel) => { if (!stillUsed.has(channel)) { this.realtime.channels.delete(channel); } }); this.realtime.connect(); - } + }; } - prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } { + prepareRequest( + method: string, + url: URL, + headers: Headers = {}, + params: Payload = {}, + ): { uri: string; options: RequestInit } { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); - if (typeof window !== 'undefined' && window.localStorage && this.shouldUseFallbackCredentials(url)) { - const cookieFallback = window.localStorage.getItem('cookieFallback'); + if ( + typeof window !== 'undefined' && + window.localStorage && + this.shouldUseFallbackCredentials(url) + ) { + const cookieFallback = + window.localStorage.getItem('cookieFallback'); if (cookieFallback) { headers['X-Fallback-Cookies'] = cookieFallback; } } - let options: RequestInit = { + const options: RequestInit = { method, headers, }; @@ -1022,7 +1129,7 @@ class Client { options.body = JSONbig.stringify(params); break; - case 'multipart/form-data': + case 'multipart/form-data': { const formData = new FormData(); for (const [key, value] of Object.entries(params)) { @@ -1040,14 +1147,24 @@ class Client { options.body = formData; delete headers['content-type']; break; + } } } return { uri: url.toString(), options }; } - async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { - const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? []; + async chunkedUpload( + method: string, + url: URL, + headers: Headers = {}, + originalPayload: Payload = {}, + onProgress: (progress: UploadProgress) => void, + ) { + const [fileParam, file] = + Object.entries(originalPayload).find( + ([_, value]) => value instanceof File, + ) ?? []; if (!file || !fileParam) { throw new Error('File not found in payload'); @@ -1061,12 +1178,20 @@ class Client { // Upload first chunk alone to get the upload ID const firstChunkEnd = Math.min(Client.CHUNK_SIZE, file.size); - const firstChunkHeaders = { ...headers, 'content-range': `bytes 0-${firstChunkEnd - 1}/${file.size}` }; + const firstChunkHeaders = { + ...headers, + 'content-range': `bytes 0-${firstChunkEnd - 1}/${file.size}`, + }; const firstChunk = file.slice(0, firstChunkEnd); const firstPayload = { ...originalPayload }; firstPayload[fileParam] = new File([firstChunk], file.name); - let response = await this.call(method, url, firstChunkHeaders, firstPayload); + const response = await this.call( + method, + url, + firstChunkHeaders, + firstPayload, + ); const uploadId = response?.$id; if (onProgress && typeof onProgress === 'function') { @@ -1075,7 +1200,7 @@ class Client { progress: Math.round((firstChunkEnd / file.size) * 100), sizeUploaded: firstChunkEnd, chunksTotal: totalChunks, - chunksUploaded: 1 + chunksUploaded: 1, }); } @@ -1102,29 +1227,39 @@ class Client { const isUploadComplete = (chunkResponse: any) => { const chunksUploaded = chunkResponse?.chunksUploaded; const chunksTotal = chunkResponse?.chunksTotal ?? totalChunks; - return typeof chunksUploaded === 'number' && typeof chunksTotal === 'number' && chunksUploaded >= chunksTotal; + return ( + typeof chunksUploaded === 'number' && + typeof chunksTotal === 'number' && + chunksUploaded >= chunksTotal + ); }; - const uploadChunk = async (chunk: typeof chunks[0]) => { + const uploadChunk = async (chunk: (typeof chunks)[0]) => { const chunkHeaders = { ...headers }; if (uploadId) { chunkHeaders['x-appwrite-id'] = uploadId; } - chunkHeaders['content-range'] = `bytes ${chunk.start}-${chunk.end - 1}/${file.size}`; - + chunkHeaders['content-range'] = + `bytes ${chunk.start}-${chunk.end - 1}/${file.size}`; + const chunkBlob = file.slice(chunk.start, chunk.end); const chunkPayload = { ...originalPayload }; chunkPayload[fileParam] = new File([chunkBlob], file.name); - const chunkResponse = await this.call(method, url, chunkHeaders, chunkPayload); + const chunkResponse = await this.call( + method, + url, + chunkHeaders, + chunkPayload, + ); if (rejected) { return chunkResponse; } - + completedCount++; - uploadedBytes += (chunk.end - chunk.start); - + uploadedBytes += chunk.end - chunk.start; + lastResponse = chunkResponse; if (isUploadComplete(chunkResponse)) { finalResponse = chunkResponse; @@ -1136,7 +1271,7 @@ class Client { progress: Math.round((uploadedBytes / file.size) * 100), sizeUploaded: uploadedBytes, chunksTotal: totalChunks, - chunksUploaded: completedCount + chunksUploaded: completedCount, }); } @@ -1184,12 +1319,23 @@ class Client { async ping(): Promise { return this.call('GET', new URL(this.config.endpoint + '/ping'), { 'X-Appwrite-Project': this.config.project, - 'accept': 'application/json', + accept: 'application/json', }); } - async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { - const { uri, options } = this.prepareRequest(method, url, headers, params); + async call( + method: string, + url: URL, + headers: Headers = {}, + params: Payload = {}, + responseType = 'json', + ): Promise { + const { uri, options } = this.prepareRequest( + method, + url, + headers, + params, + ); let data: any = null; @@ -1200,40 +1346,63 @@ class Client { throw new AppwriteException( `Invalid Origin. Register your new client (${window.location.host}) as a new Web platform on your project console dashboard`, 403, - "forbidden", - "" + 'forbidden', + '', ); } const warnings = response.headers.get('x-appwrite-warning'); if (warnings) { - warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning)); + warnings + .split(';') + .forEach((warning: string) => + console.warn('Warning: ' + warning), + ); } - if (response.headers.get('content-type')?.includes('application/json')) { + if ( + response.headers.get('content-type')?.includes('application/json') + ) { data = JSONbig.parse(await response.text()); } else if (responseType === 'arrayBuffer') { data = await response.arrayBuffer(); } else { data = { - message: await response.text() + message: await response.text(), }; } if (400 <= response.status) { - let responseText = ''; - if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') { + let responseText: string; + if ( + response.headers + .get('content-type') + ?.includes('application/json') || + responseType === 'arrayBuffer' + ) { responseText = JSONbig.stringify(data); } else { responseText = data?.message; } - throw new AppwriteException(data?.message ?? responseText, response.status, data?.type, responseText); + throw new AppwriteException( + data?.message ?? responseText, + response.status, + data?.type, + responseText, + ); } const cookieFallback = response.headers.get('X-Fallback-Cookies'); - if (typeof window !== 'undefined' && window.localStorage && cookieFallback && this.shouldUseFallbackCredentials(url)) { - window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.'); + if ( + typeof window !== 'undefined' && + window.localStorage && + cookieFallback && + this.shouldUseFallbackCredentials(url) + ) { + window.console.warn( + 'Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.', + ); window.localStorage.setItem('cookieFallback', cookieFallback); } @@ -1253,7 +1422,7 @@ class Client { let output: Payload = {}; for (const [key, value] of Object.entries(data)) { - let finalKey = prefix ? prefix + '[' + key +']' : key; + const finalKey = prefix ? prefix + '[' + key + ']' : key; if (Array.isArray(value)) { output = { ...output, ...Client.flatten(value, finalKey) }; } else { diff --git a/src/enums/account-key-scopes.ts b/src/enums/account-key-scopes.ts index ef159baf..eba747aa 100644 --- a/src/enums/account-key-scopes.ts +++ b/src/enums/account-key-scopes.ts @@ -2,4 +2,4 @@ export enum AccountKeyScopes { Account = 'account', TeamsRead = 'teams.read', TeamsWrite = 'teams.write', -} \ No newline at end of file +} diff --git a/src/enums/adapter.ts b/src/enums/adapter.ts index a3b1ae0c..ff6b3f42 100644 --- a/src/enums/adapter.ts +++ b/src/enums/adapter.ts @@ -1,4 +1,4 @@ export enum Adapter { Static = 'static', Ssr = 'ssr', -} \ No newline at end of file +} diff --git a/src/enums/addon.ts b/src/enums/addon-key.ts similarity index 84% rename from src/enums/addon.ts rename to src/enums/addon-key.ts index 04dbfbd0..7de5d934 100644 --- a/src/enums/addon.ts +++ b/src/enums/addon-key.ts @@ -1,6 +1,6 @@ -export enum Addon { +export enum AddonKey { Baa = 'baa', Premiumgeodb = 'premiumgeodb', Premiumgeodborg = 'premiumgeodborg', BackupRecovery = 'backup_recovery', -} \ No newline at end of file +} diff --git a/src/enums/appwrite-migration-resource.ts b/src/enums/appwrite-migration-resource.ts index 0ce6d078..2f7829ba 100644 --- a/src/enums/appwrite-migration-resource.ts +++ b/src/enums/appwrite-migration-resource.ts @@ -38,4 +38,4 @@ export enum AppwriteMigrationResource { Projectservices = 'project-services', Projectemailtemplate = 'project-email-template', Rule = 'rule', -} \ No newline at end of file +} diff --git a/src/enums/attribute-status.ts b/src/enums/attribute-status.ts index ade1d36a..43f788fa 100644 --- a/src/enums/attribute-status.ts +++ b/src/enums/attribute-status.ts @@ -4,4 +4,4 @@ export enum AttributeStatus { Deleting = 'deleting', Stuck = 'stuck', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/authentication-factor.ts b/src/enums/authentication-factor.ts index 928c4074..d16c3fe5 100644 --- a/src/enums/authentication-factor.ts +++ b/src/enums/authentication-factor.ts @@ -3,4 +3,5 @@ export enum AuthenticationFactor { Phone = 'phone', Totp = 'totp', Recoverycode = 'recoverycode', -} \ No newline at end of file + Custom = 'custom', +} diff --git a/src/enums/authenticator-type.ts b/src/enums/authenticator-type.ts index 34db0cca..0c918278 100644 --- a/src/enums/authenticator-type.ts +++ b/src/enums/authenticator-type.ts @@ -1,3 +1,3 @@ export enum AuthenticatorType { Totp = 'totp', -} \ No newline at end of file +} diff --git a/src/enums/backup-services.ts b/src/enums/backup-services.ts index adef40d2..c95b851a 100644 --- a/src/enums/backup-services.ts +++ b/src/enums/backup-services.ts @@ -6,4 +6,4 @@ export enum BackupServices { DedicatedDatabases = 'dedicatedDatabases', Functions = 'functions', Storage = 'storage', -} \ No newline at end of file +} diff --git a/src/enums/billing-plan-group.ts b/src/enums/billing-plan-group.ts index 8aa025b3..e8cd15d8 100644 --- a/src/enums/billing-plan-group.ts +++ b/src/enums/billing-plan-group.ts @@ -2,4 +2,4 @@ export enum BillingPlanGroup { Starter = 'starter', Pro = 'pro', Scale = 'scale', -} \ No newline at end of file +} diff --git a/src/enums/block-mode.ts b/src/enums/block-mode.ts index ea179cc2..a2f7af62 100644 --- a/src/enums/block-mode.ts +++ b/src/enums/block-mode.ts @@ -1,4 +1,4 @@ export enum BlockMode { Full = 'full', Readonly = 'readonly', -} \ No newline at end of file +} diff --git a/src/enums/block-resource-type.ts b/src/enums/block-resource-type.ts index 1db8a7cc..e689c2a4 100644 --- a/src/enums/block-resource-type.ts +++ b/src/enums/block-resource-type.ts @@ -8,4 +8,4 @@ export enum BlockResourceType { Topics = 'topics', Subscribers = 'subscribers', Messages = 'messages', -} \ No newline at end of file +} diff --git a/src/enums/browser-permission.ts b/src/enums/browser-permission.ts index 6e2c4cda..a670a6e0 100644 --- a/src/enums/browser-permission.ts +++ b/src/enums/browser-permission.ts @@ -19,4 +19,4 @@ export enum BrowserPermission { Screenwakelock = 'screen-wake-lock', Webshare = 'web-share', Xrspatialtracking = 'xr-spatial-tracking', -} \ No newline at end of file +} diff --git a/src/enums/browser-theme.ts b/src/enums/browser-theme.ts index 9f8c382a..acb8d578 100644 --- a/src/enums/browser-theme.ts +++ b/src/enums/browser-theme.ts @@ -1,4 +1,4 @@ export enum BrowserTheme { Light = 'light', Dark = 'dark', -} \ No newline at end of file +} diff --git a/src/enums/browser.ts b/src/enums/browser.ts index cec52fb6..78762163 100644 --- a/src/enums/browser.ts +++ b/src/enums/browser.ts @@ -13,4 +13,4 @@ export enum Browser { OperaMini = 'om', Opera = 'op', OperaNext = 'on', -} \ No newline at end of file +} diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 50f152ac..2dfd9c61 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -50,6 +50,7 @@ export enum BuildRuntime { Dart310 = 'dart-3.10', Dart311 = 'dart-3.11', Dart312 = 'dart-3.12', + Dart313 = 'dart-3.13', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -77,6 +78,7 @@ export enum BuildRuntime { Bun11 = 'bun-1.1', Bun12 = 'bun-1.2', Bun13 = 'bun-1.3', + Bun14 = 'bun-1.4', Go123 = 'go-1.23', Go124 = 'go-1.24', Go125 = 'go-1.25', @@ -91,4 +93,5 @@ export enum BuildRuntime { Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', Flutter344 = 'flutter-3.44', -} \ No newline at end of file + Flutter347 = 'flutter-3.47', +} diff --git a/src/enums/cache-database.ts b/src/enums/cache-database.ts index 47a06a6b..936ed1e5 100644 --- a/src/enums/cache-database.ts +++ b/src/enums/cache-database.ts @@ -2,4 +2,4 @@ export enum CacheDatabase { Console = 'console', Project = 'project', Logs = 'logs', -} \ No newline at end of file +} diff --git a/src/enums/cache-target.ts b/src/enums/cache-target.ts index b6d74b56..edef428c 100644 --- a/src/enums/cache-target.ts +++ b/src/enums/cache-target.ts @@ -5,4 +5,4 @@ export enum CacheTarget { Pubsub = 'pubsub', Queue = 'queue', All = 'all', -} \ No newline at end of file +} diff --git a/src/enums/column-status.ts b/src/enums/column-status.ts index f53e8a66..934872ec 100644 --- a/src/enums/column-status.ts +++ b/src/enums/column-status.ts @@ -4,4 +4,4 @@ export enum ColumnStatus { Deleting = 'deleting', Stuck = 'stuck', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/compression.ts b/src/enums/compression.ts index 1bec0e78..79d297c3 100644 --- a/src/enums/compression.ts +++ b/src/enums/compression.ts @@ -2,4 +2,4 @@ export enum Compression { None = 'none', Gzip = 'gzip', Zstd = 'zstd', -} \ No newline at end of file +} diff --git a/src/enums/console-resource-type.ts b/src/enums/console-resource-type.ts index 9ae46294..279c5248 100644 --- a/src/enums/console-resource-type.ts +++ b/src/enums/console-resource-type.ts @@ -1,3 +1,3 @@ export enum ConsoleResourceType { Rules = 'rules', -} \ No newline at end of file +} diff --git a/src/enums/credit-card.ts b/src/enums/credit-card.ts index e6ce2429..946e4931 100644 --- a/src/enums/credit-card.ts +++ b/src/enums/credit-card.ts @@ -16,4 +16,4 @@ export enum CreditCard { MIR = 'mir', Maestro = 'maestro', Rupay = 'rupay', -} \ No newline at end of file +} diff --git a/src/enums/database-status.ts b/src/enums/database-status.ts index 8a01e3b7..54e1ada0 100644 --- a/src/enums/database-status.ts +++ b/src/enums/database-status.ts @@ -13,4 +13,4 @@ export enum DatabaseStatus { Pausing = 'pausing', Resuming = 'resuming', Failingover = 'failing-over', -} \ No newline at end of file +} diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts index b39f921e..725f3641 100644 --- a/src/enums/database-type.ts +++ b/src/enums/database-type.ts @@ -6,4 +6,4 @@ export enum DatabaseType { Mysql = 'mysql', Postgresql = 'postgresql', Mongodb = 'mongodb', -} \ No newline at end of file +} diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index 85ccf867..e849833d 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,4 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', -} \ No newline at end of file +} diff --git a/src/enums/deployment-download-type.ts b/src/enums/deployment-download-type.ts index 538709bc..80cdec29 100644 --- a/src/enums/deployment-download-type.ts +++ b/src/enums/deployment-download-type.ts @@ -1,4 +1,4 @@ export enum DeploymentDownloadType { Source = 'source', Output = 'output', -} \ No newline at end of file +} diff --git a/src/enums/deployment-status.ts b/src/enums/deployment-status.ts index 7e8f4a1b..f89b3903 100644 --- a/src/enums/deployment-status.ts +++ b/src/enums/deployment-status.ts @@ -5,4 +5,4 @@ export enum DeploymentStatus { Ready = 'ready', Canceled = 'canceled', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/detection-framework-type.ts b/src/enums/detection-framework-type.ts index 9f77d6b5..078fe2b4 100644 --- a/src/enums/detection-framework-type.ts +++ b/src/enums/detection-framework-type.ts @@ -1,3 +1,3 @@ export enum DetectionFrameworkType { Framework = 'framework', -} \ No newline at end of file +} diff --git a/src/enums/detection-runtime-type.ts b/src/enums/detection-runtime-type.ts index eee7e3b0..a4f6f8e3 100644 --- a/src/enums/detection-runtime-type.ts +++ b/src/enums/detection-runtime-type.ts @@ -1,3 +1,3 @@ export enum DetectionRuntimeType { Runtime = 'runtime', -} \ No newline at end of file +} diff --git a/src/enums/documents-db-index-type.ts b/src/enums/documents-db-index-type.ts index b741ba90..6c04a5f7 100644 --- a/src/enums/documents-db-index-type.ts +++ b/src/enums/documents-db-index-type.ts @@ -2,4 +2,4 @@ export enum DocumentsDBIndexType { Key = 'key', Fulltext = 'fulltext', Unique = 'unique', -} \ No newline at end of file +} diff --git a/src/enums/domain-purchase-status.ts b/src/enums/domain-purchase-status.ts index e21a3ffd..f219dc2f 100644 --- a/src/enums/domain-purchase-status.ts +++ b/src/enums/domain-purchase-status.ts @@ -3,4 +3,4 @@ export enum DomainPurchaseStatus { Succeeded = 'succeeded', Failed = 'failed', Cancelled = 'cancelled', -} \ No newline at end of file +} diff --git a/src/enums/domain-registration-type.ts b/src/enums/domain-registration-type.ts index 9e0e10b0..4ef7f07a 100644 --- a/src/enums/domain-registration-type.ts +++ b/src/enums/domain-registration-type.ts @@ -3,4 +3,4 @@ export enum DomainRegistrationType { Transfer = 'transfer', Renewal = 'renewal', Trade = 'trade', -} \ No newline at end of file +} diff --git a/src/enums/domain-suggestion-type.ts b/src/enums/domain-suggestion-type.ts index d2eca6eb..eab9e2f7 100644 --- a/src/enums/domain-suggestion-type.ts +++ b/src/enums/domain-suggestion-type.ts @@ -1,4 +1,4 @@ export enum DomainSuggestionType { Premium = 'premium', Suggestion = 'suggestion', -} \ No newline at end of file +} diff --git a/src/enums/domain-transfer-status-enum.ts b/src/enums/domain-transfer-status-enum.ts index 1cc6eb88..a9dbdd89 100644 --- a/src/enums/domain-transfer-status-enum.ts +++ b/src/enums/domain-transfer-status-enum.ts @@ -7,4 +7,4 @@ export enum DomainTransferStatusEnum { Completed = 'completed', Cancelled = 'cancelled', ServiceUnavailable = 'service_unavailable', -} \ No newline at end of file +} diff --git a/src/enums/embedding-model.ts b/src/enums/embedding-model.ts index d06bb77b..29bf262f 100644 --- a/src/enums/embedding-model.ts +++ b/src/enums/embedding-model.ts @@ -1,6 +1,4 @@ export enum EmbeddingModel { Nomicembedtext = 'nomic-embed-text', - Embeddinggemma = 'embedding-gemma', Allminilm = 'all-minilm', - Bgesmall = 'bge-small', -} \ No newline at end of file +} diff --git a/src/enums/execution-method.ts b/src/enums/execution-method.ts index 39d4c1e8..a01b6b1a 100644 --- a/src/enums/execution-method.ts +++ b/src/enums/execution-method.ts @@ -6,4 +6,4 @@ export enum ExecutionMethod { DELETE = 'DELETE', OPTIONS = 'OPTIONS', HEAD = 'HEAD', -} \ No newline at end of file +} diff --git a/src/enums/execution-resource-type.ts b/src/enums/execution-resource-type.ts new file mode 100644 index 00000000..f2773e86 --- /dev/null +++ b/src/enums/execution-resource-type.ts @@ -0,0 +1,4 @@ +export enum ExecutionResourceType { + Functions = 'functions', + Sites = 'sites', +} diff --git a/src/enums/execution-status.ts b/src/enums/execution-status.ts index 992d987d..81bd3955 100644 --- a/src/enums/execution-status.ts +++ b/src/enums/execution-status.ts @@ -4,4 +4,4 @@ export enum ExecutionStatus { Completed = 'completed', Failed = 'failed', Scheduled = 'scheduled', -} \ No newline at end of file +} diff --git a/src/enums/execution-trigger.ts b/src/enums/execution-trigger.ts index 1829d514..84fa8f60 100644 --- a/src/enums/execution-trigger.ts +++ b/src/enums/execution-trigger.ts @@ -2,4 +2,4 @@ export enum ExecutionTrigger { Http = 'http', Schedule = 'schedule', Event = 'event', -} \ No newline at end of file +} diff --git a/src/enums/firebase-migration-resource.ts b/src/enums/firebase-migration-resource.ts index b8e16769..6c7224aa 100644 --- a/src/enums/firebase-migration-resource.ts +++ b/src/enums/firebase-migration-resource.ts @@ -9,4 +9,4 @@ export enum FirebaseMigrationResource { Collection = 'collection', Bucket = 'bucket', File = 'file', -} \ No newline at end of file +} diff --git a/src/enums/flag.ts b/src/enums/flag.ts index 7e1d8781..ab49b648 100644 --- a/src/enums/flag.ts +++ b/src/enums/flag.ts @@ -194,4 +194,4 @@ export enum Flag { SouthAfrica = 'za', Zambia = 'zm', Zimbabwe = 'zw', -} \ No newline at end of file +} diff --git a/src/enums/framework.ts b/src/enums/framework.ts index 7093da33..6173a0ef 100644 --- a/src/enums/framework.ts +++ b/src/enums/framework.ts @@ -14,4 +14,4 @@ export enum Framework { Reactnative = 'react-native', Vite = 'vite', Other = 'other', -} \ No newline at end of file +} diff --git a/src/enums/function-template-use-case.ts b/src/enums/function-template-use-case.ts index e1c25508..36ba9f19 100644 --- a/src/enums/function-template-use-case.ts +++ b/src/enums/function-template-use-case.ts @@ -6,4 +6,4 @@ export enum FunctionTemplateUseCase { Utilities = 'utilities', Devtools = 'dev-tools', Auth = 'auth', -} \ No newline at end of file +} diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index 758fad74..4c210ffd 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -6,4 +6,4 @@ export enum ImageFormat { Heic = 'heic', Avif = 'avif', Gif = 'gif', -} \ No newline at end of file +} diff --git a/src/enums/image-gravity.ts b/src/enums/image-gravity.ts index 815095dd..7b269c31 100644 --- a/src/enums/image-gravity.ts +++ b/src/enums/image-gravity.ts @@ -1,4 +1,5 @@ export enum ImageGravity { + Auto = 'auto', Center = 'center', Topleft = 'top-left', Top = 'top', @@ -8,4 +9,4 @@ export enum ImageGravity { Bottomleft = 'bottom-left', Bottom = 'bottom', Bottomright = 'bottom-right', -} \ No newline at end of file +} diff --git a/src/enums/index-status.ts b/src/enums/index-status.ts index 6ce90ac8..241a017d 100644 --- a/src/enums/index-status.ts +++ b/src/enums/index-status.ts @@ -4,4 +4,4 @@ export enum IndexStatus { Deleting = 'deleting', Stuck = 'stuck', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/invalidation-type.ts b/src/enums/invalidation-type.ts index 828f5402..e2b0443e 100644 --- a/src/enums/invalidation-type.ts +++ b/src/enums/invalidation-type.ts @@ -2,4 +2,4 @@ export enum InvalidationType { Tag = 'tag', Path = 'path', All = 'all', -} \ No newline at end of file +} diff --git a/src/enums/message-priority.ts b/src/enums/message-priority.ts index f3113a85..c4f491ef 100644 --- a/src/enums/message-priority.ts +++ b/src/enums/message-priority.ts @@ -1,4 +1,4 @@ export enum MessagePriority { Normal = 'normal', High = 'high', -} \ No newline at end of file +} diff --git a/src/enums/message-status.ts b/src/enums/message-status.ts index 08bd483b..05be0e81 100644 --- a/src/enums/message-status.ts +++ b/src/enums/message-status.ts @@ -4,4 +4,4 @@ export enum MessageStatus { Scheduled = 'scheduled', Sent = 'sent', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/messaging-provider-type.ts b/src/enums/messaging-provider-type.ts index 18c9929b..f10f6309 100644 --- a/src/enums/messaging-provider-type.ts +++ b/src/enums/messaging-provider-type.ts @@ -2,4 +2,4 @@ export enum MessagingProviderType { Email = 'email', Sms = 'sms', Push = 'push', -} \ No newline at end of file +} diff --git a/src/enums/n-host-migration-resource.ts b/src/enums/n-host-migration-resource.ts index 4c1366af..ef3d8688 100644 --- a/src/enums/n-host-migration-resource.ts +++ b/src/enums/n-host-migration-resource.ts @@ -10,4 +10,4 @@ export enum NHostMigrationResource { Collection = 'collection', Bucket = 'bucket', File = 'file', -} \ No newline at end of file +} diff --git a/src/enums/o-auth-2-google-prompt.ts b/src/enums/o-auth-2-google-prompt.ts index f8e98e12..23c5e9fc 100644 --- a/src/enums/o-auth-2-google-prompt.ts +++ b/src/enums/o-auth-2-google-prompt.ts @@ -2,4 +2,4 @@ export enum OAuth2GooglePrompt { None = 'none', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/o-auth-2-oidc-prompt.ts b/src/enums/o-auth-2-oidc-prompt.ts index daa1ef0e..1836202f 100644 --- a/src/enums/o-auth-2-oidc-prompt.ts +++ b/src/enums/o-auth-2-oidc-prompt.ts @@ -3,4 +3,4 @@ export enum OAuth2OidcPrompt { Login = 'login', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index e7136d69..92a95970 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -8,6 +8,7 @@ export enum OAuthProvider { Bitbucket = 'bitbucket', Bitly = 'bitly', Box = 'box', + Cloudflare = 'cloudflare', Dailymotion = 'dailymotion', Discord = 'discord', Disqus = 'disqus', @@ -19,6 +20,8 @@ export enum OAuthProvider { Github = 'github', Gitlab = 'gitlab', Google = 'google', + Huggingface = 'huggingface', + Kakao = 'kakao', Keycloak = 'keycloak', Kick = 'kick', Linkedin = 'linkedin', @@ -29,10 +32,12 @@ export enum OAuthProvider { Paypal = 'paypal', PaypalSandbox = 'paypalSandbox', Podio = 'podio', + Resend = 'resend', Salesforce = 'salesforce', Slack = 'slack', Spotify = 'spotify', Stripe = 'stripe', + Tiktok = 'tiktok', Tradeshift = 'tradeshift', TradeshiftBox = 'tradeshiftBox', Twitch = 'twitch', @@ -43,4 +48,4 @@ export enum OAuthProvider { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', -} \ No newline at end of file +} diff --git a/src/enums/on-duplicate.ts b/src/enums/on-duplicate.ts index 9ab3dc85..66bfcddf 100644 --- a/src/enums/on-duplicate.ts +++ b/src/enums/on-duplicate.ts @@ -2,4 +2,4 @@ export enum OnDuplicate { Fail = 'fail', Skip = 'skip', Overwrite = 'overwrite', -} \ No newline at end of file +} diff --git a/src/enums/order-by.ts b/src/enums/order-by.ts index 62dffb98..f954f10a 100644 --- a/src/enums/order-by.ts +++ b/src/enums/order-by.ts @@ -1,4 +1,4 @@ export enum OrderBy { Asc = 'asc', Desc = 'desc', -} \ No newline at end of file +} diff --git a/src/enums/organization-key-scopes.ts b/src/enums/organization-key-scopes.ts index eb18181d..2e878b48 100644 --- a/src/enums/organization-key-scopes.ts +++ b/src/enums/organization-key-scopes.ts @@ -15,4 +15,4 @@ export enum OrganizationKeyScopes { DomainsWrite = 'domains.write', KeysRead = 'keys.read', KeysWrite = 'keys.write', -} \ No newline at end of file +} diff --git a/src/enums/password-hash.ts b/src/enums/password-hash.ts index 76834af4..d615ce6f 100644 --- a/src/enums/password-hash.ts +++ b/src/enums/password-hash.ts @@ -10,4 +10,4 @@ export enum PasswordHash { Sha3256 = 'sha3-256', Sha3384 = 'sha3-384', Sha3512 = 'sha3-512', -} \ No newline at end of file +} diff --git a/src/enums/platform-type.ts b/src/enums/platform-type.ts index bde1d30f..5585e88c 100644 --- a/src/enums/platform-type.ts +++ b/src/enums/platform-type.ts @@ -4,4 +4,4 @@ export enum PlatformType { Android = 'android', Linux = 'linux', Web = 'web', -} \ No newline at end of file +} diff --git a/src/enums/platform.ts b/src/enums/platform.ts index 8b017e32..a96801e7 100644 --- a/src/enums/platform.ts +++ b/src/enums/platform.ts @@ -1,4 +1,4 @@ export enum Platform { Appwrite = 'appwrite', Imagine = 'imagine', -} \ No newline at end of file +} diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index a05c217e..367ed141 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,4 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', -} \ No newline at end of file +} diff --git a/src/enums/project-email-template-id.ts b/src/enums/project-email-template-id.ts index b5aba1a6..c8ecbec4 100644 --- a/src/enums/project-email-template-id.ts +++ b/src/enums/project-email-template-id.ts @@ -6,4 +6,4 @@ export enum ProjectEmailTemplateId { MfaChallenge = 'mfaChallenge', SessionAlert = 'sessionAlert', OtpSession = 'otpSession', -} \ No newline at end of file +} diff --git a/src/enums/project-email-template-locale.ts b/src/enums/project-email-template-locale.ts index b5bb7cf8..c9e85ac2 100644 --- a/src/enums/project-email-template-locale.ts +++ b/src/enums/project-email-template-locale.ts @@ -130,4 +130,4 @@ export enum ProjectEmailTemplateLocale { Zhsg = 'zh-sg', Zhtw = 'zh-tw', Zu = 'zu', -} \ No newline at end of file +} diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index a6fd8052..e17dffdb 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -1,6 +1,7 @@ export enum ProjectKeyScopes { ProjectRead = 'project.read', ProjectWrite = 'project.write', + UsageRead = 'usage.read', KeysRead = 'keys.read', KeysWrite = 'keys.write', PlatformsRead = 'platforms.read', @@ -33,12 +34,29 @@ export enum ProjectKeyScopes { IndexesWrite = 'indexes.write', RowsRead = 'rows.read', RowsWrite = 'rows.write', + EmbeddingsWrite = 'embeddings.write', CollectionsRead = 'collections.read', CollectionsWrite = 'collections.write', AttributesRead = 'attributes.read', AttributesWrite = 'attributes.write', DocumentsRead = 'documents.read', DocumentsWrite = 'documents.write', + DocumentsdbRead = 'documentsdb.read', + DocumentsdbWrite = 'documentsdb.write', + DocumentsdbCollectionsRead = 'documentsdb.collections.read', + DocumentsdbCollectionsWrite = 'documentsdb.collections.write', + DocumentsdbDocumentsRead = 'documentsdb.documents.read', + DocumentsdbDocumentsWrite = 'documentsdb.documents.write', + DocumentsdbIndexesRead = 'documentsdb.indexes.read', + DocumentsdbIndexesWrite = 'documentsdb.indexes.write', + VectorsdbRead = 'vectorsdb.read', + VectorsdbWrite = 'vectorsdb.write', + VectorsdbCollectionsRead = 'vectorsdb.collections.read', + VectorsdbCollectionsWrite = 'vectorsdb.collections.write', + VectorsdbDocumentsRead = 'vectorsdb.documents.read', + VectorsdbDocumentsWrite = 'vectorsdb.documents.write', + VectorsdbIndexesRead = 'vectorsdb.indexes.read', + VectorsdbIndexesWrite = 'vectorsdb.indexes.write', BucketsRead = 'buckets.read', BucketsWrite = 'buckets.write', FilesRead = 'files.read', @@ -91,7 +109,6 @@ export enum ProjectKeyScopes { ArchivesWrite = 'archives.write', RestorationsRead = 'restorations.read', RestorationsWrite = 'restorations.write', - DedicatedDatabasesExecute = 'dedicatedDatabases.execute', DomainsRead = 'domains.read', DomainsWrite = 'domains.write', WafRulesRead = 'wafRules.read', @@ -103,5 +120,4 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', - UsageRead = 'usage.read', -} \ No newline at end of file +} diff --git a/src/enums/project-o-auth-2-google-prompt.ts b/src/enums/project-o-auth-2-google-prompt.ts index 75db98ec..43b77ed4 100644 --- a/src/enums/project-o-auth-2-google-prompt.ts +++ b/src/enums/project-o-auth-2-google-prompt.ts @@ -2,4 +2,4 @@ export enum ProjectOAuth2GooglePrompt { None = 'none', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/project-o-auth-2-oidc-prompt.ts b/src/enums/project-o-auth-2-oidc-prompt.ts index 6d346b16..12344220 100644 --- a/src/enums/project-o-auth-2-oidc-prompt.ts +++ b/src/enums/project-o-auth-2-oidc-prompt.ts @@ -3,4 +3,4 @@ export enum ProjectOAuth2OidcPrompt { Login = 'login', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts index 125ee887..3ab5db15 100644 --- a/src/enums/project-o-auth-provider-id.ts +++ b/src/enums/project-o-auth-provider-id.ts @@ -8,6 +8,7 @@ export enum ProjectOAuthProviderId { Bitbucket = 'bitbucket', Bitly = 'bitly', Box = 'box', + Cloudflare = 'cloudflare', Dailymotion = 'dailymotion', Discord = 'discord', Disqus = 'disqus', @@ -19,6 +20,8 @@ export enum ProjectOAuthProviderId { Github = 'github', Gitlab = 'gitlab', Google = 'google', + Huggingface = 'huggingface', + Kakao = 'kakao', Keycloak = 'keycloak', Kick = 'kick', Linkedin = 'linkedin', @@ -29,10 +32,12 @@ export enum ProjectOAuthProviderId { Paypal = 'paypal', PaypalSandbox = 'paypalSandbox', Podio = 'podio', + Resend = 'resend', Salesforce = 'salesforce', Slack = 'slack', Spotify = 'spotify', Stripe = 'stripe', + Tiktok = 'tiktok', Tradeshift = 'tradeshift', TradeshiftBox = 'tradeshiftBox', Twitch = 'twitch', @@ -43,4 +48,4 @@ export enum ProjectOAuthProviderId { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', -} \ No newline at end of file +} diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index 823727a0..c05f7f60 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -9,8 +9,9 @@ export enum ProjectPolicyId { Sessionlimit = 'session-limit', Userlimit = 'user-limit', Membershipprivacy = 'membership-privacy', + Mfafactors = 'mfa-factors', Denyaliasedemail = 'deny-aliased-email', Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', -} \ No newline at end of file +} diff --git a/src/enums/project-protocol-id.ts b/src/enums/project-protocol-id.ts index 10a89c21..81546e67 100644 --- a/src/enums/project-protocol-id.ts +++ b/src/enums/project-protocol-id.ts @@ -2,4 +2,4 @@ export enum ProjectProtocolId { Rest = 'rest', Graphql = 'graphql', Websocket = 'websocket', -} \ No newline at end of file +} diff --git a/src/enums/project-service-id.ts b/src/enums/project-service-id.ts index 0da78c59..843da957 100644 --- a/src/enums/project-service-id.ts +++ b/src/enums/project-service-id.ts @@ -18,4 +18,4 @@ export enum ProjectServiceId { Messaging = 'messaging', Advisor = 'advisor', Oauth2 = 'oauth2', -} \ No newline at end of file +} diff --git a/src/enums/project-smtp-secure.ts b/src/enums/project-smtp-secure.ts index d3d37687..03d38af2 100644 --- a/src/enums/project-smtp-secure.ts +++ b/src/enums/project-smtp-secure.ts @@ -1,4 +1,4 @@ export enum ProjectSMTPSecure { Tls = 'tls', Ssl = 'ssl', -} \ No newline at end of file +} diff --git a/src/enums/project-usage-range.ts b/src/enums/project-usage-range.ts index 2a0a9867..8a6cfa0e 100644 --- a/src/enums/project-usage-range.ts +++ b/src/enums/project-usage-range.ts @@ -1,4 +1,4 @@ export enum ProjectUsageRange { OneHour = '1h', OneDay = '1d', -} \ No newline at end of file +} diff --git a/src/enums/proxy-resource-type.ts b/src/enums/proxy-resource-type.ts index e04c8046..0bb3f1eb 100644 --- a/src/enums/proxy-resource-type.ts +++ b/src/enums/proxy-resource-type.ts @@ -1,4 +1,4 @@ export enum ProxyResourceType { Site = 'site', Function = 'function', -} \ No newline at end of file +} diff --git a/src/enums/proxy-rule-deployment-resource-type.ts b/src/enums/proxy-rule-deployment-resource-type.ts index 89236c74..ef695072 100644 --- a/src/enums/proxy-rule-deployment-resource-type.ts +++ b/src/enums/proxy-rule-deployment-resource-type.ts @@ -1,4 +1,4 @@ export enum ProxyRuleDeploymentResourceType { Function = 'function', Site = 'site', -} \ No newline at end of file +} diff --git a/src/enums/proxy-rule-status.ts b/src/enums/proxy-rule-status.ts index 67b8e4cb..f717f93f 100644 --- a/src/enums/proxy-rule-status.ts +++ b/src/enums/proxy-rule-status.ts @@ -2,4 +2,4 @@ export enum ProxyRuleStatus { Unverified = 'unverified', Verifying = 'verifying', Verified = 'verified', -} \ No newline at end of file +} diff --git a/src/enums/query-suggestion-resource.ts b/src/enums/query-suggestion-resource.ts index feb6f5e4..6482f6a1 100644 --- a/src/enums/query-suggestion-resource.ts +++ b/src/enums/query-suggestion-resource.ts @@ -57,6 +57,7 @@ export enum QuerySuggestionResource { Alerts = 'alerts', Payments = 'payments', BillingDiscounts = 'billingdiscounts', + ResourcesDeleted = 'resourcesdeleted', Sources = 'sources', Deals = 'deals', Blocks = 'blocks', @@ -82,13 +83,13 @@ export enum QuerySuggestionResource { Functions = 'functions', Sites = 'sites', Deployments = 'deployments', + Executions = 'executions', Variables = 'variables', Migrations = 'migrations', ResourceTokens = 'resourcetokens', Transactions = 'transactions', TransactionLogs = 'transactionlogs', Stats = 'stats', - Executions = 'executions', DedicatedDatabases = 'dedicateddatabases', DedicatedDatabaseConfigs = 'dedicateddatabaseconfigs', DedicatedDatabaseRuntimes = 'dedicateddatabaseruntimes', @@ -96,4 +97,4 @@ export enum QuerySuggestionResource { DedicatedDatabaseBackups = 'dedicateddatabasebackups', DedicatedDatabaseRestorations = 'dedicateddatabaserestorations', DedicatedDatabaseBranches = 'dedicateddatabasebranches', -} \ No newline at end of file +} diff --git a/src/enums/region.ts b/src/enums/region.ts index 948dd0b8..30fc88c2 100644 --- a/src/enums/region.ts +++ b/src/enums/region.ts @@ -5,4 +5,4 @@ export enum Region { Sfo = 'sfo', Sgp = 'sgp', Tor = 'tor', -} \ No newline at end of file +} diff --git a/src/enums/relation-mutate.ts b/src/enums/relation-mutate.ts index 722a7572..87a43132 100644 --- a/src/enums/relation-mutate.ts +++ b/src/enums/relation-mutate.ts @@ -2,4 +2,4 @@ export enum RelationMutate { Cascade = 'cascade', Restrict = 'restrict', SetNull = 'setNull', -} \ No newline at end of file +} diff --git a/src/enums/relationship-type.ts b/src/enums/relationship-type.ts index 532015af..da136011 100644 --- a/src/enums/relationship-type.ts +++ b/src/enums/relationship-type.ts @@ -3,4 +3,4 @@ export enum RelationshipType { ManyToOne = 'manyToOne', ManyToMany = 'manyToMany', OneToMany = 'oneToMany', -} \ No newline at end of file +} diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 63e04b2a..7bbcbb6f 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -50,6 +50,7 @@ export enum Runtime { Dart310 = 'dart-3.10', Dart311 = 'dart-3.11', Dart312 = 'dart-3.12', + Dart313 = 'dart-3.13', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -77,6 +78,7 @@ export enum Runtime { Bun11 = 'bun-1.1', Bun12 = 'bun-1.2', Bun13 = 'bun-1.3', + Bun14 = 'bun-1.4', Go123 = 'go-1.23', Go124 = 'go-1.24', Go125 = 'go-1.25', @@ -91,4 +93,5 @@ export enum Runtime { Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', Flutter344 = 'flutter-3.44', -} \ No newline at end of file + Flutter347 = 'flutter-3.47', +} diff --git a/src/enums/schedule-resource-type.ts b/src/enums/schedule-resource-type.ts index 25ffc458..cc9dc740 100644 --- a/src/enums/schedule-resource-type.ts +++ b/src/enums/schedule-resource-type.ts @@ -3,4 +3,4 @@ export enum ScheduleResourceType { Execution = 'execution', Message = 'message', Backup = 'backup', -} \ No newline at end of file +} diff --git a/src/enums/site-template-use-case.ts b/src/enums/site-template-use-case.ts index 7e29c016..cad044e8 100644 --- a/src/enums/site-template-use-case.ts +++ b/src/enums/site-template-use-case.ts @@ -8,4 +8,4 @@ export enum SiteTemplateUseCase { Ai = 'ai', Forms = 'forms', Dashboard = 'dashboard', -} \ No newline at end of file +} diff --git a/src/enums/smtp-encryption.ts b/src/enums/smtp-encryption.ts index 876177b6..5fe9c93a 100644 --- a/src/enums/smtp-encryption.ts +++ b/src/enums/smtp-encryption.ts @@ -2,4 +2,4 @@ export enum SmtpEncryption { None = 'none', Ssl = 'ssl', Tls = 'tls', -} \ No newline at end of file +} diff --git a/src/enums/status-code.ts b/src/enums/status-code.ts index 425d65c3..f5bfac49 100644 --- a/src/enums/status-code.ts +++ b/src/enums/status-code.ts @@ -3,4 +3,4 @@ export enum StatusCode { Found = '302', TemporaryRedirect = '307', PermanentRedirect = '308', -} \ No newline at end of file +} diff --git a/src/enums/status.ts b/src/enums/status.ts index abaf754f..972f2366 100644 --- a/src/enums/status.ts +++ b/src/enums/status.ts @@ -1,3 +1,3 @@ export enum Status { Active = 'active', -} \ No newline at end of file +} diff --git a/src/enums/supabase-migration-resource.ts b/src/enums/supabase-migration-resource.ts index de6b7b90..d877e508 100644 --- a/src/enums/supabase-migration-resource.ts +++ b/src/enums/supabase-migration-resource.ts @@ -10,4 +10,4 @@ export enum SupabaseMigrationResource { Collection = 'collection', Bucket = 'bucket', File = 'file', -} \ No newline at end of file +} diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index a199cd9c..246bfc4a 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,4 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', -} \ No newline at end of file +} diff --git a/src/enums/template-reference-type.ts b/src/enums/template-reference-type.ts index bd72cfb5..afcaea00 100644 --- a/src/enums/template-reference-type.ts +++ b/src/enums/template-reference-type.ts @@ -2,4 +2,4 @@ export enum TemplateReferenceType { Commit = 'commit', Branch = 'branch', Tag = 'tag', -} \ No newline at end of file +} diff --git a/src/enums/timezone.ts b/src/enums/timezone.ts index 207298a8..24c08db9 100644 --- a/src/enums/timezone.ts +++ b/src/enums/timezone.ts @@ -418,4 +418,4 @@ export enum Timezone { PacificWake = 'pacific/wake', PacificWallis = 'pacific/wallis', Utc = 'utc', -} \ No newline at end of file +} diff --git a/src/enums/usage-event-dimension.ts b/src/enums/usage-event-dimension.ts index 446f977b..7147c229 100644 --- a/src/enums/usage-event-dimension.ts +++ b/src/enums/usage-event-dimension.ts @@ -18,4 +18,10 @@ export enum UsageEventDimension { SdkVersion = 'sdkVersion', TeamId = 'teamId', ResourceId = 'resourceId', -} \ No newline at end of file + Isp = 'isp', + AutonomousSystemNumber = 'autonomousSystemNumber', + AutonomousSystemOrganization = 'autonomousSystemOrganization', + ConnectionType = 'connectionType', + ConnectionUsageType = 'connectionUsageType', + ConnectionOrganization = 'connectionOrganization', +} diff --git a/src/enums/usage-event-metric.ts b/src/enums/usage-event-metric.ts new file mode 100644 index 00000000..e62f1b05 --- /dev/null +++ b/src/enums/usage-event-metric.ts @@ -0,0 +1,55 @@ +export enum UsageEventMetric { + NetworkRequests = 'network.requests', + NetworkInbound = 'network.inbound', + NetworkOutbound = 'network.outbound', + WebhooksEventsSent = 'webhooks.events.sent', + WebhooksEventsFailed = 'webhooks.events.failed', + AuthMethodPhone = 'auth.method.phone', + MessagesSent = 'messages.sent', + MessagesSmsSent = 'messages.sms.sent', + Executions = 'executions', + ExecutionsCompute = 'executions.compute', + ExecutionsMbSeconds = 'executions.mbSeconds', + FunctionsExecutions = 'functions.executions', + SitesExecutions = 'sites.executions', + FunctionsExecutionsCompute = 'functions.executions.compute', + SitesExecutionsCompute = 'sites.executions.compute', + FunctionsExecutionsMbSeconds = 'functions.executions.mbSeconds', + SitesExecutionsMbSeconds = 'sites.executions.mbSeconds', + Builds = 'builds', + BuildsSuccess = 'builds.success', + BuildsFailed = 'builds.failed', + BuildsCompute = 'builds.compute', + BuildsComputeSuccess = 'builds.compute.success', + BuildsComputeFailed = 'builds.compute.failed', + BuildsMbSeconds = 'builds.mbSeconds', + FunctionsBuildsMbSeconds = 'functions.builds.mbSeconds', + SitesBuildsMbSeconds = 'sites.builds.mbSeconds', + DatabasesOperationsReads = 'databases.operations.reads', + DatabasesOperationsWrites = 'databases.operations.writes', + DocumentsdbDatabasesOperationsReads = 'documentsdb.databases.operations.reads', + DocumentsdbDatabasesOperationsWrites = 'documentsdb.databases.operations.writes', + VectorsdbDatabasesOperationsReads = 'vectorsdb.databases.operations.reads', + VectorsdbDatabasesOperationsWrites = 'vectorsdb.databases.operations.writes', + FilesImagesTransformed = 'files.imagesTransformed', + AvatarsScreenshotsGenerated = 'avatars.screenshotsGenerated', + RealtimeMessagesSent = 'realtime.messages.sent', + RealtimeInbound = 'realtime.inbound', + RealtimeOutbound = 'realtime.outbound', + EmbeddingsText = 'embeddings.text', + EmbeddingsTextTotalTokens = 'embeddings.text.totalTokens', + EmbeddingsTextTotalDuration = 'embeddings.text.totalDuration', + EmbeddingsTextTotalErrors = 'embeddings.text.totalErrors', + WafRequestsDenied = 'waf.requests.denied', + WafRequestsChallenged = 'waf.requests.challenged', + WafRequestsRateLimited = 'waf.requests.rateLimited', + WafRequestsRedirected = 'waf.requests.redirected', + WafRequestsChallengeSolved = 'waf.requests.challengeSolved', + WafChallengeSolveTimeMs = 'waf.challenge.solveTimeMs', + AffiliatesClicks = 'affiliates.clicks', + AffiliatesSignups = 'affiliates.signups', + AffiliatesConversions = 'affiliates.conversions', + DedicatedDatabasesInbound = 'dedicatedDatabases.inbound', + DedicatedDatabasesOutbound = 'dedicatedDatabases.outbound', + DedicatedDatabasesCompute = 'dedicatedDatabases.compute', +} diff --git a/src/enums/usage-gauge-dimension.ts b/src/enums/usage-gauge-dimension.ts index ec8e10a8..485e806f 100644 --- a/src/enums/usage-gauge-dimension.ts +++ b/src/enums/usage-gauge-dimension.ts @@ -4,4 +4,4 @@ export enum UsageGaugeDimension { Service = 'service', ResourceType = 'resourceType', Ordinal = 'ordinal', -} \ No newline at end of file +} diff --git a/src/enums/usage-gauge-metric.ts b/src/enums/usage-gauge-metric.ts new file mode 100644 index 00000000..5de2cb5c --- /dev/null +++ b/src/enums/usage-gauge-metric.ts @@ -0,0 +1,50 @@ +export enum UsageGaugeMetric { + Teams = 'teams', + Users = 'users', + Messages = 'messages', + Sessions = 'sessions', + Databases = 'databases', + Collections = 'collections', + Documents = 'documents', + DatabasesStorage = 'databases.storage', + DocumentsdbDatabases = 'documentsdb.databases', + DocumentsdbCollections = 'documentsdb.collections', + DocumentsdbDocuments = 'documentsdb.documents', + DocumentsdbDatabasesStorage = 'documentsdb.databases.storage', + VectorsdbDatabases = 'vectorsdb.databases', + VectorsdbCollections = 'vectorsdb.collections', + VectorsdbDocuments = 'vectorsdb.documents', + VectorsdbDatabasesStorage = 'vectorsdb.databases.storage', + Buckets = 'buckets', + Files = 'files', + FilesStorage = 'files.storage', + Sites = 'sites', + Functions = 'functions', + Deployments = 'deployments', + DeploymentsStorage = 'deployments.storage', + Builds = 'builds', + BuildsStorage = 'builds.storage', + UsersMau = 'users.mau', + UsersDau = 'users.dau', + UsersWau = 'users.wau', + Webhooks = 'webhooks', + Platforms = 'platforms', + Providers = 'providers', + Topics = 'topics', + Targets = 'targets', + Keys = 'keys', + Domains = 'domains', + RealtimeConnections = 'realtime.connections', + BackupsPolicies = 'backups.policies', + BackupsStorage = 'backups.storage', + DedicatedDatabasesStorage = 'dedicatedDatabases.storage', + DedicatedDatabasesConnections = 'dedicatedDatabases.connections', + DedicatedDatabasesCpu = 'dedicatedDatabases.cpu', + DedicatedDatabasesMemory = 'dedicatedDatabases.memory', + DedicatedDatabasesQps = 'dedicatedDatabases.qps', + DedicatedDatabasesIopsRead = 'dedicatedDatabases.iopsRead', + DedicatedDatabasesIopsWrite = 'dedicatedDatabases.iopsWrite', + Apps = 'apps', + AppsUsers = 'apps.users', + AppsInstallations = 'apps.installations', +} diff --git a/src/enums/usage-interval.ts b/src/enums/usage-interval.ts index 813d82dc..aa75cb12 100644 --- a/src/enums/usage-interval.ts +++ b/src/enums/usage-interval.ts @@ -4,4 +4,4 @@ export enum UsageInterval { ThirtyMinutes = '30m', OneHour = '1h', OneDay = '1d', -} \ No newline at end of file +} diff --git a/src/enums/usage-order-by.ts b/src/enums/usage-order-by.ts index 7c63910f..7d1fef3b 100644 --- a/src/enums/usage-order-by.ts +++ b/src/enums/usage-order-by.ts @@ -1,4 +1,4 @@ export enum UsageOrderBy { Time = 'time', Value = 'value', -} \ No newline at end of file +} diff --git a/src/enums/usage-order-direction.ts b/src/enums/usage-order-direction.ts index ca39bbb2..a28bee04 100644 --- a/src/enums/usage-order-direction.ts +++ b/src/enums/usage-order-direction.ts @@ -1,4 +1,4 @@ export enum UsageOrderDirection { Asc = 'asc', Desc = 'desc', -} \ No newline at end of file +} diff --git a/src/enums/usage-range.ts b/src/enums/usage-range.ts index f9ea3c0e..28a1f770 100644 --- a/src/enums/usage-range.ts +++ b/src/enums/usage-range.ts @@ -2,4 +2,4 @@ export enum UsageRange { TwentyFourHours = '24h', ThirtyDays = '30d', NinetyDays = '90d', -} \ No newline at end of file +} diff --git a/src/enums/vcs-detection-type.ts b/src/enums/vcs-detection-type.ts index 173a66bd..4a8a24a2 100644 --- a/src/enums/vcs-detection-type.ts +++ b/src/enums/vcs-detection-type.ts @@ -1,4 +1,4 @@ export enum VCSDetectionType { Runtime = 'runtime', Framework = 'framework', -} \ No newline at end of file +} diff --git a/src/enums/vcs-reference-type.ts b/src/enums/vcs-reference-type.ts index cb5270f5..55f1d89d 100644 --- a/src/enums/vcs-reference-type.ts +++ b/src/enums/vcs-reference-type.ts @@ -2,4 +2,4 @@ export enum VCSReferenceType { Branch = 'branch', Commit = 'commit', Tag = 'tag', -} \ No newline at end of file +} diff --git a/src/enums/vectors-db-index-type.ts b/src/enums/vectors-db-index-type.ts index a38d5ea1..d497359c 100644 --- a/src/enums/vectors-db-index-type.ts +++ b/src/enums/vectors-db-index-type.ts @@ -5,4 +5,4 @@ export enum VectorsDBIndexType { Object = 'object', Key = 'key', Unique = 'unique', -} \ No newline at end of file +} diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts index 351f5091..38534a93 100644 --- a/src/enums/waf-rule-action.ts +++ b/src/enums/waf-rule-action.ts @@ -4,4 +4,4 @@ export enum WafRuleAction { Challenge = 'challenge', RateLimit = 'rateLimit', Redirect = 'redirect', -} \ No newline at end of file +} diff --git a/src/id.ts b/src/id.ts index 33495cc8..d9ebe835 100644 --- a/src/id.ts +++ b/src/id.ts @@ -14,7 +14,8 @@ export class ID { const msec = now.getMilliseconds(); // Convert to hexadecimal - const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0'); + const hexTimestamp = + sec.toString(16) + msec.toString(16).padStart(5, '0'); return hexTimestamp; } @@ -25,12 +26,12 @@ export class ID { * @returns {string} */ public static custom(id: string): string { - return id + return id; } /** * Have Appwrite generate a unique ID for you. - * + * * @param {number} padding. Default is 7. * @returns {string} */ diff --git a/src/index.ts b/src/index.ts index e200dd7a..6b7112f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,11 @@ /** * Appwrite Console SDK * - * This SDK is compatible with Appwrite server version 1.9.x. - * For older versions, please check - * [previous releases](https://github.com/appwrite/sdk-for-console/releases). + * This SDK targets Appwrite server version 2.0.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-console/releases) + * when APIs differ. */ export { Client, Query, AppwriteException } from './client'; export { Account } from './services/account'; @@ -48,7 +50,12 @@ export { VectorsDB } from './services/vectors-db'; export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export { Realtime } from './services/realtime'; -export type { Models, Payload, RealtimeResponseEvent, UploadProgress } from './client'; +export type { + Models, + Payload, + RealtimeResponseEvent, + UploadProgress, +} from './client'; export type { RealtimeSubscription } from './services/realtime'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; @@ -101,7 +108,7 @@ export { FirebaseMigrationResource } from './enums/firebase-migration-resource'; export { NHostMigrationResource } from './enums/n-host-migration-resource'; export { SupabaseMigrationResource } from './enums/supabase-migration-resource'; export { OrganizationKeyScopes } from './enums/organization-key-scopes'; -export { Addon } from './enums/addon'; +export { AddonKey } from './enums/addon-key'; export { UsageRange } from './enums/usage-range'; export { ProjectAuthMethodId } from './enums/project-auth-method-id'; export { ProjectOAuth2GooglePrompt } from './enums/project-o-auth-2-google-prompt'; @@ -124,10 +131,12 @@ export { SiteTemplateUseCase } from './enums/site-template-use-case'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; export { TablesDBIndexType } from './enums/tables-db-index-type'; +export { UsageEventMetric } from './enums/usage-event-metric'; export { UsageInterval } from './enums/usage-interval'; export { UsageEventDimension } from './enums/usage-event-dimension'; export { UsageOrderBy } from './enums/usage-order-by'; export { UsageOrderDirection } from './enums/usage-order-direction'; +export { UsageGaugeMetric } from './enums/usage-gauge-metric'; export { UsageGaugeDimension } from './enums/usage-gauge-dimension'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; @@ -141,6 +150,7 @@ export { IndexStatus } from './enums/index-status'; export { DetectionFrameworkType } from './enums/detection-framework-type'; export { DetectionRuntimeType } from './enums/detection-runtime-type'; export { DeploymentStatus } from './enums/deployment-status'; +export { ExecutionResourceType } from './enums/execution-resource-type'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; export { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; diff --git a/src/models.ts b/src/models.ts index f67829bb..3e2de11d 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,32 +1,31 @@ -import { DatabaseType } from "./enums/database-type" -import { DatabaseStatus } from "./enums/database-status" -import { AttributeStatus } from "./enums/attribute-status" -import { ColumnStatus } from "./enums/column-status" -import { IndexStatus } from "./enums/index-status" -import { DetectionFrameworkType } from "./enums/detection-framework-type" -import { DetectionRuntimeType } from "./enums/detection-runtime-type" -import { DeploymentStatus } from "./enums/deployment-status" -import { ExecutionTrigger } from "./enums/execution-trigger" -import { ExecutionStatus } from "./enums/execution-status" -import { ProjectAuthMethodId } from "./enums/project-auth-method-id" -import { ProjectServiceId } from "./enums/project-service-id" -import { ProjectProtocolId } from "./enums/project-protocol-id" -import { OAuth2GooglePrompt } from "./enums/o-auth-2-google-prompt" -import { OAuth2OidcPrompt } from "./enums/o-auth-2-oidc-prompt" -import { PlatformType } from "./enums/platform-type" -import { ProxyRuleDeploymentResourceType } from "./enums/proxy-rule-deployment-resource-type" -import { ProxyRuleStatus } from "./enums/proxy-rule-status" -import { MessageStatus } from "./enums/message-status" -import { BillingPlanGroup } from "./enums/billing-plan-group" -import { DomainTransferStatusEnum } from "./enums/domain-transfer-status-enum" -import { DomainPurchaseStatus } from "./enums/domain-purchase-status" -import { WafRuleAction } from "./enums/waf-rule-action" +import { DatabaseType } from './enums/database-type'; +import { AttributeStatus } from './enums/attribute-status'; +import { ColumnStatus } from './enums/column-status'; +import { IndexStatus } from './enums/index-status'; +import { DetectionFrameworkType } from './enums/detection-framework-type'; +import { DetectionRuntimeType } from './enums/detection-runtime-type'; +import { DeploymentStatus } from './enums/deployment-status'; +import { ExecutionResourceType } from './enums/execution-resource-type'; +import { ExecutionTrigger } from './enums/execution-trigger'; +import { ExecutionStatus } from './enums/execution-status'; +import { ProjectAuthMethodId } from './enums/project-auth-method-id'; +import { ProjectServiceId } from './enums/project-service-id'; +import { ProjectProtocolId } from './enums/project-protocol-id'; +import { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +import { OAuth2OidcPrompt } from './enums/o-auth-2-oidc-prompt'; +import { PlatformType } from './enums/platform-type'; +import { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; +import { ProxyRuleStatus } from './enums/proxy-rule-status'; +import { MessageStatus } from './enums/message-status'; +import { BillingPlanGroup } from './enums/billing-plan-group'; +import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { DomainPurchaseStatus } from './enums/domain-purchase-status'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models */ export namespace Models { - declare const __default: unique symbol; /** @@ -41,12 +40,14 @@ export namespace Models { * List of rows. */ rows: Row[]; - } + }; /** * Documents List */ - export type DocumentList = { + export type DocumentList< + Document extends Models.Document = Models.DefaultDocument, + > = { /** * Total number of documents that matched your query. */ @@ -55,7 +56,7 @@ export namespace Models { * List of documents. */ documents: Document[]; - } + }; /** * Presences List @@ -69,7 +70,7 @@ export namespace Models { * List of presences. */ presences: Presence[]; - } + }; /** * Tables List @@ -83,7 +84,7 @@ export namespace Models { * List of tables. */ tables: Table[]; - } + }; /** * Collections List @@ -97,7 +98,7 @@ export namespace Models { * List of collections. */ collections: Collection[]; - } + }; /** * Databases List @@ -111,7 +112,7 @@ export namespace Models { * List of databases. */ databases: Database[]; - } + }; /** * Indexes List @@ -125,7 +126,7 @@ export namespace Models { * List of indexes. */ indexes: Index[]; - } + }; /** * Column Indexes List @@ -139,12 +140,14 @@ export namespace Models { * List of indexes. */ indexes: ColumnIndex[]; - } + }; /** * Users List */ - export type UserList = { + export type UserList< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Total number of users that matched your query. */ @@ -153,7 +156,7 @@ export namespace Models { * List of users. */ users: User[]; - } + }; /** * Sessions List @@ -167,7 +170,7 @@ export namespace Models { * List of sessions. */ sessions: Session[]; - } + }; /** * Identities List @@ -181,7 +184,7 @@ export namespace Models { * List of identities. */ identities: Identity[]; - } + }; /** * Notifications List @@ -195,7 +198,7 @@ export namespace Models { * List of notifications. */ notifications: Notification[]; - } + }; /** * Logs List @@ -209,7 +212,7 @@ export namespace Models { * List of logs. */ logs: Log[]; - } + }; /** * Files List @@ -223,7 +226,7 @@ export namespace Models { * List of files. */ files: File[]; - } + }; /** * Buckets List @@ -237,7 +240,7 @@ export namespace Models { * List of buckets. */ buckets: Bucket[]; - } + }; /** * Resource Tokens List @@ -251,12 +254,14 @@ export namespace Models { * List of tokens. */ tokens: ResourceToken[]; - } + }; /** * Teams List */ - export type TeamList = { + export type TeamList< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Total number of teams that matched your query. */ @@ -265,7 +270,7 @@ export namespace Models { * List of teams. */ teams: Team[]; - } + }; /** * Memberships List @@ -279,7 +284,7 @@ export namespace Models { * List of memberships. */ memberships: Membership[]; - } + }; /** * Sites List @@ -293,7 +298,7 @@ export namespace Models { * List of sites. */ sites: Site[]; - } + }; /** * Site Templates List @@ -307,7 +312,7 @@ export namespace Models { * List of templates. */ templates: TemplateSite[]; - } + }; /** * Functions List @@ -321,7 +326,7 @@ export namespace Models { * List of functions. */ functions: Function[]; - } + }; /** * Function Templates List @@ -335,7 +340,7 @@ export namespace Models { * List of templates. */ templates: TemplateFunction[]; - } + }; /** * Installations List @@ -349,7 +354,7 @@ export namespace Models { * List of installations. */ installations: Installation[]; - } + }; /** * Framework Provider Repositories List @@ -367,7 +372,7 @@ export namespace Models { * Provider repository list type. */ type: string; - } + }; /** * Runtime Provider Repositories List @@ -385,7 +390,7 @@ export namespace Models { * Provider repository list type. */ type: string; - } + }; /** * VcsNamespace @@ -411,7 +416,7 @@ export namespace Models { * Namespace avatar URL. */ avatarUrl: string; - } + }; /** * VCS Namespaces List @@ -425,7 +430,7 @@ export namespace Models { * List of namespaces. */ namespaces: VcsNamespace[]; - } + }; /** * Branches List @@ -439,7 +444,7 @@ export namespace Models { * List of branches. */ branches: Branch[]; - } + }; /** * Frameworks List @@ -453,7 +458,7 @@ export namespace Models { * List of frameworks. */ frameworks: Framework[]; - } + }; /** * Runtimes List @@ -467,7 +472,7 @@ export namespace Models { * List of runtimes. */ runtimes: Runtime[]; - } + }; /** * Deployments List @@ -481,7 +486,7 @@ export namespace Models { * List of deployments. */ deployments: Deployment[]; - } + }; /** * Executions List @@ -495,7 +500,7 @@ export namespace Models { * List of executions. */ executions: Execution[]; - } + }; /** * Projects List @@ -509,7 +514,7 @@ export namespace Models { * List of projects. */ projects: Project[]; - } + }; /** * Webhooks List @@ -523,7 +528,7 @@ export namespace Models { * List of webhooks. */ webhooks: Webhook[]; - } + }; /** * API Keys List @@ -537,7 +542,7 @@ export namespace Models { * List of keys. */ keys: Key[]; - } + }; /** * Dev Keys List @@ -551,7 +556,7 @@ export namespace Models { * List of devKeys. */ devKeys: DevKey[]; - } + }; /** * Countries List @@ -565,7 +570,7 @@ export namespace Models { * List of countries. */ countries: Country[]; - } + }; /** * Continents List @@ -579,7 +584,7 @@ export namespace Models { * List of continents. */ continents: Continent[]; - } + }; /** * Languages List @@ -593,7 +598,7 @@ export namespace Models { * List of languages. */ languages: Language[]; - } + }; /** * Currencies List @@ -607,7 +612,7 @@ export namespace Models { * List of currencies. */ currencies: Currency[]; - } + }; /** * Phones List @@ -621,7 +626,7 @@ export namespace Models { * List of phones. */ phones: Phone[]; - } + }; /** * Variables List @@ -635,7 +640,7 @@ export namespace Models { * List of variables. */ variables: Variable[]; - } + }; /** * Mock Numbers List @@ -649,7 +654,7 @@ export namespace Models { * List of mockNumbers. */ mockNumbers: MockNumber[]; - } + }; /** * Policies List @@ -662,8 +667,24 @@ export namespace Models { /** * List of policies. */ - policies: (Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail)[]; - } + policies: ( + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + )[]; + }; /** * Email Templates List @@ -677,7 +698,7 @@ export namespace Models { * List of templates. */ templates: EmailTemplate[]; - } + }; /** * Rule List @@ -691,7 +712,7 @@ export namespace Models { * List of rules. */ rules: ProxyRule[]; - } + }; /** * Schedules List @@ -705,7 +726,7 @@ export namespace Models { * List of schedules. */ schedules: Schedule[]; - } + }; /** * Stages List @@ -715,7 +736,7 @@ export namespace Models { * List of stages. */ stages: Stage[]; - } + }; /** * Locale codes list @@ -729,7 +750,7 @@ export namespace Models { * List of localeCodes. */ localeCodes: LocaleCode[]; - } + }; /** * Provider list @@ -743,7 +764,7 @@ export namespace Models { * List of providers. */ providers: Provider[]; - } + }; /** * Message list @@ -757,7 +778,7 @@ export namespace Models { * List of messages. */ messages: Message[]; - } + }; /** * Topic list @@ -771,7 +792,7 @@ export namespace Models { * List of topics. */ topics: Topic[]; - } + }; /** * Subscriber list @@ -785,7 +806,7 @@ export namespace Models { * List of subscribers. */ subscribers: Subscriber[]; - } + }; /** * Target list @@ -799,7 +820,7 @@ export namespace Models { * List of targets. */ targets: Target[]; - } + }; /** * Transaction List @@ -813,7 +834,7 @@ export namespace Models { * List of transactions. */ transactions: Transaction[]; - } + }; /** * Migrations List @@ -827,7 +848,7 @@ export namespace Models { * List of migrations. */ migrations: Migration[]; - } + }; /** * Specifications List @@ -841,7 +862,7 @@ export namespace Models { * List of specifications. */ specifications: Specification[]; - } + }; /** * VCS Content List @@ -855,7 +876,7 @@ export namespace Models { * List of contents. */ contents: VcsContent[]; - } + }; /** * VectorsDB Collections List @@ -869,7 +890,7 @@ export namespace Models { * List of collections. */ collections: VectorsdbCollection[]; - } + }; /** * Embedding list @@ -883,7 +904,7 @@ export namespace Models { * List of embeddings. */ embeddings: Embedding[]; - } + }; /** * Insights List @@ -897,7 +918,7 @@ export namespace Models { * List of insights. */ insights: Insight[]; - } + }; /** * Reports List @@ -911,7 +932,7 @@ export namespace Models { * List of reports. */ reports: Report[]; - } + }; /** * Database @@ -957,6 +978,18 @@ export namespace Models { * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ replicas?: number; + /** + * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. + */ + error?: string; + /** + * Container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). Null when the database has no dedicated backing or the runtime has not reported one. + */ + containerStatus?: string; + /** + * Idle-lifecycle state of the dedicated backing: active, warm, cold, or hibernated. Null when the database has no dedicated backing or the runtime has not reported one. + */ + lifecycleState?: string; /** * Database backup policies. */ @@ -965,7 +998,7 @@ export namespace Models { * Database backup archives. */ archives?: BackupArchive[]; - } + }; /** * Embedding @@ -987,7 +1020,7 @@ export namespace Models { * Error message if embedding generation fails. Empty string if no error. */ error: string; - } + }; /** * Collection @@ -1028,7 +1061,26 @@ export namespace Models { /** * Collection attributes. */ - attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + attributes: ( + | Models.AttributeBoolean + | Models.AttributeBigint + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext + | Models.AttributeString + )[]; /** * Collection indexes. */ @@ -1041,7 +1093,7 @@ export namespace Models { * Currently used document size in bytes based on defined attributes. */ bytesUsed: number; - } + }; /** * Attributes List @@ -1054,8 +1106,27 @@ export namespace Models { /** * List of attributes. */ - attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; - } + attributes: ( + | Models.AttributeBoolean + | Models.AttributeBigint + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext + | Models.AttributeString + )[]; + }; /** * AttributeString @@ -1105,7 +1176,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeInteger @@ -1155,7 +1226,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number; - } + }; /** * AttributeBigInt @@ -1205,7 +1276,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number | bigint; - } + }; /** * AttributeFloat @@ -1255,7 +1326,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number; - } + }; /** * AttributeBoolean @@ -1297,7 +1368,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: boolean; - } + }; /** * AttributeEmail @@ -1343,7 +1414,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeEnum @@ -1393,7 +1464,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeIP @@ -1439,7 +1510,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeURL @@ -1485,7 +1556,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeDatetime @@ -1531,7 +1602,7 @@ export namespace Models { * Default value for attribute when not provided. Only null is optional */ default?: string; - } + }; /** * AttributeRelationship @@ -1593,7 +1664,7 @@ export namespace Models { * Whether this is the parent or child side of the relationship */ side: string; - } + }; /** * AttributePoint @@ -1635,7 +1706,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number[]; - } + }; /** * AttributeLine @@ -1677,7 +1748,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number[][]; - } + }; /** * AttributePolygon @@ -1719,7 +1790,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number[][][]; - } + }; /** * AttributeVarchar @@ -1769,7 +1840,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeText @@ -1815,7 +1886,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeMediumtext @@ -1861,7 +1932,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeLongtext @@ -1907,7 +1978,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * VectorsDB Collection @@ -1965,7 +2036,7 @@ export namespace Models { * Embedding dimension. */ dimension: number; - } + }; /** * AttributeObject @@ -2003,7 +2074,7 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - } + }; /** * AttributeVector @@ -2045,7 +2116,7 @@ export namespace Models { * Vector dimensions. */ size: number; - } + }; /** * Table @@ -2086,7 +2157,26 @@ export namespace Models { /** * Table columns. */ - columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + columns: ( + | Models.ColumnBoolean + | Models.ColumnBigint + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext + | Models.ColumnString + )[]; /** * Table indexes. */ @@ -2099,7 +2189,7 @@ export namespace Models { * Currently used row size in bytes based on defined columns. */ bytesUsed: number; - } + }; /** * Columns List @@ -2112,8 +2202,27 @@ export namespace Models { /** * List of columns. */ - columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; - } + columns: ( + | Models.ColumnBoolean + | Models.ColumnBigint + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext + | Models.ColumnString + )[]; + }; /** * ColumnString @@ -2163,7 +2272,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnInteger @@ -2213,7 +2322,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number; - } + }; /** * ColumnBigInt @@ -2263,7 +2372,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number | bigint; - } + }; /** * ColumnFloat @@ -2313,7 +2422,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number; - } + }; /** * ColumnBoolean @@ -2355,7 +2464,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: boolean; - } + }; /** * ColumnEmail @@ -2401,7 +2510,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnEnum @@ -2451,7 +2560,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnIP @@ -2497,7 +2606,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnURL @@ -2543,7 +2652,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnDatetime @@ -2589,7 +2698,7 @@ export namespace Models { * Default value for column when not provided. Only null is optional */ default?: string; - } + }; /** * ColumnRelationship @@ -2651,7 +2760,7 @@ export namespace Models { * Whether this is the parent or child side of the relationship */ side: string; - } + }; /** * ColumnPoint @@ -2693,7 +2802,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number[]; - } + }; /** * ColumnLine @@ -2735,7 +2844,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number[][]; - } + }; /** * ColumnPolygon @@ -2777,7 +2886,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number[][][]; - } + }; /** * ColumnVarchar @@ -2827,7 +2936,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnText @@ -2873,7 +2982,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnMediumtext @@ -2919,7 +3028,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnLongtext @@ -2965,7 +3074,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * Index @@ -3011,7 +3120,7 @@ export namespace Models { * Index orders. */ orders?: string[]; - } + }; /** * Index @@ -3057,7 +3166,7 @@ export namespace Models { * Index orders. */ orders?: string[]; - } + }; /** * Row @@ -3091,7 +3200,7 @@ export namespace Models { * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; - } + }; export type DefaultRow = Row & { [key: string]: any; @@ -3130,7 +3239,7 @@ export namespace Models { * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; - } + }; export type DefaultDocument = Document & { [key: string]: any; @@ -3177,7 +3286,7 @@ export namespace Models { * Presence metadata. */ metadata?: object; - } + }; /** * Log @@ -3271,12 +3380,14 @@ export namespace Models { * Country name. */ countryName: string; - } + }; /** * User */ - export type User = { + export type User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * User ID. */ @@ -3381,7 +3492,7 @@ export namespace Models { * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ impersonatorUserId?: string; - } + }; /** * AlgoMD5 @@ -3391,7 +3502,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoSHA @@ -3401,7 +3512,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoPHPass @@ -3411,7 +3522,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoBcrypt @@ -3421,7 +3532,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoScrypt @@ -3447,7 +3558,7 @@ export namespace Models { * Length used to compute hash. */ length: number; - } + }; /** * AlgoScryptModified @@ -3469,7 +3580,7 @@ export namespace Models { * Key used to compute hash. */ signerKey: string; - } + }; /** * AlgoArgon2 @@ -3491,13 +3602,12 @@ export namespace Models { * Number of threads used to compute hash. */ threads: number; - } + }; /** * Preferences */ - export type Preferences = { - } + export type Preferences = {}; export type DefaultPreferences = Preferences & { [key: string]: any; @@ -3624,7 +3734,7 @@ export namespace Models { * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. */ mfaUpdatedAt: string; - } + }; /** * Identity @@ -3670,7 +3780,7 @@ export namespace Models { * Identity Provider Refresh Token. */ providerRefreshToken: string; - } + }; /** * Notification @@ -3740,7 +3850,7 @@ export namespace Models { * Most recent time the notification was viewed from a notification logo. */ lastSeen?: string; - } + }; /** * Token @@ -3770,7 +3880,7 @@ export namespace Models { * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. */ phrase: string; - } + }; /** * JWT @@ -3780,7 +3890,7 @@ export namespace Models { * JWT encoded string. */ jwt: string; - } + }; /** * Locale @@ -3858,7 +3968,7 @@ export namespace Models { * Registered organization of the IP */ connectionOrganization?: string; - } + }; /** * LocaleCode @@ -3872,7 +3982,7 @@ export namespace Models { * Locale name */ name: string; - } + }; /** * File @@ -3942,7 +4052,7 @@ export namespace Models { * Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). */ compression: string; - } + }; /** * Bucket @@ -4004,7 +4114,7 @@ export namespace Models { * Total size of this bucket in bytes. */ totalSize: number; - } + }; /** * ResourceToken @@ -4038,12 +4148,14 @@ export namespace Models { * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ accessedAt: string; - } + }; /** * Team */ - export type Team = { + export type Team< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Team ID. */ @@ -4068,7 +4180,7 @@ export namespace Models { * Team preferences as a key-value object */ prefs: Preferences; - } + }; /** * Membership @@ -4134,7 +4246,7 @@ export namespace Models { * User list of roles */ roles: string[]; - } + }; /** * Site @@ -4204,6 +4316,10 @@ export namespace Models { * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ latestDeploymentStatus: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; /** * Site variables. */ @@ -4276,7 +4392,7 @@ export namespace Models { * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ fallbackFile: string; - } + }; /** * Template Site @@ -4297,7 +4413,7 @@ export namespace Models { /** * URL hosting a template demo. */ - demoUrl: string; + demoUrl?: string; /** * File URL with preview screenshot in dark theme preference. */ @@ -4334,7 +4450,7 @@ export namespace Models { * Site variables. */ variables: TemplateVariable[]; - } + }; /** * Template Framework @@ -4375,8 +4491,8 @@ export namespace Models { /** * Fallback file for SPA. Only relevant for static serve runtime. */ - fallbackFile: string; - } + fallbackFile?: string; + }; /** * Function @@ -4510,7 +4626,7 @@ export namespace Models { * Machine specification for executions. */ runtimeSpecification: string; - } + }; /** * Template Function @@ -4584,7 +4700,7 @@ export namespace Models { * Function scopes. */ scopes: string[]; - } + }; /** * Template Runtime @@ -4606,7 +4722,7 @@ export namespace Models { * Path to function in VCS (Version Control System) repository */ providerRootDirectory: string; - } + }; /** * Template Variable @@ -4640,7 +4756,7 @@ export namespace Models { * Variable Type. */ type: string; - } + }; /** * Installation @@ -4670,7 +4786,7 @@ export namespace Models { * VCS (Version Control System) installation ID. */ providerInstallationId: string; - } + }; /** * ProviderRepository @@ -4716,7 +4832,7 @@ export namespace Models { * Environment variables found in .env files */ variables: string[]; - } + }; /** * ProviderRepositoryFramework @@ -4766,7 +4882,7 @@ export namespace Models { * Auto-detected framework. Empty if type is not "framework". */ framework: string; - } + }; /** * ProviderRepositoryRuntime @@ -4816,7 +4932,7 @@ export namespace Models { * Auto-detected runtime. Empty if type is not "runtime". */ runtime: string; - } + }; /** * DetectionFramework @@ -4846,7 +4962,7 @@ export namespace Models { * Site Output Directory */ outputDirectory: string; - } + }; /** * DetectionRuntime @@ -4872,7 +4988,7 @@ export namespace Models { * Function install and build commands */ commands: string; - } + }; /** * DetectionVariable @@ -4886,7 +5002,7 @@ export namespace Models { * Value of environment variable */ value: string; - } + }; /** * VcsContents @@ -4904,7 +5020,7 @@ export namespace Models { * Name of directory or file. */ name: string; - } + }; /** * Branch @@ -4914,7 +5030,7 @@ export namespace Models { * Branch Name. */ name: string; - } + }; /** * Runtime @@ -4952,7 +5068,7 @@ export namespace Models { * List of supported architectures. */ supports: string[]; - } + }; /** * Framework @@ -4978,7 +5094,7 @@ export namespace Models { * List of supported adapters. */ adapters: FrameworkAdapter[]; - } + }; /** * Framework Adapter @@ -5003,8 +5119,8 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile: string; - } + fallbackFile?: string; + }; /** * Deployment @@ -5118,7 +5234,7 @@ export namespace Models { * The branch of the vcs repository */ providerBranchUrl: string; - } + }; /** * Execution @@ -5141,19 +5257,23 @@ export namespace Models { */ $permissions: string[]; /** - * Function ID. + * Function or site ID. */ - functionId: string; + resourceId: string; + /** + * Execution resource type. + */ + resourceType: ExecutionResourceType; /** - * Function's deployment ID used to create the execution. + * Deployment ID used to create the execution. */ deploymentId: string; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, or `event`. */ trigger: ExecutionTrigger; /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * The status of the resource execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. */ status: ExecutionStatus; /** @@ -5181,11 +5301,11 @@ export namespace Models { */ responseHeaders: Headers[]; /** - * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Resource logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ logs: string; /** - * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Resource errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ errors: string; /** @@ -5196,7 +5316,7 @@ export namespace Models { * The scheduled time for execution. If left empty, execution will be queued immediately. */ scheduledAt?: string; - } + }; /** * Project @@ -5313,7 +5433,7 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled: boolean; + wafEnabled?: boolean; /** * Billing limits reached */ @@ -5334,6 +5454,10 @@ export namespace Models { * OAuth2 server scopes used when an authorization request omits the scope parameter */ oAuth2ServerDefaultScopes?: string[]; + /** + * Scopes an application may request when installed on a team + */ + oAuth2ServerInstallationScopes?: string[]; /** * OAuth2 server accepted RFC 9396 authorization_details types */ @@ -5382,7 +5506,7 @@ export namespace Models { * OAuth2 server discovery URL */ oAuth2ServerDiscoveryUrl?: string; - } + }; /** * ProjectAuthMethod @@ -5396,7 +5520,7 @@ export namespace Models { * Auth method status. */ enabled: boolean; - } + }; /** * ProjectService @@ -5410,7 +5534,7 @@ export namespace Models { * Service status. */ enabled: boolean; - } + }; /** * ProjectProtocol @@ -5424,7 +5548,7 @@ export namespace Models { * Protocol status. */ enabled: boolean; - } + }; /** * Webhook @@ -5482,7 +5606,7 @@ export namespace Models { * Number of consecutive failed webhook attempts. */ attempts: number; - } + }; /** * Key @@ -5524,7 +5648,7 @@ export namespace Models { * List of SDK user agents that used this key. */ sdks: string[]; - } + }; /** * Ephemeral Key @@ -5566,7 +5690,7 @@ export namespace Models { * List of SDK user agents that used this key. */ sdks: string[]; - } + }; /** * DevKey @@ -5604,7 +5728,7 @@ export namespace Models { * List of SDK user agents that used this key. */ sdks: string[]; - } + }; /** * Mock Number @@ -5615,7 +5739,7 @@ export namespace Models { */ number: string; /** - * Mock OTP for the number. + * Mock OTP for the number. */ otp: string; /** @@ -5626,7 +5750,7 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - } + }; /** * OAuth2GitHub @@ -5648,7 +5772,7 @@ export namespace Models { * GitHub OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Discord @@ -5670,7 +5794,7 @@ export namespace Models { * Discord OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Figma @@ -5692,7 +5816,7 @@ export namespace Models { * Figma OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Dropbox @@ -5714,7 +5838,7 @@ export namespace Models { * Dropbox OAuth2 app secret. */ appSecret: string; - } + }; /** * OAuth2Dailymotion @@ -5736,7 +5860,7 @@ export namespace Models { * Dailymotion OAuth2 API secret. */ apiSecret: string; - } + }; /** * OAuth2Bitbucket @@ -5758,7 +5882,7 @@ export namespace Models { * Bitbucket OAuth2 secret. */ secret: string; - } + }; /** * OAuth2Bitly @@ -5780,7 +5904,7 @@ export namespace Models { * Bitly OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Box @@ -5802,7 +5926,7 @@ export namespace Models { * Box OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Autodesk @@ -5824,7 +5948,7 @@ export namespace Models { * Autodesk OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Google @@ -5850,7 +5974,7 @@ export namespace Models { * Google OAuth2 prompt values. */ prompt: OAuth2GooglePrompt[]; - } + }; /** * OAuth2Zoom @@ -5872,7 +5996,7 @@ export namespace Models { * Zoom OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Zoho @@ -5894,7 +6018,7 @@ export namespace Models { * Zoho OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Yandex @@ -5916,7 +6040,7 @@ export namespace Models { * Yandex OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2X @@ -5938,7 +6062,7 @@ export namespace Models { * X OAuth2 secret key. */ secretKey: string; - } + }; /** * OAuth2WordPress @@ -5960,7 +6084,7 @@ export namespace Models { * WordPress OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Twitch @@ -5982,7 +6106,7 @@ export namespace Models { * Twitch OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Stripe @@ -6004,7 +6128,7 @@ export namespace Models { * Stripe OAuth2 API secret key. */ apiSecretKey: string; - } + }; /** * OAuth2Spotify @@ -6026,7 +6150,7 @@ export namespace Models { * Spotify OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Slack @@ -6048,7 +6172,7 @@ export namespace Models { * Slack OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Podio @@ -6070,7 +6194,7 @@ export namespace Models { * Podio OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Notion @@ -6092,7 +6216,7 @@ export namespace Models { * Notion OAuth2 client secret. */ oauthClientSecret: string; - } + }; /** * OAuth2Salesforce @@ -6114,7 +6238,7 @@ export namespace Models { * Salesforce OAuth2 consumer secret. */ customerSecret: string; - } + }; /** * OAuth2Yahoo @@ -6136,7 +6260,51 @@ export namespace Models { * Yahoo OAuth2 client secret. */ clientSecret: string; - } + }; + + /** + * OAuth2Cloudflare + */ + export type OAuth2Cloudflare = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Cloudflare OAuth2 client ID. + */ + clientId: string; + /** + * Cloudflare OAuth2 client secret. + */ + clientSecret: string; + }; + + /** + * OAuth2HuggingFace + */ + export type OAuth2HuggingFace = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Hugging Face OAuth2 client ID. + */ + clientId: string; + /** + * Hugging Face OAuth2 client secret. + */ + clientSecret: string; + }; /** * OAuth2Linkedin @@ -6158,7 +6326,7 @@ export namespace Models { * LinkedIn OAuth2 primary client secret. */ primaryClientSecret: string; - } + }; /** * OAuth2Disqus @@ -6180,7 +6348,7 @@ export namespace Models { * Disqus OAuth2 secret key. */ secretKey: string; - } + }; /** * OAuth2Amazon @@ -6202,7 +6370,7 @@ export namespace Models { * Amazon OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Etsy @@ -6224,7 +6392,7 @@ export namespace Models { * Etsy OAuth2 shared secret. */ sharedSecret: string; - } + }; /** * OAuth2Facebook @@ -6246,7 +6414,7 @@ export namespace Models { * Facebook OAuth2 app secret. */ appSecret: string; - } + }; /** * OAuth2Tradeshift @@ -6268,7 +6436,7 @@ export namespace Models { * Tradeshift OAuth2 client secret. */ oauth2ClientSecret: string; - } + }; /** * OAuth2Paypal @@ -6290,7 +6458,7 @@ export namespace Models { * PayPal OAuth2 secret key. */ secretKey: string; - } + }; /** * OAuth2Gitlab @@ -6316,7 +6484,7 @@ export namespace Models { * GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted instances. */ endpoint: string; - } + }; /** * OAuth2Appwrite @@ -6338,7 +6506,7 @@ export namespace Models { * Appwrite OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Authentik @@ -6364,7 +6532,7 @@ export namespace Models { * Authentik OAuth2 endpoint domain. */ endpoint: string; - } + }; /** * OAuth2Auth0 @@ -6390,7 +6558,7 @@ export namespace Models { * Auth0 OAuth2 endpoint domain. */ endpoint: string; - } + }; /** * OAuth2FusionAuth @@ -6416,7 +6584,7 @@ export namespace Models { * FusionAuth OAuth2 endpoint domain. */ endpoint: string; - } + }; /** * OAuth2Keycloak @@ -6446,7 +6614,7 @@ export namespace Models { * Keycloak OAuth2 realm name. */ realmName: string; - } + }; /** * OAuth2Oidc @@ -6492,7 +6660,7 @@ export namespace Models { * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ maxAge?: number; - } + }; /** * OAuth2Okta @@ -6522,7 +6690,7 @@ export namespace Models { * Okta OAuth2 authorization server ID. */ authorizationServerId: string; - } + }; /** * OAuth2Kick @@ -6544,7 +6712,7 @@ export namespace Models { * Kick OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Apple @@ -6574,7 +6742,7 @@ export namespace Models { * Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. */ p8File: string; - } + }; /** * OAuth2Microsoft @@ -6600,7 +6768,73 @@ export namespace Models { * Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. */ tenant: string; - } + }; + + /** + * OAuth2Resend + */ + export type OAuth2Resend = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Resend OAuth2 client ID. + */ + clientId: string; + /** + * Resend OAuth2 client secret. + */ + clientSecret: string; + }; + + /** + * OAuth2TikTok + */ + export type OAuth2TikTok = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * TikTok OAuth2 client key. + */ + clientId: string; + /** + * TikTok OAuth2 client secret. + */ + clientSecret: string; + }; + + /** + * OAuth2Kakao + */ + export type OAuth2Kakao = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Kakao OAuth2 REST API key. + */ + clientId: string; + /** + * Kakao OAuth2 client secret. + */ + clientSecret: string; + }; /** * OAuth2 Providers List @@ -6613,8 +6847,55 @@ export namespace Models { /** * List of OAuth2 providers. */ - providers: (Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Appwrite | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft)[]; - } + providers: ( + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Appwrite + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare + | Models.OAuth2TikTok + | Models.OAuth2Kakao + )[]; + }; /** * Policy Password Dictionary @@ -6628,7 +6909,7 @@ export namespace Models { * Whether password dictionary policy is enabled. */ enabled: boolean; - } + }; /** * Policy Password History @@ -6642,7 +6923,7 @@ export namespace Models { * Password history length. A value of 0 means the policy is disabled. */ total: number; - } + }; /** * Policy Password Strength @@ -6672,7 +6953,7 @@ export namespace Models { * Whether passwords must include at least one symbol. */ symbols: boolean; - } + }; /** * Policy Password Personal Data @@ -6686,7 +6967,7 @@ export namespace Models { * Whether password personal data policy is enabled. */ enabled: boolean; - } + }; /** * Policy Session Alert @@ -6700,7 +6981,7 @@ export namespace Models { * Whether session alert policy is enabled. */ enabled: boolean; - } + }; /** * Policy Session Duration @@ -6714,7 +6995,7 @@ export namespace Models { * Session duration in seconds. */ duration: number; - } + }; /** * Policy Session Invalidation @@ -6728,7 +7009,7 @@ export namespace Models { * Whether session invalidation policy is enabled. */ enabled: boolean; - } + }; /** * Policy Session Limit @@ -6742,7 +7023,7 @@ export namespace Models { * Maximum number of sessions allowed per user. A value of 0 means the policy is disabled. */ total: number; - } + }; /** * Policy User Limit @@ -6756,7 +7037,7 @@ export namespace Models { * Maximum number of users allowed in the project. A value of 0 means the policy is disabled. */ total: number; - } + }; /** * Policy Membership Privacy @@ -6790,7 +7071,33 @@ export namespace Models { * Whether user last access time is visible in memberships. */ userAccessedAt: boolean; - } + }; + + /** + * Policy MFA Factors + */ + export type PolicyMfaFactors = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether TOTP can be used to complete an MFA challenge. + */ + totp: boolean; + /** + * Whether email can be used to complete an MFA challenge. + */ + email: boolean; + /** + * Whether phone (SMS) can be used to complete an MFA challenge. + */ + phone: boolean; + /** + * Whether the custom factor can be used to complete an MFA challenge. + */ + custom: boolean; + }; /** * Platform Web @@ -6820,7 +7127,7 @@ export namespace Models { * Web app hostname. Empty string for other platforms. */ hostname: string; - } + }; /** * Platform Apple @@ -6850,7 +7157,7 @@ export namespace Models { * Apple bundle identifier. */ bundleIdentifier: string; - } + }; /** * Platform Android @@ -6880,7 +7187,7 @@ export namespace Models { * Android application ID. */ applicationId: string; - } + }; /** * Platform Windows @@ -6910,7 +7217,7 @@ export namespace Models { * Windows package identifier name. */ packageIdentifierName: string; - } + }; /** * Platform Linux @@ -6940,7 +7247,7 @@ export namespace Models { * Linux package name. */ packageName: string; - } + }; /** * Platforms List @@ -6953,8 +7260,14 @@ export namespace Models { /** * List of platforms. */ - platforms: (Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux)[]; - } + platforms: ( + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + )[]; + }; /** * Variable @@ -6992,7 +7305,7 @@ export namespace Models { * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. */ resourceId: string; - } + }; /** * Country @@ -7006,7 +7319,7 @@ export namespace Models { * Country two-character ISO 3166-1 alpha code. */ code: string; - } + }; /** * Continent @@ -7020,7 +7333,7 @@ export namespace Models { * Continent two letter code. */ code: string; - } + }; /** * Language @@ -7038,7 +7351,7 @@ export namespace Models { * Language native name. */ nativeName: string; - } + }; /** * Currency @@ -7072,7 +7385,7 @@ export namespace Models { * Currency plural name */ namePlural: string; - } + }; /** * Phone @@ -7090,7 +7403,7 @@ export namespace Models { * Country name. */ countryName: string; - } + }; /** * Metric @@ -7104,7 +7417,7 @@ export namespace Models { * The date at which this metric was aggregated in ISO 8601 format. */ date: string; - } + }; /** * Metric Breakdown @@ -7126,7 +7439,7 @@ export namespace Models { * The estimated value of this metric at the end of the period. */ estimate?: number; - } + }; /** * UsageUsers @@ -7152,7 +7465,7 @@ export namespace Models { * Aggregated number of active sessions per period. */ sessions: Metric[]; - } + }; /** * UsagePresence @@ -7170,7 +7483,7 @@ export namespace Models { * Aggregated number of online users per period. */ presences: Metric[]; - } + }; /** * Project @@ -7448,7 +7761,171 @@ export namespace Models { * Aggregated consumed Realtime bandwidth (in bytes) per period. */ realtimeBandwidth: Metric[]; - } + }; + + /** + * usageDataPoint + */ + export type UsageDataPoint = { + /** + * Bucket start timestamp in ISO 8601. Omitted for flat dimension aggregates. + */ + time?: string; + /** + * Aggregated value for the point. + */ + value: number; + /** + * Value when broken down by `path`. + */ + path?: string; + /** + * Value when broken down by `method`. + */ + method?: string; + /** + * Value when broken down by `status`. + */ + status?: string; + /** + * Value when broken down by `service`. + */ + service?: string; + /** + * Value when broken down by `country`. + */ + country?: string; + /** + * Value when broken down by `region`. + */ + region?: string; + /** + * Value when broken down by `hostname`. + */ + hostname?: string; + /** + * Value when broken down by `ip`. + */ + ip?: string; + /** + * Value when broken down by `osName`. + */ + osName?: string; + /** + * Value when broken down by `clientType`. + */ + clientType?: string; + /** + * Value when broken down by `clientName`. + */ + clientName?: string; + /** + * Value when broken down by `sdk`. + */ + sdk?: string; + /** + * Value when broken down by `sdkVersion`. + */ + sdkVersion?: string; + /** + * Value when broken down by `deviceName`. + */ + deviceName?: string; + /** + * Value when broken down by `resourceId`. + */ + resourceId?: string; + /** + * Value when broken down by `resourceType`. + */ + resourceType?: string; + /** + * Value when broken down by `ordinal`. + */ + ordinal?: string; + /** + * Continent code when broken down by `continentCode`. + */ + continentCode?: string; + /** + * City name when broken down by `city`. + */ + city?: string; + /** + * Region/state chain when broken down by `subdivisions`. + */ + subdivisions?: string; + /** + * Internet service provider when broken down by `isp`. + */ + isp?: string; + /** + * Autonomous System Number (ASN) when broken down by `autonomousSystemNumber`. + */ + autonomousSystemNumber?: string; + /** + * Organization owning the ASN when broken down by `autonomousSystemOrganization`. + */ + autonomousSystemOrganization?: string; + /** + * Connection type when broken down by `connectionType`. + */ + connectionType?: string; + /** + * Connection usage type when broken down by `connectionUsageType`. + */ + connectionUsageType?: string; + /** + * Registered organization of the IP when broken down by `connectionOrganization`. + */ + connectionOrganization?: string; + /** + * Owning team ID when broken down by `teamId`. + */ + teamId?: string; + }; + + /** + * usageMetric + */ + export type UsageMetric = { + /** + * Metric key this series describes. + */ + metric: string; + /** + * Data points in the requested order. + */ + points: UsageDataPoint[]; + }; + + /** + * usageEventList + */ + export type UsageEventList = { + /** + * Requested interval, or an empty string for a flat aggregate. + */ + interval: string; + /** + * One series per requested event metric. + */ + metrics: UsageMetric[]; + }; + + /** + * usageGaugeList + */ + export type UsageGaugeList = { + /** + * Requested interval, or an empty string for a flat aggregate. + */ + interval: string; + /** + * One series per requested gauge metric. + */ + metrics: UsageMetric[]; + }; /** * Headers @@ -7462,7 +7939,7 @@ export namespace Models { * Header value. */ value: string; - } + }; /** * Specification @@ -7484,7 +7961,7 @@ export namespace Models { * Size slug. */ slug: string; - } + }; /** * Rule @@ -7550,7 +8027,7 @@ export namespace Models { * Certificate auto-renewal date in ISO 8601 format. */ renewAt: string; - } + }; /** * Schedule @@ -7600,7 +8077,7 @@ export namespace Models { * The region where the schedule is deployed. */ region: string; - } + }; /** * Stage @@ -7626,7 +8103,7 @@ export namespace Models { * Actor type when the stage was recorded. */ actorType: string; - } + }; /** * EmailTemplate @@ -7664,7 +8141,7 @@ export namespace Models { * Email subject */ subject: string; - } + }; /** * Console Variables @@ -7710,6 +8187,14 @@ export namespace Models { * List of configured VCS providers. */ _APP_VCS_PROVIDERS: string[]; + /** + * List of configured VCS providers that support repository creation. + */ + _APP_VCS_PROVIDERS_WITH_REPOSITORY_CREATION: string[]; + /** + * List of configured VCS providers that can host public repositories. + */ + _APP_VCS_PROVIDERS_WITH_PUBLIC_REPOSITORIES: string[]; /** * Defines if main domain is configured. If so, custom domains can be created. */ @@ -7782,7 +8267,7 @@ export namespace Models { * Whether email verification for console users is required. Can be "true" or "false". */ _APP_CONSOLE_EMAIL_VERIFICATION: string; - } + }; /** * Console OAuth2 Provider Parameter @@ -7804,7 +8289,7 @@ export namespace Models { * Optional hint for this parameter, typically calling out a common wrong value. Empty string when no hint is set. */ hint: string; - } + }; /** * Console OAuth2 Provider @@ -7818,7 +8303,7 @@ export namespace Models { * List of parameters required to configure this OAuth2 provider. */ parameters: ConsoleOAuth2ProviderParameter[]; - } + }; /** * Console OAuth2 Providers List @@ -7832,7 +8317,7 @@ export namespace Models { * List of OAuth2 providers, each with the parameters required to configure it. */ oAuth2Providers: ConsoleOAuth2Provider[]; - } + }; /** * Console Key Scope @@ -7854,7 +8339,7 @@ export namespace Models { * Scope is deprecated. */ deprecated: boolean; - } + }; /** * Console Key Scopes List @@ -7868,7 +8353,7 @@ export namespace Models { * List of key scopes, each with its ID and description. */ scopes: ConsoleKeyScope[]; - } + }; /** * MFA Challenge @@ -7890,7 +8375,33 @@ export namespace Models { * Token expiration date in ISO 8601 format. */ expire: string; - } + }; + + /** + * MFA Challenge Secret + */ + export type MfaChallengeSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * Challenge code to be delivered to the end user through a custom channel. + */ + code: string; + }; /** * MFA Recovery Codes @@ -7900,7 +8411,7 @@ export namespace Models { * Recovery codes. */ recoveryCodes: string[]; - } + }; /** * MFAType @@ -7914,7 +8425,7 @@ export namespace Models { * URI for authenticator apps. */ uri: string; - } + }; /** * MFAFactors @@ -7936,7 +8447,11 @@ export namespace Models { * Can recovery code be used for MFA challenge for this account. */ recoveryCode: boolean; - } + /** + * Can custom factor be used for MFA challenge for this account. + */ + custom: boolean; + }; /** * Provider @@ -7978,7 +8493,7 @@ export namespace Models { * Provider options. */ options?: object; - } + }; /** * Message @@ -8036,7 +8551,7 @@ export namespace Models { * Status of delivery. */ status: MessageStatus; - } + }; /** * Topic @@ -8074,7 +8589,7 @@ export namespace Models { * Subscribe permissions. */ subscribe: string[]; - } + }; /** * Transaction @@ -8104,7 +8619,7 @@ export namespace Models { * Expiration time in ISO 8601 format. */ expiresAt: string; - } + }; /** * Subscriber @@ -8146,7 +8661,7 @@ export namespace Models { * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ providerType: string; - } + }; /** * Target @@ -8188,7 +8703,7 @@ export namespace Models { * Is the target expired. */ expired: boolean; - } + }; /** * Migration @@ -8207,7 +8722,7 @@ export namespace Models { */ $updatedAt: string; /** - * Migration status ( pending, processing, failed, completed ) + * Migration status ( pending, processing, failed, completed ) */ status: string; /** @@ -8269,7 +8784,7 @@ export namespace Models { /** * An array of objects containing the report data of the resources that were migrated. */ - resourceData: object; + resourceData: Record[]; /** * All errors that occurred during the migration process. */ @@ -8278,7 +8793,7 @@ export namespace Models { * Migration options used during the migration process. */ options: object; - } + }; /** * Migration Report @@ -8396,7 +8911,7 @@ export namespace Models { * Number of backup policies to be migrated. */ backuppolicy: number; - } + }; /** * Insight @@ -8470,7 +8985,7 @@ export namespace Models { * User ID that dismissed the insight. Empty when not dismissed. */ dismissedBy?: string; - } + }; /** * InsightCTA @@ -8492,7 +9007,7 @@ export namespace Models { * Parameter map the client should pass to the service method when this CTA is triggered. Keys match the target API's parameter names (e.g. databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes for the legacy Databases API). */ params: object; - } + }; /** * Report @@ -8546,7 +9061,7 @@ export namespace Models { * Time the report was analyzed in ISO 8601 format. */ analyzedAt?: string; - } + }; /** * ActivityEvent @@ -8668,7 +9183,7 @@ export namespace Models { * Version of the SDK that triggered the event. */ sdkVersion: string; - } + }; /** * AdditionalResource @@ -8698,7 +9213,7 @@ export namespace Models { * Description on invoice */ invoiceDesc: string; - } + }; /** * Addon @@ -8744,7 +9259,7 @@ export namespace Models { * Value to apply at the start of the next billing cycle. Null means no change is scheduled. For toggle addons, 0 means the addon will be removed at the next cycle. */ nextValue?: number; - } + }; /** * AddonPrice @@ -8782,7 +9297,7 @@ export namespace Models { * When the current billing cycle ends. */ billingCycleEnd: string; - } + }; /** * AffiliateLink @@ -8812,7 +9327,7 @@ export namespace Models { * Link status. Can be one of `active` or `disabled`. */ status: string; - } + }; /** * Affiliate links list @@ -8826,7 +9341,7 @@ export namespace Models { * List of links. */ links: AffiliateLink[]; - } + }; /** * AffiliateReferral @@ -8872,7 +9387,7 @@ export namespace Models { * Conversion time in ISO 8601 format. */ convertedAt?: string; - } + }; /** * Affiliate referrals list @@ -8886,7 +9401,7 @@ export namespace Models { * List of referrals. */ referrals: AffiliateReferral[]; - } + }; /** * AffiliateReward @@ -8932,7 +9447,7 @@ export namespace Models { * Credit document ID created when the reward was claimed. */ creditId?: string; - } + }; /** * Affiliate rewards list @@ -8946,7 +9461,7 @@ export namespace Models { * List of rewards. */ rewards: AffiliateReward[]; - } + }; /** * Breakdown @@ -8969,10 +9484,10 @@ export namespace Models { */ amount: number; /** - * + * */ resources: UsageResources[]; - } + }; /** * Team @@ -9026,6 +9541,14 @@ export namespace Models { * Total databases storage usage */ usageDatabasesStorage: number; + /** + * Total functions storage usage, deployments and builds together. Supersedes usageDeploymentsStorage and usageBuildsStorage. + */ + usageFunctionsStorage: number; + /** + * Total sites storage usage, deployments and builds together. Supersedes usageDeploymentsStorage and usageBuildsStorage. + */ + usageSitesStorage: number; /** * Total active users for the billing period */ @@ -9094,7 +9617,7 @@ export namespace Models { * Usage resources */ resources: UsageResources[]; - } + }; /** * Archive @@ -9148,7 +9671,7 @@ export namespace Models { * The resource type to backup. Set only if this archive should backup a single resource. */ resourceType?: string; - } + }; /** * Backup @@ -9222,7 +9745,7 @@ export namespace Models { * Error message if backup failed. */ error: string; - } + }; /** * BackupList @@ -9236,7 +9759,7 @@ export namespace Models { * List of backups. */ backups: DedicatedDatabaseBackup[]; - } + }; /** * BackupStorageConfig @@ -9262,7 +9785,7 @@ export namespace Models { * Custom endpoint for S3-compatible storage. */ endpoint: string; - } + }; /** * Address @@ -9300,7 +9823,7 @@ export namespace Models { * postal code */ postalCode: string; - } + }; /** * Limits @@ -9338,7 +9861,7 @@ export namespace Models { * Budget limit percentage */ budgetLimit?: number; - } + }; /** * billingPlan @@ -9492,6 +10015,10 @@ export namespace Models { * Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). */ usageLogsIntervals?: string[]; + /** + * Metrics this plan only records as a total. They cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. + */ + usageAggregateOnlyMetrics?: string[]; /** * Number of days of console inactivity before a project is paused. 0 means pausing is disabled. */ @@ -9556,6 +10083,10 @@ export namespace Models { * Does plan support credit */ supportsCredits: boolean; + /** + * Does plan support dedicated databases. + */ + supportsDedicatedDatabases: boolean; /** * Does plan support blocking disposable email addresses. */ @@ -9616,11 +10147,15 @@ export namespace Models { * Details of the program this plan is a part of. */ program?: Program; + /** + * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. + */ + databaseComputeCredit: number; /** * Dedicated database limits available to this plan. */ dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; - } + }; /** * Addon @@ -9634,7 +10169,7 @@ export namespace Models { * Addon projects */ projects?: BillingPlanAddonDetails; - } + }; /** * Details @@ -9672,7 +10207,7 @@ export namespace Models { * Description on invoice */ invoiceDesc: string; - } + }; /** * PlanLimits @@ -9686,7 +10221,7 @@ export namespace Models { * Daily credits limit (if applicable) */ dailyCredits?: number; - } + }; /** * dedicatedDatabaseLimits @@ -9768,7 +10303,7 @@ export namespace Models { * Replica synchronization modes available for dedicated databases. */ allowedSyncModes?: string[]; - } + }; /** * BillingPlanSupportedAddons @@ -9786,7 +10321,7 @@ export namespace Models { * Whether the plan supports Premium Geo DB addon (organization-level) */ premiumGeoDBOrg: boolean; - } + }; /** * Block @@ -9836,7 +10371,7 @@ export namespace Models { * Billing plan of the organization that owns the project. */ billingPlan: string; - } + }; /** * BlockDelete @@ -9850,7 +10385,7 @@ export namespace Models { * List of deleted blocks */ blocks: Block[]; - } + }; /** * Branch @@ -9881,7 +10416,7 @@ export namespace Models { */ port: number; /** - * Database name the client sends for routing to the branch. + * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ database: string; /** @@ -9904,17 +10439,21 @@ export namespace Models { * Full connection string for the branch. */ connectionString: string; - } + }; /** * BranchList */ export type DedicatedDatabaseBranchList = { + /** + * Total number of branches. + */ + total: number; /** * List of branches. */ branches: DedicatedDatabaseBranch[]; - } + }; /** * Campaign @@ -9968,7 +10507,7 @@ export namespace Models { * Is footer */ footer?: boolean; - } + }; /** * Coupon @@ -10006,7 +10545,7 @@ export namespace Models { * If the coupon is only valid for new organizations or not. */ onlyNewOrgs: boolean; - } + }; /** * Credit @@ -10056,7 +10595,7 @@ export namespace Models { * Status of the credit. Can be one of `disabled`, `active` or `expired`. */ status: string; - } + }; /** * CreditAvailable @@ -10066,7 +10605,7 @@ export namespace Models { * Total available credits for the organization. */ available: number; - } + }; /** * CreditList @@ -10084,7 +10623,7 @@ export namespace Models { * Total available credit balance in USD */ available: number; - } + }; /** * Database Migration @@ -10130,6 +10669,10 @@ export namespace Models { * Number of documents still pending replication to the target. */ lagDocuments: number; + /** + * Highest source changelog sequence applied to the target so far. + */ + changelogWatermark: number; /** * Time the migrated data was verified against the source in ISO 8601 format. */ @@ -10143,14 +10686,18 @@ export namespace Models { */ soakUntil: string; /** - * Whether the migration cuts over automatically once ready. + * Whether the migration cuts over automatically once ready. Set when the migration is created and never changed afterwards, so it always reports what was asked for. */ autoCutover: boolean; + /** + * Whether a cutover has been requested and not yet attempted. Set by the cutover endpoint and cleared when the attempt is made, so a cutover that fails a check parks the migration again rather than retrying on its own. + */ + cutoverRequested: boolean; /** * Whether the migration is paused. */ paused: boolean; - } + }; /** * DedicatedDatabase @@ -10193,7 +10740,7 @@ export namespace Models { */ specification: string; /** - * Database backend provider. Possible values: prisma, edge. + * Database backend provider. Possible values: edge. */ backend: string; /** @@ -10212,6 +10759,10 @@ export namespace Models { * Database password for connections. */ connectionPassword: string; + /** + * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. + */ + credentialGeneration: number; /** * Full database connection string (URI format). */ @@ -10225,7 +10776,7 @@ export namespace Models { */ status: string; /** - * Container status for lifecycle-managed database runtimes: active or inactive. + * Container status for lifecycle-managed database runtimes: active, inactive, or failed (a wake was declined because the backing namespace is gone). */ containerStatus: string; /** @@ -10256,6 +10807,18 @@ export namespace Models { * Storage allocated in GB. */ storage: number; + /** + * Storage resize status. Possible values: idle (no resize in flight), resizing (the volume is growing towards storageTargetGb). + */ + storageStatus: string; + /** + * Size in GB the volume is growing towards while storageStatus is resizing. 0 when no resize is in flight. + */ + storageTargetGb: number; + /** + * Time the in-flight storage resize started, in ISO 8601 format. + */ + storageResizeStartedAt?: string; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -10276,10 +10839,6 @@ export namespace Models { * Replication sync mode: async, sync, or quorum. */ syncMode: string; - /** - * Number of cross-region replicas. Cross-region availability is enabled when greater than 0. - */ - crossRegionReplicas: number; /** * Maximum concurrent client connections. This is the limit a client pool may reach; the engine's own max_connections reported by the status endpoint is a smaller backend limit the pooler multiplexes onto and does not constrain a client pool. */ @@ -10313,7 +10872,7 @@ export namespace Models { */ storageAutoscalingThresholdPercent: number; /** - * Maximum storage size in GB for autoscaling. 0 means no limit. + * Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. */ storageAutoscalingMaxGb: number; /** @@ -10352,7 +10911,7 @@ export namespace Models { * Error message if status is failed. */ error: string; - } + }; /** * Execution @@ -10361,7 +10920,7 @@ export namespace Models { /** * Result rows as a list of column-name => value maps. Empty for non-returning statements. */ - rows: object; + rows: Record[]; /** * Number of rows returned (for SELECT) or affected (for INSERT/UPDATE/DELETE). */ @@ -10382,7 +10941,7 @@ export namespace Models { * Serialised payload size in bytes. */ bytes: number; - } + }; /** * ExecutionColumn @@ -10396,7 +10955,7 @@ export namespace Models { * Engine-specific column type (e.g. int4, text, timestamptz). */ type: string; - } + }; /** * Restoration @@ -10411,9 +10970,13 @@ export namespace Models { */ $createdAt: string; /** - * Database ID being restored. + * Database ID being restored into. */ databaseId: string; + /** + * Source database ID when restoring a backup into another database. + */ + sourceDatabaseId: string; /** * Project ID. */ @@ -10446,14 +11009,14 @@ export namespace Models { * Error message if restoration failed. */ error: string; - } + }; /** * Status */ export type DatabaseStatus = { /** - * Overall health status: healthy, degraded, or unhealthy. + * Overall health status: healthy, degraded, unhealthy, or unknown when nothing could be measured. */ health: string; /** @@ -10497,9 +11060,9 @@ export namespace Models { */ syncStandbyCount: number; /** - * Whether the reported sync state was read from the engine. When false the state could not be confirmed and the other sync fields carry no reading. + * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed: boolean; + syncStateConfirmed?: boolean; /** * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ @@ -10508,7 +11071,7 @@ export namespace Models { * Storage volume information. */ volumes: DatabaseStatusVolume[]; - } + }; /** * DNSRecord @@ -10562,7 +11125,7 @@ export namespace Models { * Comment for the DNS record. */ comment: string; - } + }; /** * Domain @@ -10620,7 +11183,7 @@ export namespace Models { * Dns records */ dnsRecords: DnsRecord[]; - } + }; /** * DomainPrice @@ -10639,9 +11202,9 @@ export namespace Models { */ available: boolean; /** - * Domain registration price. + * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. */ - price: number; + price?: number; /** * Price period in years. */ @@ -10650,7 +11213,15 @@ export namespace Models { * Whether the domain is a premium domain. */ premium: boolean; - } + /** + * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. + */ + renewalPrice?: number; + /** + * Renewal price period in years. + */ + renewalPeriodYears: number; + }; /** * DomainPurchase @@ -10696,7 +11267,7 @@ export namespace Models { * Currency code. */ currency: string; - } + }; /** * DomainSuggestion @@ -10718,7 +11289,7 @@ export namespace Models { * Is the domain available? */ available: boolean; - } + }; /** * domainTransferOut @@ -10728,7 +11299,7 @@ export namespace Models { * Domain transfer authorization code. */ authCode: string; - } + }; /** * domainTransferStatus @@ -10746,7 +11317,7 @@ export namespace Models { * Transfer status timestamp in ISO 8601 format. */ timestamp: string; - } + }; /** * Downgrade Feedback @@ -10792,7 +11363,7 @@ export namespace Models { * Console version */ version: string; - } + }; /** * Estimation @@ -10830,7 +11401,7 @@ export namespace Models { * Trial end date */ trialEndDate?: string; - } + }; /** * DeleteOrganization @@ -10840,7 +11411,7 @@ export namespace Models { * List of unpaid invoices */ unpaidInvoices: Invoice[]; - } + }; /** * Item @@ -10854,7 +11425,7 @@ export namespace Models { * Gross payable amount */ value: number; - } + }; /** * EstimationPlanChange @@ -10880,7 +11451,7 @@ export namespace Models { * Plan limits and compliance information */ limits: PlanChangeLimits; - } + }; /** * UpdatePlan @@ -10922,7 +11493,7 @@ export namespace Models { * Organization's existing credits */ organizationCredits: number; - } + }; /** * Extensions @@ -10940,7 +11511,7 @@ export namespace Models { * Curated metadata (display name, description, category) for each available extension. */ metadata: PostgresExtension[]; - } + }; /** * Member @@ -10959,10 +11530,14 @@ export namespace Models { */ status: string; /** - * Replication lag in seconds. Null when the lag is not known: a primary has none to report, and a member the backend has not probed has none yet. + * Whether the engine reports this member's replication stream as up. Null when no reading was taken: a primary has no stream to report, and a member that is not active, or whose probe did not answer, has none yet. False is a reading and null is the absence of one, so the two are not interchangeable. Read it beside lagSeconds before expecting a failover that names no target to find a promotable standby: a member streaming at a known lag is one, and a member reporting null is not evidence either way. + */ + replicating?: boolean; + /** + * Replication lag in seconds. Null when the lag is not known: a primary has none to report, and a member the backend has not probed has none yet. Also null against `replicating: true`, for a member that is streaming but whose engine printed no numeric lag. */ lagSeconds?: number; - } + }; /** * Operation @@ -10981,11 +11556,11 @@ export namespace Models { */ databaseId: string; /** - * Operation type, such as provision, update, restore, pausing, resuming, failover, backup-create or cross-region-enable. + * Operation type, such as provision, update, credentials-update, restore, pausing, resuming, failover, backup-create or cross-region-enable. */ type: string; /** - * Operation status. Possible values: running (in progress), completed (finished successfully), failed (ended in an error). + * Operation status. Possible values: queued (accepted and waiting to resume), running (in progress), completed (finished successfully), failed (ended in an error). */ status: string; /** @@ -11005,14 +11580,14 @@ export namespace Models { */ completedAt?: string; /** - * Machine-readable failure code. `LockLost` marks an attempt that was fenced and abandoned because another worker took over the database. + * Machine-readable failure code. `Interrupted` marks an attempt that ended before its outcome could be confirmed. */ errorCode: string; /** * Failure message if the operation failed. */ errorMessage: string; - } + }; /** * OperationList @@ -11026,7 +11601,7 @@ export namespace Models { * List of operations. */ operations: DedicatedDatabaseOperation[]; - } + }; /** * Replicas @@ -11057,14 +11632,14 @@ export namespace Models { */ syncStandbyCount: number; /** - * Whether the reported sync state was read from the engine. When false the state could not be confirmed and the other sync fields carry no reading. + * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed: boolean; + syncStateConfirmed?: boolean; /** * Per-pod statuses for the primary and every replica. */ members: DedicatedDatabaseMember[]; - } + }; /** * Invalidation @@ -11086,7 +11661,7 @@ export namespace Models { * Invalidation status. */ status: string; - } + }; /** * Invoice @@ -11184,12 +11759,14 @@ export namespace Models { * End date of the invoice */ to: string; - } + }; /** * Organization */ - export type Organization = { + export type Organization< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Team ID. */ @@ -11330,7 +11907,7 @@ export namespace Models { * Selected projects */ projects: string[]; - } + }; /** * PaymentAuthentication @@ -11360,7 +11937,7 @@ export namespace Models { * Project ID for project-level addon payments. Empty for organization-level addons. */ projectId: string; - } + }; /** * paymentMethod @@ -11446,7 +12023,7 @@ export namespace Models { * True when payment method has failed to process multiple times. */ failed: boolean; - } + }; /** * PITRWindows @@ -11460,7 +12037,7 @@ export namespace Models { * Latest available recovery point. */ latest: string; - } + }; /** * PlanChangeEstimationDetails @@ -11497,38 +12074,46 @@ export namespace Models { /** * Line items breakdown */ - items: object; + items: Record[]; /** * Applied discounts breakdown */ - discounts: object; - } + discounts: Record[]; + }; /** * PlanChangeLimits */ export type PlanChangeLimits = { /** - * Total number of projects in the organization + * Whether the plan change is allowed */ - totalProjects: number; + canChangePlan: boolean; /** - * Number of projects exceeding target plan limits + * Active addon keys that the target plan does not support. When non-empty, `canChangePlan` is false. */ - nonCompliantProjects: number; + unsupportedAddons: string[]; /** - * Whether the plan change is allowed + * Project count against the target plan limit */ - canChangePlan: boolean; + projects: PlanChangeResourceCompliance; /** - * Project compliance details + * Organization member count against the target plan limit */ - projects: PlanChangeProjectCompliance[]; + members: PlanChangeResourceCompliance; /** - * Active addon keys that the target plan does not support. When non-empty, `canChangePlan` is false. + * Custom domain count against the target plan limit */ - unsupportedAddons: string[]; - } + domains: PlanChangeResourceCompliance; + /** + * Number of projects exceeding target plan limits + */ + nonCompliantProjects: number; + /** + * Per-project compliance details. Populated for downgrades only. + */ + projectCompliance: PlanChangeProjectCompliance[]; + }; /** * PlanChangeProjectCompliance @@ -11554,7 +12139,7 @@ export namespace Models { * Failure reason when compliance could not be evaluated. Present only when the project DB or Regions API was unreachable; in that case `isCompliant` is false (fail closed) and `resources` is empty. */ error?: string; - } + }; /** * PlanChangeResourceCompliance @@ -11573,7 +12158,7 @@ export namespace Models { */ limit: number; /** - * Compliance status + * Compliance status. Either `over_limit` or `within_limit`. */ status: string; /** @@ -11581,10 +12166,10 @@ export namespace Models { */ excess: number; /** - * Suggestion for resolving the compliance issue + * Suggestion for resolving the compliance issue. Empty when the resource is within limits. */ resolutionHint: string; - } + }; /** * backup @@ -11638,7 +12223,7 @@ export namespace Models { * Is this policy enabled. */ enabled: boolean; - } + }; /** * Policy Deny Aliased Email @@ -11652,7 +12237,7 @@ export namespace Models { * Whether the deny aliased email policy is enabled. */ enabled: boolean; - } + }; /** * Policy Deny Disposable Email @@ -11666,7 +12251,7 @@ export namespace Models { * Whether the deny disposable email policy is enabled. */ enabled: boolean; - } + }; /** * Policy Deny Free Email @@ -11680,7 +12265,7 @@ export namespace Models { * Whether the deny free email policy is enabled. */ enabled: boolean; - } + }; /** * Policy Deny Corporate Email @@ -11694,7 +12279,7 @@ export namespace Models { * Whether the deny non-corporate email policy is enabled. */ enabled: boolean; - } + }; /** * PoolerConfig @@ -11740,7 +12325,7 @@ export namespace Models { * Effective memory limit applied to the pooler sidecar container (Kubernetes quantity). Returns the proportional default (15% of DB memory, floor 128Mi) unless overridden. */ poolerMemoryLimit: string; - } + }; /** * Postgres extension @@ -11762,7 +12347,7 @@ export namespace Models { * Category the extension belongs to. */ category: string; - } + }; /** * Program @@ -11804,7 +12389,7 @@ export namespace Models { * Billing plan ID that this is program is associated with. */ billingPlanId: string; - } + }; /** * Region @@ -11834,7 +12419,7 @@ export namespace Models { * Region flag code. */ flag: string; - } + }; /** * Restoration @@ -11881,10 +12466,10 @@ export namespace Models { */ resources: string[]; /** - * Optional data in key-value object. + * Optional data in key-value object. */ options: string; - } + }; /** * Dedicated database restorations list @@ -11898,7 +12483,7 @@ export namespace Models { * List of restorations. */ restorations: DedicatedDatabaseRestoration[]; - } + }; /** * Review @@ -11920,7 +12505,7 @@ export namespace Models { * Review */ review: string; - } + }; /** * Roles @@ -11934,24 +12519,40 @@ export namespace Models { * Array of roles assigned to current user. */ roles: string[]; - } + }; /** * Specification */ export type DedicatedDatabaseSpecification = { /** - * Specification slug. Use this value when creating a dedicated database. + * Specification slug. Use this value when creating a dedicated database. + */ + slug: string; + /** + * Human readable specification name. + */ + name: string; + /** + * Monthly price of the specification in USD. + */ + price: number; + /** + * Price per GB of storage above the included amount, per month, in USD. + */ + storageOverageRate: number; + /** + * Price per GB of bandwidth above the included amount, per month, in USD. */ - slug: string; + bandwidthOverageRate: number; /** - * Human readable specification name. + * High availability replica price as a fraction of the specification price. */ - name: string; + replicaRate: number; /** - * Monthly price of the specification in USD. + * Point-in-time recovery price as a fraction of the specification price. */ - price: number; + pitrRate: number; /** * Allocated CPU in millicores. */ @@ -11976,7 +12577,7 @@ export namespace Models { * Whether the specification is available on the current plan. */ enabled: boolean; - } + }; /** * SpecificationList @@ -11990,37 +12591,7 @@ export namespace Models { * Total number of specifications. */ total: number; - /** - * Overage and add-on pricing shared across all specifications. - */ - pricing: DedicatedDatabaseSpecificationPricing; - } - - /** - * SpecificationPricing - */ - export type DedicatedDatabaseSpecificationPricing = { - /** - * Price per GB of storage above the included amount, per month, in USD. - */ - storageOverageRate: number; - /** - * Price per GB of bandwidth above the included amount, per month, in USD. - */ - bandwidthOverageRate: number; - /** - * High availability replica price as a fraction of the specification cost. - */ - replicaRate: number; - /** - * Cross-region replica price as a fraction of the specification cost. - */ - crossRegionReplicaRate: number; - /** - * Point-in-time recovery price as a fraction of the specification cost. - */ - pitrRate: number; - } + }; /** * Connections @@ -12034,7 +12605,7 @@ export namespace Models { * The engine's own max_connections. On a pooled database this is the backend limit the pooler multiplexes onto, not the ceiling a client pool may reach — that is networkMaxConnections on the database resource. */ max: number; - } + }; /** * Replica @@ -12053,10 +12624,14 @@ export namespace Models { */ healthy: boolean; /** - * Replication lag in seconds (null for primary). + * Whether the engine reports this member's replication stream as up. Null when no reading was taken: a primary has no stream to report, and a member that is not healthy, or whose probe did not answer, has none yet. `healthy` is a reachability probe of the member itself and says nothing about replication, so a healthy member may still not be replicating. + */ + replicating?: boolean; + /** + * Replication lag in seconds (null for primary). Also null against `replicating: true`, for a member that is streaming but whose engine printed no numeric lag. */ lagSeconds?: number; - } + }; /** * Volume @@ -12078,7 +12653,7 @@ export namespace Models { * Whether the volume is mounted. */ mounted: boolean; - } + }; /** * usageBillingPlan @@ -12128,171 +12703,7 @@ export namespace Models { * Credits additional resources */ credits?: AdditionalResource; - } - - /** - * usageDataPoint - */ - export type UsageDataPoint = { - /** - * Bucket start timestamp (ISO 8601). When `interval` is omitted this is the request end time, marking the aggregate as-of moment. - */ - time: string; - /** - * Aggregated value for the bucket. Counters are whole numbers; gauge rates (e.g. queries per second) may be fractional. - */ - value: number; - /** - * API endpoint path when broken down by `path`. - */ - path?: string; - /** - * HTTP method when broken down by `method`. - */ - method?: string; - /** - * HTTP status code when broken down by `status`. - */ - status?: string; - /** - * API service segment when broken down by `service`. - */ - service?: string; - /** - * Country code when broken down by `country`. - */ - country?: string; - /** - * Continent code when broken down by `continentCode`. - */ - continentCode?: string; - /** - * City name when broken down by `city`. - */ - city?: string; - /** - * Region/state chain when broken down by `subdivisions`. - */ - subdivisions?: string; - /** - * Internet service provider when broken down by `isp`. - */ - isp?: string; - /** - * Autonomous System Number (ASN) when broken down by `autonomousSystemNumber`. - */ - autonomousSystemNumber?: string; - /** - * Organization owning the ASN when broken down by `autonomousSystemOrganization`. - */ - autonomousSystemOrganization?: string; - /** - * Connection type (e.g. cable, cellular, corporate) when broken down by `connectionType`. - */ - connectionType?: string; - /** - * User type (e.g. residential, business, hosting) when broken down by `connectionUsageType`. - */ - connectionUsageType?: string; - /** - * Registered organization of the IP when broken down by `connectionOrganization`. - */ - connectionOrganization?: string; - /** - * Appwrite region when broken down by `region`. - */ - region?: string; - /** - * Caller origin hostname when broken down by `hostname`. - */ - hostname?: string; - /** - * Caller IP address when broken down by `ip`. - */ - ip?: string; - /** - * Operating system name when broken down by `osName`. - */ - osName?: string; - /** - * Client type when broken down by `clientType`. - */ - clientType?: string; - /** - * Client name when broken down by `clientName`. - */ - clientName?: string; - /** - * SDK name when broken down by `sdk`. - */ - sdk?: string; - /** - * SDK version when broken down by `sdkVersion`. - */ - sdkVersion?: string; - /** - * Device classification when broken down by `deviceName`. - */ - deviceName?: string; - /** - * Owning team ID when broken down by `teamId`. - */ - teamId?: string; - /** - * External resource ID when broken down by `resourceId`. - */ - resourceId?: string; - /** - * Resource type when broken down by `resourceType`. - */ - resourceType?: string; - /** - * Node ordinal when broken down by `ordinal`. A stable per-node identity, not a role: ordinal 0 is the first member created, and a failover can leave the primary on any ordinal. Read the role from the database's replicas endpoint. - */ - ordinal?: string; - } - - /** - * usageEventList - */ - export type UsageEventList = { - /** - * Time interval size (1h or 1d). Empty when the request omits `interval` — points then carry the request end time as their as-of marker. - */ - interval: string; - /** - * One entry per requested metric, each carrying its own points[] time series (sums per bucket / dimension over time). - */ - metrics: UsageMetric[]; - } - - /** - * usageGaugeList - */ - export type UsageGaugeList = { - /** - * Time interval size (1h or 1d). Empty when the request omits `interval` — points then carry the request end time as their as-of marker. - */ - interval: string; - /** - * One entry per requested metric, each carrying its own points[] time series (latest-snapshot per bucket / dimension via argMax over time). - */ - metrics: UsageMetric[]; - } - - /** - * usageMetric - */ - export type UsageMetric = { - /** - * Metric key this series describes. - */ - metric: string; - /** - * Data points for this metric, ordered by time ascending. With `interval`, each entry is one bucket; without, each entry is one row of the dimensional or aggregate breakdown. - */ - points: UsageDataPoint[]; - } + }; /** * Organization @@ -12418,7 +12829,7 @@ export namespace Models { * Aggregated stats for total realtime bandwidth. */ realtimeBandwidthTotal: number; - } + }; /** * OrganizationProject @@ -12431,11 +12842,11 @@ export namespace Models { /** * Aggregated stats for number of requests. */ - bandwidth: Metric[]; + bandwidth: number; /** * Aggregated stats for consumed bandwidth. */ - users: Metric[]; + users: number; /** * Aggregated stats for function executions. */ @@ -12443,11 +12854,11 @@ export namespace Models { /** * Aggregated stats for database reads. */ - databasesReads: Metric[]; + databasesReads: number; /** * Aggregated stats for database writes. */ - databasesWrites: Metric[]; + databasesWrites: number; /** * Aggregated stats for function executions in mb seconds. */ @@ -12479,7 +12890,7 @@ export namespace Models { /** * Aggregated stats for file transformations. */ - imageTransformations: Metric[]; + imageTransformations: number; /** * Aggregated stats for total file transformations. */ @@ -12487,7 +12898,7 @@ export namespace Models { /** * Aggregated stats for file transformations. */ - screenshotsGenerated: Metric[]; + screenshotsGenerated: number; /** * Aggregated stats for total file transformations. */ @@ -12504,7 +12915,7 @@ export namespace Models { * Aggregated stats for realtime bandwidth. */ realtimeBandwidth: number; - } + }; /** * Resource @@ -12542,7 +12953,7 @@ export namespace Models { * Dedicated database specification slug for per-database line items (e.g. s-2vcpu-2gb). Empty for other resources. */ specification: string; - } + }; /** * App @@ -12652,7 +13063,7 @@ export namespace Models { * List of application secrets. */ secrets: AppSecret[]; - } + }; /** * AppSecret @@ -12694,7 +13105,7 @@ export namespace Models { * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * AppSecretPlaintext @@ -12736,7 +13147,7 @@ export namespace Models { * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * AppScope @@ -12762,7 +13173,7 @@ export namespace Models { * Whether the scope is deprecated. Deprecated scopes can still be requested but should not be offered for new grants. */ deprecated: boolean; - } + }; /** * AppInstallation @@ -12795,7 +13206,7 @@ export namespace Models { /** * Authorization details granted to the application. Rich authorization request (RFC 9396) style entries; the Appwrite Console stores authorized project IDs here. */ - authorizationDetails: object; + authorizationDetails: Record[]; /** * ID of the user who created the installation. */ @@ -12808,7 +13219,7 @@ export namespace Models { * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * AppKey @@ -12850,7 +13261,7 @@ export namespace Models { * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * OAuth2 Authorize @@ -12864,7 +13275,7 @@ export namespace Models { * URL the end user should be redirected to when the flow can complete without consent. Empty when consent is still required. */ redirectUrl: string; - } + }; /** * OAuth2 Approve @@ -12874,7 +13285,7 @@ export namespace Models { * URL the end user should be redirected to after the grant is approved, carrying the authorization `code` and/or `id_token` along with the original `state`. */ redirectUrl: string; - } + }; /** * OAuth2 Reject @@ -12884,7 +13295,7 @@ export namespace Models { * URL the end user should be redirected to after the grant is rejected, carrying an `access_denied` error. */ redirectUrl: string; - } + }; /** * OAuth2 Grant @@ -12938,7 +13349,7 @@ export namespace Models { * Grant expiration time in ISO 8601 format. */ expire: string; - } + }; /** * OAuth2 Device Authorization @@ -12968,7 +13379,7 @@ export namespace Models { * Minimum polling interval for the token endpoint in seconds. */ interval: number; - } + }; /** * OAuth2 PAR @@ -12982,7 +13393,7 @@ export namespace Models { * Lifetime of the authorization request handle in seconds. */ expires_in: number; - } + }; /** * OAuth2 Token @@ -13016,7 +13427,7 @@ export namespace Models { * OpenID Connect ID token. Returned when the `openid` scope is granted. */ id_token?: string; - } + }; /** * OAuth2 Consent @@ -13062,7 +13473,7 @@ export namespace Models { * Consent expiration time in ISO 8601 format. Empty when the consent has no token-bound expiry yet. */ expire: string; - } + }; /** * OAuth2 Consent Token @@ -13112,7 +13523,7 @@ export namespace Models { * Expiration time of the current access token of this family in ISO 8601 format. */ expire: string; - } + }; /** * WafRule @@ -13169,12 +13580,12 @@ export namespace Models { /** * List of conditions evaluated for this rule. */ - conditions: object; + conditions: Record[]; /** * Action specific configuration. */ config: object; - } + }; /** * WafRuleBypass @@ -13231,12 +13642,12 @@ export namespace Models { /** * List of conditions evaluated for this rule. */ - conditions: object; + conditions: Record[]; /** * Action specific configuration. */ config: object; - } + }; /** * WafRuleDeny @@ -13293,12 +13704,12 @@ export namespace Models { /** * List of conditions evaluated for this rule. */ - conditions: object; + conditions: Record[]; /** * Action specific configuration. */ config: object; - } + }; /** * WafRuleChallenge @@ -13355,7 +13766,7 @@ export namespace Models { /** * List of conditions evaluated for this rule. */ - conditions: object; + conditions: Record[]; /** * Action specific configuration. */ @@ -13372,7 +13783,7 @@ export namespace Models { * Seconds a visitor stays cleared after passing the challenge before being challenged again. */ ttl: number; - } + }; /** * WafRuleRateLimit @@ -13429,7 +13840,7 @@ export namespace Models { /** * List of conditions evaluated for this rule. */ - conditions: object; + conditions: Record[]; /** * Action specific configuration. */ @@ -13446,7 +13857,15 @@ export namespace Models { * 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 @@ -13503,7 +13922,7 @@ export namespace Models { /** * List of conditions evaluated for this rule. */ - conditions: object; + conditions: Record[]; /** * Action specific configuration. */ @@ -13516,7 +13935,7 @@ export namespace Models { * HTTP status code used for the redirect. */ statusCode: number; - } + }; /** * WAF rule list @@ -13530,7 +13949,7 @@ export namespace Models { * List of rules. */ rules: WafRule[]; - } + }; /** * OAuth2 Project @@ -13548,7 +13967,7 @@ export namespace Models { * API endpoint of the region the project is deployed in. Empty when the region has no public hostname configured. */ endpoint: string; - } + }; /** * OAuth2 Organization @@ -13558,7 +13977,7 @@ export namespace Models { * Organization ID. */ $id: string; - } + }; /** * OAuth2 accessible projects list @@ -13572,7 +13991,7 @@ export namespace Models { * List of projects. */ projects: Oauth2Project[]; - } + }; /** * OAuth2 accessible organizations list @@ -13586,7 +14005,7 @@ export namespace Models { * List of organizations. */ organizations: Oauth2Organization[]; - } + }; /** * OAuth2 consents list @@ -13600,7 +14019,7 @@ export namespace Models { * List of consents. */ consents: Oauth2Consent[]; - } + }; /** * OAuth2 consent tokens list @@ -13614,7 +14033,7 @@ export namespace Models { * List of tokens. */ tokens: Oauth2ConsentToken[]; - } + }; /** * Activity event list @@ -13628,7 +14047,7 @@ export namespace Models { * List of events. */ events: ActivityEvent[]; - } + }; /** * Addons list @@ -13642,7 +14061,7 @@ export namespace Models { * List of addons. */ addons: Addon[]; - } + }; /** * Aggregation team list @@ -13656,7 +14075,7 @@ export namespace Models { * List of aggregations. */ aggregations: AggregationTeam[]; - } + }; /** * Backup archive list @@ -13670,7 +14089,7 @@ export namespace Models { * List of archives. */ archives: BackupArchive[]; - } + }; /** * Backup policy list @@ -13684,7 +14103,7 @@ export namespace Models { * List of policies. */ policies: BackupPolicy[]; - } + }; /** * Backup restoration list @@ -13698,7 +14117,7 @@ export namespace Models { * List of restorations. */ restorations: BackupRestoration[]; - } + }; /** * Billing address list @@ -13712,7 +14131,7 @@ export namespace Models { * List of billingAddresses. */ billingAddresses: BillingAddress[]; - } + }; /** * Billing invoices list @@ -13726,7 +14145,7 @@ export namespace Models { * List of invoices. */ invoices: Invoice[]; - } + }; /** * Billing plan list @@ -13740,7 +14159,7 @@ export namespace Models { * List of plans. */ plans: BillingPlan[]; - } + }; /** * Blocks list @@ -13754,7 +14173,7 @@ export namespace Models { * List of blocks. */ blocks: Block[]; - } + }; /** * Database Migrations List @@ -13768,7 +14187,7 @@ export namespace Models { * List of migrations. */ migrations: DatabaseMigration[]; - } + }; /** * Dedicated databases list @@ -13782,7 +14201,7 @@ export namespace Models { * List of databases. */ databases: DedicatedDatabase[]; - } + }; /** * DNS records list @@ -13796,7 +14215,7 @@ export namespace Models { * List of dnsRecords. */ dnsRecords: DnsRecord[]; - } + }; /** * Domain suggestions list @@ -13810,7 +14229,21 @@ export namespace Models { * List of suggestions. */ suggestions: DomainSuggestion[]; - } + }; + + /** + * Domain prices list + */ + export type DomainPricesList = { + /** + * Total number of prices that matched your query. + */ + total: number; + /** + * List of prices. + */ + prices: DomainPrice[]; + }; /** * Domains list @@ -13824,12 +14257,14 @@ export namespace Models { * List of domains. */ domains: Domain[]; - } + }; /** * Organizations list */ - export type OrganizationList = { + export type OrganizationList< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Total number of teams that matched your query. */ @@ -13838,7 +14273,7 @@ export namespace Models { * List of teams. */ teams: Organization[]; - } + }; /** * Payment methods list @@ -13852,7 +14287,7 @@ export namespace Models { * List of paymentMethods. */ paymentMethods: PaymentMethod[]; - } + }; /** * Postgres extensions list @@ -13866,7 +14301,7 @@ export namespace Models { * List of extensions. */ extensions: PostgresExtension[]; - } + }; /** * Regions list @@ -13880,7 +14315,7 @@ export namespace Models { * List of regions. */ regions: ConsoleRegion[]; - } + }; /** * Apps list @@ -13894,7 +14329,7 @@ export namespace Models { * List of apps. */ apps: App[]; - } + }; /** * App secrets list @@ -13908,7 +14343,7 @@ export namespace Models { * List of secrets. */ secrets: AppSecret[]; - } + }; /** * App scopes list @@ -13922,7 +14357,7 @@ export namespace Models { * List of scopes. */ scopes: AppScope[]; - } + }; /** * App installations list @@ -13936,7 +14371,7 @@ export namespace Models { * List of installations. */ installations: AppInstallation[]; - } + }; /** * App keys list @@ -13950,5 +14385,5 @@ export namespace Models { * List of keys. */ keys: AppKey[]; - } + }; } diff --git a/src/operator.ts b/src/operator.ts index 2386a6c4..86b59205 100644 --- a/src/operator.ts +++ b/src/operator.ts @@ -3,306 +3,304 @@ export type OperatorValuesList = string[] | number[] | boolean[] | any[]; export type OperatorValues = OperatorValuesSingle | OperatorValuesList; export enum Condition { - Equal = "equal", - NotEqual = "notEqual", - GreaterThan = "greaterThan", - GreaterThanEqual = "greaterThanEqual", - LessThan = "lessThan", - LessThanEqual = "lessThanEqual", - Contains = "contains", - IsNull = "isNull", - IsNotNull = "isNotNull", + Equal = 'equal', + NotEqual = 'notEqual', + GreaterThan = 'greaterThan', + GreaterThanEqual = 'greaterThanEqual', + LessThan = 'lessThan', + LessThanEqual = 'lessThanEqual', + Contains = 'contains', + IsNull = 'isNull', + IsNotNull = 'isNotNull', } /** * Helper class to generate operator strings for atomic operations. */ export class Operator { - method: string; - values: OperatorValuesList | undefined; + method: string; + values: OperatorValuesList | undefined; - /** - * Constructor for Operator class. - * - * @param {string} method - * @param {OperatorValues} values - */ - constructor( - method: string, - values?: OperatorValues - ) { - this.method = method; + /** + * Constructor for Operator class. + * + * @param {string} method + * @param {OperatorValues} values + */ + constructor(method: string, values?: OperatorValues) { + this.method = method; - if (values !== undefined) { - if (Array.isArray(values)) { - this.values = values; - } else { - this.values = [values] as OperatorValuesList; - } + if (values !== undefined) { + if (Array.isArray(values)) { + this.values = values; + } else { + this.values = [values] as OperatorValuesList; + } + } } - } - /** - * Convert the operator object to a JSON string. - * - * @returns {string} - */ - toString(): string { - return JSON.stringify({ - method: this.method, - values: this.values, - }); - } - - /** - * Increment a numeric attribute by a specified value. - * - * @param {number} value - * @param {number} max - * @returns {string} - */ - static increment = (value: number = 1, max?: number): string => { - if (isNaN(value) || !isFinite(value)) { - throw new Error("Value cannot be NaN or Infinity"); - } - if (max !== undefined && (isNaN(max) || !isFinite(max))) { - throw new Error("Max cannot be NaN or Infinity"); - } - const values: any[] = [value]; - if (max !== undefined) { - values.push(max); + /** + * Convert the operator object to a JSON string. + * + * @returns {string} + */ + toString(): string { + return JSON.stringify({ + method: this.method, + values: this.values, + }); } - return new Operator("increment", values).toString(); - }; - /** - * Decrement a numeric attribute by a specified value. - * - * @param {number} value - * @param {number} min - * @returns {string} - */ - static decrement = (value: number = 1, min?: number): string => { - if (isNaN(value) || !isFinite(value)) { - throw new Error("Value cannot be NaN or Infinity"); - } - if (min !== undefined && (isNaN(min) || !isFinite(min))) { - throw new Error("Min cannot be NaN or Infinity"); - } - const values: any[] = [value]; - if (min !== undefined) { - values.push(min); - } - return new Operator("decrement", values).toString(); - }; + /** + * Increment a numeric attribute by a specified value. + * + * @param {number} value + * @param {number} max + * @returns {string} + */ + static increment = (value: number = 1, max?: number): string => { + if (isNaN(value) || !isFinite(value)) { + throw new Error('Value cannot be NaN or Infinity'); + } + if (max !== undefined && (isNaN(max) || !isFinite(max))) { + throw new Error('Max cannot be NaN or Infinity'); + } + const values: any[] = [value]; + if (max !== undefined) { + values.push(max); + } + return new Operator('increment', values).toString(); + }; - /** - * Multiply a numeric attribute by a specified factor. - * - * @param {number} factor - * @param {number} max - * @returns {string} - */ - static multiply = (factor: number, max?: number): string => { - if (isNaN(factor) || !isFinite(factor)) { - throw new Error("Factor cannot be NaN or Infinity"); - } - if (max !== undefined && (isNaN(max) || !isFinite(max))) { - throw new Error("Max cannot be NaN or Infinity"); - } - const values: any[] = [factor]; - if (max !== undefined) { - values.push(max); - } - return new Operator("multiply", values).toString(); - }; + /** + * Decrement a numeric attribute by a specified value. + * + * @param {number} value + * @param {number} min + * @returns {string} + */ + static decrement = (value: number = 1, min?: number): string => { + if (isNaN(value) || !isFinite(value)) { + throw new Error('Value cannot be NaN or Infinity'); + } + if (min !== undefined && (isNaN(min) || !isFinite(min))) { + throw new Error('Min cannot be NaN or Infinity'); + } + const values: any[] = [value]; + if (min !== undefined) { + values.push(min); + } + return new Operator('decrement', values).toString(); + }; - /** - * Divide a numeric attribute by a specified divisor. - * - * @param {number} divisor - * @param {number} min - * @returns {string} - */ - static divide = (divisor: number, min?: number): string => { - if (isNaN(divisor) || !isFinite(divisor)) { - throw new Error("Divisor cannot be NaN or Infinity"); - } - if (min !== undefined && (isNaN(min) || !isFinite(min))) { - throw new Error("Min cannot be NaN or Infinity"); - } - if (divisor === 0) { - throw new Error("Divisor cannot be zero"); - } - const values: any[] = [divisor]; - if (min !== undefined) { - values.push(min); - } - return new Operator("divide", values).toString(); - }; + /** + * Multiply a numeric attribute by a specified factor. + * + * @param {number} factor + * @param {number} max + * @returns {string} + */ + static multiply = (factor: number, max?: number): string => { + if (isNaN(factor) || !isFinite(factor)) { + throw new Error('Factor cannot be NaN or Infinity'); + } + if (max !== undefined && (isNaN(max) || !isFinite(max))) { + throw new Error('Max cannot be NaN or Infinity'); + } + const values: any[] = [factor]; + if (max !== undefined) { + values.push(max); + } + return new Operator('multiply', values).toString(); + }; - /** - * Apply modulo operation on a numeric attribute. - * - * @param {number} divisor - * @returns {string} - */ - static modulo = (divisor: number): string => { - if (isNaN(divisor) || !isFinite(divisor)) { - throw new Error("Divisor cannot be NaN or Infinity"); - } - if (divisor === 0) { - throw new Error("Divisor cannot be zero"); - } - return new Operator("modulo", [divisor]).toString(); - }; + /** + * Divide a numeric attribute by a specified divisor. + * + * @param {number} divisor + * @param {number} min + * @returns {string} + */ + static divide = (divisor: number, min?: number): string => { + if (isNaN(divisor) || !isFinite(divisor)) { + throw new Error('Divisor cannot be NaN or Infinity'); + } + if (min !== undefined && (isNaN(min) || !isFinite(min))) { + throw new Error('Min cannot be NaN or Infinity'); + } + if (divisor === 0) { + throw new Error('Divisor cannot be zero'); + } + const values: any[] = [divisor]; + if (min !== undefined) { + values.push(min); + } + return new Operator('divide', values).toString(); + }; - /** - * Raise a numeric attribute to a specified power. - * - * @param {number} exponent - * @param {number} max - * @returns {string} - */ - static power = (exponent: number, max?: number): string => { - if (isNaN(exponent) || !isFinite(exponent)) { - throw new Error("Exponent cannot be NaN or Infinity"); - } - if (max !== undefined && (isNaN(max) || !isFinite(max))) { - throw new Error("Max cannot be NaN or Infinity"); - } - const values: any[] = [exponent]; - if (max !== undefined) { - values.push(max); - } - return new Operator("power", values).toString(); - }; + /** + * Apply modulo operation on a numeric attribute. + * + * @param {number} divisor + * @returns {string} + */ + static modulo = (divisor: number): string => { + if (isNaN(divisor) || !isFinite(divisor)) { + throw new Error('Divisor cannot be NaN or Infinity'); + } + if (divisor === 0) { + throw new Error('Divisor cannot be zero'); + } + return new Operator('modulo', [divisor]).toString(); + }; + + /** + * Raise a numeric attribute to a specified power. + * + * @param {number} exponent + * @param {number} max + * @returns {string} + */ + static power = (exponent: number, max?: number): string => { + if (isNaN(exponent) || !isFinite(exponent)) { + throw new Error('Exponent cannot be NaN or Infinity'); + } + if (max !== undefined && (isNaN(max) || !isFinite(max))) { + throw new Error('Max cannot be NaN or Infinity'); + } + const values: any[] = [exponent]; + if (max !== undefined) { + values.push(max); + } + return new Operator('power', values).toString(); + }; - /** - * Append values to an array attribute. - * - * @param {any[]} values - * @returns {string} - */ - static arrayAppend = (values: any[]): string => - new Operator("arrayAppend", values).toString(); + /** + * Append values to an array attribute. + * + * @param {any[]} values + * @returns {string} + */ + static arrayAppend = (values: any[]): string => + new Operator('arrayAppend', values).toString(); - /** - * Prepend values to an array attribute. - * - * @param {any[]} values - * @returns {string} - */ - static arrayPrepend = (values: any[]): string => - new Operator("arrayPrepend", values).toString(); + /** + * Prepend values to an array attribute. + * + * @param {any[]} values + * @returns {string} + */ + static arrayPrepend = (values: any[]): string => + new Operator('arrayPrepend', values).toString(); - /** - * Insert a value at a specific index in an array attribute. - * - * @param {number} index - * @param {any} value - * @returns {string} - */ - static arrayInsert = (index: number, value: any): string => - new Operator("arrayInsert", [index, value]).toString(); + /** + * Insert a value at a specific index in an array attribute. + * + * @param {number} index + * @param {any} value + * @returns {string} + */ + static arrayInsert = (index: number, value: any): string => + new Operator('arrayInsert', [index, value]).toString(); - /** - * Remove a value from an array attribute. - * - * @param {any} value - * @returns {string} - */ - static arrayRemove = (value: any): string => - new Operator("arrayRemove", [value]).toString(); + /** + * Remove a value from an array attribute. + * + * @param {any} value + * @returns {string} + */ + static arrayRemove = (value: any): string => + new Operator('arrayRemove', [value]).toString(); - /** - * Remove duplicate values from an array attribute. - * - * @returns {string} - */ - static arrayUnique = (): string => - new Operator("arrayUnique", []).toString(); + /** + * Remove duplicate values from an array attribute. + * + * @returns {string} + */ + static arrayUnique = (): string => + new Operator('arrayUnique', []).toString(); - /** - * Keep only values that exist in both the current array and the provided array. - * - * @param {any[]} values - * @returns {string} - */ - static arrayIntersect = (values: any[]): string => - new Operator("arrayIntersect", values).toString(); + /** + * Keep only values that exist in both the current array and the provided array. + * + * @param {any[]} values + * @returns {string} + */ + static arrayIntersect = (values: any[]): string => + new Operator('arrayIntersect', values).toString(); - /** - * Remove values from the array that exist in the provided array. - * - * @param {any[]} values - * @returns {string} - */ - static arrayDiff = (values: any[]): string => - new Operator("arrayDiff", values).toString(); + /** + * Remove values from the array that exist in the provided array. + * + * @param {any[]} values + * @returns {string} + */ + static arrayDiff = (values: any[]): string => + new Operator('arrayDiff', values).toString(); - /** - * Filter array values based on a condition. - * - * @param {Condition} condition - * @param {any} value - * @returns {string} - */ - static arrayFilter = (condition: Condition, value?: any): string => { - const values: any[] = [condition as string, value === undefined ? null : value]; - return new Operator("arrayFilter", values).toString(); - }; + /** + * Filter array values based on a condition. + * + * @param {Condition} condition + * @param {any} value + * @returns {string} + */ + static arrayFilter = (condition: Condition, value?: any): string => { + const values: any[] = [ + condition as string, + value === undefined ? null : value, + ]; + return new Operator('arrayFilter', values).toString(); + }; - /** - * Concatenate a value to a string or array attribute. - * - * @param {any} value - * @returns {string} - */ - static stringConcat = (value: any): string => - new Operator("stringConcat", [value]).toString(); + /** + * Concatenate a value to a string or array attribute. + * + * @param {any} value + * @returns {string} + */ + static stringConcat = (value: any): string => + new Operator('stringConcat', [value]).toString(); - /** - * Replace occurrences of a search string with a replacement string. - * - * @param {string} search - * @param {string} replace - * @returns {string} - */ - static stringReplace = (search: string, replace: string): string => - new Operator("stringReplace", [search, replace]).toString(); + /** + * Replace occurrences of a search string with a replacement string. + * + * @param {string} search + * @param {string} replace + * @returns {string} + */ + static stringReplace = (search: string, replace: string): string => + new Operator('stringReplace', [search, replace]).toString(); - /** - * Toggle a boolean attribute. - * - * @returns {string} - */ - static toggle = (): string => - new Operator("toggle", []).toString(); + /** + * Toggle a boolean attribute. + * + * @returns {string} + */ + static toggle = (): string => new Operator('toggle', []).toString(); - /** - * Add days to a date attribute. - * - * @param {number} days - * @returns {string} - */ - static dateAddDays = (days: number): string => - new Operator("dateAddDays", [days]).toString(); + /** + * Add days to a date attribute. + * + * @param {number} days + * @returns {string} + */ + static dateAddDays = (days: number): string => + new Operator('dateAddDays', [days]).toString(); - /** - * Subtract days from a date attribute. - * - * @param {number} days - * @returns {string} - */ - static dateSubDays = (days: number): string => - new Operator("dateSubDays", [days]).toString(); + /** + * Subtract days from a date attribute. + * + * @param {number} days + * @returns {string} + */ + static dateSubDays = (days: number): string => + new Operator('dateSubDays', [days]).toString(); - /** - * Set a date attribute to the current date and time. - * - * @returns {string} - */ - static dateSetNow = (): string => - new Operator("dateSetNow", []).toString(); + /** + * Set a date attribute to the current date and time. + * + * @returns {string} + */ + static dateSetNow = (): string => new Operator('dateSetNow', []).toString(); } diff --git a/src/permission.ts b/src/permission.ts index 94d9cedd..758211bf 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -10,7 +10,7 @@ export class Permission { */ static read = (role: string): string => { return `read("${role}")`; - } + }; /** * Generate write permission string for the provided role. @@ -23,7 +23,7 @@ export class Permission { */ static write = (role: string): string => { return `write("${role}")`; - } + }; /** * Generate create permission string for the provided role. @@ -33,7 +33,7 @@ export class Permission { */ static create = (role: string): string => { return `create("${role}")`; - } + }; /** * Generate update permission string for the provided role. @@ -43,7 +43,7 @@ export class Permission { */ static update = (role: string): string => { return `update("${role}")`; - } + }; /** * Generate delete permission string for the provided role. @@ -53,5 +53,5 @@ export class Permission { */ static delete = (role: string): string => { return `delete("${role}")`; - } + }; } diff --git a/src/query.ts b/src/query.ts index e0e97257..7a7da885 100644 --- a/src/query.ts +++ b/src/query.ts @@ -2,7 +2,8 @@ import JSONbigModule from 'json-bigint'; const JSONbig = JSONbigModule({ useNativeBigInt: true }); type QueryTypesSingle = string | number | bigint | boolean; -export type QueryTypesList = string[] | number[] | bigint[] | boolean[] | Query[] | any[]; +export type QueryTypesList = + string[] | number[] | bigint[] | boolean[] | Query[] | any[]; export type QueryTypes = QueryTypesSingle | QueryTypesList; type AttributesTypes = string | string[]; @@ -10,597 +11,652 @@ type AttributesTypes = string | string[]; * Helper class to generate query strings. */ export class Query { - method: string; - attribute: AttributesTypes | undefined; - values: QueryTypesList | undefined; - - /** - * Constructor for Query class. - * - * @param {string} method - * @param {AttributesTypes} attribute - * @param {QueryTypes} values - */ - constructor( - method: string, - attribute?: AttributesTypes, - values?: QueryTypes - ) { - this.method = method; - this.attribute = attribute; - - if (values !== undefined) { - if (Array.isArray(values)) { - this.values = values; - } else { - this.values = [values] as QueryTypesList; - } + method: string; + attribute: AttributesTypes | undefined; + values: QueryTypesList | undefined; + + /** + * Constructor for Query class. + * + * @param {string} method + * @param {AttributesTypes} attribute + * @param {QueryTypes} values + */ + constructor( + method: string, + attribute?: AttributesTypes, + values?: QueryTypes, + ) { + this.method = method; + this.attribute = attribute; + + if (values !== undefined) { + if (Array.isArray(values)) { + this.values = values; + } else { + this.values = [values] as QueryTypesList; + } + } } - } - - /** - * Convert the query object to a JSON string. - * - * @returns {string} - */ - toString(): string { - return JSONbig.stringify({ - method: this.method, - attribute: this.attribute, - values: this.values, - }); - } - - /** - * Filter resources where attribute is equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static equal = (attribute: string, value: QueryTypes): string => - new Query("equal", attribute, value).toString(); - - /** - * Filter resources where attribute is not equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static notEqual = (attribute: string, value: QueryTypes): string => - new Query("notEqual", attribute, value).toString(); - - /** - * Filter resources where attribute matches a regular expression pattern. - * - * @param {string} attribute The attribute to filter on. - * @param {string} pattern The regular expression pattern to match. - * @returns {string} - */ - static regex = (attribute: string, pattern: string): string => - new Query("regex", attribute, pattern).toString(); - - /** - * Filter resources where attribute is less than value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static lessThan = (attribute: string, value: QueryTypes): string => - new Query("lessThan", attribute, value).toString(); - - /** - * Filter resources where attribute is less than or equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static lessThanEqual = (attribute: string, value: QueryTypes): string => - new Query("lessThanEqual", attribute, value).toString(); - - /** - * Filter resources where attribute is greater than value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static greaterThan = (attribute: string, value: QueryTypes): string => - new Query("greaterThan", attribute, value).toString(); - - /** - * Filter resources where attribute is greater than or equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static greaterThanEqual = (attribute: string, value: QueryTypes): string => - new Query("greaterThanEqual", attribute, value).toString(); - - /** - * Filter resources where attribute is null. - * - * @param {string} attribute - * @returns {string} - */ - static isNull = (attribute: string): string => - new Query("isNull", attribute).toString(); - - /** - * Filter resources where attribute is not null. - * - * @param {string} attribute - * @returns {string} - */ - static isNotNull = (attribute: string): string => - new Query("isNotNull", attribute).toString(); - - /** - * Filter resources where the specified attributes exist. - * - * @param {string[]} attributes The list of attributes that must exist. - * @returns {string} - */ - static exists = (attributes: string[]): string => - new Query("exists", undefined, attributes).toString(); - - /** - * Filter resources where the specified attributes do not exist. - * - * @param {string[]} attributes The list of attributes that must not exist. - * @returns {string} - */ - static notExists = (attributes: string[]): string => - new Query("notExists", undefined, attributes).toString(); - - /** - * Filter resources where attribute is between start and end (inclusive). - * - * @param {string} attribute - * @param {string | number | bigint} start - * @param {string | number | bigint} end - * @returns {string} - */ - static between = (attribute: string, start: string | number | bigint, end: string | number | bigint): string => - new Query("between", attribute, [start, end] as QueryTypesList).toString(); - - /** - * Filter resources where attribute starts with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static startsWith = (attribute: string, value: string): string => - new Query("startsWith", attribute, value).toString(); - - /** - * Filter resources where attribute ends with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static endsWith = (attribute: string, value: string): string => - new Query("endsWith", attribute, value).toString(); - - /** - * Specify which attributes should be returned by the API call. - * - * @param {string[]} attributes - * @returns {string} - */ - static select = (attributes: string[]): string => - new Query("select", undefined, attributes).toString(); - - /** - * Filter resources by searching attribute for value. - * A fulltext index on attribute is required for this query to work. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static search = (attribute: string, value: string): string => - new Query("search", attribute, value).toString(); - - /** - * Sort results by attribute descending. - * - * @param {string} attribute - * @returns {string} - */ - static orderDesc = (attribute: string): string => - new Query("orderDesc", attribute).toString(); - - /** - * Sort results by attribute ascending. - * - * @param {string} attribute - * @returns {string} - */ - static orderAsc = (attribute: string): string => - new Query("orderAsc", attribute).toString(); - - /** - * Sort results randomly. - * - * @returns {string} - */ - static orderRandom = (): string => - new Query("orderRandom").toString(); - - /** - * Return results after documentId. - * - * @param {string} documentId - * @returns {string} - */ - static cursorAfter = (documentId: string): string => - new Query("cursorAfter", undefined, documentId).toString(); - - /** - * Return results before documentId. - * - * @param {string} documentId - * @returns {string} - */ - static cursorBefore = (documentId: string): string => - new Query("cursorBefore", undefined, documentId).toString(); - - /** - * Return only limit results. - * - * @param {number} limit - * @returns {string} - */ - static limit = (limit: number): string => - new Query("limit", undefined, limit).toString(); - - /** - * Filter resources by skipping the first offset results. - * - * @param {number} offset - * @returns {string} - */ - static offset = (offset: number): string => - new Query("offset", undefined, offset).toString(); - - /** - * Filter resources where attribute contains the specified value. - * For string attributes, checks if the string contains the substring. - * - * Note: For array attributes, use {@link containsAny} or {@link containsAll} instead. - * @param {string} attribute - * @param {string | string[]} value - * @returns {string} - */ - static contains = (attribute: string, value: string | any[]): string => - new Query("contains", attribute, value).toString(); - - /** - * Filter resources where attribute contains ANY of the specified values. - * For array and relationship attributes, matches documents where the attribute - * contains at least one of the given values. - * - * @param {string} attribute - * @param {any[]} value - * @returns {string} - */ - static containsAny = (attribute: string, value: any[]): string => - new Query("containsAny", attribute, value).toString(); - - /** - * Filter resources where attribute contains ALL of the specified values. - * For array and relationship attributes, matches documents where the attribute - * contains every one of the given values. - * - * @param {string} attribute - * @param {any[]} value - * @returns {string} - */ - static containsAll = (attribute: string, value: any[]): string => - new Query("containsAll", attribute, value).toString(); - - /** - * Filter resources where attribute does not contain the specified value. - * - * @param {string} attribute - * @param {string | any[]} value - * @returns {string} - */ - static notContains = (attribute: string, value: string | any[]): string => - new Query("notContains", attribute, value).toString(); - - /** - * Filter resources by searching attribute for value (inverse of search). - * A fulltext index on attribute is required for this query to work. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static notSearch = (attribute: string, value: string): string => - new Query("notSearch", attribute, value).toString(); - - /** - * Filter resources where attribute is not between start and end (exclusive). - * - * @param {string} attribute - * @param {string | number | bigint} start - * @param {string | number | bigint} end - * @returns {string} - */ - static notBetween = (attribute: string, start: string | number | bigint, end: string | number | bigint): string => - new Query("notBetween", attribute, [start, end] as QueryTypesList).toString(); - - /** - * Filter resources where attribute does not start with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static notStartsWith = (attribute: string, value: string): string => - new Query("notStartsWith", attribute, value).toString(); - - /** - * Filter resources where attribute does not end with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static notEndsWith = (attribute: string, value: string): string => - new Query("notEndsWith", attribute, value).toString(); - - /** - * Filter resources where document was created before date. - * - * @param {string} value - * @returns {string} - */ - static createdBefore = (value: string): string => - Query.lessThan("$createdAt", value); - - /** - * Filter resources where document was created after date. - * - * @param {string} value - * @returns {string} - */ - static createdAfter = (value: string): string => - Query.greaterThan("$createdAt", value); - - /** - * Filter resources where document was created between dates. - * - * @param {string} start - * @param {string} end - * @returns {string} - */ - static createdBetween = (start: string, end: string): string => - Query.between("$createdAt", start, end); - - /** - * Filter resources where document was updated before date. - * - * @param {string} value - * @returns {string} - */ - static updatedBefore = (value: string): string => - Query.lessThan("$updatedAt", value); - - /** - * Filter resources where document was updated after date. - * - * @param {string} value - * @returns {string} - */ - static updatedAfter = (value: string): string => - Query.greaterThan("$updatedAt", value); - - /** - * Filter resources where document was updated between dates. - * - * @param {string} start - * @param {string} end - * @returns {string} - */ - static updatedBetween = (start: string, end: string): string => - Query.between("$updatedAt", start, end); - - /** - * Combine multiple queries using logical OR operator. - * - * @param {string[]} queries - * @returns {string} - */ - static or = (queries: string[]) => - new Query("or", undefined, queries.map((query) => JSONbig.parse(query))).toString(); - - /** - * Combine multiple queries using logical AND operator. - * - * @param {string[]} queries - * @returns {string} - */ - static and = (queries: string[]) => - new Query("and", undefined, queries.map((query) => JSONbig.parse(query))).toString(); - - /** - * Filter array elements where at least one element matches all the specified queries. - * - * @param {string} attribute The attribute containing the array to filter on. - * @param {string[]} queries The list of query strings to match against array elements. - * @returns {string} - */ - static elemMatch = (attribute: string, queries: string[]): string => - new Query( - "elemMatch", - attribute, - queries.map((query) => JSONbig.parse(query)) - ).toString(); - - /** - * Filter resources where attribute is at a specific distance from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources where attribute is not at a specific distance from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceNotEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceNotEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources where attribute is at a distance greater than the specified value from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceGreaterThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceGreaterThan", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources where attribute is at a distance less than the specified value from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceLessThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceLessThan", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources using vector dot product similarity. - * - * @param {string} attribute - * @param {number[]} vector - * @returns {string} - */ - static vectorDot = (attribute: string, vector: number[]): string => - new Query("vectorDot", attribute, [vector] as QueryTypesList).toString(); - - /** - * Filter resources using vector cosine similarity. - * - * @param {string} attribute - * @param {number[]} vector - * @returns {string} - */ - static vectorCosine = (attribute: string, vector: number[]): string => - new Query("vectorCosine", attribute, [vector] as QueryTypesList).toString(); - - /** - * Filter resources using vector Euclidean distance. - * - * @param {string} attribute - * @param {number[]} vector - * @returns {string} - */ - static vectorEuclidean = (attribute: string, vector: number[]): string => - new Query("vectorEuclidean", attribute, [vector] as QueryTypesList).toString(); - - /** - * Filter resources where attribute intersects with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static intersects = (attribute: string, values: any[]): string => - new Query("intersects", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not intersect with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notIntersects = (attribute: string, values: any[]): string => - new Query("notIntersects", attribute, [values]).toString(); - - /** - * Filter resources where attribute crosses the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static crosses = (attribute: string, values: any[]): string => - new Query("crosses", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not cross the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notCrosses = (attribute: string, values: any[]): string => - new Query("notCrosses", attribute, [values]).toString(); - - /** - * Filter resources where attribute overlaps with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static overlaps = (attribute: string, values: any[]): string => - new Query("overlaps", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not overlap with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notOverlaps = (attribute: string, values: any[]): string => - new Query("notOverlaps", attribute, [values]).toString(); - - /** - * Filter resources where attribute touches the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static touches = (attribute: string, values: any[]): string => - new Query("touches", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not touch the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notTouches = (attribute: string, values: any[]): string => - new Query("notTouches", attribute, [values]).toString(); + + /** + * Convert the query object to a JSON string. + * + * @returns {string} + */ + toString(): string { + return JSONbig.stringify({ + method: this.method, + attribute: this.attribute, + values: this.values, + }); + } + + /** + * Filter resources where attribute is equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static equal = (attribute: string, value: QueryTypes): string => + new Query('equal', attribute, value).toString(); + + /** + * Filter resources where attribute is not equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static notEqual = (attribute: string, value: QueryTypes): string => + new Query('notEqual', attribute, value).toString(); + + /** + * Filter resources where attribute matches a regular expression pattern. + * + * @param {string} attribute The attribute to filter on. + * @param {string} pattern The regular expression pattern to match. + * @returns {string} + */ + static regex = (attribute: string, pattern: string): string => + new Query('regex', attribute, pattern).toString(); + + /** + * Filter resources where attribute is less than value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static lessThan = (attribute: string, value: QueryTypes): string => + new Query('lessThan', attribute, value).toString(); + + /** + * Filter resources where attribute is less than or equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static lessThanEqual = (attribute: string, value: QueryTypes): string => + new Query('lessThanEqual', attribute, value).toString(); + + /** + * Filter resources where attribute is greater than value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static greaterThan = (attribute: string, value: QueryTypes): string => + new Query('greaterThan', attribute, value).toString(); + + /** + * Filter resources where attribute is greater than or equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static greaterThanEqual = (attribute: string, value: QueryTypes): string => + new Query('greaterThanEqual', attribute, value).toString(); + + /** + * Filter resources where attribute is null. + * + * @param {string} attribute + * @returns {string} + */ + static isNull = (attribute: string): string => + new Query('isNull', attribute).toString(); + + /** + * Filter resources where attribute is not null. + * + * @param {string} attribute + * @returns {string} + */ + static isNotNull = (attribute: string): string => + new Query('isNotNull', attribute).toString(); + + /** + * Filter resources where the specified attributes exist. + * + * @param {string[]} attributes The list of attributes that must exist. + * @returns {string} + */ + static exists = (attributes: string[]): string => + new Query('exists', undefined, attributes).toString(); + + /** + * Filter resources where the specified attributes do not exist. + * + * @param {string[]} attributes The list of attributes that must not exist. + * @returns {string} + */ + static notExists = (attributes: string[]): string => + new Query('notExists', undefined, attributes).toString(); + + /** + * Filter resources where attribute is between start and end (inclusive). + * + * @param {string} attribute + * @param {string | number | bigint} start + * @param {string | number | bigint} end + * @returns {string} + */ + static between = ( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): string => + new Query('between', attribute, [ + start, + end, + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute starts with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static startsWith = (attribute: string, value: string): string => + new Query('startsWith', attribute, value).toString(); + + /** + * Filter resources where attribute ends with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static endsWith = (attribute: string, value: string): string => + new Query('endsWith', attribute, value).toString(); + + /** + * Specify which attributes should be returned by the API call. + * + * @param {string[]} attributes + * @returns {string} + */ + static select = (attributes: string[]): string => + new Query('select', undefined, attributes).toString(); + + /** + * Filter resources by searching attribute for value. + * A fulltext index on attribute is required for this query to work. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static search = (attribute: string, value: string): string => + new Query('search', attribute, value).toString(); + + /** + * Sort results by attribute descending. + * + * @param {string} attribute + * @returns {string} + */ + static orderDesc = (attribute: string): string => + new Query('orderDesc', attribute).toString(); + + /** + * Sort results by attribute ascending. + * + * @param {string} attribute + * @returns {string} + */ + static orderAsc = (attribute: string): string => + new Query('orderAsc', attribute).toString(); + + /** + * Sort results randomly. + * + * @returns {string} + */ + static orderRandom = (): string => new Query('orderRandom').toString(); + + /** + * Return results after documentId. + * + * @param {string} documentId + * @returns {string} + */ + static cursorAfter = (documentId: string): string => + new Query('cursorAfter', undefined, documentId).toString(); + + /** + * Return results before documentId. + * + * @param {string} documentId + * @returns {string} + */ + static cursorBefore = (documentId: string): string => + new Query('cursorBefore', undefined, documentId).toString(); + + /** + * Return only limit results. + * + * @param {number} limit + * @returns {string} + */ + static limit = (limit: number): string => + new Query('limit', undefined, limit).toString(); + + /** + * Filter resources by skipping the first offset results. + * + * @param {number} offset + * @returns {string} + */ + static offset = (offset: number): string => + new Query('offset', undefined, offset).toString(); + + /** + * Filter resources where attribute contains the specified value. + * For string attributes, checks if the string contains the substring. + * + * Note: For array attributes, use {@link containsAny} or {@link containsAll} instead. + * @param {string} attribute + * @param {string | string[]} value + * @returns {string} + */ + static contains = (attribute: string, value: string | any[]): string => + new Query('contains', attribute, value).toString(); + + /** + * Filter resources where attribute contains ANY of the specified values. + * For array and relationship attributes, matches documents where the attribute + * contains at least one of the given values. + * + * @param {string} attribute + * @param {any[]} value + * @returns {string} + */ + static containsAny = (attribute: string, value: any[]): string => + new Query('containsAny', attribute, value).toString(); + + /** + * Filter resources where attribute contains ALL of the specified values. + * For array and relationship attributes, matches documents where the attribute + * contains every one of the given values. + * + * @param {string} attribute + * @param {any[]} value + * @returns {string} + */ + static containsAll = (attribute: string, value: any[]): string => + new Query('containsAll', attribute, value).toString(); + + /** + * Filter resources where attribute does not contain the specified value. + * + * @param {string} attribute + * @param {string | any[]} value + * @returns {string} + */ + static notContains = (attribute: string, value: string | any[]): string => + new Query('notContains', attribute, value).toString(); + + /** + * Filter resources by searching attribute for value (inverse of search). + * A fulltext index on attribute is required for this query to work. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notSearch = (attribute: string, value: string): string => + new Query('notSearch', attribute, value).toString(); + + /** + * Filter resources where attribute is not between start and end (exclusive). + * + * @param {string} attribute + * @param {string | number | bigint} start + * @param {string | number | bigint} end + * @returns {string} + */ + static notBetween = ( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): string => + new Query('notBetween', attribute, [ + start, + end, + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute does not start with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notStartsWith = (attribute: string, value: string): string => + new Query('notStartsWith', attribute, value).toString(); + + /** + * Filter resources where attribute does not end with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notEndsWith = (attribute: string, value: string): string => + new Query('notEndsWith', attribute, value).toString(); + + /** + * Filter resources where document was created before date. + * + * @param {string} value + * @returns {string} + */ + static createdBefore = (value: string): string => + Query.lessThan('$createdAt', value); + + /** + * Filter resources where document was created after date. + * + * @param {string} value + * @returns {string} + */ + static createdAfter = (value: string): string => + Query.greaterThan('$createdAt', value); + + /** + * Filter resources where document was created between dates. + * + * @param {string} start + * @param {string} end + * @returns {string} + */ + static createdBetween = (start: string, end: string): string => + Query.between('$createdAt', start, end); + + /** + * Filter resources where document was updated before date. + * + * @param {string} value + * @returns {string} + */ + static updatedBefore = (value: string): string => + Query.lessThan('$updatedAt', value); + + /** + * Filter resources where document was updated after date. + * + * @param {string} value + * @returns {string} + */ + static updatedAfter = (value: string): string => + Query.greaterThan('$updatedAt', value); + + /** + * Filter resources where document was updated between dates. + * + * @param {string} start + * @param {string} end + * @returns {string} + */ + static updatedBetween = (start: string, end: string): string => + Query.between('$updatedAt', start, end); + + /** + * Combine multiple queries using logical OR operator. + * + * @param {string[]} queries + * @returns {string} + */ + static or = (queries: string[]) => + new Query( + 'or', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** + * Combine multiple queries using logical AND operator. + * + * @param {string[]} queries + * @returns {string} + */ + static and = (queries: string[]) => + new Query( + 'and', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** + * Filter array elements where at least one element matches all the specified queries. + * + * @param {string} attribute The attribute containing the array to filter on. + * @param {string[]} queries The list of query strings to match against array elements. + * @returns {string} + */ + static elemMatch = (attribute: string, queries: string[]): string => + new Query( + 'elemMatch', + attribute, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** + * Filter resources where attribute is at a specific distance from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceEqual = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceEqual', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute is not at a specific distance from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceNotEqual = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceNotEqual', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute is at a distance greater than the specified value from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceGreaterThan = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceGreaterThan', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute is at a distance less than the specified value from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceLessThan = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceLessThan', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources using vector dot product similarity. + * + * @param {string} attribute + * @param {number[]} vector + * @returns {string} + */ + static vectorDot = (attribute: string, vector: number[]): string => + new Query('vectorDot', attribute, [ + vector, + ] as QueryTypesList).toString(); + + /** + * Filter resources using vector cosine similarity. + * + * @param {string} attribute + * @param {number[]} vector + * @returns {string} + */ + static vectorCosine = (attribute: string, vector: number[]): string => + new Query('vectorCosine', attribute, [ + vector, + ] as QueryTypesList).toString(); + + /** + * Filter resources using vector Euclidean distance. + * + * @param {string} attribute + * @param {number[]} vector + * @returns {string} + */ + static vectorEuclidean = (attribute: string, vector: number[]): string => + new Query('vectorEuclidean', attribute, [ + vector, + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute intersects with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static intersects = (attribute: string, values: any[]): string => + new Query('intersects', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not intersect with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notIntersects = (attribute: string, values: any[]): string => + new Query('notIntersects', attribute, [values]).toString(); + + /** + * Filter resources where attribute crosses the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static crosses = (attribute: string, values: any[]): string => + new Query('crosses', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not cross the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notCrosses = (attribute: string, values: any[]): string => + new Query('notCrosses', attribute, [values]).toString(); + + /** + * Filter resources where attribute overlaps with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static overlaps = (attribute: string, values: any[]): string => + new Query('overlaps', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not overlap with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notOverlaps = (attribute: string, values: any[]): string => + new Query('notOverlaps', attribute, [values]).toString(); + + /** + * Filter resources where attribute touches the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static touches = (attribute: string, values: any[]): string => + new Query('touches', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not touch the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notTouches = (attribute: string, values: any[]): string => + new Query('notTouches', attribute, [values]).toString(); } diff --git a/src/role.ts b/src/role.ts index 79f8c6b6..51a05aaf 100644 --- a/src/role.ts +++ b/src/role.ts @@ -2,99 +2,98 @@ * Helper class to generate role strings for `Permission`. */ export class Role { - /** * Grants access to anyone. - * + * * This includes authenticated and unauthenticated users. - * + * * @returns {string} */ public static any(): string { - return 'any' + return 'any'; } /** * Grants access to a specific user by user ID. - * + * * You can optionally pass verified or unverified for * `status` to target specific types of users. * - * @param {string} id - * @param {string} status + * @param {string} id + * @param {string} status * @returns {string} */ public static user(id: string, status: string = ''): string { if (status === '') { - return `user:${id}` + return `user:${id}`; } - return `user:${id}/${status}` + return `user:${id}/${status}`; } /** * Grants access to any authenticated or anonymous user. - * + * * You can optionally pass verified or unverified for * `status` to target specific types of users. - * - * @param {string} status + * + * @param {string} status * @returns {string} */ public static users(status: string = ''): string { if (status === '') { - return 'users' + return 'users'; } - return `users/${status}` + return `users/${status}`; } /** * Grants access to any guest user without a session. - * + * * Authenticated users don't have access to this role. - * + * * @returns {string} */ public static guests(): string { - return 'guests' + return 'guests'; } /** * Grants access to a team by team ID. - * + * * You can optionally pass a role for `role` to target * team members with the specified role. - * - * @param {string} id - * @param {string} role + * + * @param {string} id + * @param {string} role * @returns {string} */ public static team(id: string, role: string = ''): string { if (role === '') { - return `team:${id}` + return `team:${id}`; } - return `team:${id}/${role}` + return `team:${id}/${role}`; } /** * Grants access to a specific member of a team. - * + * * When the member is removed from the team, they will * no longer have access. - * - * @param {string} id + * + * @param {string} id * @returns {string} */ public static member(id: string): string { - return `member:${id}` + return `member:${id}`; } /** * Grants access to a user with the specified label. - * - * @param {string} name + * + * @param {string} name * @returns {string} */ public static label(name: string): string { - return `label:${name}` + return `label:${name}`; } -} \ No newline at end of file +} diff --git a/src/service.ts b/src/service.ts index 8b360685..f6020344 100644 --- a/src/service.ts +++ b/src/service.ts @@ -5,7 +5,7 @@ export class Service { /** * The size for chunked uploads in bytes. */ - static CHUNK_SIZE = 5*1024*1024; // 5MB + static CHUNK_SIZE = 5 * 1024 * 1024; // 5MB client: Client; @@ -17,7 +17,7 @@ export class Service { let output: Payload = {}; for (const [key, value] of Object.entries(data)) { - let finalKey = prefix ? prefix + '[' + key +']' : key; + const finalKey = prefix ? prefix + '[' + key + ']' : key; if (Array.isArray(value)) { output = { ...output, ...Service.flatten(value, finalKey) }; } else { @@ -27,4 +27,4 @@ export class Service { return output; } -} \ No newline at end of file +} diff --git a/src/services/account.ts b/src/services/account.ts index 9ada6e92..7dfbeb0d 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,12 +1,11 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { AccountKeyScopes } from '../enums/account-key-scopes'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; - export class Account { client: Client; @@ -20,23 +19,19 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - get(): Promise> { - + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise> { const apiPath = '/account'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -49,7 +44,14 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - create(params: { userId: string, email: string, password: string, name?: string }): Promise>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * @@ -61,24 +63,45 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(userId: string, email: string, password: string, name?: string): Promise>; create( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + create( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -91,9 +114,10 @@ export class Account { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -113,15 +137,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -131,7 +150,6 @@ export class Account { * @returns {Promise<{}>} */ delete(): Promise<{}> { - const apiPath = '/account'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -139,14 +157,10 @@ export class Account { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -156,7 +170,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listBillingAddresses(params?: { queries?: string[] }): Promise; + listBillingAddresses(params?: { + queries?: string[]; + }): Promise; /** * List all billing addresses for a user. * @@ -165,22 +181,28 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBillingAddresses(queries?: string[]): Promise; listBillingAddresses( - paramsOrFirst?: { queries?: string[] } | string[] + queries?: string[], + ): Promise; + listBillingAddresses( + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/account/billing-addresses'; const payload: Payload = {}; @@ -191,15 +213,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -214,7 +231,14 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createBillingAddress(params: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }): Promise; + createBillingAddress(params: { + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + }): Promise; /** * Add a new billing address to a user's account. * @@ -228,15 +252,49 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBillingAddress(country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string): Promise; createBillingAddress( - paramsOrFirst: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] + country: string, + city: string, + streetAddress: string, + addressLine2?: string, + state?: string, + postalCode?: string, + ): Promise; + createBillingAddress( + paramsOrFirst: + | { + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?] ): Promise { - let params: { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; + let params: { + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + }; } else { params = { country: paramsOrFirst as string, @@ -244,10 +302,10 @@ export class Account { streetAddress: rest[1] as string, addressLine2: rest[2] as string, state: rest[3] as string, - postalCode: rest[4] as string + postalCode: rest[4] as string, }; } - + const country = params.country; const city = params.city; const streetAddress = params.streetAddress; @@ -256,15 +314,18 @@ export class Account { const postalCode = params.postalCode; if (typeof country === 'undefined') { - throw new AppwriteException('Missing required parameter: "country"'); + throw new AppwriteException( + 'Missing required parameter: "country"', + ); } if (typeof city === 'undefined') { throw new AppwriteException('Missing required parameter: "city"'); } if (typeof streetAddress === 'undefined') { - throw new AppwriteException('Missing required parameter: "streetAddress"'); + throw new AppwriteException( + 'Missing required parameter: "streetAddress"', + ); } - const apiPath = '/account/billing-addresses'; const payload: Payload = {}; if (typeof country !== 'undefined') { @@ -290,15 +351,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -308,7 +364,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - getBillingAddress(params: { billingAddressId: string }): Promise; + getBillingAddress(params: { + billingAddressId: string; + }): Promise; /** * Get a specific billing address for a user using it's ID. * @@ -319,39 +377,45 @@ export class Account { */ getBillingAddress(billingAddressId: string): Promise; getBillingAddress( - paramsOrFirst: { billingAddressId: string } | string + paramsOrFirst: { billingAddressId: string } | string, ): Promise { let params: { billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { billingAddressId: string }; } else { params = { - billingAddressId: paramsOrFirst as string + billingAddressId: paramsOrFirst as string, }; } - - const billingAddressId = params.billingAddressId; - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } + const billingAddressId = params.billingAddressId; - const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', encodeURIComponent(String(billingAddressId))); + if ( + typeof billingAddressId === 'undefined' || + billingAddressId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "billingAddressId"', + ); + } + const apiPath = '/account/billing-addresses/{billingAddressId}'.replace( + '{billingAddressId}', + encodeURIComponent(String(billingAddressId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -367,7 +431,15 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateBillingAddress(params: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }): Promise; + updateBillingAddress(params: { + billingAddressId: string; + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + }): Promise; /** * Update a specific billing address using it's ID. * @@ -382,15 +454,53 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBillingAddress(billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string): Promise; updateBillingAddress( - paramsOrFirst: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + billingAddressId: string, + country: string, + city: string, + streetAddress: string, + addressLine2?: string, + state?: string, + postalCode?: string, + ): Promise; + updateBillingAddress( + paramsOrFirst: + | { + billingAddressId: string; + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?] ): Promise { - let params: { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { billingAddressId: string, country: string, city: string, streetAddress: string, addressLine2?: string, state?: string, postalCode?: string }; + let params: { + billingAddressId: string; + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + billingAddressId: string; + country: string; + city: string; + streetAddress: string; + addressLine2?: string; + state?: string; + postalCode?: string; + }; } else { params = { billingAddressId: paramsOrFirst as string, @@ -399,10 +509,10 @@ export class Account { streetAddress: rest[2] as string, addressLine2: rest[3] as string, state: rest[4] as string, - postalCode: rest[5] as string + postalCode: rest[5] as string, }; } - + const billingAddressId = params.billingAddressId; const country = params.country; const city = params.city; @@ -411,20 +521,31 @@ export class Account { const state = params.state; const postalCode = params.postalCode; - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); + if ( + typeof billingAddressId === 'undefined' || + billingAddressId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "billingAddressId"', + ); } if (typeof country === 'undefined') { - throw new AppwriteException('Missing required parameter: "country"'); + throw new AppwriteException( + 'Missing required parameter: "country"', + ); } if (typeof city === 'undefined') { throw new AppwriteException('Missing required parameter: "city"'); } if (typeof streetAddress === 'undefined') { - throw new AppwriteException('Missing required parameter: "streetAddress"'); + throw new AppwriteException( + 'Missing required parameter: "streetAddress"', + ); } - - const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', encodeURIComponent(String(billingAddressId))); + const apiPath = '/account/billing-addresses/{billingAddressId}'.replace( + '{billingAddressId}', + encodeURIComponent(String(billingAddressId)), + ); const payload: Payload = {}; if (typeof country !== 'undefined') { payload['country'] = country; @@ -449,15 +570,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -478,40 +594,46 @@ export class Account { */ deleteBillingAddress(billingAddressId: string): Promise<{}>; deleteBillingAddress( - paramsOrFirst: { billingAddressId: string } | string + paramsOrFirst: { billingAddressId: string } | string, ): Promise<{}> { let params: { billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { billingAddressId: string }; } else { params = { - billingAddressId: paramsOrFirst as string + billingAddressId: paramsOrFirst as string, }; } - - const billingAddressId = params.billingAddressId; - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } + const billingAddressId = params.billingAddressId; - const apiPath = '/account/billing-addresses/{billingAddressId}'.replace('{billingAddressId}', encodeURIComponent(String(billingAddressId))); + if ( + typeof billingAddressId === 'undefined' || + billingAddressId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "billingAddressId"', + ); + } + const apiPath = '/account/billing-addresses/{billingAddressId}'.replace( + '{billingAddressId}', + encodeURIComponent(String(billingAddressId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -522,7 +644,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listConsents(params?: { queries?: string[], total?: boolean }): Promise; + listConsents(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of the OAuth2 consents the current user has given to third-party apps. * @@ -532,26 +657,36 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listConsents(queries?: string[], total?: boolean): Promise; listConsents( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listConsents( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/account/consents'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -564,15 +699,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -593,39 +723,42 @@ export class Account { */ getConsent(consentId: string): Promise; getConsent( - paramsOrFirst: { consentId: string } | string + paramsOrFirst: { consentId: string } | string, ): Promise { let params: { consentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { consentId: string }; } else { params = { - consentId: paramsOrFirst as string + consentId: paramsOrFirst as string, }; } - + const consentId = params.consentId; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + if (typeof consentId === 'undefined' || consentId === '') { + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - - const apiPath = '/account/consents/{consentId}'.replace('{consentId}', encodeURIComponent(String(consentId))); + const apiPath = '/account/consents/{consentId}'.replace( + '{consentId}', + encodeURIComponent(String(consentId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -645,41 +778,42 @@ export class Account { * @deprecated Use the object parameter style method for a better developer experience. */ deleteConsent(consentId: string): Promise<{}>; - deleteConsent( - paramsOrFirst: { consentId: string } | string - ): Promise<{}> { + deleteConsent(paramsOrFirst: { consentId: string } | string): Promise<{}> { let params: { consentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { consentId: string }; } else { params = { - consentId: paramsOrFirst as string + consentId: paramsOrFirst as string, }; } - + const consentId = params.consentId; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + if (typeof consentId === 'undefined' || consentId === '') { + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - - const apiPath = '/account/consents/{consentId}'.replace('{consentId}', encodeURIComponent(String(consentId))); + const apiPath = '/account/consents/{consentId}'.replace( + '{consentId}', + encodeURIComponent(String(consentId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -691,7 +825,11 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listConsentTokens(params: { consentId: string, queries?: string[], total?: boolean }): Promise; + listConsentTokens(params: { + consentId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of the token families issued under an OAuth2 consent. Each entry represents one authorized device or session; the token secrets themselves are never returned. * @@ -702,32 +840,49 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listConsentTokens(consentId: string, queries?: string[], total?: boolean): Promise; listConsentTokens( - paramsOrFirst: { consentId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + consentId: string, + queries?: string[], + total?: boolean, + ): Promise; + listConsentTokens( + paramsOrFirst: + { consentId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { consentId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { consentId: string, queries?: string[], total?: boolean }; + let params: { consentId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + consentId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { consentId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const consentId = params.consentId; const queries = params.queries; const total = params.total; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + if (typeof consentId === 'undefined' || consentId === '') { + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - - const apiPath = '/account/consents/{consentId}/tokens'.replace('{consentId}', encodeURIComponent(String(consentId))); + const apiPath = '/account/consents/{consentId}/tokens'.replace( + '{consentId}', + encodeURIComponent(String(consentId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -739,15 +894,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -758,7 +908,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - getConsentToken(params: { consentId: string, tokenId: string }): Promise; + getConsentToken(params: { + consentId: string; + tokenId: string; + }): Promise; /** * Get a token family issued under an OAuth2 consent by its unique ID. The token secrets themselves are never returned. * @@ -768,47 +921,57 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getConsentToken(consentId: string, tokenId: string): Promise; getConsentToken( - paramsOrFirst: { consentId: string, tokenId: string } | string, - ...rest: [(string)?] + consentId: string, + tokenId: string, + ): Promise; + getConsentToken( + paramsOrFirst: { consentId: string; tokenId: string } | string, + ...rest: [string?] ): Promise { - let params: { consentId: string, tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { consentId: string, tokenId: string }; + let params: { consentId: string; tokenId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + consentId: string; + tokenId: string; + }; } else { params = { consentId: paramsOrFirst as string, - tokenId: rest[0] as string + tokenId: rest[0] as string, }; } - + const consentId = params.consentId; const tokenId = params.tokenId; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + if (typeof consentId === 'undefined' || consentId === '') { + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + if (typeof tokenId === 'undefined' || tokenId === '') { + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/account/consents/{consentId}/tokens/{tokenId}'.replace('{consentId}', encodeURIComponent(String(consentId))).replace('{tokenId}', encodeURIComponent(String(tokenId))); + const apiPath = '/account/consents/{consentId}/tokens/{tokenId}' + .replace('{consentId}', encodeURIComponent(String(consentId))) + .replace('{tokenId}', encodeURIComponent(String(tokenId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -819,7 +982,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteConsentToken(params: { consentId: string, tokenId: string }): Promise<{}>; + deleteConsentToken(params: { + consentId: string; + tokenId: string; + }): Promise<{}>; /** * Delete a token family issued under an OAuth2 consent by its unique ID. The access and refresh tokens of the family stop working immediately; other token families and the consent itself are unaffected. * @@ -831,46 +997,53 @@ export class Account { */ deleteConsentToken(consentId: string, tokenId: string): Promise<{}>; deleteConsentToken( - paramsOrFirst: { consentId: string, tokenId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { consentId: string; tokenId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { consentId: string, tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { consentId: string, tokenId: string }; + let params: { consentId: string; tokenId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + consentId: string; + tokenId: string; + }; } else { params = { consentId: paramsOrFirst as string, - tokenId: rest[0] as string + tokenId: rest[0] as string, }; } - + const consentId = params.consentId; const tokenId = params.tokenId; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + if (typeof consentId === 'undefined' || consentId === '') { + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + if (typeof tokenId === 'undefined' || tokenId === '') { + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/account/consents/{consentId}/tokens/{tokenId}'.replace('{consentId}', encodeURIComponent(String(consentId))).replace('{tokenId}', encodeURIComponent(String(tokenId))); + const apiPath = '/account/consents/{consentId}/tokens/{tokenId}' + .replace('{consentId}', encodeURIComponent(String(consentId))) + .replace('{tokenId}', encodeURIComponent(String(tokenId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -891,56 +1064,64 @@ export class Account { */ getCoupon(couponId: string): Promise; getCoupon( - paramsOrFirst: { couponId: string } | string + paramsOrFirst: { couponId: string } | string, ): Promise { let params: { couponId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { couponId: string }; } else { params = { - couponId: paramsOrFirst as string + couponId: paramsOrFirst as string, }; } - + const couponId = params.couponId; - if (typeof couponId === 'undefined') { - throw new AppwriteException('Missing required parameter: "couponId"'); + if (typeof couponId === 'undefined' || couponId === '') { + throw new AppwriteException( + 'Missing required parameter: "couponId"', + ); } - - const apiPath = '/account/coupons/{couponId}'.replace('{couponId}', encodeURIComponent(String(couponId))); + const apiPath = '/account/coupons/{couponId}'.replace( + '{couponId}', + encodeURIComponent(String(couponId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. - * + * * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise>} */ - updateEmail(params: { email: string, password: string }): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + email: string; + password: string; + }): Promise>; /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. - * + * * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. @@ -948,22 +1129,33 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(email: string, password: string): Promise>; - updateEmail( - paramsOrFirst: { email: string, password: string } | string, - ...rest: [(string)?] + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(email: string, password: string): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { email: string; password: string } | string, + ...rest: [string?] ): Promise> { - let params: { email: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { email: string, password: string }; + let params: { email: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + email: string; + password: string; + }; } else { params = { email: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const email = params.email; const password = params.password; @@ -971,9 +1163,10 @@ export class Account { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/email'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -987,15 +1180,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1006,7 +1194,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listIdentities(params?: { queries?: string[], total?: boolean }): Promise; + listIdentities(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the list of identities for the currently logged in user. * @@ -1016,26 +1207,36 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIdentities(queries?: string[], total?: boolean): Promise; listIdentities( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listIdentities( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/account/identities'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1048,15 +1249,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1077,39 +1273,43 @@ export class Account { */ deleteIdentity(identityId: string): Promise<{}>; deleteIdentity( - paramsOrFirst: { identityId: string } | string + paramsOrFirst: { identityId: string } | string, ): Promise<{}> { let params: { identityId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { identityId: string }; } else { params = { - identityId: paramsOrFirst as string + identityId: paramsOrFirst as string, }; } - + const identityId = params.identityId; - if (typeof identityId === 'undefined') { - throw new AppwriteException('Missing required parameter: "identityId"'); + if (typeof identityId === 'undefined' || identityId === '') { + throw new AppwriteException( + 'Missing required parameter: "identityId"', + ); } - - const apiPath = '/account/identities/{identityId}'.replace('{identityId}', encodeURIComponent(String(identityId))); + const apiPath = '/account/identities/{identityId}'.replace( + '{identityId}', + encodeURIComponent(String(identityId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1130,20 +1330,24 @@ export class Account { */ listInvoices(queries?: string[]): Promise; listInvoices( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/account/invoices'; const payload: Payload = {}; @@ -1154,15 +1358,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1183,20 +1382,24 @@ export class Account { */ createJWT(duration?: number): Promise; createJWT( - paramsOrFirst?: { duration?: number } | number + paramsOrFirst?: { duration?: number } | number, ): Promise { let params: { duration?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { duration?: number }; } else { params = { - duration: paramsOrFirst as number + duration: paramsOrFirst as number, }; } - - const duration = params.duration; + const duration = params.duration; const apiPath = '/account/jwts'; const payload: Payload = {}; @@ -1208,15 +1411,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1237,20 +1435,24 @@ export class Account { */ listKeys(total?: boolean): Promise; listKeys( - paramsOrFirst?: { total?: boolean } | boolean + paramsOrFirst?: { total?: boolean } | boolean, ): Promise { let params: { total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { total?: boolean }; } else { params = { - total: paramsOrFirst as boolean + total: paramsOrFirst as boolean, }; } - - const total = params.total; + const total = params.total; const apiPath = '/account/keys'; const payload: Payload = {}; @@ -1261,15 +1463,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1281,7 +1478,11 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createKey(params: { name: string, scopes: AccountKeyScopes[], expire?: string }): Promise; + createKey(params: { + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + }): Promise; /** * Create a new account API key. * @@ -1292,23 +1493,41 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createKey(name: string, scopes: AccountKeyScopes[], expire?: string): Promise; createKey( - paramsOrFirst: { name: string, scopes: AccountKeyScopes[], expire?: string } | string, - ...rest: [(AccountKeyScopes[])?, (string)?] + name: string, + scopes: AccountKeyScopes[], + expire?: string, + ): Promise; + createKey( + paramsOrFirst: + | { name: string; scopes: AccountKeyScopes[]; expire?: string } + | string, + ...rest: [AccountKeyScopes[]?, string?] ): Promise { - let params: { name: string, scopes: AccountKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { name: string, scopes: AccountKeyScopes[], expire?: string }; + let params: { + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + }; } else { params = { name: paramsOrFirst as string, scopes: rest[0] as AccountKeyScopes[], - expire: rest[1] as string + expire: rest[1] as string, }; } - + const name = params.name; const scopes = params.scopes; const expire = params.expire; @@ -1319,7 +1538,6 @@ export class Account { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - const apiPath = '/account/keys'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1336,15 +1554,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1364,40 +1577,39 @@ export class Account { * @deprecated Use the object parameter style method for a better developer experience. */ getKey(keyId: string): Promise; - getKey( - paramsOrFirst: { keyId: string } | string - ): Promise { + getKey(paramsOrFirst: { keyId: string } | string): Promise { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - + const keyId = params.keyId; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/account/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/account/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1410,7 +1622,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string }): Promise; + updateKey(params: { + keyId: string; + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * @@ -1422,30 +1639,56 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (AccountKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: AccountKeyScopes[], + expire?: string, + ): Promise; + updateKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, AccountKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: AccountKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as AccountKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; const expire = params.expire; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } if (typeof name === 'undefined') { @@ -1454,8 +1697,10 @@ export class Account { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - - const apiPath = '/account/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/account/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1471,15 +1716,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1499,41 +1739,40 @@ export class Account { * @deprecated Use the object parameter style method for a better developer experience. */ deleteKey(keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { keyId: string } | string - ): Promise<{}> { + deleteKey(paramsOrFirst: { keyId: string } | string): Promise<{}> { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - + const keyId = params.keyId; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/account/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/account/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1544,7 +1783,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params?: { queries?: string[], total?: boolean }): Promise; + listLogs(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. * @@ -1556,24 +1798,31 @@ export class Account { */ listLogs(queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/account/logs'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1586,15 +1835,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1604,7 +1848,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateMFA(params: { mfa: boolean }): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { mfa: boolean }): Promise>; /** * Enable or disable MFA on an account. * @@ -1613,26 +1859,33 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFA(mfa: boolean): Promise>; - updateMFA( - paramsOrFirst: { mfa: boolean } | boolean + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(mfa: boolean): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { mfa: boolean } | boolean, ): Promise> { let params: { mfa: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { mfa: boolean }; } else { params = { - mfa: paramsOrFirst as boolean + mfa: paramsOrFirst as boolean, }; } - + const mfa = params.mfa; if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } - const apiPath = '/account/mfa'; const payload: Payload = {}; if (typeof mfa !== 'undefined') { @@ -1643,15 +1896,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1662,7 +1910,9 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead. */ - createMfaAuthenticator(params: { type: AuthenticatorType }): Promise; + createMfaAuthenticator(params: { + type: AuthenticatorType; + }): Promise; /** * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -1673,40 +1923,42 @@ export class Account { */ createMfaAuthenticator(type: AuthenticatorType): Promise; createMfaAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1716,7 +1968,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createMFAAuthenticator(params: { type: AuthenticatorType }): Promise; + createMFAAuthenticator(params: { + type: AuthenticatorType; + }): Promise; /** * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -1727,40 +1981,42 @@ export class Account { */ createMFAAuthenticator(type: AuthenticatorType): Promise; createMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1772,7 +2028,12 @@ export class Account { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead. */ - updateMfaAuthenticator(params: { type: AuthenticatorType, otp: string }): Promise>; + updateMfaAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + type: AuthenticatorType; + otp: string; + }): Promise>; /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -1782,22 +2043,35 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise>; - updateMfaAuthenticator( - paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, - ...rest: [(string)?] + updateMfaAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(type: AuthenticatorType, otp: string): Promise>; + updateMfaAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { type: AuthenticatorType; otp: string } | AuthenticatorType, + ...rest: [string?] ): Promise> { - let params: { type: AuthenticatorType, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + let params: { type: AuthenticatorType; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('type' in paramsOrFirst || 'otp' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + type: AuthenticatorType; + otp: string; + }; } else { params = { type: paramsOrFirst as AuthenticatorType, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const type = params.type; const otp = params.otp; @@ -1807,8 +2081,10 @@ export class Account { if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); const payload: Payload = {}; if (typeof otp !== 'undefined') { payload['otp'] = otp; @@ -1818,15 +2094,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1837,7 +2108,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateMFAAuthenticator(params: { type: AuthenticatorType, otp: string }): Promise>; + updateMFAAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + type: AuthenticatorType; + otp: string; + }): Promise>; /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -1847,22 +2123,35 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFAAuthenticator(type: AuthenticatorType, otp: string): Promise>; - updateMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, - ...rest: [(string)?] + updateMFAAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(type: AuthenticatorType, otp: string): Promise>; + updateMFAAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { type: AuthenticatorType; otp: string } | AuthenticatorType, + ...rest: [string?] ): Promise> { - let params: { type: AuthenticatorType, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + let params: { type: AuthenticatorType; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('type' in paramsOrFirst || 'otp' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + type: AuthenticatorType; + otp: string; + }; } else { params = { type: paramsOrFirst as AuthenticatorType, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const type = params.type; const otp = params.otp; @@ -1872,8 +2161,10 @@ export class Account { if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); const payload: Payload = {}; if (typeof otp !== 'undefined') { payload['otp'] = otp; @@ -1883,15 +2174,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1913,39 +2199,42 @@ export class Account { */ deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}>; deleteMfaAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise<{}> { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1966,78 +2255,89 @@ export class Account { */ deleteMFAAuthenticator(type: AuthenticatorType): Promise<{}>; deleteMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise<{}> { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * - * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`, `custom`. * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead. */ - createMfaChallenge(params: { factor: AuthenticationFactor }): Promise; + createMfaChallenge(params: { + factor: AuthenticationFactor; + }): Promise; /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * - * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`, `custom`. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMfaChallenge(factor: AuthenticationFactor): Promise; createMfaChallenge( - paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + factor: AuthenticationFactor, + ): Promise; + createMfaChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor, ): Promise { let params: { factor: AuthenticationFactor }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'factor' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; } else { params = { - factor: paramsOrFirst as AuthenticationFactor + factor: paramsOrFirst as AuthenticationFactor, }; } - + const factor = params.factor; if (typeof factor === 'undefined') { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof factor !== 'undefined') { @@ -2048,53 +2348,56 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * - * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`, `custom`. * @throws {AppwriteException} * @returns {Promise} */ - createMFAChallenge(params: { factor: AuthenticationFactor }): Promise; + createMFAChallenge(params: { + factor: AuthenticationFactor; + }): Promise; /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * - * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`, `custom`. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMFAChallenge(factor: AuthenticationFactor): Promise; createMFAChallenge( - paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + factor: AuthenticationFactor, + ): Promise; + createMFAChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor, ): Promise { let params: { factor: AuthenticationFactor }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'factor' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; } else { params = { - factor: paramsOrFirst as AuthenticationFactor + factor: paramsOrFirst as AuthenticationFactor, }; } - + const factor = params.factor; if (typeof factor === 'undefined') { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof factor !== 'undefined') { @@ -2105,15 +2408,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2125,7 +2423,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead. */ - updateMfaChallenge(params: { challengeId: string, otp: string }): Promise; + updateMfaChallenge(params: { + challengeId: string; + otp: string; + }): Promise; /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -2135,32 +2436,43 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfaChallenge(challengeId: string, otp: string): Promise; updateMfaChallenge( - paramsOrFirst: { challengeId: string, otp: string } | string, - ...rest: [(string)?] + challengeId: string, + otp: string, + ): Promise; + updateMfaChallenge( + paramsOrFirst: { challengeId: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { challengeId: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + let params: { challengeId: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + otp: string; + }; } else { params = { challengeId: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const challengeId = params.challengeId; const otp = params.otp; if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof challengeId !== 'undefined') { @@ -2174,15 +2486,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -2193,7 +2500,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateMFAChallenge(params: { challengeId: string, otp: string }): Promise; + updateMFAChallenge(params: { + challengeId: string; + otp: string; + }): Promise; /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -2203,32 +2513,43 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFAChallenge(challengeId: string, otp: string): Promise; updateMFAChallenge( - paramsOrFirst: { challengeId: string, otp: string } | string, - ...rest: [(string)?] + challengeId: string, + otp: string, + ): Promise; + updateMFAChallenge( + paramsOrFirst: { challengeId: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { challengeId: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + let params: { challengeId: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + otp: string; + }; } else { params = { challengeId: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const challengeId = params.challengeId; const otp = params.otp; if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenges'; const payload: Payload = {}; if (typeof challengeId !== 'undefined') { @@ -2242,15 +2563,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -2261,22 +2577,16 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead. */ listMfaFactors(): Promise { - const apiPath = '/account/mfa/factors'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2286,22 +2596,16 @@ export class Account { * @returns {Promise} */ listMFAFactors(): Promise { - const apiPath = '/account/mfa/factors'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2312,22 +2616,16 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead. */ getMfaRecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2337,22 +2635,16 @@ export class Account { * @returns {Promise} */ getMFARecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2363,7 +2655,6 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead. */ createMfaRecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2371,15 +2662,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2389,7 +2675,6 @@ export class Account { * @returns {Promise} */ createMFARecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2397,15 +2682,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2416,7 +2696,6 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead. */ updateMfaRecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2424,15 +2703,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2442,7 +2716,6 @@ export class Account { * @returns {Promise} */ updateMFARecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2450,15 +2723,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2468,7 +2736,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(params: { name: string }): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { name: string }): Promise>; /** * Update currently logged in user account name. * @@ -2477,26 +2747,33 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateName(name: string): Promise>; - updateName( - paramsOrFirst: { name: string } | string + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(name: string): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { name: string } | string, ): Promise> { let params: { name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { name: string }; } else { params = { - name: paramsOrFirst as string + name: paramsOrFirst as string, }; } - + const name = params.name; if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/account/name'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -2507,15 +2784,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2526,7 +2798,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updatePassword(params: { password: string, oldPassword?: string }): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + password: string; + oldPassword?: string; + }): Promise>; /** * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * @@ -2536,29 +2813,44 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePassword(password: string, oldPassword?: string): Promise>; - updatePassword( - paramsOrFirst: { password: string, oldPassword?: string } | string, - ...rest: [(string)?] + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + password: string, + oldPassword?: string, + ): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { password: string; oldPassword?: string } | string, + ...rest: [string?] ): Promise> { - let params: { password: string, oldPassword?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { password: string, oldPassword?: string }; + let params: { password: string; oldPassword?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + password: string; + oldPassword?: string; + }; } else { params = { password: paramsOrFirst as string, - oldPassword: rest[0] as string + oldPassword: rest[0] as string, }; } - + const password = params.password; const oldPassword = params.oldPassword; if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/password'; const payload: Payload = {}; if (typeof password !== 'undefined') { @@ -2572,15 +2864,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2590,7 +2877,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listPaymentMethods(params?: { queries?: string[] }): Promise; + listPaymentMethods(params?: { + queries?: string[]; + }): Promise; /** * List payment methods for this account. * @@ -2601,20 +2890,24 @@ export class Account { */ listPaymentMethods(queries?: string[]): Promise; listPaymentMethods( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/account/payment-methods'; const payload: Payload = {}; @@ -2625,15 +2918,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2643,7 +2931,6 @@ export class Account { * @returns {Promise} */ createPaymentMethod(): Promise { - const apiPath = '/account/payment-methods'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2651,15 +2938,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2669,7 +2951,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - getPaymentMethod(params: { paymentMethodId: string }): Promise; + getPaymentMethod(params: { + paymentMethodId: string; + }): Promise; /** * Get a specific payment method for the user. * @@ -2680,39 +2964,42 @@ export class Account { */ getPaymentMethod(paymentMethodId: string): Promise; getPaymentMethod( - paramsOrFirst: { paymentMethodId: string } | string + paramsOrFirst: { paymentMethodId: string } | string, ): Promise { let params: { paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { paymentMethodId: string }; } else { params = { - paymentMethodId: paramsOrFirst as string + paymentMethodId: paramsOrFirst as string, }; } - + const paymentMethodId = params.paymentMethodId; - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + if (typeof paymentMethodId === 'undefined' || paymentMethodId === '') { + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } - - const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', encodeURIComponent(String(paymentMethodId))); + const apiPath = '/account/payment-methods/{paymentMethodId}'.replace( + '{paymentMethodId}', + encodeURIComponent(String(paymentMethodId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2725,7 +3012,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updatePaymentMethod(params: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }): Promise; + updatePaymentMethod(params: { + paymentMethodId: string; + expiryMonth: number; + expiryYear: number; + state?: string; + }): Promise; /** * Update a new payment method for the current user account. * @@ -2737,40 +3029,74 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePaymentMethod(paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string): Promise; updatePaymentMethod( - paramsOrFirst: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string } | string, - ...rest: [(number)?, (number)?, (string)?] + paymentMethodId: string, + expiryMonth: number, + expiryYear: number, + state?: string, + ): Promise; + updatePaymentMethod( + paramsOrFirst: + | { + paymentMethodId: string; + expiryMonth: number; + expiryYear: number; + state?: string; + } + | string, + ...rest: [number?, number?, string?] ): Promise { - let params: { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string, expiryMonth: number, expiryYear: number, state?: string }; + let params: { + paymentMethodId: string; + expiryMonth: number; + expiryYear: number; + state?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + paymentMethodId: string; + expiryMonth: number; + expiryYear: number; + state?: string; + }; } else { params = { paymentMethodId: paramsOrFirst as string, expiryMonth: rest[0] as number, expiryYear: rest[1] as number, - state: rest[2] as string + state: rest[2] as string, }; } - + const paymentMethodId = params.paymentMethodId; const expiryMonth = params.expiryMonth; const expiryYear = params.expiryYear; const state = params.state; - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + if (typeof paymentMethodId === 'undefined' || paymentMethodId === '') { + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } if (typeof expiryMonth === 'undefined') { - throw new AppwriteException('Missing required parameter: "expiryMonth"'); + throw new AppwriteException( + 'Missing required parameter: "expiryMonth"', + ); } if (typeof expiryYear === 'undefined') { - throw new AppwriteException('Missing required parameter: "expiryYear"'); + throw new AppwriteException( + 'Missing required parameter: "expiryYear"', + ); } - - const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', encodeURIComponent(String(paymentMethodId))); + const apiPath = '/account/payment-methods/{paymentMethodId}'.replace( + '{paymentMethodId}', + encodeURIComponent(String(paymentMethodId)), + ); const payload: Payload = {}; if (typeof expiryMonth !== 'undefined') { payload['expiryMonth'] = expiryMonth; @@ -2786,15 +3112,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2815,40 +3136,43 @@ export class Account { */ deletePaymentMethod(paymentMethodId: string): Promise<{}>; deletePaymentMethod( - paramsOrFirst: { paymentMethodId: string } | string + paramsOrFirst: { paymentMethodId: string } | string, ): Promise<{}> { let params: { paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { paymentMethodId: string }; } else { params = { - paymentMethodId: paramsOrFirst as string + paymentMethodId: paramsOrFirst as string, }; } - + const paymentMethodId = params.paymentMethodId; - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + if (typeof paymentMethodId === 'undefined' || paymentMethodId === '') { + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } - - const apiPath = '/account/payment-methods/{paymentMethodId}'.replace('{paymentMethodId}', encodeURIComponent(String(paymentMethodId))); + const apiPath = '/account/payment-methods/{paymentMethodId}'.replace( + '{paymentMethodId}', + encodeURIComponent(String(paymentMethodId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -2861,7 +3185,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updatePaymentMethodProvider(params: { paymentMethodId: string, providerMethodId: string, name: string, state?: string }): Promise; + updatePaymentMethodProvider(params: { + paymentMethodId: string; + providerMethodId: string; + name: string; + state?: string; + }): Promise; /** * Update payment method provider. * @@ -2873,40 +3202,73 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePaymentMethodProvider(paymentMethodId: string, providerMethodId: string, name: string, state?: string): Promise; updatePaymentMethodProvider( - paramsOrFirst: { paymentMethodId: string, providerMethodId: string, name: string, state?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + paymentMethodId: string, + providerMethodId: string, + name: string, + state?: string, + ): Promise; + updatePaymentMethodProvider( + paramsOrFirst: + | { + paymentMethodId: string; + providerMethodId: string; + name: string; + state?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise { - let params: { paymentMethodId: string, providerMethodId: string, name: string, state?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { paymentMethodId: string, providerMethodId: string, name: string, state?: string }; + let params: { + paymentMethodId: string; + providerMethodId: string; + name: string; + state?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + paymentMethodId: string; + providerMethodId: string; + name: string; + state?: string; + }; } else { params = { paymentMethodId: paramsOrFirst as string, providerMethodId: rest[0] as string, name: rest[1] as string, - state: rest[2] as string + state: rest[2] as string, }; } - + const paymentMethodId = params.paymentMethodId; const providerMethodId = params.providerMethodId; const name = params.name; const state = params.state; - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + if (typeof paymentMethodId === 'undefined' || paymentMethodId === '') { + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } if (typeof providerMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerMethodId"'); + throw new AppwriteException( + 'Missing required parameter: "providerMethodId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/account/payment-methods/{paymentMethodId}/provider'.replace('{paymentMethodId}', encodeURIComponent(String(paymentMethodId))); + const apiPath = + '/account/payment-methods/{paymentMethodId}/provider'.replace( + '{paymentMethodId}', + encodeURIComponent(String(paymentMethodId)), + ); const payload: Payload = {}; if (typeof providerMethodId !== 'undefined') { payload['providerMethodId'] = providerMethodId; @@ -2922,15 +3284,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2940,7 +3297,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updatePaymentMethodMandateOptions(params: { paymentMethodId: string }): Promise; + updatePaymentMethodMandateOptions(params: { + paymentMethodId: string; + }): Promise; /** * Update payment method mandate options. * @@ -2949,42 +3308,48 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePaymentMethodMandateOptions(paymentMethodId: string): Promise; updatePaymentMethodMandateOptions( - paramsOrFirst: { paymentMethodId: string } | string + paymentMethodId: string, + ): Promise; + updatePaymentMethodMandateOptions( + paramsOrFirst: { paymentMethodId: string } | string, ): Promise { let params: { paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { paymentMethodId: string }; } else { params = { - paymentMethodId: paramsOrFirst as string + paymentMethodId: paramsOrFirst as string, }; } - + const paymentMethodId = params.paymentMethodId; - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + if (typeof paymentMethodId === 'undefined' || paymentMethodId === '') { + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } - - const apiPath = '/account/payment-methods/{paymentMethodId}/setup'.replace('{paymentMethodId}', encodeURIComponent(String(paymentMethodId))); + const apiPath = + '/account/payment-methods/{paymentMethodId}/setup'.replace( + '{paymentMethodId}', + encodeURIComponent(String(paymentMethodId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2995,7 +3360,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updatePhone(params: { phone: string, password: string }): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + phone: string; + password: string; + }): Promise>; /** * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. * @@ -3005,22 +3375,33 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhone(phone: string, password: string): Promise>; - updatePhone( - paramsOrFirst: { phone: string, password: string } | string, - ...rest: [(string)?] + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(phone: string, password: string): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { phone: string; password: string } | string, + ...rest: [string?] ): Promise> { - let params: { phone: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { phone: string, password: string }; + let params: { phone: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + phone: string; + password: string; + }; } else { params = { phone: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const phone = params.phone; const password = params.password; @@ -3028,9 +3409,10 @@ export class Account { throw new AppwriteException('Missing required parameter: "phone"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/phone'; const payload: Payload = {}; if (typeof phone !== 'undefined') { @@ -3044,15 +3426,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3061,23 +3438,19 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(): Promise { - + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise { const apiPath = '/account/prefs'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -3087,7 +3460,11 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updatePrefs(params: { prefs: Partial }): Promise>; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + prefs: Partial; + }): Promise>; /** * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * @@ -3096,26 +3473,34 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs(prefs: Partial): Promise>; - updatePrefs( - paramsOrFirst: { prefs: Partial } | Partial + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(prefs: Partial): Promise>; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { prefs: Partial } | Partial, ): Promise> { let params: { prefs: Partial }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('prefs' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'prefs' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { prefs: Partial }; } else { params = { - prefs: paramsOrFirst as Partial + prefs: paramsOrFirst as Partial, }; } - + const prefs = params.prefs; if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } - const apiPath = '/account/prefs'; const payload: Payload = {}; if (typeof prefs !== 'undefined') { @@ -3126,15 +3511,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3145,7 +3525,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createRecovery(params: { email: string, url: string }): Promise; + createRecovery(params: { + email: string; + url: string; + }): Promise; /** * Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. * @@ -3157,20 +3540,24 @@ export class Account { */ createRecovery(email: string, url: string): Promise; createRecovery( - paramsOrFirst: { email: string, url: string } | string, - ...rest: [(string)?] + paramsOrFirst: { email: string; url: string } | string, + ...rest: [string?] ): Promise { - let params: { email: string, url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { email: string, url: string }; + let params: { email: string; url: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { email: string; url: string }; } else { params = { email: paramsOrFirst as string, - url: rest[0] as string + url: rest[0] as string, }; } - + const email = params.email; const url = params.url; @@ -3180,7 +3567,6 @@ export class Account { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/recovery'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -3194,20 +3580,15 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param {string} params.userId - User ID. @@ -3216,10 +3597,14 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateRecovery(params: { userId: string, secret: string, password: string }): Promise; + updateRecovery(params: { + userId: string; + secret: string; + password: string; + }): Promise; /** * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param {string} userId - User ID. @@ -3229,23 +3614,36 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecovery(userId: string, secret: string, password: string): Promise; updateRecovery( - paramsOrFirst: { userId: string, secret: string, password: string } | string, - ...rest: [(string)?, (string)?] + userId: string, + secret: string, + password: string, + ): Promise; + updateRecovery( + paramsOrFirst: + { userId: string; secret: string; password: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { userId: string, secret: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string, password: string }; + let params: { userId: string; secret: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + password: string; + }; } else { params = { userId: paramsOrFirst as string, secret: rest[0] as string, - password: rest[1] as string + password: rest[1] as string, }; } - + const userId = params.userId; const secret = params.secret; const password = params.password; @@ -3257,9 +3655,10 @@ export class Account { throw new AppwriteException('Missing required parameter: "secret"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/recovery'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -3276,15 +3675,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -3294,22 +3688,16 @@ export class Account { * @returns {Promise} */ listSessions(): Promise { - const apiPath = '/account/sessions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -3319,7 +3707,6 @@ export class Account { * @returns {Promise<{}>} */ deleteSessions(): Promise<{}> { - const apiPath = '/account/sessions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -3327,14 +3714,10 @@ export class Account { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -3344,7 +3727,6 @@ export class Account { * @returns {Promise} */ createAnonymousSession(): Promise { - const apiPath = '/account/sessions/anonymous'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -3352,20 +3734,15 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} params.email - User email. @@ -3373,10 +3750,13 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createEmailPasswordSession(params: { email: string, password: string }): Promise; + createEmailPasswordSession(params: { + email: string; + password: string; + }): Promise; /** * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} email - User email. @@ -3385,22 +3765,32 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailPasswordSession(email: string, password: string): Promise; createEmailPasswordSession( - paramsOrFirst: { email: string, password: string } | string, - ...rest: [(string)?] + email: string, + password: string, + ): Promise; + createEmailPasswordSession( + paramsOrFirst: { email: string; password: string } | string, + ...rest: [string?] ): Promise { - let params: { email: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { email: string, password: string }; + let params: { email: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + email: string; + password: string; + }; } else { params = { email: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const email = params.email; const password = params.password; @@ -3408,9 +3798,10 @@ export class Account { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/sessions/email'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -3424,15 +3815,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3444,7 +3830,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead. */ - updateMagicURLSession(params: { userId: string, secret: string }): Promise; + updateMagicURLSession(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -3454,22 +3843,32 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMagicURLSession(userId: string, secret: string): Promise; updateMagicURLSession( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + userId: string, + secret: string, + ): Promise; + updateMagicURLSession( + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; } else { params = { userId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const userId = params.userId; const secret = params.secret; @@ -3479,7 +3878,6 @@ export class Account { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/sessions/magic-url'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -3493,42 +3891,42 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * + * * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {void | string} */ - createOAuth2Session(params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }): void | string; + createOAuth2Session(params: { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }): void | string; /** * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * + * * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -3536,34 +3934,68 @@ export class Account { * @returns {void | string} * @deprecated Use the object parameter style method for a better developer experience. */ - createOAuth2Session(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | string; createOAuth2Session( - paramsOrFirst: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] } | OAuthProvider, - ...rest: [(string)?, (string)?, (string[])?] + provider: OAuthProvider, + success?: string, + failure?: string, + scopes?: string[], + ): void | string; + createOAuth2Session( + paramsOrFirst: + | { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + } + | OAuthProvider, + ...rest: [string?, string?, string[]?] ): void | string { - let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; + let params: { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('provider' in paramsOrFirst || + 'success' in paramsOrFirst || + 'failure' in paramsOrFirst || + 'scopes' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }; } else { params = { provider: paramsOrFirst as OAuthProvider, success: rest[0] as string, failure: rest[1] as string, - scopes: rest[2] as string[] + scopes: rest[2] as string[], }; } - + const provider = params.provider; const success = params.success; const failure = params.failure; const scopes = params.scopes; if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); } - - const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', encodeURIComponent(String(provider))); + const apiPath = '/account/sessions/oauth2/{provider}'.replace( + '{provider}', + encodeURIComponent(String(provider)), + ); const payload: Payload = {}; if (typeof success !== 'undefined') { payload['success'] = success; @@ -3576,17 +4008,12 @@ export class Account { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'text/html', - } - payload['project'] = this.client.config.project; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + if (typeof window !== 'undefined' && window?.location) { window.location.href = uri.toString(); return; @@ -3604,7 +4031,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead. */ - updatePhoneSession(params: { userId: string, secret: string }): Promise; + updatePhoneSession(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -3616,20 +4046,27 @@ export class Account { */ updatePhoneSession(userId: string, secret: string): Promise; updatePhoneSession( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; } else { params = { userId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const userId = params.userId; const secret = params.secret; @@ -3639,7 +4076,6 @@ export class Account { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/sessions/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -3653,15 +4089,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -3672,7 +4103,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createSession(params: { userId: string, secret: string }): Promise; + createSession(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -3684,20 +4118,27 @@ export class Account { */ createSession(userId: string, secret: string): Promise; createSession( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; } else { params = { userId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const userId = params.userId; const secret = params.secret; @@ -3707,7 +4148,6 @@ export class Account { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/sessions/token'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -3721,21 +4161,16 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. * - * @param {string} params.sessionId - Session ID. Use the string 'current' to get the current device session. Defaults to 'current'. + * @param {string} params.sessionId - Session ID. Use the string 'current' to get the current device session. * @throws {AppwriteException} * @returns {Promise} */ @@ -3743,52 +4178,55 @@ export class Account { /** * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. * - * @param {string} sessionId - Session ID. Use the string 'current' to get the current device session. Defaults to 'current'. + * @param {string} sessionId - Session ID. Use the string 'current' to get the current device session. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getSession(sessionId: string): Promise; getSession( - paramsOrFirst: { sessionId: string } | string + paramsOrFirst: { sessionId: string } | string, ): Promise { let params: { sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { sessionId: string }; } else { params = { - sessionId: paramsOrFirst as string + sessionId: paramsOrFirst as string, }; } - + const sessionId = params.sessionId; - if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + if (typeof sessionId === 'undefined' || sessionId === '') { + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId))); + const apiPath = '/account/sessions/{sessionId}'.replace( + '{sessionId}', + encodeURIComponent(String(sessionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * - * @param {string} params.sessionId - Session ID. Use the string 'current' to update the current device session. Defaults to 'current'. + * @param {string} params.sessionId - Session ID. Use the string 'current' to update the current device session. * @throws {AppwriteException} * @returns {Promise} */ @@ -3796,53 +4234,56 @@ export class Account { /** * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * - * @param {string} sessionId - Session ID. Use the string 'current' to update the current device session. Defaults to 'current'. + * @param {string} sessionId - Session ID. Use the string 'current' to update the current device session. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ updateSession(sessionId: string): Promise; updateSession( - paramsOrFirst: { sessionId: string } | string + paramsOrFirst: { sessionId: string } | string, ): Promise { let params: { sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { sessionId: string }; } else { params = { - sessionId: paramsOrFirst as string + sessionId: paramsOrFirst as string, }; } - + const sessionId = params.sessionId; - if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + if (typeof sessionId === 'undefined' || sessionId === '') { + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId))); + const apiPath = '/account/sessions/{sessionId}'.replace( + '{sessionId}', + encodeURIComponent(String(sessionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * - * @param {string} params.sessionId - Session ID. Use the string 'current' to delete the current device session. Defaults to 'current'. + * @param {string} params.sessionId - Session ID. Use the string 'current' to delete the current device session. * @throws {AppwriteException} * @returns {Promise<{}>} */ @@ -3850,46 +4291,48 @@ export class Account { /** * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * - * @param {string} sessionId - Session ID. Use the string 'current' to delete the current device session. Defaults to 'current'. + * @param {string} sessionId - Session ID. Use the string 'current' to delete the current device session. * @throws {AppwriteException} * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ deleteSession(sessionId: string): Promise<{}>; - deleteSession( - paramsOrFirst: { sessionId: string } | string - ): Promise<{}> { + deleteSession(paramsOrFirst: { sessionId: string } | string): Promise<{}> { let params: { sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { sessionId: string }; } else { params = { - sessionId: paramsOrFirst as string + sessionId: paramsOrFirst as string, }; } - + const sessionId = params.sessionId; - if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + if (typeof sessionId === 'undefined' || sessionId === '') { + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId))); + const apiPath = '/account/sessions/{sessionId}'.replace( + '{sessionId}', + encodeURIComponent(String(sessionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -3898,8 +4341,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateStatus(): Promise> { - + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise> { const apiPath = '/account/status'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -3907,15 +4351,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3927,7 +4366,11 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createPushTarget(params: { targetId: string, identifier: string, providerId?: string }): Promise; + createPushTarget(params: { + targetId: string; + identifier: string; + providerId?: string; + }): Promise; /** * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. * @@ -3938,34 +4381,55 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPushTarget(targetId: string, identifier: string, providerId?: string): Promise; createPushTarget( - paramsOrFirst: { targetId: string, identifier: string, providerId?: string } | string, - ...rest: [(string)?, (string)?] + targetId: string, + identifier: string, + providerId?: string, + ): Promise; + createPushTarget( + paramsOrFirst: + | { targetId: string; identifier: string; providerId?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { targetId: string, identifier: string, providerId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { targetId: string, identifier: string, providerId?: string }; + let params: { + targetId: string; + identifier: string; + providerId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + targetId: string; + identifier: string; + providerId?: string; + }; } else { params = { targetId: paramsOrFirst as string, identifier: rest[0] as string, - providerId: rest[1] as string + providerId: rest[1] as string, }; } - + const targetId = params.targetId; const identifier = params.identifier; const providerId = params.providerId; if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } if (typeof identifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "identifier"'); + throw new AppwriteException( + 'Missing required parameter: "identifier"', + ); } - const apiPath = '/account/targets/push'; const payload: Payload = {}; if (typeof targetId !== 'undefined') { @@ -3982,15 +4446,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4001,7 +4460,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updatePushTarget(params: { targetId: string, identifier: string }): Promise; + updatePushTarget(params: { + targetId: string; + identifier: string; + }): Promise; /** * Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead. * @@ -4011,33 +4473,49 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePushTarget(targetId: string, identifier: string): Promise; updatePushTarget( - paramsOrFirst: { targetId: string, identifier: string } | string, - ...rest: [(string)?] + targetId: string, + identifier: string, + ): Promise; + updatePushTarget( + paramsOrFirst: { targetId: string; identifier: string } | string, + ...rest: [string?] ): Promise { - let params: { targetId: string, identifier: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { targetId: string, identifier: string }; + let params: { targetId: string; identifier: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + targetId: string; + identifier: string; + }; } else { params = { targetId: paramsOrFirst as string, - identifier: rest[0] as string + identifier: rest[0] as string, }; } - + const targetId = params.targetId; const identifier = params.identifier; - if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + if (typeof targetId === 'undefined' || targetId === '') { + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } if (typeof identifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "identifier"'); + throw new AppwriteException( + 'Missing required parameter: "identifier"', + ); } - - const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', encodeURIComponent(String(targetId))); + const apiPath = '/account/targets/{targetId}/push'.replace( + '{targetId}', + encodeURIComponent(String(targetId)), + ); const payload: Payload = {}; if (typeof identifier !== 'undefined') { payload['identifier'] = identifier; @@ -4047,15 +4525,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4076,46 +4549,50 @@ export class Account { */ deletePushTarget(targetId: string): Promise<{}>; deletePushTarget( - paramsOrFirst: { targetId: string } | string + paramsOrFirst: { targetId: string } | string, ): Promise<{}> { let params: { targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { targetId: string }; } else { params = { - targetId: paramsOrFirst as string + targetId: paramsOrFirst as string, }; } - + const targetId = params.targetId; - if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + if (typeof targetId === 'undefined' || targetId === '') { + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } - - const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', encodeURIComponent(String(targetId))); + const apiPath = '/account/targets/{targetId}/push'.replace( + '{targetId}', + encodeURIComponent(String(targetId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * + * * * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} params.email - User email. @@ -4123,12 +4600,16 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createEmailToken(params: { userId: string, email: string, phrase?: boolean }): Promise; + createEmailToken(params: { + userId: string; + email: string; + phrase?: boolean; + }): Promise; /** * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * + * * * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} email - User email. @@ -4137,23 +4618,36 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailToken(userId: string, email: string, phrase?: boolean): Promise; createEmailToken( - paramsOrFirst: { userId: string, email: string, phrase?: boolean } | string, - ...rest: [(string)?, (boolean)?] + userId: string, + email: string, + phrase?: boolean, + ): Promise; + createEmailToken( + paramsOrFirst: + { userId: string; email: string; phrase?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { userId: string, email: string, phrase?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, phrase?: boolean }; + let params: { userId: string; email: string; phrase?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + phrase?: boolean; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, - phrase: rest[1] as boolean + phrase: rest[1] as boolean, }; } - + const userId = params.userId; const email = params.email; const phrase = params.phrase; @@ -4164,7 +4658,6 @@ export class Account { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } - const apiPath = '/account/tokens/email'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -4181,22 +4674,17 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * + * * * @param {string} params.userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} params.email - User email. @@ -4205,12 +4693,17 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createMagicURLToken(params: { userId: string, email: string, url?: string, phrase?: boolean }): Promise; + createMagicURLToken(params: { + userId: string; + email: string; + url?: string; + phrase?: boolean; + }): Promise; /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * + * * * @param {string} userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} email - User email. @@ -4220,24 +4713,45 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise; createMagicURLToken( - paramsOrFirst: { userId: string, email: string, url?: string, phrase?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + userId: string, + email: string, + url?: string, + phrase?: boolean, + ): Promise; + createMagicURLToken( + paramsOrFirst: + | { userId: string; email: string; url?: string; phrase?: boolean } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { userId: string, email: string, url?: string, phrase?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, url?: string, phrase?: boolean }; + let params: { + userId: string; + email: string; + url?: string; + phrase?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + url?: string; + phrase?: boolean; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, url: rest[1] as string, - phrase: rest[2] as boolean + phrase: rest[2] as boolean, }; } - + const userId = params.userId; const email = params.email; const url = params.url; @@ -4249,7 +4763,6 @@ export class Account { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } - const apiPath = '/account/tokens/magic-url'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -4269,40 +4782,40 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + * * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {void | string} */ - createOAuth2Token(params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }): void | string; + createOAuth2Token(params: { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }): void | string; /** - * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + * * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -4310,34 +4823,68 @@ export class Account { * @returns {void | string} * @deprecated Use the object parameter style method for a better developer experience. */ - createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | string; createOAuth2Token( - paramsOrFirst: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] } | OAuthProvider, - ...rest: [(string)?, (string)?, (string[])?] + provider: OAuthProvider, + success?: string, + failure?: string, + scopes?: string[], + ): void | string; + createOAuth2Token( + paramsOrFirst: + | { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + } + | OAuthProvider, + ...rest: [string?, string?, string[]?] ): void | string { - let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; + let params: { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('provider' in paramsOrFirst || + 'success' in paramsOrFirst || + 'failure' in paramsOrFirst || + 'scopes' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }; } else { params = { provider: paramsOrFirst as OAuthProvider, success: rest[0] as string, failure: rest[1] as string, - scopes: rest[2] as string[] + scopes: rest[2] as string[], }; } - + const provider = params.provider; const success = params.success; const failure = params.failure; const scopes = params.scopes; if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); } - - const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', encodeURIComponent(String(provider))); + const apiPath = '/account/tokens/oauth2/{provider}'.replace( + '{provider}', + encodeURIComponent(String(provider)), + ); const payload: Payload = {}; if (typeof success !== 'undefined') { payload['success'] = success; @@ -4350,17 +4897,12 @@ export class Account { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'text/html', - } - payload['project'] = this.client.config.project; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + if (typeof window !== 'undefined' && window?.location) { window.location.href = uri.toString(); return; @@ -4371,7 +4913,7 @@ export class Account { /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} params.userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. @@ -4379,10 +4921,13 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createPhoneToken(params: { userId: string, phone: string }): Promise; + createPhoneToken(params: { + userId: string; + phone: string; + }): Promise; /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. - * + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. @@ -4393,20 +4938,24 @@ export class Account { */ createPhoneToken(userId: string, phone: string): Promise; createPhoneToken( - paramsOrFirst: { userId: string, phone: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; phone: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, phone: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, phone: string }; + let params: { userId: string; phone: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; phone: string }; } else { params = { userId: paramsOrFirst as string, - phone: rest[0] as string + phone: rest[0] as string, }; } - + const userId = params.userId; const phone = params.phone; @@ -4416,7 +4965,6 @@ export class Account { if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } - const apiPath = '/account/tokens/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -4430,22 +4978,17 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @throws {AppwriteException} @@ -4454,9 +4997,9 @@ export class Account { createEmailVerification(params: { url: string }): Promise; /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @throws {AppwriteException} @@ -4465,24 +5008,27 @@ export class Account { */ createEmailVerification(url: string): Promise; createEmailVerification( - paramsOrFirst: { url: string } | string + paramsOrFirst: { url: string } | string, ): Promise { let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { url: string }; } else { params = { - url: paramsOrFirst as string + url: paramsOrFirst as string, }; } - + const url = params.url; if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -4493,22 +5039,17 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @throws {AppwriteException} @@ -4518,9 +5059,9 @@ export class Account { createVerification(params: { url: string }): Promise; /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @throws {AppwriteException} @@ -4529,24 +5070,27 @@ export class Account { */ createVerification(url: string): Promise; createVerification( - paramsOrFirst: { url: string } | string + paramsOrFirst: { url: string } | string, ): Promise { let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { url: string }; } else { params = { - url: paramsOrFirst as string + url: paramsOrFirst as string, }; } - + const url = params.url; if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -4557,15 +5101,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4576,7 +5115,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailVerification(params: { userId: string, secret: string }): Promise; + updateEmailVerification(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -4586,22 +5128,32 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailVerification(userId: string, secret: string): Promise; updateEmailVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + userId: string, + secret: string, + ): Promise; + updateEmailVerification( + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; } else { params = { userId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const userId = params.userId; const secret = params.secret; @@ -4611,7 +5163,6 @@ export class Account { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -4625,15 +5176,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4645,7 +5191,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead. */ - updateVerification(params: { userId: string, secret: string }): Promise; + updateVerification(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -4657,20 +5206,27 @@ export class Account { */ updateVerification(userId: string, secret: string): Promise; updateVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; } else { params = { userId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const userId = params.userId; const secret = params.secret; @@ -4680,7 +5236,6 @@ export class Account { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -4694,15 +5249,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4712,7 +5262,6 @@ export class Account { * @returns {Promise} */ createPhoneVerification(): Promise { - const apiPath = '/account/verifications/phone'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -4720,15 +5269,10 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4739,7 +5283,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updatePhoneVerification(params: { userId: string, secret: string }): Promise; + updatePhoneVerification(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -4749,22 +5296,32 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneVerification(userId: string, secret: string): Promise; updatePhoneVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + userId: string, + secret: string, + ): Promise; + updatePhoneVerification( + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; } else { params = { userId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const userId = params.userId; const secret = params.secret; @@ -4774,7 +5331,6 @@ export class Account { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verifications/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -4788,14 +5344,9 @@ export class Account { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 60b2fb7a..44d02900 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Activities { client: Client; @@ -17,7 +15,9 @@ export class Activities { * @throws {AppwriteException} * @returns {Promise} */ - listEvents(params?: { queries?: string[] }): Promise; + listEvents(params?: { + queries?: string[]; + }): Promise; /** * List all events for selected filters. * @@ -28,20 +28,24 @@ export class Activities { */ listEvents(queries?: string[]): Promise; listEvents( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/activities/events'; const payload: Payload = {}; @@ -52,20 +56,15 @@ export class Activities { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get event by ID. - * + * * * @param {string} params.eventId - Event ID. * @throws {AppwriteException} @@ -74,7 +73,7 @@ export class Activities { getEvent(params: { eventId: string }): Promise; /** * Get event by ID. - * + * * * @param {string} eventId - Event ID. * @throws {AppwriteException} @@ -83,38 +82,41 @@ export class Activities { */ getEvent(eventId: string): Promise; getEvent( - paramsOrFirst: { eventId: string } | string + paramsOrFirst: { eventId: string } | string, ): Promise { let params: { eventId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { eventId: string }; } else { params = { - eventId: paramsOrFirst as string + eventId: paramsOrFirst as string, }; } - + const eventId = params.eventId; - if (typeof eventId === 'undefined') { - throw new AppwriteException('Missing required parameter: "eventId"'); + if (typeof eventId === 'undefined' || eventId === '') { + throw new AppwriteException( + 'Missing required parameter: "eventId"', + ); } - - const apiPath = '/activities/events/{eventId}'.replace('{eventId}', encodeURIComponent(String(eventId))); + const apiPath = '/activities/events/{eventId}'.replace( + '{eventId}', + encodeURIComponent(String(eventId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 23120269..5b528330 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Advisor { client: Client; @@ -12,17 +10,20 @@ export class Advisor { /** * Get a list of all the project's analyzer reports. You can use the query params to filter your results. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listReports(params?: { queries?: string[], total?: boolean }): Promise; + listReports(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the project's analyzer reports. You can use the query params to filter your results. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. @@ -30,26 +31,36 @@ export class Advisor { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listReports(queries?: string[], total?: boolean): Promise; listReports( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listReports( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/reports'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -62,20 +73,15 @@ export class Advisor { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. - * + * * * @param {string} params.reportId - Report ID. * @throws {AppwriteException} @@ -84,7 +90,7 @@ export class Advisor { getReport(params: { reportId: string }): Promise; /** * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. - * + * * * @param {string} reportId - Report ID. * @throws {AppwriteException} @@ -93,44 +99,47 @@ export class Advisor { */ getReport(reportId: string): Promise; getReport( - paramsOrFirst: { reportId: string } | string + paramsOrFirst: { reportId: string } | string, ): Promise { let params: { reportId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { reportId: string }; } else { params = { - reportId: paramsOrFirst as string + reportId: paramsOrFirst as string, }; } - + const reportId = params.reportId; - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + if (typeof reportId === 'undefined' || reportId === '') { + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - - const apiPath = '/reports/{reportId}'.replace('{reportId}', encodeURIComponent(String(reportId))); + const apiPath = '/reports/{reportId}'.replace( + '{reportId}', + encodeURIComponent(String(reportId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. - * + * * * @param {string} params.reportId - Report ID. * @throws {AppwriteException} @@ -139,7 +148,7 @@ export class Advisor { deleteReport(params: { reportId: string }): Promise<{}>; /** * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. - * + * * * @param {string} reportId - Report ID. * @throws {AppwriteException} @@ -147,45 +156,47 @@ export class Advisor { * @deprecated Use the object parameter style method for a better developer experience. */ deleteReport(reportId: string): Promise<{}>; - deleteReport( - paramsOrFirst: { reportId: string } | string - ): Promise<{}> { + deleteReport(paramsOrFirst: { reportId: string } | string): Promise<{}> { let params: { reportId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { reportId: string }; } else { params = { - reportId: paramsOrFirst as string + reportId: paramsOrFirst as string, }; } - + const reportId = params.reportId; - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + if (typeof reportId === 'undefined' || reportId === '') { + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - - const apiPath = '/reports/{reportId}'.replace('{reportId}', encodeURIComponent(String(reportId))); + const apiPath = '/reports/{reportId}'.replace( + '{reportId}', + encodeURIComponent(String(reportId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * List the insights produced under a single analyzer report. You can use the query params to filter your results further. - * + * * * @param {string} params.reportId - Parent report ID. * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy @@ -193,10 +204,14 @@ export class Advisor { * @throws {AppwriteException} * @returns {Promise} */ - listInsights(params: { reportId: string, queries?: string[], total?: boolean }): Promise; + listInsights(params: { + reportId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List the insights produced under a single analyzer report. You can use the query params to filter your results further. - * + * * * @param {string} reportId - Parent report ID. * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy @@ -205,32 +220,49 @@ export class Advisor { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInsights(reportId: string, queries?: string[], total?: boolean): Promise; listInsights( - paramsOrFirst: { reportId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + reportId: string, + queries?: string[], + total?: boolean, + ): Promise; + listInsights( + paramsOrFirst: + { reportId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { reportId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string, queries?: string[], total?: boolean }; + let params: { reportId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + reportId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { reportId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const reportId = params.reportId; const queries = params.queries; const total = params.total; - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + if (typeof reportId === 'undefined' || reportId === '') { + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - - const apiPath = '/reports/{reportId}/insights'.replace('{reportId}', encodeURIComponent(String(reportId))); + const apiPath = '/reports/{reportId}/insights'.replace( + '{reportId}', + encodeURIComponent(String(reportId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -242,30 +274,28 @@ export class Advisor { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get an insight by its unique ID, scoped to its parent report. - * + * * * @param {string} params.reportId - Parent report ID. * @param {string} params.insightId - Insight ID. * @throws {AppwriteException} * @returns {Promise} */ - getInsight(params: { reportId: string, insightId: string }): Promise; + getInsight(params: { + reportId: string; + insightId: string; + }): Promise; /** * Get an insight by its unique ID, scoped to its parent report. - * + * * * @param {string} reportId - Parent report ID. * @param {string} insightId - Insight ID. @@ -275,44 +305,51 @@ export class Advisor { */ getInsight(reportId: string, insightId: string): Promise; getInsight( - paramsOrFirst: { reportId: string, insightId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { reportId: string; insightId: string } | string, + ...rest: [string?] ): Promise { - let params: { reportId: string, insightId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string, insightId: string }; + let params: { reportId: string; insightId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + reportId: string; + insightId: string; + }; } else { params = { reportId: paramsOrFirst as string, - insightId: rest[0] as string + insightId: rest[0] as string, }; } - + const reportId = params.reportId; const insightId = params.insightId; - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + if (typeof reportId === 'undefined' || reportId === '') { + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - if (typeof insightId === 'undefined') { - throw new AppwriteException('Missing required parameter: "insightId"'); + if (typeof insightId === 'undefined' || insightId === '') { + throw new AppwriteException( + 'Missing required parameter: "insightId"', + ); } - - const apiPath = '/reports/{reportId}/insights/{insightId}'.replace('{reportId}', encodeURIComponent(String(reportId))).replace('{insightId}', encodeURIComponent(String(insightId))); + const apiPath = '/reports/{reportId}/insights/{insightId}' + .replace('{reportId}', encodeURIComponent(String(reportId))) + .replace('{insightId}', encodeURIComponent(String(insightId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/affiliates.ts b/src/services/affiliates.ts index a6ac11ff..e3578e3c 100644 --- a/src/services/affiliates.ts +++ b/src/services/affiliates.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Affiliates { client: Client; @@ -12,16 +10,18 @@ export class Affiliates { /** * List affiliate links for the current account. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, status * @throws {AppwriteException} * @returns {Promise} */ - listLinks(params?: { queries?: string[] }): Promise; + listLinks(params?: { + queries?: string[]; + }): Promise; /** * List affiliate links for the current account. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, status * @throws {AppwriteException} @@ -30,20 +30,24 @@ export class Affiliates { */ listLinks(queries?: string[]): Promise; listLinks( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/affiliates/links'; const payload: Payload = {}; @@ -54,30 +58,28 @@ export class Affiliates { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a shareable affiliate link for the current account. Every console user is automatically in the affiliates program. - * + * * * @param {string} params.linkId - Link 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. This ID is the shareable referral code. * @param {string} params.name - Link name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise} */ - createLink(params: { linkId: string, name?: string }): Promise; + createLink(params: { + linkId: string; + name?: string; + }): Promise; /** * Create a shareable affiliate link for the current account. Every console user is automatically in the affiliates program. - * + * * * @param {string} linkId - Link 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. This ID is the shareable referral code. * @param {string} name - Link name. Max length: 128 chars. @@ -87,27 +89,30 @@ export class Affiliates { */ createLink(linkId: string, name?: string): Promise; createLink( - paramsOrFirst: { linkId: string, name?: string } | string, - ...rest: [(string)?] + paramsOrFirst: { linkId: string; name?: string } | string, + ...rest: [string?] ): Promise { - let params: { linkId: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { linkId: string, name?: string }; + let params: { linkId: string; name?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { linkId: string; name?: string }; } else { params = { linkId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const linkId = params.linkId; const name = params.name; if (typeof linkId === 'undefined') { throw new AppwriteException('Missing required parameter: "linkId"'); } - const apiPath = '/affiliates/links'; const payload: Payload = {}; if (typeof linkId !== 'undefined') { @@ -121,20 +126,15 @@ export class Affiliates { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get a single affiliate link owned by the current account. - * + * * * @param {string} params.linkId - Link ID. * @throws {AppwriteException} @@ -143,7 +143,7 @@ export class Affiliates { getLink(params: { linkId: string }): Promise; /** * Get a single affiliate link owned by the current account. - * + * * * @param {string} linkId - Link ID. * @throws {AppwriteException} @@ -152,44 +152,45 @@ export class Affiliates { */ getLink(linkId: string): Promise; getLink( - paramsOrFirst: { linkId: string } | string + paramsOrFirst: { linkId: string } | string, ): Promise { let params: { linkId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { linkId: string }; } else { params = { - linkId: paramsOrFirst as string + linkId: paramsOrFirst as string, }; } - + const linkId = params.linkId; - if (typeof linkId === 'undefined') { + if (typeof linkId === 'undefined' || linkId === '') { throw new AppwriteException('Missing required parameter: "linkId"'); } - - const apiPath = '/affiliates/links/{linkId}'.replace('{linkId}', encodeURIComponent(String(linkId))); + const apiPath = '/affiliates/links/{linkId}'.replace( + '{linkId}', + encodeURIComponent(String(linkId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Delete an affiliate link owned by the current account. Existing referrals and rewards keep their stored link IDs for history. - * + * * * @param {string} params.linkId - Link ID. * @throws {AppwriteException} @@ -198,7 +199,7 @@ export class Affiliates { deleteLink(params: { linkId: string }): Promise<{}>; /** * Delete an affiliate link owned by the current account. Existing referrals and rewards keep their stored link IDs for history. - * + * * * @param {string} linkId - Link ID. * @throws {AppwriteException} @@ -206,55 +207,56 @@ export class Affiliates { * @deprecated Use the object parameter style method for a better developer experience. */ deleteLink(linkId: string): Promise<{}>; - deleteLink( - paramsOrFirst: { linkId: string } | string - ): Promise<{}> { + deleteLink(paramsOrFirst: { linkId: string } | string): Promise<{}> { let params: { linkId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { linkId: string }; } else { params = { - linkId: paramsOrFirst as string + linkId: paramsOrFirst as string, }; } - + const linkId = params.linkId; - if (typeof linkId === 'undefined') { + if (typeof linkId === 'undefined' || linkId === '') { throw new AppwriteException('Missing required parameter: "linkId"'); } - - const apiPath = '/affiliates/links/{linkId}'.replace('{linkId}', encodeURIComponent(String(linkId))); + const apiPath = '/affiliates/links/{linkId}'.replace( + '{linkId}', + encodeURIComponent(String(linkId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * List referrals attributed to the current account's affiliate links. Responses include privacy-safe metadata only (truncated user ID and signup country), never email or name. Referrals are created automatically on signup when the invite cookie is present. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referredUserMaskedId, referredUserCountry, status, attributedAt, expiresAt, convertedAt * @throws {AppwriteException} * @returns {Promise} */ - listReferrals(params?: { queries?: string[] }): Promise; + listReferrals(params?: { + queries?: string[]; + }): Promise; /** * List referrals attributed to the current account's affiliate links. Responses include privacy-safe metadata only (truncated user ID and signup country), never email or name. Referrals are created automatically on signup when the invite cookie is present. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referredUserMaskedId, referredUserCountry, status, attributedAt, expiresAt, convertedAt * @throws {AppwriteException} @@ -263,20 +265,24 @@ export class Affiliates { */ listReferrals(queries?: string[]): Promise; listReferrals( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/affiliates/referrals'; const payload: Payload = {}; @@ -287,29 +293,26 @@ export class Affiliates { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * List rewards earned by the current account from affiliate link conversions. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referralId, amount, status, teamId, creditId * @throws {AppwriteException} * @returns {Promise} */ - listRewards(params?: { queries?: string[] }): Promise; + listRewards(params?: { + queries?: string[]; + }): Promise; /** * List rewards earned by the current account from affiliate link conversions. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: linkId, referralId, amount, status, teamId, creditId * @throws {AppwriteException} @@ -318,20 +321,24 @@ export class Affiliates { */ listRewards(queries?: string[]): Promise; listRewards( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/affiliates/rewards'; const payload: Payload = {}; @@ -342,20 +349,15 @@ export class Affiliates { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Claim a pending affiliate reward by setting its status to `claimed`. Creates organization credits for the target organization. The current user must be an owner of that organization. - * + * * * @param {string} params.rewardId - Reward ID * @param {string} params.status - New reward status. Use `claimed` to claim the reward as organization credits. @@ -363,10 +365,14 @@ export class Affiliates { * @throws {AppwriteException} * @returns {Promise} */ - updateReward(params: { rewardId: string, status: string, organizationId: string }): Promise; + updateReward(params: { + rewardId: string; + status: string; + organizationId: string; + }): Promise; /** * Claim a pending affiliate reward by setting its status to `claimed`. Creates organization credits for the target organization. The current user must be an owner of that organization. - * + * * * @param {string} rewardId - Reward ID * @param {string} status - New reward status. Use `claimed` to claim the reward as organization credits. @@ -375,38 +381,62 @@ export class Affiliates { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateReward(rewardId: string, status: string, organizationId: string): Promise; updateReward( - paramsOrFirst: { rewardId: string, status: string, organizationId: string } | string, - ...rest: [(string)?, (string)?] + rewardId: string, + status: string, + organizationId: string, + ): Promise; + updateReward( + paramsOrFirst: + | { rewardId: string; status: string; organizationId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { rewardId: string, status: string, organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { rewardId: string, status: string, organizationId: string }; + let params: { + rewardId: string; + status: string; + organizationId: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + rewardId: string; + status: string; + organizationId: string; + }; } else { params = { rewardId: paramsOrFirst as string, status: rest[0] as string, - organizationId: rest[1] as string + organizationId: rest[1] as string, }; } - + const rewardId = params.rewardId; const status = params.status; const organizationId = params.organizationId; - if (typeof rewardId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rewardId"'); + if (typeof rewardId === 'undefined' || rewardId === '') { + throw new AppwriteException( + 'Missing required parameter: "rewardId"', + ); } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/affiliates/rewards/{rewardId}'.replace('{rewardId}', encodeURIComponent(String(rewardId))); + const apiPath = '/affiliates/rewards/{rewardId}'.replace( + '{rewardId}', + encodeURIComponent(String(rewardId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -419,14 +449,9 @@ export class Affiliates { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 945c12ab..27c3ec89 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Apps { client: Client; @@ -18,7 +16,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * List applications. * @@ -30,24 +31,31 @@ export class Apps { */ list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/apps'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -60,15 +68,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -96,7 +99,27 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }): Promise; + create(params: { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + }): Promise; /** * Create a new application. * @@ -123,15 +146,120 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string): Promise; create( - paramsOrFirst: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?, (string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?, (string)?] + appId: string, + name: string, + redirectUris: string[], + description?: string, + clientUri?: string, + logoUri?: string, + privacyPolicyUrl?: string, + termsUrl?: string, + contacts?: string[], + tagline?: string, + tags?: string[], + images?: string[], + supportUrl?: string, + dataDeletionUrl?: string, + postLogoutRedirectUris?: string[], + enabled?: boolean, + type?: string, + deviceFlow?: boolean, + teamId?: string, + ): Promise; + create( + paramsOrFirst: + | { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + } + | string, + ...rest: [ + string?, + string[]?, + string?, + string?, + string?, + string?, + string?, + string[]?, + string?, + string[]?, + string[]?, + string?, + string?, + string[]?, + boolean?, + string?, + boolean?, + string?, + ] ): Promise { - let params: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }; + let params: { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + }; } else { params = { appId: paramsOrFirst as string, @@ -152,10 +280,10 @@ export class Apps { enabled: rest[14] as boolean, type: rest[15] as string, deviceFlow: rest[16] as boolean, - teamId: rest[17] as string + teamId: rest[17] as string, }; } - + const appId = params.appId; const name = params.name; const redirectUris = params.redirectUris; @@ -183,9 +311,10 @@ export class Apps { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof redirectUris === 'undefined') { - throw new AppwriteException('Missing required parameter: "redirectUris"'); + throw new AppwriteException( + 'Missing required parameter: "redirectUris"', + ); } - const apiPath = '/apps'; const payload: Payload = {}; if (typeof appId !== 'undefined') { @@ -250,15 +379,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -268,22 +392,16 @@ export class Apps { * @returns {Promise} */ listInstallationScopes(): Promise { - const apiPath = '/apps/scopes/installations'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -293,28 +411,22 @@ export class Apps { * @returns {Promise} */ listOAuth2Scopes(): Promise { - const apiPath = '/apps/scopes/oauth2'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get an application by its unique ID. * - * @param {string} params.appId - Application unique ID or HTTPS client ID metadata document URL. + * @param {string} params.appId - Application unique ID. * @throws {AppwriteException} * @returns {Promise} */ @@ -322,46 +434,45 @@ export class Apps { /** * Get an application by its unique ID. * - * @param {string} appId - Application unique ID or HTTPS client ID metadata document URL. + * @param {string} appId - Application unique ID. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ get(appId: string): Promise; - get( - paramsOrFirst: { appId: string } | string - ): Promise { + get(paramsOrFirst: { appId: string } | string): Promise { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - + const appId = params.appId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -385,12 +496,33 @@ export class Apps { * @param {string[]} params.postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. * @param {string} params.type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. * @param {boolean} params.deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. - * @param {string[]} params.installationScopes - Scopes the application requests when installed on a team. Organization-level and project-level scopes only; use the list scopes endpoint with `type=installation` to discover available values. Maximum of 100 scopes are allowed. + * @param {string[]} params.installationScopes - Scopes the application requests when installed on a team. Only scopes allowed by the project's OAuth2 server installation scopes configuration are accepted; use the list installation scopes endpoint to discover available values. Maximum of 100 scopes are allowed. * @param {string} params.installationRedirectUrl - URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }): Promise; + update(params: { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + }): Promise; /** * Update an application by its unique ID. * @@ -412,21 +544,131 @@ export class Apps { * @param {string[]} postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. * @param {string} type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. * @param {boolean} deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. - * @param {string[]} installationScopes - Scopes the application requests when installed on a team. Organization-level and project-level scopes only; use the list scopes endpoint with `type=installation` to discover available values. Maximum of 100 scopes are allowed. + * @param {string[]} installationScopes - Scopes the application requests when installed on a team. Only scopes allowed by the project's OAuth2 server installation scopes configuration are accepted; use the list installation scopes endpoint to discover available values. Maximum of 100 scopes are allowed. * @param {string} installationRedirectUrl - URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string): Promise; update( - paramsOrFirst: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (string[])?, (string[])?, (string)?, (boolean)?, (string[])?, (string)?] + appId: string, + name: string, + description?: string, + clientUri?: string, + logoUri?: string, + privacyPolicyUrl?: string, + termsUrl?: string, + contacts?: string[], + tagline?: string, + tags?: string[], + images?: string[], + supportUrl?: string, + dataDeletionUrl?: string, + enabled?: boolean, + redirectUris?: string[], + postLogoutRedirectUris?: string[], + type?: string, + deviceFlow?: boolean, + installationScopes?: string[], + installationRedirectUrl?: string, + ): Promise; + update( + paramsOrFirst: + | { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string[]?, + string?, + string[]?, + string[]?, + string?, + string?, + boolean?, + string[]?, + string[]?, + string?, + boolean?, + string[]?, + string?, + ] ): Promise { - let params: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }; + let params: { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + }; } else { params = { appId: paramsOrFirst as string, @@ -448,10 +690,10 @@ export class Apps { type: rest[15] as string, deviceFlow: rest[16] as boolean, installationScopes: rest[17] as string[], - installationRedirectUrl: rest[18] as string + installationRedirectUrl: rest[18] as string, }; } - + const appId = params.appId; const name = params.name; const description = params.description; @@ -473,14 +715,16 @@ export class Apps { const installationScopes = params.installationScopes; const installationRedirectUrl = params.installationRedirectUrl; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -544,15 +788,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -572,41 +811,40 @@ export class Apps { * @deprecated Use the object parameter style method for a better developer experience. */ delete(appId: string): Promise<{}>; - delete( - paramsOrFirst: { appId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { appId: string } | string): Promise<{}> { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - + const appId = params.appId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -618,7 +856,11 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params: { appId: string, queries?: string[], total?: boolean }): Promise; + listInstallations(params: { + appId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List installations of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. * @@ -629,32 +871,47 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(appId: string, queries?: string[], total?: boolean): Promise; listInstallations( - paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + appId: string, + queries?: string[], + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst: + { appId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { appId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + let params: { appId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { appId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const appId = params.appId; const queries = params.queries; const total = params.total; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/installations'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/installations'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -666,15 +923,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -685,7 +937,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { appId: string, installationId: string }): Promise; + getInstallation(params: { + appId: string; + installationId: string; + }): Promise; /** * Get an installation of an application by its unique ID. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. * @@ -695,47 +950,58 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getInstallation(appId: string, installationId: string): Promise; getInstallation( - paramsOrFirst: { appId: string, installationId: string } | string, - ...rest: [(string)?] + appId: string, + installationId: string, + ): Promise; + getInstallation( + paramsOrFirst: { appId: string; installationId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + let params: { appId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + installationId: string; + }; } else { params = { appId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const appId = params.appId; const installationId = params.installationId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/apps/{appId}/installations/{installationId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/apps/{appId}/installations/{installationId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -746,7 +1012,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteInstallation(params: { appId: string, installationId: string }): Promise<{}>; + deleteInstallation(params: { + appId: string; + installationId: string; + }): Promise<{}>; /** * Delete an installation of an application by its unique ID. Requires a caller with update access to the app. Previously issued installation access tokens are revoked. * @@ -758,46 +1027,54 @@ export class Apps { */ deleteInstallation(appId: string, installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { appId: string, installationId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; installationId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { appId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + let params: { appId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + installationId: string; + }; } else { params = { appId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const appId = params.appId; const installationId = params.installationId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/apps/{appId}/installations/{installationId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/apps/{appId}/installations/{installationId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -808,7 +1085,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - createInstallationToken(params: { appId: string, installationId: string }): Promise; + createInstallationToken(params: { + appId: string; + installationId: string; + }): Promise; /** * Create a token for an installation of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. The returned token carries the scopes and authorization details granted to the installation, and can be used as an `Authorization: Bearer` header everywhere OAuth2 access tokens are accepted. Multiple tokens can be active for the same installation at once; each token stays valid until it expires or the installation is updated or deleted. * @@ -818,48 +1098,59 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInstallationToken(appId: string, installationId: string): Promise; createInstallationToken( - paramsOrFirst: { appId: string, installationId: string } | string, - ...rest: [(string)?] + appId: string, + installationId: string, + ): Promise; + createInstallationToken( + paramsOrFirst: { appId: string; installationId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + let params: { appId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + installationId: string; + }; } else { params = { appId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const appId = params.appId; const installationId = params.installationId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/apps/{appId}/installations/{installationId}/tokens'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/apps/{appId}/installations/{installationId}/tokens' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -871,7 +1162,11 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - listKeys(params: { appId: string, queries?: string[], total?: boolean }): Promise; + listKeys(params: { + appId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List app keys for an application. * @@ -882,32 +1177,47 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listKeys(appId: string, queries?: string[], total?: boolean): Promise; listKeys( - paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + appId: string, + queries?: string[], + total?: boolean, + ): Promise; + listKeys( + paramsOrFirst: + { appId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { appId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + let params: { appId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { appId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const appId = params.appId; const queries = params.queries; const total = params.total; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/keys'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/keys'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -919,15 +1229,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -948,40 +1253,41 @@ export class Apps { */ createKey(appId: string): Promise; createKey( - paramsOrFirst: { appId: string } | string + paramsOrFirst: { appId: string } | string, ): Promise { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - + const appId = params.appId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/keys'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/keys'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -992,7 +1298,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - getKey(params: { appId: string, keyId: string }): Promise; + getKey(params: { appId: string; keyId: string }): Promise; /** * Get an app key by its unique ID. * @@ -1004,45 +1310,45 @@ export class Apps { */ getKey(appId: string, keyId: string): Promise; getKey( - paramsOrFirst: { appId: string, keyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; keyId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, keyId: string }; + let params: { appId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { appId: string; keyId: string }; } else { params = { appId: paramsOrFirst as string, - keyId: rest[0] as string + keyId: rest[0] as string, }; } - + const appId = params.appId; const keyId = params.keyId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/apps/{appId}/keys/{keyId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/apps/{appId}/keys/{keyId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1053,7 +1359,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteKey(params: { appId: string, keyId: string }): Promise<{}>; + deleteKey(params: { appId: string; keyId: string }): Promise<{}>; /** * Delete an app key by its unique ID. * @@ -1065,93 +1371,105 @@ export class Apps { */ deleteKey(appId: string, keyId: string): Promise<{}>; deleteKey( - paramsOrFirst: { appId: string, keyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; keyId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { appId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, keyId: string }; + let params: { appId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { appId: string; keyId: string }; } else { params = { appId: paramsOrFirst as string, - keyId: rest[0] as string + keyId: rest[0] as string, }; } - + const appId = params.appId; const keyId = params.keyId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/apps/{appId}/keys/{keyId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/apps/{appId}/keys/{keyId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Update the labels of an application. Labels are read-only for clients; only a server SDK using a project API key can set them. Replaces the previous labels. * * @param {string} params.appId - Application unique ID. - * @param {string[]} params.labels - Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @param {string[]} params.labels - Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. * @throws {AppwriteException} * @returns {Promise} */ - updateLabels(params: { appId: string, labels: string[] }): Promise; + updateLabels(params: { + appId: string; + labels: string[]; + }): Promise; /** * Update the labels of an application. Labels are read-only for clients; only a server SDK using a project API key can set them. Replaces the previous labels. * * @param {string} appId - Application unique ID. - * @param {string[]} labels - Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @param {string[]} labels - Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ updateLabels(appId: string, labels: string[]): Promise; updateLabels( - paramsOrFirst: { appId: string, labels: string[] } | string, - ...rest: [(string[])?] + paramsOrFirst: { appId: string; labels: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { appId: string, labels: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, labels: string[] }; + let params: { appId: string; labels: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + labels: string[]; + }; } else { params = { appId: paramsOrFirst as string, - labels: rest[0] as string[] + labels: rest[0] as string[], }; } - + const appId = params.appId; const labels = params.labels; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } - - const apiPath = '/apps/{appId}/labels'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/labels'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; if (typeof labels !== 'undefined') { payload['labels'] = labels; @@ -1161,15 +1479,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1181,7 +1494,11 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - listSecrets(params: { appId: string, queries?: string[], total?: boolean }): Promise; + listSecrets(params: { + appId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List client secrets for an application. * @@ -1192,32 +1509,47 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSecrets(appId: string, queries?: string[], total?: boolean): Promise; listSecrets( - paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + appId: string, + queries?: string[], + total?: boolean, + ): Promise; + listSecrets( + paramsOrFirst: + { appId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { appId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + let params: { appId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { appId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const appId = params.appId; const queries = params.queries; const total = params.total; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/secrets'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/secrets'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1229,15 +1561,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1258,40 +1585,41 @@ export class Apps { */ createSecret(appId: string): Promise; createSecret( - paramsOrFirst: { appId: string } | string + paramsOrFirst: { appId: string } | string, ): Promise { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - + const appId = params.appId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/secrets'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/secrets'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1302,7 +1630,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - getSecret(params: { appId: string, secretId: string }): Promise; + getSecret(params: { + appId: string; + secretId: string; + }): Promise; /** * Get an application client secret by its unique ID. * @@ -1314,45 +1645,50 @@ export class Apps { */ getSecret(appId: string, secretId: string): Promise; getSecret( - paramsOrFirst: { appId: string, secretId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; secretId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, secretId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, secretId: string }; + let params: { appId: string; secretId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + secretId: string; + }; } else { params = { appId: paramsOrFirst as string, - secretId: rest[0] as string + secretId: rest[0] as string, }; } - + const appId = params.appId; const secretId = params.secretId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof secretId === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretId"'); + if (typeof secretId === 'undefined' || secretId === '') { + throw new AppwriteException( + 'Missing required parameter: "secretId"', + ); } - - const apiPath = '/apps/{appId}/secrets/{secretId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{secretId}', encodeURIComponent(String(secretId))); + const apiPath = '/apps/{appId}/secrets/{secretId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace('{secretId}', encodeURIComponent(String(secretId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1363,7 +1699,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSecret(params: { appId: string, secretId: string }): Promise<{}>; + deleteSecret(params: { appId: string; secretId: string }): Promise<{}>; /** * Delete an application client secret by its unique ID. * @@ -1375,46 +1711,51 @@ export class Apps { */ deleteSecret(appId: string, secretId: string): Promise<{}>; deleteSecret( - paramsOrFirst: { appId: string, secretId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; secretId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { appId: string, secretId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, secretId: string }; + let params: { appId: string; secretId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + secretId: string; + }; } else { params = { appId: paramsOrFirst as string, - secretId: rest[0] as string + secretId: rest[0] as string, }; } - + const appId = params.appId; const secretId = params.secretId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - if (typeof secretId === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretId"'); + if (typeof secretId === 'undefined' || secretId === '') { + throw new AppwriteException( + 'Missing required parameter: "secretId"', + ); } - - const apiPath = '/apps/{appId}/secrets/{secretId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{secretId}', encodeURIComponent(String(secretId))); + const apiPath = '/apps/{appId}/secrets/{secretId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace('{secretId}', encodeURIComponent(String(secretId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1425,7 +1766,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - updateTeam(params: { appId: string, teamId: string }): Promise; + updateTeam(params: { appId: string; teamId: string }): Promise; /** * Transfer an application to another team by its unique ID. * @@ -1437,31 +1778,37 @@ export class Apps { */ updateTeam(appId: string, teamId: string): Promise; updateTeam( - paramsOrFirst: { appId: string, teamId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; teamId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, teamId: string }; + let params: { appId: string; teamId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { appId: string; teamId: string }; } else { params = { appId: paramsOrFirst as string, - teamId: rest[0] as string + teamId: rest[0] as string, }; } - + const appId = params.appId; const teamId = params.teamId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/apps/{appId}/team'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/team'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; if (typeof teamId !== 'undefined') { payload['teamId'] = teamId; @@ -1471,15 +1818,10 @@ export class Apps { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1499,40 +1841,39 @@ export class Apps { * @deprecated Use the object parameter style method for a better developer experience. */ deleteTokens(appId: string): Promise<{}>; - deleteTokens( - paramsOrFirst: { appId: string } | string - ): Promise<{}> { + deleteTokens(paramsOrFirst: { appId: string } | string): Promise<{}> { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - + const appId = params.appId; - if (typeof appId === 'undefined') { + if (typeof appId === 'undefined' || appId === '') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/tokens'.replace('{appId}', encodeURIComponent(String(appId))); + const apiPath = '/apps/{appId}/tokens'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/assistant.ts b/src/services/assistant.ts index a8b12ee3..cae5471b 100644 --- a/src/services/assistant.ts +++ b/src/services/assistant.ts @@ -1,7 +1,4 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - +import { AppwriteException, Client, type Payload } from '../client'; export class Assistant { client: Client; @@ -11,7 +8,7 @@ export class Assistant { } /** - * Send a prompt to the AI assistant and receive a response. This endpoint allows you to interact with Appwrite's AI assistant by sending questions or prompts and receiving helpful responses in real-time through a server-sent events stream. + * Send a prompt to the AI assistant and receive a response. This endpoint allows you to interact with Appwrite's AI assistant by sending questions or prompts and receiving helpful responses in real-time through a server-sent events stream. * * @param {string} params.prompt - Prompt. A string containing questions asked to the AI assistant. * @throws {AppwriteException} @@ -19,7 +16,7 @@ export class Assistant { */ chat(params: { prompt: string }): Promise<{}>; /** - * Send a prompt to the AI assistant and receive a response. This endpoint allows you to interact with Appwrite's AI assistant by sending questions or prompts and receiving helpful responses in real-time through a server-sent events stream. + * Send a prompt to the AI assistant and receive a response. This endpoint allows you to interact with Appwrite's AI assistant by sending questions or prompts and receiving helpful responses in real-time through a server-sent events stream. * * @param {string} prompt - Prompt. A string containing questions asked to the AI assistant. * @throws {AppwriteException} @@ -27,25 +24,26 @@ export class Assistant { * @deprecated Use the object parameter style method for a better developer experience. */ chat(prompt: string): Promise<{}>; - chat( - paramsOrFirst: { prompt: string } | string - ): Promise<{}> { + chat(paramsOrFirst: { prompt: string } | string): Promise<{}> { let params: { prompt: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { prompt: string }; } else { params = { - prompt: paramsOrFirst as string + prompt: paramsOrFirst as string, }; } - + const prompt = params.prompt; if (typeof prompt === 'undefined') { throw new AppwriteException('Missing required parameter: "prompt"'); } - const apiPath = '/console/assistant'; const payload: Payload = {}; if (typeof prompt !== 'undefined') { @@ -56,14 +54,9 @@ export class Assistant { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'text/plain', - } + accept: 'text/plain', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 151d1123..2ad22d6c 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,6 +1,5 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; +import { AppwriteException, Client, type Payload } from '../client'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; @@ -9,7 +8,6 @@ import { BrowserTheme } from '../enums/browser-theme'; import { Timezone } from '../enums/timezone'; import { BrowserPermission } from '../enums/browser-permission'; import { ImageFormat } from '../enums/image-format'; - export class Avatars { client: Client; @@ -19,7 +17,7 @@ export class Avatars { /** * You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param {Browser} params.code - Browser Code. @@ -29,10 +27,15 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getBrowser(params: { code: Browser, width?: number, height?: number, quality?: number }): string; + getBrowser(params: { + code: Browser; + width?: number; + height?: number; + quality?: number; + }): string; /** * You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param {Browser} code - Browser Code. @@ -43,24 +46,54 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getBrowser(code: Browser, width?: number, height?: number, quality?: number): string; getBrowser( - paramsOrFirst: { code: Browser, width?: number, height?: number, quality?: number } | Browser, - ...rest: [(number)?, (number)?, (number)?] + code: Browser, + width?: number, + height?: number, + quality?: number, + ): string; + getBrowser( + paramsOrFirst: + | { + code: Browser; + width?: number; + height?: number; + quality?: number; + } + | Browser, + ...rest: [number?, number?, number?] ): string { - let params: { code: Browser, width?: number, height?: number, quality?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { code: Browser, width?: number, height?: number, quality?: number }; + let params: { + code: Browser; + width?: number; + height?: number; + quality?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('code' in paramsOrFirst || + 'width' in paramsOrFirst || + 'height' in paramsOrFirst || + 'quality' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + code: Browser; + width?: number; + height?: number; + quality?: number; + }; } else { params = { code: paramsOrFirst as Browser, width: rest[0] as number, height: rest[1] as number, - quality: rest[2] as number + quality: rest[2] as number, }; } - + const code = params.code; const width = params.width; const height = params.height; @@ -69,8 +102,10 @@ export class Avatars { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/avatars/browsers/{code}'.replace('{code}', encodeURIComponent(String(code))); + const apiPath = '/avatars/browsers/{code}'.replace( + '{code}', + encodeURIComponent(String(code)), + ); const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; @@ -83,26 +118,20 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {CreditCard} params.code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay. * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -111,12 +140,17 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getCreditCard(params: { code: CreditCard, width?: number, height?: number, quality?: number }): string; + getCreditCard(params: { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + }): string; /** * The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {CreditCard} code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay. * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -126,24 +160,54 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): string; getCreditCard( - paramsOrFirst: { code: CreditCard, width?: number, height?: number, quality?: number } | CreditCard, - ...rest: [(number)?, (number)?, (number)?] + code: CreditCard, + width?: number, + height?: number, + quality?: number, + ): string; + getCreditCard( + paramsOrFirst: + | { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + } + | CreditCard, + ...rest: [number?, number?, number?] ): string { - let params: { code: CreditCard, width?: number, height?: number, quality?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { code: CreditCard, width?: number, height?: number, quality?: number }; + let params: { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('code' in paramsOrFirst || + 'width' in paramsOrFirst || + 'height' in paramsOrFirst || + 'quality' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + }; } else { params = { code: paramsOrFirst as CreditCard, width: rest[0] as number, height: rest[1] as number, - quality: rest[2] as number + quality: rest[2] as number, }; } - + const code = params.code; const width = params.width; const height = params.height; @@ -152,8 +216,10 @@ export class Avatars { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', encodeURIComponent(String(code))); + const apiPath = '/avatars/credit-cards/{code}'.replace( + '{code}', + encodeURIComponent(String(code)), + ); const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; @@ -166,24 +232,18 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} params.url - Website URL which you want to fetch the favicon from. @@ -193,7 +253,7 @@ export class Avatars { getFavicon(params: { url: string }): string; /** * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} url - Website URL which you want to fetch the favicon from. @@ -202,25 +262,26 @@ export class Avatars { * @deprecated Use the object parameter style method for a better developer experience. */ getFavicon(url: string): string; - getFavicon( - paramsOrFirst: { url: string } | string - ): string { + getFavicon(paramsOrFirst: { url: string } | string): string { let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { url: string }; } else { params = { - url: paramsOrFirst as string + url: paramsOrFirst as string, }; } - + const url = params.url; if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/avatars/favicon'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -228,26 +289,20 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {Flag} params.code - Country Code. ISO Alpha-2 country code format. * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -256,12 +311,17 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getFlag(params: { code: Flag, width?: number, height?: number, quality?: number }): string; + getFlag(params: { + code: Flag; + width?: number; + height?: number; + quality?: number; + }): string; /** * You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {Flag} code - Country Code. ISO Alpha-2 country code format. * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -271,24 +331,49 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getFlag(code: Flag, width?: number, height?: number, quality?: number): string; getFlag( - paramsOrFirst: { code: Flag, width?: number, height?: number, quality?: number } | Flag, - ...rest: [(number)?, (number)?, (number)?] + code: Flag, + width?: number, + height?: number, + quality?: number, + ): string; + getFlag( + paramsOrFirst: + | { code: Flag; width?: number; height?: number; quality?: number } + | Flag, + ...rest: [number?, number?, number?] ): string { - let params: { code: Flag, width?: number, height?: number, quality?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { code: Flag, width?: number, height?: number, quality?: number }; + let params: { + code: Flag; + width?: number; + height?: number; + quality?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('code' in paramsOrFirst || + 'width' in paramsOrFirst || + 'height' in paramsOrFirst || + 'quality' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + code: Flag; + width?: number; + height?: number; + quality?: number; + }; } else { params = { code: paramsOrFirst as Flag, width: rest[0] as number, height: rest[1] as number, - quality: rest[2] as number + quality: rest[2] as number, }; } - + const code = params.code; const width = params.width; const height = params.height; @@ -297,8 +382,10 @@ export class Avatars { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/avatars/flags/{code}'.replace('{code}', encodeURIComponent(String(code))); + const apiPath = '/avatars/flags/{code}'.replace( + '{code}', + encodeURIComponent(String(code)), + ); const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; @@ -311,26 +398,20 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} params.url - Image URL which you want to crop. @@ -339,12 +420,12 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getImage(params: { url: string, width?: number, height?: number }): string; + getImage(params: { url: string; width?: number; height?: number }): string; /** * Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} url - Image URL which you want to crop. @@ -356,21 +437,30 @@ export class Avatars { */ getImage(url: string, width?: number, height?: number): string; getImage( - paramsOrFirst: { url: string, width?: number, height?: number } | string, - ...rest: [(number)?, (number)?] + paramsOrFirst: + { url: string; width?: number; height?: number } | string, + ...rest: [number?, number?] ): string { - let params: { url: string, width?: number, height?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, width?: number, height?: number }; + let params: { url: string; width?: number; height?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + url: string; + width?: number; + height?: number; + }; } else { params = { url: paramsOrFirst as string, width: rest[0] as number, - height: rest[1] as number + height: rest[1] as number, }; } - + const url = params.url; const width = params.width; const height = params.height; @@ -378,7 +468,6 @@ export class Avatars { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/avatars/image'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -392,28 +481,22 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. - * + * * You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {string} params.name - Full Name. When empty, current user name or email will be used. Max length: 128 chars. * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -422,14 +505,19 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getInitials(params?: { name?: string, width?: number, height?: number, background?: string }): string; + getInitials(params?: { + name?: string; + width?: number; + height?: number; + background?: string; + }): string; /** * Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. - * + * * You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {string} name - Full Name. When empty, current user name or email will be used. Max length: 128 chars. * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -439,30 +527,56 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getInitials(name?: string, width?: number, height?: number, background?: string): string; getInitials( - paramsOrFirst?: { name?: string, width?: number, height?: number, background?: string } | string, - ...rest: [(number)?, (number)?, (string)?] + name?: string, + width?: number, + height?: number, + background?: string, + ): string; + getInitials( + paramsOrFirst?: + | { + name?: string; + width?: number; + height?: number; + background?: string; + } + | string, + ...rest: [number?, number?, string?] ): string { - let params: { name?: string, width?: number, height?: number, background?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { name?: string, width?: number, height?: number, background?: string }; + let params: { + name?: string; + width?: number; + height?: number; + background?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + name?: string; + width?: number; + height?: number; + background?: string; + }; } else { params = { name: paramsOrFirst as string, width: rest[0] as number, height: rest[1] as number, - background: rest[2] as string + background: rest[2] as string, }; } - + const name = params.name; const width = params.width; const height = params.height; const background = params.background; - const apiPath = '/avatars/initials'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -479,24 +593,172 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', + payload['project'] = this.client.config.project; + + for (const [key, value] of Object.entries(Service.flatten(payload))) { + uri.searchParams.append(key, value); + } + + return uri.toString(); + } + + /** + * Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. + * + * Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. + * + * @param {number} params.width - Output image width in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} params.height - Output image height in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} params.quality - Output image quality between 0 and 100. Defaults to 100. + * @param {string} params.output - Output image format. Defaults to 'png'. + * @param {string} params.rating - Maximum image rating to fetch from Gravatar/Libravatar. Defaults to 'g'. + * @param {string} params.userId - User ID to resolve the photo for. Pass 'current()' for the currently authenticated user. When omitted, the session user is used only if no emailHash and no name is passed. + * @param {string} params.emailHash - SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own email. Pass the hash, never the address itself. + * @param {string} params.name - Name to render initials from instead of the user's own name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {string} + */ + getPhoto(params?: { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + }): string; + /** + * Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. + * + * Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. + * + * @param {number} width - Output image width in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} height - Output image height in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} quality - Output image quality between 0 and 100. Defaults to 100. + * @param {string} output - Output image format. Defaults to 'png'. + * @param {string} rating - Maximum image rating to fetch from Gravatar/Libravatar. Defaults to 'g'. + * @param {string} userId - User ID to resolve the photo for. Pass 'current()' for the currently authenticated user. When omitted, the session user is used only if no emailHash and no name is passed. + * @param {string} emailHash - SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own email. Pass the hash, never the address itself. + * @param {string} name - Name to render initials from instead of the user's own name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {string} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPhoto( + width?: number, + height?: number, + quality?: number, + output?: string, + rating?: string, + userId?: string, + emailHash?: string, + name?: string, + ): string; + getPhoto( + paramsOrFirst?: + | { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + } + | number, + ...rest: [number?, number?, string?, string?, string?, string?, string?] + ): string { + let params: { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + }; + } else { + params = { + width: paramsOrFirst as number, + height: rest[0] as number, + quality: rest[1] as number, + output: rest[2] as string, + rating: rest[3] as string, + userId: rest[4] as string, + emailHash: rest[5] as string, + name: rest[6] as string, + }; } + const width = params.width; + const height = params.height; + const quality = params.quality; + const output = params.output; + const rating = params.rating; + const userId = params.userId; + const emailHash = params.emailHash; + const name = params.name; + + const apiPath = '/avatars/photo'; + const payload: Payload = {}; + if (typeof width !== 'undefined') { + payload['width'] = width; + } + if (typeof height !== 'undefined') { + payload['height'] = height; + } + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + if (typeof output !== 'undefined') { + payload['output'] = output; + } + if (typeof rating !== 'undefined') { + payload['rating'] = rating; + } + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof emailHash !== 'undefined') { + payload['emailHash'] = emailHash; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. - * + * * * @param {string} params.text - Plain text to be converted to QR code image. * @param {number} params.size - QR code size. Pass an integer between 1 to 1000. Defaults to 400. @@ -505,10 +767,15 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getQR(params: { text: string, size?: number, margin?: number, download?: boolean }): string; + getQR(params: { + text: string; + size?: number; + margin?: number; + download?: boolean; + }): string; /** * Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. - * + * * * @param {string} text - Plain text to be converted to QR code image. * @param {number} size - QR code size. Pass an integer between 1 to 1000. Defaults to 400. @@ -518,24 +785,50 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getQR(text: string, size?: number, margin?: number, download?: boolean): string; getQR( - paramsOrFirst: { text: string, size?: number, margin?: number, download?: boolean } | string, - ...rest: [(number)?, (number)?, (boolean)?] + text: string, + size?: number, + margin?: number, + download?: boolean, + ): string; + getQR( + paramsOrFirst: + | { + text: string; + size?: number; + margin?: number; + download?: boolean; + } + | string, + ...rest: [number?, number?, boolean?] ): string { - let params: { text: string, size?: number, margin?: number, download?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { text: string, size?: number, margin?: number, download?: boolean }; + let params: { + text: string; + size?: number; + margin?: number; + download?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + text: string; + size?: number; + margin?: number; + download?: boolean; + }; } else { params = { text: paramsOrFirst as string, size: rest[0] as number, margin: rest[1] as number, - download: rest[2] as boolean + download: rest[2] as boolean, }; } - + const text = params.text; const size = params.size; const margin = params.margin; @@ -544,7 +837,6 @@ export class Avatars { if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); } - const apiPath = '/avatars/qr'; const payload: Payload = {}; if (typeof text !== 'undefined') { @@ -561,26 +853,20 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. - * + * * You can configure the browser viewport size, theme, user agent, geolocation, permissions, and more. Capture either just the viewport or the full page scroll. - * + * * When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px. * * @param {string} params.url - Website URL which you want to capture. @@ -606,12 +892,33 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): string; + getScreenshot(params: { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + }): string; /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. - * + * * You can configure the browser viewport size, theme, user agent, geolocation, permissions, and more. Capture either just the viewport or the full page scroll. - * + * * When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px. * * @param {string} url - Website URL which you want to capture. @@ -638,15 +945,125 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): string; getScreenshot( - paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, - ...rest: [(object)?, (number)?, (number)?, (number)?, (BrowserTheme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] + url: string, + headers?: object, + viewportWidth?: number, + viewportHeight?: number, + scale?: number, + theme?: BrowserTheme, + userAgent?: string, + fullpage?: boolean, + locale?: string, + timezone?: Timezone, + latitude?: number, + longitude?: number, + accuracy?: number, + touch?: boolean, + permissions?: BrowserPermission[], + sleep?: number, + width?: number, + height?: number, + quality?: number, + output?: ImageFormat, + ): string; + getScreenshot( + paramsOrFirst: + | { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + } + | string, + ...rest: [ + object?, + number?, + number?, + number?, + BrowserTheme?, + string?, + boolean?, + string?, + Timezone?, + number?, + number?, + number?, + boolean?, + BrowserPermission[]?, + number?, + number?, + number?, + number?, + ImageFormat?, + ] ): string { - let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; + let params: { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + }; } else { params = { url: paramsOrFirst as string, @@ -668,10 +1085,10 @@ export class Avatars { width: rest[15] as number, height: rest[16] as number, quality: rest[17] as number, - output: rest[18] as ImageFormat + output: rest[18] as ImageFormat, }; } - + const url = params.url; const headers = params.headers; const viewportWidth = params.viewportWidth; @@ -696,7 +1113,6 @@ export class Avatars { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/avatars/screenshots'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -761,18 +1177,12 @@ export class Avatars { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } } diff --git a/src/services/backups.ts b/src/services/backups.ts index d18c2139..cb904cfa 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,9 +1,7 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; - export class Backups { client: Client; @@ -18,7 +16,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - listArchives(params?: { queries?: string[] }): Promise; + listArchives(params?: { + queries?: string[]; + }): Promise; /** * List all archives for a project. * @@ -29,20 +29,24 @@ export class Backups { */ listArchives(queries?: string[]): Promise; listArchives( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/backups/archives'; const payload: Payload = {}; @@ -53,15 +57,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -72,7 +71,10 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - createArchive(params: { services: BackupServices[], resourceId?: string }): Promise; + createArchive(params: { + services: BackupServices[]; + resourceId?: string; + }): Promise; /** * Create a new archive asynchronously for a project. * @@ -82,29 +84,43 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createArchive(services: BackupServices[], resourceId?: string): Promise; createArchive( - paramsOrFirst: { services: BackupServices[], resourceId?: string } | BackupServices[], - ...rest: [(string)?] + services: BackupServices[], + resourceId?: string, + ): Promise; + createArchive( + paramsOrFirst: + | { services: BackupServices[]; resourceId?: string } + | BackupServices[], + ...rest: [string?] ): Promise { - let params: { services: BackupServices[], resourceId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('services' in paramsOrFirst || 'resourceId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { services: BackupServices[], resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('services' in paramsOrFirst || 'resourceId' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + services: BackupServices[]; + resourceId?: string; + }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string + resourceId: rest[0] as string, }; } - + const services = params.services; const resourceId = params.resourceId; if (typeof services === 'undefined') { - throw new AppwriteException('Missing required parameter: "services"'); + throw new AppwriteException( + 'Missing required parameter: "services"', + ); } - const apiPath = '/backups/archives'; const payload: Payload = {}; if (typeof services !== 'undefined') { @@ -118,15 +134,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -147,39 +158,42 @@ export class Backups { */ getArchive(archiveId: string): Promise; getArchive( - paramsOrFirst: { archiveId: string } | string + paramsOrFirst: { archiveId: string } | string, ): Promise { let params: { archiveId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { archiveId: string }; } else { params = { - archiveId: paramsOrFirst as string + archiveId: paramsOrFirst as string, }; } - + const archiveId = params.archiveId; - if (typeof archiveId === 'undefined') { - throw new AppwriteException('Missing required parameter: "archiveId"'); + if (typeof archiveId === 'undefined' || archiveId === '') { + throw new AppwriteException( + 'Missing required parameter: "archiveId"', + ); } - - const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', encodeURIComponent(String(archiveId))); + const apiPath = '/backups/archives/{archiveId}'.replace( + '{archiveId}', + encodeURIComponent(String(archiveId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -199,41 +213,42 @@ export class Backups { * @deprecated Use the object parameter style method for a better developer experience. */ deleteArchive(archiveId: string): Promise<{}>; - deleteArchive( - paramsOrFirst: { archiveId: string } | string - ): Promise<{}> { + deleteArchive(paramsOrFirst: { archiveId: string } | string): Promise<{}> { let params: { archiveId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { archiveId: string }; } else { params = { - archiveId: paramsOrFirst as string + archiveId: paramsOrFirst as string, }; } - + const archiveId = params.archiveId; - if (typeof archiveId === 'undefined') { - throw new AppwriteException('Missing required parameter: "archiveId"'); + if (typeof archiveId === 'undefined' || archiveId === '') { + throw new AppwriteException( + 'Missing required parameter: "archiveId"', + ); } - - const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', encodeURIComponent(String(archiveId))); + const apiPath = '/backups/archives/{archiveId}'.replace( + '{archiveId}', + encodeURIComponent(String(archiveId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -243,7 +258,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - listPolicies(params?: { queries?: string[] }): Promise; + listPolicies(params?: { + queries?: string[]; + }): Promise; /** * List all policies for a project. * @@ -254,20 +271,24 @@ export class Backups { */ listPolicies(queries?: string[]): Promise; listPolicies( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/backups/policies'; const payload: Payload = {}; @@ -278,15 +299,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -302,7 +318,15 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - createPolicy(params: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }): Promise; + createPolicy(params: { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + }): Promise; /** * Create a new backup policy. * @@ -317,15 +341,60 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPolicy(policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean): Promise; createPolicy( - paramsOrFirst: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean } | string, - ...rest: [(BackupServices[])?, (number)?, (string)?, (string)?, (string)?, (boolean)?] + policyId: string, + services: BackupServices[], + retention: number, + schedule: string, + name?: string, + resourceId?: string, + enabled?: boolean, + ): Promise; + createPolicy( + paramsOrFirst: + | { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + } + | string, + ...rest: [ + BackupServices[]?, + number?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; + let params: { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + }; } else { params = { policyId: paramsOrFirst as string, @@ -334,10 +403,10 @@ export class Backups { schedule: rest[2] as string, name: rest[3] as string, resourceId: rest[4] as string, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const policyId = params.policyId; const services = params.services; const retention = params.retention; @@ -347,18 +416,25 @@ export class Backups { const enabled = params.enabled; if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } if (typeof services === 'undefined') { - throw new AppwriteException('Missing required parameter: "services"'); + throw new AppwriteException( + 'Missing required parameter: "services"', + ); } if (typeof retention === 'undefined') { - throw new AppwriteException('Missing required parameter: "retention"'); + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); } if (typeof schedule === 'undefined') { - throw new AppwriteException('Missing required parameter: "schedule"'); + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); } - const apiPath = '/backups/policies'; const payload: Payload = {}; if (typeof policyId !== 'undefined') { @@ -387,15 +463,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -416,39 +487,42 @@ export class Backups { */ getPolicy(policyId: string): Promise; getPolicy( - paramsOrFirst: { policyId: string } | string + paramsOrFirst: { policyId: string } | string, ): Promise { let params: { policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { policyId: string }; } else { params = { - policyId: paramsOrFirst as string + policyId: paramsOrFirst as string, }; } - + const policyId = params.policyId; - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/backups/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -462,7 +536,13 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - updatePolicy(params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }): Promise; + updatePolicy(params: { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + }): Promise; /** * Update an existing policy using it's ID. * @@ -475,36 +555,70 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePolicy(policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean): Promise; updatePolicy( - paramsOrFirst: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean } | string, - ...rest: [(string)?, (number)?, (string)?, (boolean)?] + policyId: string, + name?: string, + retention?: number, + schedule?: string, + enabled?: boolean, + ): Promise; + updatePolicy( + paramsOrFirst: + | { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, number?, string?, boolean?] ): Promise { - let params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; + let params: { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + }; } else { params = { policyId: paramsOrFirst as string, name: rest[0] as string, retention: rest[1] as number, schedule: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const policyId = params.policyId; const name = params.name; const retention = params.retention; const schedule = params.schedule; const enabled = params.enabled; - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/backups/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -523,15 +637,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -551,54 +660,55 @@ export class Backups { * @deprecated Use the object parameter style method for a better developer experience. */ deletePolicy(policyId: string): Promise<{}>; - deletePolicy( - paramsOrFirst: { policyId: string } | string - ): Promise<{}> { + deletePolicy(paramsOrFirst: { policyId: string } | string): Promise<{}> { let params: { policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { policyId: string }; } else { params = { - policyId: paramsOrFirst as string + policyId: paramsOrFirst as string, }; } - + const policyId = params.policyId; - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/backups/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Create and trigger a new restoration for a backup on a project. - * + * * For a backup of one database, the restoration resolves its destination before it is queued. When `newResourceId` is omitted, the archived database is restored in place and its own ID is returned in `options`. Pass a different `newResourceId` to restore alongside it as a new database instead. - * + * * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. - * + * * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. - * + * * When restoring a DocumentsDB or VectorsDB database from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification and lands the data there. An in-place restore swaps the database onto that backing only once the restore has succeeded, and retires the backing it displaced only once that swap is confirmed, so the source keeps serving its own data until the restored data is in place and any failure leaves it untouched. A serverless source has no dedicated backing to clone and restores onto the archived database instead. - * + * * * @param {string} params.archiveId - Backup archive ID to restore * @param {BackupServices[]} params.services - Array of services to restore @@ -607,18 +717,23 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - createRestoration(params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }): Promise; + createRestoration(params: { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + }): Promise; /** * Create and trigger a new restoration for a backup on a project. - * + * * For a backup of one database, the restoration resolves its destination before it is queued. When `newResourceId` is omitted, the archived database is restored in place and its own ID is returned in `options`. Pass a different `newResourceId` to restore alongside it as a new database instead. - * + * * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. - * + * * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. - * + * * When restoring a DocumentsDB or VectorsDB database from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification and lands the data there. An in-place restore swaps the database onto that backing only once the restore has succeeded, and retires the backing it displaced only once that swap is confirmed, so the source keeps serving its own data until the restored data is in place and any failure leaves it untouched. A serverless source has no dedicated backing to clone and restores onto the archived database instead. - * + * * * @param {string} archiveId - Backup archive ID to restore * @param {BackupServices[]} services - Array of services to restore @@ -628,36 +743,65 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRestoration(archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string): Promise; createRestoration( - paramsOrFirst: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string } | string, - ...rest: [(BackupServices[])?, (string)?, (string)?] + archiveId: string, + services: BackupServices[], + newResourceId?: string, + newResourceName?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + } + | string, + ...rest: [BackupServices[]?, string?, string?] ): Promise { - let params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; + let params: { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + }; } else { params = { archiveId: paramsOrFirst as string, services: rest[0] as BackupServices[], newResourceId: rest[1] as string, - newResourceName: rest[2] as string + newResourceName: rest[2] as string, }; } - + const archiveId = params.archiveId; const services = params.services; const newResourceId = params.newResourceId; const newResourceName = params.newResourceName; if (typeof archiveId === 'undefined') { - throw new AppwriteException('Missing required parameter: "archiveId"'); + throw new AppwriteException( + 'Missing required parameter: "archiveId"', + ); } if (typeof services === 'undefined') { - throw new AppwriteException('Missing required parameter: "services"'); + throw new AppwriteException( + 'Missing required parameter: "services"', + ); } - const apiPath = '/backups/restoration'; const payload: Payload = {}; if (typeof archiveId !== 'undefined') { @@ -677,15 +821,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -695,7 +834,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - listRestorations(params?: { queries?: string[] }): Promise; + listRestorations(params?: { + queries?: string[]; + }): Promise; /** * List all backup restorations for a project. * @@ -706,20 +847,24 @@ export class Backups { */ listRestorations(queries?: string[]): Promise; listRestorations( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/backups/restorations'; const payload: Payload = {}; @@ -730,15 +875,10 @@ export class Backups { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -748,7 +888,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - getRestoration(params: { restorationId: string }): Promise; + getRestoration(params: { + restorationId: string; + }): Promise; /** * Get the current status of a backup restoration. * @@ -759,38 +901,41 @@ export class Backups { */ getRestoration(restorationId: string): Promise; getRestoration( - paramsOrFirst: { restorationId: string } | string + paramsOrFirst: { restorationId: string } | string, ): Promise { let params: { restorationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { restorationId: string }; } else { params = { - restorationId: paramsOrFirst as string + restorationId: paramsOrFirst as string, }; } - + const restorationId = params.restorationId; - if (typeof restorationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "restorationId"'); + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); } - - const apiPath = '/backups/restorations/{restorationId}'.replace('{restorationId}', encodeURIComponent(String(restorationId))); + const apiPath = '/backups/restorations/{restorationId}'.replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/console.ts b/src/services/console.ts index a8109c35..d2f7f943 100644 --- a/src/services/console.ts +++ b/src/services/console.ts @@ -1,5 +1,4 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { Platform } from '../enums/platform'; @@ -7,7 +6,6 @@ import { ConsoleResourceType } from '../enums/console-resource-type'; import { QuerySuggestionResource } from '../enums/query-suggestion-resource'; import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; - export class Console { client: Client; @@ -33,39 +31,42 @@ export class Console { */ getCampaign(campaignId: string): Promise; getCampaign( - paramsOrFirst: { campaignId: string } | string + paramsOrFirst: { campaignId: string } | string, ): Promise { let params: { campaignId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { campaignId: string }; } else { params = { - campaignId: paramsOrFirst as string + campaignId: paramsOrFirst as string, }; } - + const campaignId = params.campaignId; - if (typeof campaignId === 'undefined') { - throw new AppwriteException('Missing required parameter: "campaignId"'); + if (typeof campaignId === 'undefined' || campaignId === '') { + throw new AppwriteException( + 'Missing required parameter: "campaignId"', + ); } - - const apiPath = '/console/campaigns/{campaignId}'.replace('{campaignId}', encodeURIComponent(String(campaignId))); + const apiPath = '/console/campaigns/{campaignId}'.replace( + '{campaignId}', + encodeURIComponent(String(campaignId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -86,44 +87,47 @@ export class Console { */ getCoupon(couponId: string): Promise; getCoupon( - paramsOrFirst: { couponId: string } | string + paramsOrFirst: { couponId: string } | string, ): Promise { let params: { couponId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { couponId: string }; } else { params = { - couponId: paramsOrFirst as string + couponId: paramsOrFirst as string, }; } - + const couponId = params.couponId; - if (typeof couponId === 'undefined') { - throw new AppwriteException('Missing required parameter: "couponId"'); + if (typeof couponId === 'undefined' || couponId === '') { + throw new AppwriteException( + 'Missing required parameter: "couponId"', + ); } - - const apiPath = '/console/coupons/{couponId}'.replace('{couponId}', encodeURIComponent(String(couponId))); + const apiPath = '/console/coupons/{couponId}'.replace( + '{couponId}', + encodeURIComponent(String(couponId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get a list of all the project's databases. You can use the query params to filter your results. This returns every database across all types and product APIs in a single call. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. @@ -131,10 +135,14 @@ export class Console { * @throws {AppwriteException} * @returns {Promise} */ - listDatabases(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listDatabases(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the project's databases. You can use the query params to filter your results. This returns every database across all types and product APIs in a single call. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name * @param {string} search - Search term to filter your list results. Max length: 256 chars. @@ -143,28 +151,41 @@ export class Console { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listDatabases(queries?: string[], search?: string, total?: boolean): Promise; listDatabases( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listDatabases( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/console/databases'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -180,15 +201,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -198,22 +214,16 @@ export class Console { * @returns {Promise} */ listOAuth2Providers(): Promise { - const apiPath = '/console/oauth2-providers'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -234,20 +244,25 @@ export class Console { */ getPlans(platform?: Platform): Promise; getPlans( - paramsOrFirst?: { platform?: Platform } | Platform + paramsOrFirst?: { platform?: Platform } | Platform, ): Promise { let params: { platform?: Platform }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('platform' in paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'platform' in paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { platform?: Platform }; } else { params = { - platform: paramsOrFirst as Platform + platform: paramsOrFirst as Platform, }; } - - const platform = params.platform; + const platform = params.platform; const apiPath = '/console/plans'; const payload: Payload = {}; @@ -258,15 +273,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -287,65 +297,60 @@ export class Console { */ getPlan(planId: string): Promise; getPlan( - paramsOrFirst: { planId: string } | string + paramsOrFirst: { planId: string } | string, ): Promise { let params: { planId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { planId: string }; } else { params = { - planId: paramsOrFirst as string + planId: paramsOrFirst as string, }; } - + const planId = params.planId; - if (typeof planId === 'undefined') { + if (typeof planId === 'undefined' || planId === '') { throw new AppwriteException('Missing required parameter: "planId"'); } - - const apiPath = '/console/plans/{planId}'.replace('{planId}', encodeURIComponent(String(planId))); + const apiPath = '/console/plans/{planId}'.replace( + '{planId}', + encodeURIComponent(String(planId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get the catalog of Postgres extensions that can be installed on a dedicated Postgres database. - * + * * * @throws {AppwriteException} * @returns {Promise} */ listPostgresExtensions(): Promise { - const apiPath = '/console/postgres-extensions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -366,39 +371,42 @@ export class Console { */ getProgram(programId: string): Promise; getProgram( - paramsOrFirst: { programId: string } | string + paramsOrFirst: { programId: string } | string, ): Promise { let params: { programId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { programId: string }; } else { params = { - programId: paramsOrFirst as string + programId: paramsOrFirst as string, }; } - + const programId = params.programId; - if (typeof programId === 'undefined') { - throw new AppwriteException('Missing required parameter: "programId"'); + if (typeof programId === 'undefined' || programId === '') { + throw new AppwriteException( + 'Missing required parameter: "programId"', + ); } - - const apiPath = '/console/programs/{programId}'.replace('{programId}', encodeURIComponent(String(programId))); + const apiPath = '/console/programs/{programId}'.replace( + '{programId}', + encodeURIComponent(String(programId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -408,7 +416,9 @@ export class Console { * @throws {AppwriteException} * @returns {Promise>} */ - createProgramMembership(params: { programId: string }): Promise>; + createProgramMembership< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { programId: string }): Promise>; /** * Create a new membership for an account to a program. * @@ -417,42 +427,49 @@ export class Console { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createProgramMembership(programId: string): Promise>; - createProgramMembership( - paramsOrFirst: { programId: string } | string + createProgramMembership< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(programId: string): Promise>; + createProgramMembership< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { programId: string } | string, ): Promise> { let params: { programId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { programId: string }; } else { params = { - programId: paramsOrFirst as string + programId: paramsOrFirst as string, }; } - + const programId = params.programId; - if (typeof programId === 'undefined') { - throw new AppwriteException('Missing required parameter: "programId"'); + if (typeof programId === 'undefined' || programId === '') { + throw new AppwriteException( + 'Missing required parameter: "programId"', + ); } - - const apiPath = '/console/programs/{programId}/memberships'.replace('{programId}', encodeURIComponent(String(programId))); + const apiPath = '/console/programs/{programId}/memberships'.replace( + '{programId}', + encodeURIComponent(String(programId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -462,22 +479,16 @@ export class Console { * @returns {Promise} */ listRegions(): Promise { - const apiPath = '/console/regions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -488,7 +499,10 @@ export class Console { * @throws {AppwriteException} * @returns {Promise<{}>} */ - getResource(params: { value: string, type: ConsoleResourceType }): Promise<{}>; + getResource(params: { + value: string; + type: ConsoleResourceType; + }): Promise<{}>; /** * Check if a resource ID is available. * @@ -500,20 +514,27 @@ export class Console { */ getResource(value: string, type: ConsoleResourceType): Promise<{}>; getResource( - paramsOrFirst: { value: string, type: ConsoleResourceType } | string, - ...rest: [(ConsoleResourceType)?] + paramsOrFirst: { value: string; type: ConsoleResourceType } | string, + ...rest: [ConsoleResourceType?] ): Promise<{}> { - let params: { value: string, type: ConsoleResourceType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { value: string, type: ConsoleResourceType }; + let params: { value: string; type: ConsoleResourceType }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + value: string; + type: ConsoleResourceType; + }; } else { params = { value: paramsOrFirst as string, - type: rest[0] as ConsoleResourceType + type: rest[0] as ConsoleResourceType, }; } - + const value = params.value; const type = params.type; @@ -523,7 +544,6 @@ export class Console { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - const apiPath = '/console/resources'; const payload: Payload = {}; if (typeof value !== 'undefined') { @@ -536,14 +556,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -553,22 +569,16 @@ export class Console { * @returns {Promise} */ listOrganizationScopes(): Promise { - const apiPath = '/console/scopes/organization'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -578,22 +588,16 @@ export class Console { * @returns {Promise} */ listProjectScopes(): Promise { - const apiPath = '/console/scopes/project'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -607,7 +611,13 @@ export class Console { * @throws {AppwriteException} * @returns {Promise<{}>} */ - createSource(params?: { ref?: string, referrer?: string, utmSource?: string, utmCampaign?: string, utmMedium?: string }): Promise<{}>; + createSource(params?: { + ref?: string; + referrer?: string; + utmSource?: string; + utmCampaign?: string; + utmMedium?: string; + }): Promise<{}>; /** * Create a new source. * @@ -620,32 +630,62 @@ export class Console { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - createSource(ref?: string, referrer?: string, utmSource?: string, utmCampaign?: string, utmMedium?: string): Promise<{}>; createSource( - paramsOrFirst?: { ref?: string, referrer?: string, utmSource?: string, utmCampaign?: string, utmMedium?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + ref?: string, + referrer?: string, + utmSource?: string, + utmCampaign?: string, + utmMedium?: string, + ): Promise<{}>; + createSource( + paramsOrFirst?: + | { + ref?: string; + referrer?: string; + utmSource?: string; + utmCampaign?: string; + utmMedium?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise<{}> { - let params: { ref?: string, referrer?: string, utmSource?: string, utmCampaign?: string, utmMedium?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { ref?: string, referrer?: string, utmSource?: string, utmCampaign?: string, utmMedium?: string }; + let params: { + ref?: string; + referrer?: string; + utmSource?: string; + utmCampaign?: string; + utmMedium?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + ref?: string; + referrer?: string; + utmSource?: string; + utmCampaign?: string; + utmMedium?: string; + }; } else { params = { ref: paramsOrFirst as string, referrer: rest[0] as string, utmSource: rest[1] as string, utmCampaign: rest[2] as string, - utmMedium: rest[3] as string + utmMedium: rest[3] as string, }; } - + const ref = params.ref; const referrer = params.referrer; const utmSource = params.utmSource; const utmCampaign = params.utmCampaign; const utmMedium = params.utmMedium; - const apiPath = '/console/sources'; const payload: Payload = {}; if (typeof ref !== 'undefined') { @@ -668,15 +708,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -690,7 +725,13 @@ export class Console { * @throws {AppwriteException} * @returns {Promise} */ - suggestColumns(params: { databaseId: string, tableId: string, context?: string, min?: number, max?: number }): Promise; + suggestColumns(params: { + databaseId: string; + tableId: string; + context?: string; + min?: number; + max?: number; + }): Promise; /** * Suggests column names and their size limits based on the provided table name. The API will also analyze other tables in the same database to provide context-aware suggestions, ensuring consistency across schema design. Users may optionally provide custom context to further refine the suggestions. * @@ -703,25 +744,55 @@ export class Console { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - suggestColumns(databaseId: string, tableId: string, context?: string, min?: number, max?: number): Promise; suggestColumns( - paramsOrFirst: { databaseId: string, tableId: string, context?: string, min?: number, max?: number } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?] + databaseId: string, + tableId: string, + context?: string, + min?: number, + max?: number, + ): Promise; + suggestColumns( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + context?: string; + min?: number; + max?: number; + } + | string, + ...rest: [string?, string?, number?, number?] ): Promise { - let params: { databaseId: string, tableId: string, context?: string, min?: number, max?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, context?: string, min?: number, max?: number }; + let params: { + databaseId: string; + tableId: string; + context?: string; + min?: number; + max?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + context?: string; + min?: number; + max?: number; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, context: rest[1] as string, min: rest[2] as number, - max: rest[3] as number + max: rest[3] as number, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const context = params.context; @@ -729,12 +800,15 @@ export class Console { const max = params.max; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - const apiPath = '/console/suggestions/columns'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -756,15 +830,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -777,7 +846,12 @@ export class Console { * @throws {AppwriteException} * @returns {Promise} */ - suggestIndexes(params: { databaseId: string, tableId: string, min?: number, max?: number }): Promise; + suggestIndexes(params: { + databaseId: string; + tableId: string; + min?: number; + max?: number; + }): Promise; /** * Suggests database indexes for table columns based on the provided table structure and existing columns. The API will also analyze the table's column types, names, and patterns to recommend optimal indexes that improve query performance for common database operations like filtering, sorting, and searching. * @@ -789,36 +863,65 @@ export class Console { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - suggestIndexes(databaseId: string, tableId: string, min?: number, max?: number): Promise; suggestIndexes( - paramsOrFirst: { databaseId: string, tableId: string, min?: number, max?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + tableId: string, + min?: number, + max?: number, + ): Promise; + suggestIndexes( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + min?: number; + max?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, tableId: string, min?: number, max?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, min?: number, max?: number }; + let params: { + databaseId: string; + tableId: string; + min?: number; + max?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + min?: number; + max?: number; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, min: rest[1] as number, - max: rest[2] as number + max: rest[2] as number, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const min = params.min; const max = params.max; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - const apiPath = '/console/suggestions/indexes'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -837,20 +940,15 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Suggest valid Appwrite query JSON objects for a supported list resource from free-text user intent. The endpoint picks a validator based on `resource` — for system resources it uses the static validator and its allowed attributes, and for user-owned table rows it loads the table schema and validates against those attributes at request time. The returned queries are guaranteed to parse and pass the relevant queries validator. - * + * * * @param {QuerySuggestionResource} params.resource - Resource to generate queries for. * @param {string} params.input - Natural language query intent used to generate filters/sorting/pagination. @@ -859,10 +957,15 @@ export class Console { * @throws {AppwriteException} * @returns {Promise<{}>} */ - suggestQueries(params: { resource: QuerySuggestionResource, input: string, databaseId?: string, tableId?: string }): Promise<{}>; + suggestQueries(params: { + resource: QuerySuggestionResource; + input: string; + databaseId?: string; + tableId?: string; + }): Promise<{}>; /** * Suggest valid Appwrite query JSON objects for a supported list resource from free-text user intent. The endpoint picks a validator based on `resource` — for system resources it uses the static validator and its allowed attributes, and for user-owned table rows it loads the table schema and validates against those attributes at request time. The returned queries are guaranteed to parse and pass the relevant queries validator. - * + * * * @param {QuerySuggestionResource} resource - Resource to generate queries for. * @param {string} input - Natural language query intent used to generate filters/sorting/pagination. @@ -872,36 +975,67 @@ export class Console { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - suggestQueries(resource: QuerySuggestionResource, input: string, databaseId?: string, tableId?: string): Promise<{}>; suggestQueries( - paramsOrFirst: { resource: QuerySuggestionResource, input: string, databaseId?: string, tableId?: string } | QuerySuggestionResource, - ...rest: [(string)?, (string)?, (string)?] + resource: QuerySuggestionResource, + input: string, + databaseId?: string, + tableId?: string, + ): Promise<{}>; + suggestQueries( + paramsOrFirst: + | { + resource: QuerySuggestionResource; + input: string; + databaseId?: string; + tableId?: string; + } + | QuerySuggestionResource, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { resource: QuerySuggestionResource, input: string, databaseId?: string, tableId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resource' in paramsOrFirst || 'input' in paramsOrFirst || 'databaseId' in paramsOrFirst || 'tableId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resource: QuerySuggestionResource, input: string, databaseId?: string, tableId?: string }; + let params: { + resource: QuerySuggestionResource; + input: string; + databaseId?: string; + tableId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resource' in paramsOrFirst || + 'input' in paramsOrFirst || + 'databaseId' in paramsOrFirst || + 'tableId' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resource: QuerySuggestionResource; + input: string; + databaseId?: string; + tableId?: string; + }; } else { params = { resource: paramsOrFirst as QuerySuggestionResource, input: rest[0] as string, databaseId: rest[1] as string, - tableId: rest[2] as string + tableId: rest[2] as string, }; } - + const resource = params.resource; const input = params.input; const databaseId = params.databaseId; const tableId = params.tableId; if (typeof resource === 'undefined') { - throw new AppwriteException('Missing required parameter: "resource"'); + throw new AppwriteException( + 'Missing required parameter: "resource"', + ); } if (typeof input === 'undefined') { throw new AppwriteException('Missing required parameter: "input"'); } - const apiPath = '/console/suggestions/queries'; const payload: Payload = {}; if (typeof resource !== 'undefined') { @@ -920,15 +1054,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -939,7 +1068,10 @@ export class Console { * @throws {AppwriteException} * @returns {Promise} */ - getEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }): Promise; + getEmailTemplate(params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }): Promise; /** * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. * @@ -949,30 +1081,53 @@ export class Console { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale): Promise; getEmailTemplate( - paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale } | ProjectEmailTemplateId, - ...rest: [(ProjectEmailTemplateLocale)?] + templateId: ProjectEmailTemplateId, + locale?: ProjectEmailTemplateLocale, + ): Promise; + getEmailTemplate( + paramsOrFirst: + | { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + } + | ProjectEmailTemplateId, + ...rest: [ProjectEmailTemplateLocale?] ): Promise { - let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + let params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, - locale: rest[0] as ProjectEmailTemplateLocale + locale: rest[0] as ProjectEmailTemplateLocale, }; } - + const templateId = params.templateId; const locale = params.locale; if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - - const apiPath = '/console/templates/email/{templateId}'.replace('{templateId}', encodeURIComponent(String(templateId))); + const apiPath = '/console/templates/email/{templateId}'.replace( + '{templateId}', + encodeURIComponent(String(templateId)), + ); const payload: Payload = {}; if (typeof locale !== 'undefined') { payload['locale'] = locale; @@ -981,15 +1136,10 @@ export class Console { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -999,21 +1149,15 @@ export class Console { * @returns {Promise} */ variables(): Promise { - const apiPath = '/console/variables'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 6fe52314..c35bd0bb 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,12 +1,10 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { DatabasesIndexType } from '../enums/databases-index-type'; import { OrderBy } from '../enums/order-by'; - export class Databases { client: Client; @@ -24,7 +22,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead. */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * @@ -35,28 +37,41 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/databases'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -72,20 +87,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new Database. - * + * * * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Database name. Max length: 128 chars. @@ -94,10 +104,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead. */ - create(params: { databaseId: string, name: string, enabled?: boolean }): Promise; + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + }): Promise; /** * Create a new Database. - * + * * * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Database name. Max length: 128 chars. @@ -106,34 +120,48 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + databaseId: string, + name: string, + enabled?: boolean, + ): Promise; + create( + paramsOrFirst: + { databaseId: string; name: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + let params: { databaseId: string; name: string; enabled?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/databases'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -150,15 +178,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -169,7 +192,9 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead. */ - listTransactions(params?: { queries?: string[] }): Promise; + listTransactions(params?: { + queries?: string[]; + }): Promise; /** * List transactions across all databases. * @@ -180,20 +205,24 @@ export class Databases { */ listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/databases/transactions'; const payload: Payload = {}; @@ -204,15 +233,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -234,20 +258,24 @@ export class Databases { */ createTransaction(ttl?: number): Promise; createTransaction( - paramsOrFirst?: { ttl?: number } | number + paramsOrFirst?: { ttl?: number } | number, ): Promise { let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { ttl?: number }; } else { params = { - ttl: paramsOrFirst as number + ttl: paramsOrFirst as number, }; } - - const ttl = params.ttl; + const ttl = params.ttl; const apiPath = '/databases/transactions'; const payload: Payload = {}; @@ -259,15 +287,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -278,7 +301,9 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead. */ - getTransaction(params: { transactionId: string }): Promise; + getTransaction(params: { + transactionId: string; + }): Promise; /** * Get a transaction by its unique ID. * @@ -289,39 +314,42 @@ export class Databases { */ getTransaction(transactionId: string): Promise; getTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/databases/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -334,7 +362,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead. */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; /** * Update a transaction, to either commit or roll back its operations. * @@ -345,32 +377,54 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; } else { params = { transactionId: paramsOrFirst as string, commit: rest[0] as boolean, - rollback: rest[1] as boolean + rollback: rest[1] as boolean, }; } - + const transactionId = params.transactionId; const commit = params.commit; const rollback = params.rollback; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/databases/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof commit !== 'undefined') { payload['commit'] = commit; @@ -383,15 +437,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -413,39 +462,43 @@ export class Databases { */ deleteTransaction(transactionId: string): Promise<{}>; deleteTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise<{}> { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/databases/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -457,7 +510,10 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead. */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; /** * Create multiple operations in a single transaction. * @@ -467,30 +523,46 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createOperations(transactionId: string, operations?: object[]): Promise; createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; } else { params = { transactionId: paramsOrFirst as string, - operations: rest[0] as object[] + operations: rest[0] as object[], }; } - + const transactionId = params.transactionId; const operations = params.operations; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}/operations'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = + '/databases/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof operations !== 'undefined') { payload['operations'] = operations; @@ -500,15 +572,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -530,39 +597,42 @@ export class Databases { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/databases/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -575,7 +645,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead. */ - update(params: { databaseId: string, name?: string, enabled?: boolean }): Promise; + update(params: { + databaseId: string; + name?: string; + enabled?: boolean; + }): Promise; /** * Update a database by its unique ID. * @@ -586,32 +660,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + databaseId: string, + name?: string, + enabled?: boolean, + ): Promise; + update( + paramsOrFirst: + { databaseId: string; name?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean }; + let params: { databaseId: string; name?: string; enabled?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/databases/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -624,15 +715,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -653,40 +739,42 @@ export class Databases { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/databases/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -700,7 +788,12 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead. */ - listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listCollections(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * @@ -712,34 +805,64 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; listCollections( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listCollections( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/databases/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -754,15 +877,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -774,13 +892,22 @@ export class Databases { * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. */ - createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise; + createCollection(params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }): Promise; /** * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -790,21 +917,71 @@ export class Databases { * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise; createCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + databaseId: string, + collectionId: string, + name: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + attributes?: object[], + indexes?: object[], + ): Promise; + createCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + object[]?, + object[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + let params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -814,10 +991,10 @@ export class Databases { documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], - indexes: rest[6] as object[] + indexes: rest[6] as object[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -827,17 +1004,23 @@ export class Databases { const attributes = params.attributes; const indexes = params.indexes; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/databases/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof collectionId !== 'undefined') { payload['collectionId'] = collectionId; @@ -865,15 +1048,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -885,7 +1063,10 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead. */ - getCollection(params: { databaseId: string, collectionId: string }): Promise; + getCollection(params: { + databaseId: string; + collectionId: string; + }): Promise; /** * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. * @@ -895,47 +1076,60 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getCollection(databaseId: string, collectionId: string): Promise; getCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + databaseId: string, + collectionId: string, + ): Promise; + getCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -952,7 +1146,15 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead. */ - updateCollection(params: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise; + updateCollection(params: { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }): Promise; /** * Update a collection by its unique ID. * @@ -967,15 +1169,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCollection(databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise; updateCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + name?: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + purge?: boolean, + ): Promise; + updateCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; + let params: { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -984,10 +1224,10 @@ export class Databases { permissions: rest[2] as string[], documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, - purge: rest[5] as boolean + purge: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -996,14 +1236,22 @@ export class Databases { const enabled = params.enabled; const purge = params.purge; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1025,15 +1273,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1045,7 +1288,10 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead. */ - deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + deleteCollection(params: { + databaseId: string; + collectionId: string; + }): Promise<{}>; /** * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. * @@ -1057,45 +1303,56 @@ export class Databases { */ deleteCollection(databaseId: string, collectionId: string): Promise<{}>; deleteCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1109,7 +1366,12 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead. */ - listAttributes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + listAttributes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List attributes in the collection. * @@ -1121,37 +1383,72 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listAttributes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; listAttributes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listAttributes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1163,20 +1460,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a bigint attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1190,10 +1482,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBigIntColumn` instead. */ - createBigIntAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createBigIntAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create a bigint attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1207,15 +1508,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBigIntAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createBigIntAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createBigIntAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1225,10 +1576,10 @@ export class Databases { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1238,20 +1589,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -1276,20 +1638,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1303,10 +1660,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. */ - updateBigIntAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateBigIntAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1320,15 +1686,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBigIntAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateBigIntAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateBigIntAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1338,10 +1754,10 @@ export class Databases { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1351,23 +1767,37 @@ export class Databases { const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -1389,20 +1819,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a boolean attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -1414,10 +1839,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead. */ - createBooleanAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise; + createBooleanAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }): Promise; /** * Create a boolean attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -1429,15 +1861,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise; createBooleanAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: boolean, + array?: boolean, + ): Promise; + createBooleanAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1445,10 +1911,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1456,20 +1922,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -1488,15 +1965,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1512,7 +1984,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. */ - updateBooleanAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise; + updateBooleanAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }): Promise; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. * @@ -1526,15 +2005,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise; updateBooleanAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: boolean, + newKey?: string, + ): Promise; + updateBooleanAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1542,10 +2055,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1553,23 +2066,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -1585,15 +2112,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1609,7 +2131,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead. */ - createDatetimeAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createDatetimeAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a date time attribute according to the ISO 8601 standard. * @@ -1623,15 +2152,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createDatetimeAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createDatetimeAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1639,10 +2202,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1650,20 +2213,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -1682,15 +2256,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1706,7 +2275,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. */ - updateDatetimeAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateDatetimeAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. * @@ -1720,15 +2296,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateDatetimeAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateDatetimeAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1736,10 +2346,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1747,23 +2357,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -1779,20 +2403,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create an email attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1804,10 +2423,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead. */ - createEmailAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createEmailAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create an email attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1819,15 +2445,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createEmailAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEmailAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1835,10 +2495,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1846,20 +2506,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/email' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -1878,20 +2549,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an email attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1903,10 +2569,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. */ - updateEmailAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEmailAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an email attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1918,15 +2591,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateEmailAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEmailAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1934,10 +2641,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1945,23 +2652,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -1977,20 +2698,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** - * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. - * + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2003,10 +2719,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead. */ - createEnumAttribute(params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise; + createEnumAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** - * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. - * + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2019,15 +2743,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise; createEnumAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEnumAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2036,10 +2798,10 @@ export class Databases { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - array: rest[5] as boolean + array: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2048,23 +2810,36 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2086,20 +2861,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an enum attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2112,10 +2882,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. */ - updateEnumAttribute(params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEnumAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2128,15 +2906,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise; updateEnumAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEnumAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2145,10 +2961,10 @@ export class Databases { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2157,26 +2973,42 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof elements !== 'undefined') { payload['elements'] = elements; @@ -2195,20 +3027,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a float attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2222,10 +3049,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead. */ - createFloatAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise; + createFloatAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }): Promise; /** * Create a float attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2239,15 +3075,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise; createFloatAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + min?: number, + max?: number, + xdefault?: number, + array?: boolean, + ): Promise; + createFloatAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2257,10 +3143,10 @@ export class Databases { min: rest[3] as number, max: rest[4] as number, xdefault: rest[5] as number, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2270,20 +3156,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/float' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2308,20 +3205,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a float attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2335,10 +3227,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. */ - updateFloatAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise; + updateFloatAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }): Promise; /** * Update a float attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2352,15 +3253,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise; updateFloatAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number, + min?: number, + max?: number, + newKey?: string, + ): Promise; + updateFloatAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2370,10 +3321,10 @@ export class Databases { xdefault: rest[3] as number, min: rest[4] as number, max: rest[5] as number, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2383,23 +3334,37 @@ export class Databases { const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2421,20 +3386,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create an integer attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2448,10 +3408,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead. */ - createIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createIntegerAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create an integer attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2465,15 +3434,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createIntegerAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createIntegerAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2483,10 +3502,10 @@ export class Databases { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2496,20 +3515,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2534,20 +3564,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an integer attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2561,10 +3586,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. */ - updateIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateIntegerAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2578,15 +3612,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateIntegerAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateIntegerAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2596,10 +3680,10 @@ export class Databases { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2609,23 +3693,37 @@ export class Databases { const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2647,20 +3745,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create IP address attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2672,10 +3765,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead. */ - createIpAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createIpAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create IP address attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2687,15 +3787,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createIpAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createIpAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2703,10 +3837,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2714,20 +3848,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2746,20 +3891,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an ip attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2771,10 +3911,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. */ - updateIpAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateIpAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2786,15 +3933,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateIpAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateIpAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2802,10 +3983,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2813,23 +3994,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2845,15 +4040,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2868,7 +4058,13 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. */ - createLineAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createLineAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric line attribute. * @@ -2881,45 +4077,86 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLineAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createLineAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createLineAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/line'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2935,15 +4172,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2959,7 +4191,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. */ - updateLineAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updateLineAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a line attribute. Changing the `default` value will not update already existing documents. * @@ -2973,15 +4212,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLineAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updateLineAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updateLineAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2989,10 +4262,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3000,20 +4273,32 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3029,20 +4314,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a longtext attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3055,10 +4335,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLongtextColumn` instead. */ - createLongtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createLongtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a longtext attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3071,15 +4359,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLongtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createLongtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createLongtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3088,10 +4414,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3100,20 +4426,31 @@ export class Databases { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3135,20 +4472,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3160,10 +4492,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. */ - updateLongtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateLongtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3175,15 +4514,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLongtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateLongtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateLongtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3191,10 +4564,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3202,23 +4575,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3234,20 +4621,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a mediumtext attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3260,10 +4642,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createMediumtextColumn` instead. */ - createMediumtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createMediumtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a mediumtext attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3276,15 +4666,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMediumtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createMediumtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createMediumtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3293,10 +4721,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3305,20 +4733,31 @@ export class Databases { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3340,20 +4779,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3365,10 +4799,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. */ - updateMediumtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateMediumtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3380,15 +4821,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMediumtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateMediumtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateMediumtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3396,10 +4871,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3407,23 +4882,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3439,15 +4928,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3462,7 +4946,13 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. */ - createPointAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] }): Promise; + createPointAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + }): Promise; /** * Create a geometric point attribute. * @@ -3475,45 +4965,86 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPointAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[]): Promise; createPointAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number[], + ): Promise; + createPointAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + } + | string, + ...rest: [string?, string?, boolean?, number[]?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[] + xdefault: rest[3] as number[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/point'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3529,15 +5060,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3553,7 +5079,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. */ - updatePointAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }): Promise; + updatePointAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }): Promise; /** * Update a point attribute. Changing the `default` value will not update already existing documents. * @@ -3567,15 +5100,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePointAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string): Promise; updatePointAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number[], + newKey?: string, + ): Promise; + updatePointAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, number[]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3583,10 +5150,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as number[], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3594,20 +5161,32 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3623,15 +5202,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3646,7 +5220,13 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. */ - createPolygonAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createPolygonAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric polygon attribute. * @@ -3659,45 +5239,86 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPolygonAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createPolygonAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createPolygonAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3713,15 +5334,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3737,7 +5353,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. */ - updatePolygonAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updatePolygonAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. * @@ -3751,15 +5374,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePolygonAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updatePolygonAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updatePolygonAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3767,10 +5424,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3778,20 +5435,32 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3807,59 +5476,113 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. * @param {string} params.relatedCollectionId - Related Collection ID. - * @param {RelationshipType} params.type - Relation type + * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? * @param {string} params.key - Attribute Key. * @param {string} params.twoWayKey - Two Way Attribute Key. - * @param {RelationMutate} params.onDelete - Constraints option + * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead. */ - createRelationshipAttribute(params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise; + createRelationshipAttribute(params: { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }): Promise; /** * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. * @param {string} relatedCollectionId - Related Collection ID. - * @param {RelationshipType} type - Relation type + * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? * @param {string} key - Attribute Key. * @param {string} twoWayKey - Two Way Attribute Key. - * @param {RelationMutate} onDelete - Constraints option + * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise; createRelationshipAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, - ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + databaseId: string, + collectionId: string, + relatedCollectionId: string, + type: RelationshipType, + twoWay?: boolean, + key?: string, + twoWayKey?: string, + onDelete?: RelationMutate, + ): Promise; + createRelationshipAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + } + | string, + ...rest: [ + string?, + string?, + RelationshipType?, + boolean?, + string?, + string?, + RelationMutate?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + let params: { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3869,10 +5592,10 @@ export class Databases { twoWay: rest[3] as boolean, key: rest[4] as string, twoWayKey: rest[5] as string, - onDelete: rest[6] as RelationMutate + onDelete: rest[6] as RelationMutate, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const relatedCollectionId = params.relatedCollectionId; @@ -3882,20 +5605,31 @@ export class Databases { const twoWayKey = params.twoWayKey; const onDelete = params.onDelete; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof relatedCollectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "relatedCollectionId"'); + throw new AppwriteException( + 'Missing required parameter: "relatedCollectionId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof relatedCollectionId !== 'undefined') { payload['relatedCollectionId'] = relatedCollectionId; @@ -3920,80 +5654,121 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. - * @param {RelationMutate} params.onDelete - Constraints option + * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @param {string} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. */ - updateRelationshipAttribute(params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise; + updateRelationshipAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }): Promise; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. - * @param {RelationMutate} onDelete - Constraints option + * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @param {string} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise; updateRelationshipAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, - ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + onDelete?: RelationMutate, + newKey?: string, + ): Promise; + updateRelationshipAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + } + | string, + ...rest: [string?, string?, RelationMutate?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, onDelete: rest[2] as RelationMutate, - newKey: rest[3] as string + newKey: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const onDelete = params.onDelete; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof onDelete !== 'undefined') { payload['onDelete'] = onDelete; @@ -4006,20 +5781,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a string attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4033,10 +5803,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead. */ - createStringAttribute(params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createStringAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a string attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4050,15 +5829,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createStringAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createStringAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4068,10 +5897,10 @@ export class Databases { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4081,11 +5910,15 @@ export class Databases { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -4094,10 +5927,17 @@ export class Databases { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/string' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4122,20 +5962,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a string attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4148,10 +5983,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. */ - updateStringAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateStringAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a string attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4164,15 +6007,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateStringAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateStringAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4181,10 +6062,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4193,23 +6074,37 @@ export class Databases { const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4228,20 +6123,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a text attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4254,10 +6144,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTextColumn` instead. */ - createTextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createTextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a text attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4270,15 +6168,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createTextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createTextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4287,10 +6223,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4299,20 +6235,31 @@ export class Databases { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/text'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4334,20 +6281,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a text attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4359,10 +6301,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. */ - updateTextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateTextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a text attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4374,15 +6323,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateTextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateTextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4390,10 +6373,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4401,23 +6384,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4433,20 +6430,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a URL attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -4458,10 +6450,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead. */ - createUrlAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createUrlAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a URL attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -4473,15 +6472,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createUrlAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createUrlAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4489,10 +6522,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4500,20 +6533,31 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/url' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4532,20 +6576,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an url attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -4557,10 +6596,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. */ - updateUrlAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateUrlAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an url attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -4572,15 +6618,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateUrlAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateUrlAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4588,10 +6668,10 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4599,23 +6679,37 @@ export class Databases { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4631,20 +6725,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a varchar attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4658,10 +6747,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createVarcharColumn` instead. */ - createVarcharAttribute(params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createVarcharAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a varchar attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4675,15 +6773,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVarcharAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createVarcharAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createVarcharAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4693,10 +6841,10 @@ export class Databases { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4706,11 +6854,15 @@ export class Databases { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -4719,10 +6871,17 @@ export class Databases { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4747,20 +6906,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4773,10 +6927,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. */ - updateVarcharAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateVarcharAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4789,15 +6951,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVarcharAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateVarcharAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateVarcharAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4806,10 +7006,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4818,23 +7018,37 @@ export class Databases { const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4853,15 +7067,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4874,7 +7083,22 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. */ - getAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise; + getAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise< + | Models.AttributeBoolean + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributeString + >; /** * Get attribute by ID. * @@ -4885,52 +7109,92 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAttribute(databaseId: string, collectionId: string, key: string): Promise; getAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + databaseId: string, + collectionId: string, + key: string, + ): Promise< + | Models.AttributeBoolean + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributeString + >; + getAttribute( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise< + | Models.AttributeBoolean + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributeString + > { + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4943,7 +7207,11 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead. */ - deleteAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + deleteAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; /** * Deletes an attribute. * @@ -4954,52 +7222,71 @@ export class Databases { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<{}>; deleteAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteAttribute( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -5015,7 +7302,16 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + listDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * @@ -5029,15 +7325,49 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5045,10 +7375,10 @@ export class Databases { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; @@ -5056,14 +7386,23 @@ export class Databases { const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -5081,15 +7420,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5105,7 +7439,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }): Promise; + createDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5119,26 +7464,83 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string): Promise; createDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit, + permissions?: string[], + transactionId?: string, + ): Promise; + createDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -5146,20 +7548,31 @@ export class Databases { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); } if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documentId !== 'undefined') { payload['documentId'] = documentId; @@ -5178,15 +7591,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -5200,7 +7608,14 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + createDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5212,40 +7627,77 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + createDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; @@ -5258,20 +7710,15 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -5281,10 +7728,17 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. */ - upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + upsertDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -5294,40 +7748,77 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + upsertDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; @@ -5340,15 +7831,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -5363,7 +7849,15 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + updateDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. * @@ -5376,39 +7870,78 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, data: rest[1] as object, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const data = params.data; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -5424,15 +7957,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5446,7 +7974,14 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead. */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; + deleteDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * @@ -5458,37 +7993,72 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -5501,15 +8071,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -5524,7 +8089,15 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead. */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; + getDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }): Promise; /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -5537,42 +8110,87 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -5584,15 +8202,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5608,7 +8221,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5622,26 +8247,84 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -5649,17 +8332,32 @@ export class Databases { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -5675,15 +8373,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -5699,7 +8392,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + updateDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -5713,26 +8418,84 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -5740,17 +8503,32 @@ export class Databases { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -5766,15 +8544,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5788,7 +8561,12 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead. */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; + deleteDocument(params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }): Promise<{}>; /** * Delete a document by its unique ID. * @@ -5800,40 +8578,81 @@ export class Databases { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + transactionId?: string, + ): Promise<{}>; + deleteDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof transactionId !== 'undefined') { payload['transactionId'] = transactionId; @@ -5843,14 +8662,10 @@ export class Databases { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -5867,7 +8682,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. */ - decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }): Promise; /** * Decrement a specific attribute of a document by a given value. * @@ -5882,15 +8707,57 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string): Promise; - decrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + min?: number, + transactionId?: string, + ): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5899,10 +8766,10 @@ export class Databases { attribute: rest[2] as string, value: rest[3] as number, min: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -5911,20 +8778,35 @@ export class Databases { const min = params.min; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))).replace('{attribute}', encodeURIComponent(String(attribute))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof attribute === 'undefined' || attribute === '') { + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); const payload: Payload = {}; if (typeof value !== 'undefined') { payload['value'] = value; @@ -5940,15 +8822,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5965,7 +8842,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. */ - incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }): Promise; /** * Increment a specific attribute of a document by a given value. * @@ -5980,15 +8867,57 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string): Promise; - incrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + max?: number, + transactionId?: string, + ): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5997,10 +8926,10 @@ export class Databases { attribute: rest[2] as string, value: rest[3] as number, max: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -6009,20 +8938,35 @@ export class Databases { const max = params.max; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))).replace('{attribute}', encodeURIComponent(String(attribute))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof attribute === 'undefined' || attribute === '') { + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); const payload: Payload = {}; if (typeof value !== 'undefined') { payload['value'] = value; @@ -6038,15 +8982,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6060,7 +8999,12 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead. */ - listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + listIndexes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List indexes in the collection. * @@ -6072,37 +9016,72 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; listIndexes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -6114,15 +9093,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -6140,7 +9114,15 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead. */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; /** * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. * Attributes can be `key`, `fulltext`, and `unique`. @@ -6156,15 +9138,60 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (DatabasesIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + databaseId: string, + collectionId: string, + key: string, + type: DatabasesIndexType, + attributes: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + DatabasesIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -6173,10 +9200,10 @@ export class Databases { type: rest[2] as DatabasesIndexType, attributes: rest[3] as string[], orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] + lengths: rest[5] as number[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -6185,11 +9212,15 @@ export class Databases { const orders = params.orders; const lengths = params.lengths; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -6198,10 +9229,17 @@ export class Databases { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "attributes"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -6223,15 +9261,10 @@ export class Databases { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -6244,7 +9277,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead. */ - getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; + getIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise; /** * Get an index by its unique ID. * @@ -6255,52 +9292,70 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getIndex(databaseId: string, collectionId: string, key: string): Promise; getIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -6313,7 +9368,11 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead. */ - deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + deleteIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; /** * Delete an index. * @@ -6324,51 +9383,70 @@ export class Databases { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; deleteIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 2049019f..f9edb0b1 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,10 +1,8 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; import { OrderBy } from '../enums/order-by'; - export class DocumentsDB { client: Client; @@ -20,7 +18,10 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * @@ -32,24 +33,31 @@ export class DocumentsDB { */ list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/documentsdb'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -62,20 +70,15 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new Database. - * + * * * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Database name. Max length: 128 chars. @@ -86,10 +89,17 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Create a new Database. - * + * * * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Database name. Max length: 128 chars. @@ -101,15 +111,49 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -117,10 +161,10 @@ export class DocumentsDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; @@ -129,12 +173,13 @@ export class DocumentsDB { const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/documentsdb'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -160,40 +205,29 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. * * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/documentsdb/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -203,7 +237,9 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - listTransactions(params?: { queries?: string[] }): Promise; + listTransactions(params?: { + queries?: string[]; + }): Promise; /** * List transactions across all databases. * @@ -214,20 +250,24 @@ export class DocumentsDB { */ listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/documentsdb/transactions'; const payload: Payload = {}; @@ -238,15 +278,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -267,20 +302,24 @@ export class DocumentsDB { */ createTransaction(ttl?: number): Promise; createTransaction( - paramsOrFirst?: { ttl?: number } | number + paramsOrFirst?: { ttl?: number } | number, ): Promise { let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { ttl?: number }; } else { params = { - ttl: paramsOrFirst as number + ttl: paramsOrFirst as number, }; } - - const ttl = params.ttl; + const ttl = params.ttl; const apiPath = '/documentsdb/transactions'; const payload: Payload = {}; @@ -292,15 +331,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -310,7 +344,9 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - getTransaction(params: { transactionId: string }): Promise; + getTransaction(params: { + transactionId: string; + }): Promise; /** * Get a transaction by its unique ID. * @@ -321,39 +357,42 @@ export class DocumentsDB { */ getTransaction(transactionId: string): Promise; getTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/documentsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -365,7 +404,11 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; /** * Update a transaction, to either commit or roll back its operations. * @@ -376,32 +419,54 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; } else { params = { transactionId: paramsOrFirst as string, commit: rest[0] as boolean, - rollback: rest[1] as boolean + rollback: rest[1] as boolean, }; } - + const transactionId = params.transactionId; const commit = params.commit; const rollback = params.rollback; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/documentsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof commit !== 'undefined') { payload['commit'] = commit; @@ -414,15 +479,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -443,39 +503,43 @@ export class DocumentsDB { */ deleteTransaction(transactionId: string): Promise<{}>; deleteTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise<{}> { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/documentsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -496,39 +560,42 @@ export class DocumentsDB { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -543,7 +610,14 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + update(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Update a database by its unique ID. * @@ -557,15 +631,49 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -573,10 +681,10 @@ export class DocumentsDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; @@ -584,14 +692,18 @@ export class DocumentsDB { const replicas = params.replicas; const syncMode = params.syncMode; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -613,15 +725,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -641,40 +748,42 @@ export class DocumentsDB { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -687,7 +796,12 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listCollections(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * @@ -699,34 +813,64 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; listCollections( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listCollections( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -741,15 +885,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -761,12 +900,21 @@ export class DocumentsDB { * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise} */ - createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise; + createCollection(params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }): Promise; /** * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * @@ -776,21 +924,71 @@ export class DocumentsDB { * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise; createCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + databaseId: string, + collectionId: string, + name: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + attributes?: object[], + indexes?: object[], + ): Promise; + createCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + object[]?, + object[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + let params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -800,10 +998,10 @@ export class DocumentsDB { documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], - indexes: rest[6] as object[] + indexes: rest[6] as object[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -813,17 +1011,23 @@ export class DocumentsDB { const attributes = params.attributes; const indexes = params.indexes; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof collectionId !== 'undefined') { payload['collectionId'] = collectionId; @@ -851,15 +1055,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -870,7 +1069,10 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - getCollection(params: { databaseId: string, collectionId: string }): Promise; + getCollection(params: { + databaseId: string; + collectionId: string; + }): Promise; /** * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. * @@ -880,47 +1082,60 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getCollection(databaseId: string, collectionId: string): Promise; getCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + databaseId: string, + collectionId: string, + ): Promise; + getCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -936,7 +1151,15 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - updateCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise; + updateCollection(params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }): Promise; /** * Update a collection by its unique ID. * @@ -951,15 +1174,53 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise; updateCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + name: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + purge?: boolean, + ): Promise; + updateCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; + let params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -968,10 +1229,10 @@ export class DocumentsDB { permissions: rest[2] as string[], documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, - purge: rest[5] as boolean + purge: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -980,17 +1241,25 @@ export class DocumentsDB { const enabled = params.enabled; const purge = params.purge; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1012,15 +1281,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1031,7 +1295,10 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + deleteCollection(params: { + databaseId: string; + collectionId: string; + }): Promise<{}>; /** * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. * @@ -1043,45 +1310,56 @@ export class DocumentsDB { */ deleteCollection(databaseId: string, collectionId: string): Promise<{}>; deleteCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1096,7 +1374,16 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise>} */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + listDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * @@ -1110,15 +1397,49 @@ export class DocumentsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1126,10 +1447,10 @@ export class DocumentsDB { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; @@ -1137,14 +1458,23 @@ export class DocumentsDB { const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1162,15 +1492,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1181,10 +1506,22 @@ export class DocumentsDB { * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise} */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; + createDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * @@ -1193,49 +1530,120 @@ export class DocumentsDB { * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; createDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?] + databaseId: string, + collectionId: string, + documentId: string, + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit, + permissions?: string[], + transactionId?: string, + ): Promise; + createDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, - permissions: rest[3] as string[] + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit, + permissions: rest[3] as string[], + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const data = params.data; const permissions = params.permissions; + const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); } if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documentId !== 'undefined') { payload['documentId'] = documentId; @@ -1246,20 +1654,18 @@ export class DocumentsDB { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1268,75 +1674,121 @@ export class DocumentsDB { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param {object[]} params.documents - Array of documents data as JSON objects. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; + createDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param {object[]} documents - Array of documents data as JSON objects. + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, - ...rest: [(string)?, (object[])?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + createDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - documents: rest[1] as object[] + documents: rest[1] as object[], + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; + const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1345,10 +1797,17 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise>} */ - upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + upsertDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1358,40 +1817,77 @@ export class DocumentsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + upsertDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; @@ -1404,15 +1900,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1426,7 +1917,15 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise>} */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + updateDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. * @@ -1439,39 +1938,78 @@ export class DocumentsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, data: rest[1] as object, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const data = params.data; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -1487,15 +2025,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1508,7 +2041,14 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise>} */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; + deleteDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * @@ -1520,37 +2060,72 @@ export class DocumentsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1563,15 +2138,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1585,7 +2155,15 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; + getDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }): Promise; /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -1598,42 +2176,87 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1645,15 +2268,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1668,7 +2286,19 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * @@ -1682,26 +2312,84 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -1709,17 +2397,32 @@ export class DocumentsDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -1735,15 +2438,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1758,7 +2456,19 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + updateDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -1772,26 +2482,84 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -1799,17 +2567,32 @@ export class DocumentsDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -1825,15 +2608,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1846,7 +2624,12 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; + deleteDocument(params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }): Promise<{}>; /** * Delete a document by its unique ID. * @@ -1858,40 +2641,81 @@ export class DocumentsDB { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + transactionId?: string, + ): Promise<{}>; + deleteDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof transactionId !== 'undefined') { payload['transactionId'] = transactionId; @@ -1901,14 +2725,10 @@ export class DocumentsDB { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1924,7 +2744,17 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }): Promise; /** * Decrement a specific column of a row by a given value. * @@ -1939,15 +2769,57 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string): Promise; - decrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + min?: number, + transactionId?: string, + ): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1956,10 +2828,10 @@ export class DocumentsDB { attribute: rest[2] as string, value: rest[3] as number, min: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -1968,20 +2840,35 @@ export class DocumentsDB { const min = params.min; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))).replace('{attribute}', encodeURIComponent(String(attribute))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof attribute === 'undefined' || attribute === '') { + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); const payload: Payload = {}; if (typeof value !== 'undefined') { payload['value'] = value; @@ -1997,15 +2884,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2021,7 +2903,17 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }): Promise; /** * Increment a specific column of a row by a given value. * @@ -2036,15 +2928,57 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string): Promise; - incrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + max?: number, + transactionId?: string, + ): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2053,10 +2987,10 @@ export class DocumentsDB { attribute: rest[2] as string, value: rest[3] as number, max: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -2065,20 +2999,35 @@ export class DocumentsDB { const max = params.max; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))).replace('{attribute}', encodeURIComponent(String(attribute))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof attribute === 'undefined' || attribute === '') { + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); const payload: Payload = {}; if (typeof value !== 'undefined') { payload['value'] = value; @@ -2094,15 +3043,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2115,7 +3059,12 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + listIndexes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List indexes in the collection. * @@ -2127,37 +3076,72 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; listIndexes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -2169,15 +3153,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2194,7 +3173,15 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; /** * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. * Attributes can be `key`, `fulltext`, and `unique`. @@ -2210,15 +3197,60 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (DocumentsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + databaseId: string, + collectionId: string, + key: string, + type: DocumentsDBIndexType, + attributes: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + DocumentsDBIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2227,10 +3259,10 @@ export class DocumentsDB { type: rest[2] as DocumentsDBIndexType, attributes: rest[3] as string[], orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] + lengths: rest[5] as number[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2239,11 +3271,15 @@ export class DocumentsDB { const orders = params.orders; const lengths = params.lengths; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -2252,10 +3288,17 @@ export class DocumentsDB { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "attributes"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2277,15 +3320,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2297,7 +3335,11 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; + getIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise; /** * Get index by ID. * @@ -2308,52 +3350,70 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getIndex(databaseId: string, collectionId: string, key: string): Promise; getIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2365,7 +3425,11 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + deleteIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; /** * Delete an index. * @@ -2376,65 +3440,87 @@ export class DocumentsDB { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; deleteIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -2442,30 +3528,45 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { payload['targetReplicaId'] = targetReplicaId; @@ -2475,15 +3576,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2496,7 +3592,12 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -2508,34 +3609,64 @@ export class DocumentsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2550,15 +3681,10 @@ export class DocumentsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2568,7 +3694,9 @@ export class DocumentsDB { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -2579,39 +3707,42 @@ export class DocumentsDB { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2632,38 +3763,41 @@ export class DocumentsDB { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/documentsdb/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/documentsdb/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 2f659fe0..7599db1e 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,10 +1,8 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; import { DomainSuggestionType } from '../enums/domain-suggestion-type'; - export class Domains { client: Client; @@ -20,7 +18,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string }): Promise; + list(params?: { + queries?: string[]; + search?: string; + }): Promise; /** * List all domains registered for this project. This endpoint supports pagination. * @@ -32,24 +33,31 @@ export class Domains { */ list(queries?: string[], search?: string): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string } | string[], - ...rest: [(string)?] + paramsOrFirst?: { queries?: string[]; search?: string } | string[], + ...rest: [string?] ): Promise { - let params: { queries?: string[], search?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + let params: { queries?: string[]; search?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + }; } else { params = { queries: paramsOrFirst as string[], - search: rest[0] as string + search: rest[0] as string, }; } - + const queries = params.queries; const search = params.search; - const apiPath = '/domains'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -62,15 +70,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -81,7 +84,7 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { teamId: string, domain: string }): Promise; + create(params: { teamId: string; domain: string }): Promise; /** * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. * @@ -93,20 +96,27 @@ export class Domains { */ create(teamId: string, domain: string): Promise; create( - paramsOrFirst: { teamId: string, domain: string } | string, - ...rest: [(string)?] + paramsOrFirst: { teamId: string; domain: string } | string, + ...rest: [string?] ): Promise { - let params: { teamId: string, domain: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, domain: string }; + let params: { teamId: string; domain: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + domain: string; + }; } else { params = { teamId: paramsOrFirst as string, - domain: rest[0] as string + domain: rest[0] as string, }; } - + const teamId = params.teamId; const domain = params.domain; @@ -116,7 +126,6 @@ export class Domains { if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } - const apiPath = '/domains'; const payload: Payload = {}; if (typeof teamId !== 'undefined') { @@ -130,15 +139,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -149,8 +153,13 @@ export class Domains { * @param {DomainRegistrationType} params.registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 2.0.0. Please use `Domains.listPrices` instead. */ - getPrice(params: { domain: string, periodYears?: number, registrationType?: DomainRegistrationType }): Promise; + getPrice(params: { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + }): Promise; /** * Get the registration price for a domain name. * @@ -161,23 +170,45 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPrice(domain: string, periodYears?: number, registrationType?: DomainRegistrationType): Promise; getPrice( - paramsOrFirst: { domain: string, periodYears?: number, registrationType?: DomainRegistrationType } | string, - ...rest: [(number)?, (DomainRegistrationType)?] + domain: string, + periodYears?: number, + registrationType?: DomainRegistrationType, + ): Promise; + getPrice( + paramsOrFirst: + | { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + } + | string, + ...rest: [number?, DomainRegistrationType?] ): Promise { - let params: { domain: string, periodYears?: number, registrationType?: DomainRegistrationType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, periodYears?: number, registrationType?: DomainRegistrationType }; + let params: { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; } else { params = { domain: paramsOrFirst as string, periodYears: rest[0] as number, - registrationType: rest[1] as DomainRegistrationType + registrationType: rest[1] as DomainRegistrationType, }; } - + const domain = params.domain; const periodYears = params.periodYears; const registrationType = params.registrationType; @@ -185,7 +216,6 @@ export class Domains { if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } - const apiPath = '/domains/price'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -201,15 +231,103 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); + } + + /** + * Check availability and get the requested registration price for one or more domain names. Availability is resolved for all domains in a single registrar lookup. Unavailable domains have a null price for new registrations, but can still be priced for renewal, transfer, or trade. Every priced domain also carries its renewal price for the same period, so a separate renewal lookup is not needed. A domain whose price could not be resolved, for example because its TLD is not supported, is returned with a null price. + * + * @param {string[]} params.domains - Domain names to check availability and price for. Maximum of 50 domains per request. + * @param {number} params.periodYears - Number of years to calculate the domain price for. Must be at least 1. + * @param {DomainRegistrationType} params.registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPrices(params: { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + }): Promise; + /** + * Check availability and get the requested registration price for one or more domain names. Availability is resolved for all domains in a single registrar lookup. Unavailable domains have a null price for new registrations, but can still be priced for renewal, transfer, or trade. Every priced domain also carries its renewal price for the same period, so a separate renewal lookup is not needed. A domain whose price could not be resolved, for example because its TLD is not supported, is returned with a null price. + * + * @param {string[]} domains - Domain names to check availability and price for. Maximum of 50 domains per request. + * @param {number} periodYears - Number of years to calculate the domain price for. Must be at least 1. + * @param {DomainRegistrationType} registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPrices( + domains: string[], + periodYears?: number, + registrationType?: DomainRegistrationType, + ): Promise; + listPrices( + paramsOrFirst: + | { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + } + | string[], + ...rest: [number?, DomainRegistrationType?] + ): Promise { + let params: { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + } else { + params = { + domains: paramsOrFirst as string[], + periodYears: rest[0] as number, + registrationType: rest[1] as DomainRegistrationType, + }; } - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + const domains = params.domains; + const periodYears = params.periodYears; + const registrationType = params.registrationType; + + if (typeof domains === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "domains"', + ); + } + const apiPath = '/domains/prices'; + const payload: Payload = {}; + if (typeof domains !== 'undefined') { + payload['domains'] = domains; + } + if (typeof periodYears !== 'undefined') { + payload['periodYears'] = periodYears; + } + if (typeof registrationType !== 'undefined') { + payload['registrationType'] = registrationType; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -230,7 +348,20 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createPurchase(params: { domain: string, organizationId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number, autoRenewal?: boolean }): Promise; + createPurchase(params: { + domain: string; + organizationId: string; + firstName: string; + lastName: string; + email: string; + phone: string; + billingAddressId: string; + paymentMethodId: string; + addressLine3?: string; + companyName?: string; + periodYears?: number; + autoRenewal?: boolean; + }): Promise; /** * Initiate a domain purchase by providing registrant details and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Purchase endpoint to capture the payment and finalize the purchase. * @@ -250,15 +381,85 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPurchase(domain: string, organizationId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number, autoRenewal?: boolean): Promise; createPurchase( - paramsOrFirst: { domain: string, organizationId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number, autoRenewal?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?] + domain: string, + organizationId: string, + firstName: string, + lastName: string, + email: string, + phone: string, + billingAddressId: string, + paymentMethodId: string, + addressLine3?: string, + companyName?: string, + periodYears?: number, + autoRenewal?: boolean, + ): Promise; + createPurchase( + paramsOrFirst: + | { + domain: string; + organizationId: string; + firstName: string; + lastName: string; + email: string; + phone: string; + billingAddressId: string; + paymentMethodId: string; + addressLine3?: string; + companyName?: string; + periodYears?: number; + autoRenewal?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + ] ): Promise { - let params: { domain: string, organizationId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number, autoRenewal?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, organizationId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number, autoRenewal?: boolean }; + let params: { + domain: string; + organizationId: string; + firstName: string; + lastName: string; + email: string; + phone: string; + billingAddressId: string; + paymentMethodId: string; + addressLine3?: string; + companyName?: string; + periodYears?: number; + autoRenewal?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + organizationId: string; + firstName: string; + lastName: string; + email: string; + phone: string; + billingAddressId: string; + paymentMethodId: string; + addressLine3?: string; + companyName?: string; + periodYears?: number; + autoRenewal?: boolean; + }; } else { params = { domain: paramsOrFirst as string, @@ -272,10 +473,10 @@ export class Domains { addressLine3: rest[7] as string, companyName: rest[8] as string, periodYears: rest[9] as number, - autoRenewal: rest[10] as boolean + autoRenewal: rest[10] as boolean, }; } - + const domain = params.domain; const organizationId = params.organizationId; const firstName = params.firstName; @@ -293,13 +494,19 @@ export class Domains { throw new AppwriteException('Missing required parameter: "domain"'); } if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof firstName === 'undefined') { - throw new AppwriteException('Missing required parameter: "firstName"'); + throw new AppwriteException( + 'Missing required parameter: "firstName"', + ); } if (typeof lastName === 'undefined') { - throw new AppwriteException('Missing required parameter: "lastName"'); + throw new AppwriteException( + 'Missing required parameter: "lastName"', + ); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); @@ -308,12 +515,15 @@ export class Domains { throw new AppwriteException('Missing required parameter: "phone"'); } if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); + throw new AppwriteException( + 'Missing required parameter: "billingAddressId"', + ); } if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } - const apiPath = '/domains/purchases'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -357,15 +567,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -376,7 +581,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - updatePurchase(params: { invoiceId: string, organizationId: string }): Promise; + updatePurchase(params: { + invoiceId: string; + organizationId: string; + }): Promise; /** * Finalize a domain purchase initiated with Create Purchase. Verifies that any required 3D Secure authentication is complete, registers the domain, captures the payment, and provisions default DNS records. Returns a 402 error if authentication is still pending. * @@ -386,33 +594,49 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePurchase(invoiceId: string, organizationId: string): Promise; updatePurchase( - paramsOrFirst: { invoiceId: string, organizationId: string } | string, - ...rest: [(string)?] + invoiceId: string, + organizationId: string, + ): Promise; + updatePurchase( + paramsOrFirst: { invoiceId: string; organizationId: string } | string, + ...rest: [string?] ): Promise { - let params: { invoiceId: string, organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { invoiceId: string, organizationId: string }; + let params: { invoiceId: string; organizationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + invoiceId: string; + organizationId: string; + }; } else { params = { invoiceId: paramsOrFirst as string, - organizationId: rest[0] as string + organizationId: rest[0] as string, }; } - + const invoiceId = params.invoiceId; const organizationId = params.organizationId; - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); } if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/domains/purchases/{invoiceId}'.replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + const apiPath = '/domains/purchases/{invoiceId}'.replace( + '{invoiceId}', + encodeURIComponent(String(invoiceId)), + ); const payload: Payload = {}; if (typeof organizationId !== 'undefined') { payload['organizationId'] = organizationId; @@ -422,15 +646,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -445,7 +664,14 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - listSuggestions(params: { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number }): Promise; + listSuggestions(params: { + query: string; + tlds?: string[]; + limit?: number; + filterType?: DomainSuggestionType; + priceMax?: number; + priceMin?: number; + }): Promise; /** * List domain suggestions. * @@ -459,15 +685,49 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSuggestions(query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number): Promise; listSuggestions( - paramsOrFirst: { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number } | string, - ...rest: [(string[])?, (number)?, (DomainSuggestionType)?, (number)?, (number)?] + query: string, + tlds?: string[], + limit?: number, + filterType?: DomainSuggestionType, + priceMax?: number, + priceMin?: number, + ): Promise; + listSuggestions( + paramsOrFirst: + | { + query: string; + tlds?: string[]; + limit?: number; + filterType?: DomainSuggestionType; + priceMax?: number; + priceMin?: number; + } + | string, + ...rest: [string[]?, number?, DomainSuggestionType?, number?, number?] ): Promise { - let params: { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number }; + let params: { + query: string; + tlds?: string[]; + limit?: number; + filterType?: DomainSuggestionType; + priceMax?: number; + priceMin?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + query: string; + tlds?: string[]; + limit?: number; + filterType?: DomainSuggestionType; + priceMax?: number; + priceMin?: number; + }; } else { params = { query: paramsOrFirst as string, @@ -475,10 +735,10 @@ export class Domains { limit: rest[1] as number, filterType: rest[2] as DomainSuggestionType, priceMax: rest[3] as number, - priceMin: rest[4] as number + priceMin: rest[4] as number, }; } - + const query = params.query; const tlds = params.tlds; const limit = params.limit; @@ -489,7 +749,6 @@ export class Domains { if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } - const apiPath = '/domains/suggestions'; const payload: Payload = {}; if (typeof query !== 'undefined') { @@ -514,15 +773,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -536,7 +790,13 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createTransferIn(params: { domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean }): Promise; + createTransferIn(params: { + domain: string; + organizationId: string; + authCode: string; + paymentMethodId: string; + autoRenewal?: boolean; + }): Promise; /** * Initiate a domain transfer-in by providing an authorization code, registrant details, and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Transfer In endpoint to capture the payment and submit the transfer. * @@ -549,25 +809,55 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTransferIn(domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean): Promise; createTransferIn( - paramsOrFirst: { domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + domain: string, + organizationId: string, + authCode: string, + paymentMethodId: string, + autoRenewal?: boolean, + ): Promise; + createTransferIn( + paramsOrFirst: + | { + domain: string; + organizationId: string; + authCode: string; + paymentMethodId: string; + autoRenewal?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean }; + let params: { + domain: string; + organizationId: string; + authCode: string; + paymentMethodId: string; + autoRenewal?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + organizationId: string; + authCode: string; + paymentMethodId: string; + autoRenewal?: boolean; + }; } else { params = { domain: paramsOrFirst as string, organizationId: rest[0] as string, authCode: rest[1] as string, paymentMethodId: rest[2] as string, - autoRenewal: rest[3] as boolean + autoRenewal: rest[3] as boolean, }; } - + const domain = params.domain; const organizationId = params.organizationId; const authCode = params.authCode; @@ -578,15 +868,20 @@ export class Domains { throw new AppwriteException('Missing required parameter: "domain"'); } if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof authCode === 'undefined') { - throw new AppwriteException('Missing required parameter: "authCode"'); + throw new AppwriteException( + 'Missing required parameter: "authCode"', + ); } if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); } - const apiPath = '/domains/transfers/in'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -609,15 +904,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -628,7 +918,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - updateTransferIn(params: { invoiceId: string, organizationId: string }): Promise; + updateTransferIn(params: { + invoiceId: string; + organizationId: string; + }): Promise; /** * Finalize a domain transfer-in initiated with Create Transfer In. Verifies that any required 3D Secure authentication is complete, submits the transfer with the authorization code, captures the payment, and sends a confirmation email. Returns a 402 error if authentication is still pending. * @@ -638,33 +931,49 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransferIn(invoiceId: string, organizationId: string): Promise; updateTransferIn( - paramsOrFirst: { invoiceId: string, organizationId: string } | string, - ...rest: [(string)?] + invoiceId: string, + organizationId: string, + ): Promise; + updateTransferIn( + paramsOrFirst: { invoiceId: string; organizationId: string } | string, + ...rest: [string?] ): Promise { - let params: { invoiceId: string, organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { invoiceId: string, organizationId: string }; + let params: { invoiceId: string; organizationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + invoiceId: string; + organizationId: string; + }; } else { params = { invoiceId: paramsOrFirst as string, - organizationId: rest[0] as string + organizationId: rest[0] as string, }; } - + const invoiceId = params.invoiceId; const organizationId = params.organizationId; - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); } if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/domains/transfers/in/{invoiceId}'.replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + const apiPath = '/domains/transfers/in/{invoiceId}'.replace( + '{invoiceId}', + encodeURIComponent(String(invoiceId)), + ); const payload: Payload = {}; if (typeof organizationId !== 'undefined') { payload['organizationId'] = organizationId; @@ -674,15 +983,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -693,7 +997,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createTransferOut(params: { domainId: string, organizationId: string }): Promise; + createTransferOut(params: { + domainId: string; + organizationId: string; + }): Promise; /** * Initiate a domain transfer-out by generating an authorization code for the specified domain. The returned `authCode` should be provided to the gaining provider to complete the transfer. If the domain has auto-renewal enabled, it will be automatically disabled as part of this operation. * @@ -703,32 +1010,45 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTransferOut(domainId: string, organizationId: string): Promise; createTransferOut( - paramsOrFirst: { domainId: string, organizationId: string } | string, - ...rest: [(string)?] + domainId: string, + organizationId: string, + ): Promise; + createTransferOut( + paramsOrFirst: { domainId: string; organizationId: string } | string, + ...rest: [string?] ): Promise { - let params: { domainId: string, organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, organizationId: string }; + let params: { domainId: string; organizationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + organizationId: string; + }; } else { params = { domainId: paramsOrFirst as string, - organizationId: rest[0] as string + organizationId: rest[0] as string, }; } - + const domainId = params.domainId; const organizationId = params.organizationId; if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - const apiPath = '/domains/transfers/out'; const payload: Payload = {}; if (typeof domainId !== 'undefined') { @@ -742,15 +1062,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -770,40 +1085,41 @@ export class Domains { * @deprecated Use the object parameter style method for a better developer experience. */ get(domainId: string): Promise; - get( - paramsOrFirst: { domainId: string } | string - ): Promise { + get(paramsOrFirst: { domainId: string } | string): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -825,41 +1141,42 @@ export class Domains { * @deprecated Use the object parameter style method for a better developer experience. */ delete(domainId: string): Promise<{}>; - delete( - paramsOrFirst: { domainId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { domainId: string } | string): Promise<{}> { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -870,7 +1187,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - updateAutoRenewal(params: { domainId: string, autoRenewal: boolean }): Promise; + updateAutoRenewal(params: { + domainId: string; + autoRenewal: boolean; + }): Promise; /** * Enable or disable auto-renewal for a domain. * @@ -880,33 +1200,49 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAutoRenewal(domainId: string, autoRenewal: boolean): Promise; updateAutoRenewal( - paramsOrFirst: { domainId: string, autoRenewal: boolean } | string, - ...rest: [(boolean)?] + domainId: string, + autoRenewal: boolean, + ): Promise; + updateAutoRenewal( + paramsOrFirst: { domainId: string; autoRenewal: boolean } | string, + ...rest: [boolean?] ): Promise { - let params: { domainId: string, autoRenewal: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, autoRenewal: boolean }; + let params: { domainId: string; autoRenewal: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + autoRenewal: boolean; + }; } else { params = { domainId: paramsOrFirst as string, - autoRenewal: rest[0] as boolean + autoRenewal: rest[0] as boolean, }; } - + const domainId = params.domainId; const autoRenewal = params.autoRenewal; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof autoRenewal === 'undefined') { - throw new AppwriteException('Missing required parameter: "autoRenewal"'); + throw new AppwriteException( + 'Missing required parameter: "autoRenewal"', + ); } - - const apiPath = '/domains/{domainId}/auto-renewal'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/auto-renewal'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof autoRenewal !== 'undefined') { payload['autoRenewal'] = autoRenewal; @@ -916,15 +1252,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -936,7 +1267,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - updateNameservers(params: { domainId: string, nameservers?: string[] }): Promise; + updateNameservers(params: { + domainId: string; + nameservers?: string[]; + }): Promise; /** * Update the registrar nameservers for the given domain. When nameservers are not provided, * the domain will be updated to use Appwrite nameservers. @@ -947,30 +1281,44 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateNameservers(domainId: string, nameservers?: string[]): Promise; updateNameservers( - paramsOrFirst: { domainId: string, nameservers?: string[] } | string, - ...rest: [(string[])?] + domainId: string, + nameservers?: string[], + ): Promise; + updateNameservers( + paramsOrFirst: { domainId: string; nameservers?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { domainId: string, nameservers?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, nameservers?: string[] }; + let params: { domainId: string; nameservers?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + nameservers?: string[]; + }; } else { params = { domainId: paramsOrFirst as string, - nameservers: rest[0] as string[] + nameservers: rest[0] as string[], }; } - + const domainId = params.domainId; const nameservers = params.nameservers; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/nameservers'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/nameservers'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof nameservers !== 'undefined') { payload['nameservers'] = nameservers; @@ -980,15 +1328,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1013,40 +1356,43 @@ export class Domains { */ verifyNameservers(domainId: string): Promise; verifyNameservers( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/nameservers/verification'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/nameservers/verification'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1056,7 +1402,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getPresetGoogleWorkspace(params: { domainId: string }): Promise; + getPresetGoogleWorkspace(params: { + domainId: string; + }): Promise; /** * List Google Workspace DNS records. * @@ -1067,52 +1415,57 @@ export class Domains { */ getPresetGoogleWorkspace(domainId: string): Promise; getPresetGoogleWorkspace( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/google-workspace'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/google-workspace'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Add Google Workspace DNS records to the domain. This will create the required MX records + * Add Google Workspace DNS records to the domain. This will create the required MX records * for Google Workspace email hosting. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} * @returns {Promise} */ - createPresetGoogleWorkspace(params: { domainId: string }): Promise; + createPresetGoogleWorkspace(params: { + domainId: string; + }): Promise; /** - * Add Google Workspace DNS records to the domain. This will create the required MX records + * Add Google Workspace DNS records to the domain. This will create the required MX records * for Google Workspace email hosting. * * @param {string} domainId - Domain unique ID. @@ -1120,42 +1473,47 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPresetGoogleWorkspace(domainId: string): Promise; createPresetGoogleWorkspace( - paramsOrFirst: { domainId: string } | string + domainId: string, + ): Promise; + createPresetGoogleWorkspace( + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/google-workspace'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/google-workspace'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1165,7 +1523,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getPresetICloud(params: { domainId: string }): Promise; + getPresetICloud(params: { + domainId: string; + }): Promise; /** * List iCloud DNS records. * @@ -1176,39 +1536,42 @@ export class Domains { */ getPresetICloud(domainId: string): Promise; getPresetICloud( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/icloud'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/icloud'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1219,7 +1582,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createPresetICloud(params: { domainId: string }): Promise; + createPresetICloud(params: { + domainId: string; + }): Promise; /** * Add iCloud DNS records to the domain. This will create the required MX and SPF records * for using iCloud email services with your domain. @@ -1231,40 +1596,43 @@ export class Domains { */ createPresetICloud(domainId: string): Promise; createPresetICloud( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/icloud'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/icloud'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1274,7 +1642,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getPresetMailgun(params: { domainId: string }): Promise; + getPresetMailgun(params: { + domainId: string; + }): Promise; /** * List Mailgun DNS records. * @@ -1285,52 +1655,57 @@ export class Domains { */ getPresetMailgun(domainId: string): Promise; getPresetMailgun( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/mailgun'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/mailgun'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records + * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records * for Mailgun in the specified domain. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} * @returns {Promise} */ - createPresetMailgun(params: { domainId: string }): Promise; + createPresetMailgun(params: { + domainId: string; + }): Promise; /** - * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records + * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records * for Mailgun in the specified domain. * * @param {string} domainId - Domain unique ID. @@ -1340,40 +1715,43 @@ export class Domains { */ createPresetMailgun(domainId: string): Promise; createPresetMailgun( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/mailgun'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/mailgun'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1383,7 +1761,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getPresetOutlook(params: { domainId: string }): Promise; + getPresetOutlook(params: { + domainId: string; + }): Promise; /** * List Outlook DNS records. * @@ -1394,39 +1774,42 @@ export class Domains { */ getPresetOutlook(domainId: string): Promise; getPresetOutlook( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/outlook'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/outlook'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1437,7 +1820,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createPresetOutlook(params: { domainId: string }): Promise; + createPresetOutlook(params: { + domainId: string; + }): Promise; /** * Add Outlook DNS records to the domain. This will create the required MX records * for setting up Outlook email hosting for your domain. @@ -1449,40 +1834,43 @@ export class Domains { */ createPresetOutlook(domainId: string): Promise; createPresetOutlook( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/outlook'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/outlook'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1492,7 +1880,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getPresetProtonMail(params: { domainId: string }): Promise; + getPresetProtonMail(params: { + domainId: string; + }): Promise; /** * List ProtonMail DNS records. * @@ -1503,39 +1893,42 @@ export class Domains { */ getPresetProtonMail(domainId: string): Promise; getPresetProtonMail( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/proton-mail'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/proton-mail'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1546,7 +1939,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createPresetProtonMail(params: { domainId: string }): Promise; + createPresetProtonMail(params: { + domainId: string; + }): Promise; /** * Add ProtonMail DNS records to the domain. This will create the required MX records * for using ProtonMail with your custom domain. @@ -1558,40 +1953,43 @@ export class Domains { */ createPresetProtonMail(domainId: string): Promise; createPresetProtonMail( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/proton-mail'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/proton-mail'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1612,39 +2010,42 @@ export class Domains { */ getPresetZoho(domainId: string): Promise; getPresetZoho( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/zoho'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/zoho'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1655,7 +2056,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - createPresetZoho(params: { domainId: string }): Promise; + createPresetZoho(params: { + domainId: string; + }): Promise; /** * Add Zoho Mail DNS records to the domain. This will create the required MX records * for setting up Zoho Mail on your domain. @@ -1667,40 +2070,43 @@ export class Domains { */ createPresetZoho(domainId: string): Promise; createPresetZoho( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/presets/zoho'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/presets/zoho'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1712,7 +2118,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - listRecords(params: { domainId: string, queries?: string[] }): Promise; + listRecords(params: { + domainId: string; + queries?: string[]; + }): Promise; /** * List DNS records for a given domain. You can use this endpoint to list all the DNS records * associated with your domain. @@ -1723,30 +2132,44 @@ export class Domains { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRecords(domainId: string, queries?: string[]): Promise; listRecords( - paramsOrFirst: { domainId: string, queries?: string[] } | string, - ...rest: [(string[])?] + domainId: string, + queries?: string[], + ): Promise; + listRecords( + paramsOrFirst: { domainId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { domainId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, queries?: string[] }; + let params: { domainId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + queries?: string[]; + }; } else { params = { domainId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const domainId = params.domainId; const queries = params.queries; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/records'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1755,70 +2178,103 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Create a new A record for the given domain. A records are used to point a domain name + * Create a new A record for the given domain. A records are used to point a domain name * to an IPv4 address. The record value should be a valid IPv4 address. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - IPv4 address for this A record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment explaining what this record is for. * @throws {AppwriteException} * @returns {Promise} */ - createRecordA(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordA(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Create a new A record for the given domain. A records are used to point a domain name + * Create a new A record for the given domain. A records are used to point a domain name * to an IPv4 address. The record value should be a valid IPv4 address. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - IPv4 address for this A record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment explaining what this record is for. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordA(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordA( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordA( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -1829,8 +2285,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/a'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/a'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1849,56 +2307,92 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Update an existing A record for the given domain. This endpoint allows you to modify - * the properties of an A record including its name (subdomain), IPv4 address, TTL, + * Update an existing A record for the given domain. This endpoint allows you to modify + * the properties of an A record including its name (subdomain), IPv4 address, TTL, * and optional comment. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - IPv4 address for this A record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment explaining what this record is for. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordA(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordA(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Update an existing A record for the given domain. This endpoint allows you to modify - * the properties of an A record including its name (subdomain), IPv4 address, TTL, + * Update an existing A record for the given domain. This endpoint allows you to modify + * the properties of an A record including its name (subdomain), IPv4 address, TTL, * and optional comment. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - IPv4 address for this A record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment explaining what this record is for. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordA(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordA( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordA( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -1906,10 +2400,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -1917,11 +2411,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -1932,8 +2430,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/a/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/a/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1952,70 +2451,103 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record + * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record * to your domain. The record will be used to point a hostname to an IPv6 address. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - IPv6 address for this AAAA record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment explaining what this record is for. * @throws {AppwriteException} * @returns {Promise} */ - createRecordAAAA(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordAAAA(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record + * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record * to your domain. The record will be used to point a hostname to an IPv6 address. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - IPv6 address for this AAAA record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment explaining what this record is for. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordAAAA(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordAAAA( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordAAAA( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2026,8 +2558,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/aaaa'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/aaaa'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2046,15 +2580,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2066,12 +2595,19 @@ export class Domains { * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - IPv6 address for this AAAA record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordAAAA(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordAAAA(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** * Update an existing AAAA record for the given domain. This endpoint allows you to modify * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, @@ -2081,21 +2617,55 @@ export class Domains { * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - IPv6 address for this AAAA record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordAAAA(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordAAAA( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordAAAA( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -2103,10 +2673,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -2114,11 +2684,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2129,8 +2703,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/aaaa/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/aaaa/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2149,72 +2724,105 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new ALIAS record for the given domain. This record type can be used to point your domain - * to another domain name that will serve as an alias. This is particularly useful when you want to + * Create a new ALIAS record for the given domain. This record type can be used to point your domain + * to another domain name that will serve as an alias. This is particularly useful when you want to * map your domain to a target domain that may change its IP address. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name. * @param {string} params.value - Target domain for this ALIAS record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordAlias(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordAlias(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Create a new ALIAS record for the given domain. This record type can be used to point your domain - * to another domain name that will serve as an alias. This is particularly useful when you want to + * Create a new ALIAS record for the given domain. This record type can be used to point your domain + * to another domain name that will serve as an alias. This is particularly useful when you want to * map your domain to a target domain that may change its IP address. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name. * @param {string} value - Target domain for this ALIAS record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordAlias(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordAlias( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordAlias( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2225,8 +2833,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/alias'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/alias'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2245,21 +2855,16 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. - * + * * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). * It provides a way to map one domain name to another. * @@ -2267,16 +2872,23 @@ export class Domains { * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name. * @param {string} params.value - Target domain for this ALIAS record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordAlias(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordAlias(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. - * + * * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). * It provides a way to map one domain name to another. * @@ -2284,21 +2896,55 @@ export class Domains { * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name. * @param {string} value - Target domain for this ALIAS record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordAlias(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordAlias( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordAlias( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -2306,10 +2952,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -2317,11 +2963,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2332,8 +2982,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/alias/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/alias/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2352,70 +3003,103 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new CAA record for the given domain. CAA records are used to specify which + * Create a new CAA record for the given domain. CAA records are used to specify which * Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for your domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name. * @param {string} params.value - CAA value (e.g. issuer domain). - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordCAA(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordCAA(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Create a new CAA record for the given domain. CAA records are used to specify which + * Create a new CAA record for the given domain. CAA records are used to specify which * Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for your domain. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name. * @param {string} value - CAA value (e.g. issuer domain). - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordCAA(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordCAA( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordCAA( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2426,8 +3110,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/caa'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/caa'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2446,56 +3132,92 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) - * record is used to specify which certificate authorities (CAs) are authorized to issue certificates + * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) + * record is used to specify which certificate authorities (CAs) are authorized to issue certificates * for a domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name. * @param {string} params.value - CAA value (e.g. issuer domain). - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordCAA(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordCAA(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) - * record is used to specify which certificate authorities (CAs) are authorized to issue certificates + * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) + * record is used to specify which certificate authorities (CAs) are authorized to issue certificates * for a domain. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name. * @param {string} value - CAA value (e.g. issuer domain). - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordCAA(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordCAA( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordCAA( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -2503,10 +3225,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -2514,11 +3236,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2529,8 +3255,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/caa/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/caa/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2549,76 +3276,109 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** * Create a new CNAME record for the given domain. - * - * A CNAME record maps a subdomain to another domain name, allowing you to create aliases - * for your domain. For example, you can create a CNAME record to point 'blog.example.com' + * + * A CNAME record maps a subdomain to another domain name, allowing you to create aliases + * for your domain. For example, you can create a CNAME record to point 'blog.example.com' * to 'example.wordpress.com'. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Canonical target for this CNAME record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordCNAME(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordCNAME(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** * Create a new CNAME record for the given domain. - * - * A CNAME record maps a subdomain to another domain name, allowing you to create aliases - * for your domain. For example, you can create a CNAME record to point 'blog.example.com' + * + * A CNAME record maps a subdomain to another domain name, allowing you to create aliases + * for your domain. For example, you can create a CNAME record to point 'blog.example.com' * to 'example.wordpress.com'. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Canonical target for this CNAME record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordCNAME(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordCNAME( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordCNAME( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2629,8 +3389,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/cname'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/cname'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2649,15 +3411,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2667,12 +3424,19 @@ export class Domains { * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Canonical target for this CNAME record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordCNAME(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordCNAME(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** * Update an existing CNAME record for the given domain. * @@ -2680,21 +3444,55 @@ export class Domains { * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Canonical target for this CNAME record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordCNAME(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordCNAME( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordCNAME( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -2702,10 +3500,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -2713,11 +3511,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2728,8 +3530,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/cname/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/cname/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2748,70 +3551,103 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new HTTPS record for the given domain. This record is used to configure HTTPS + * Create a new HTTPS record for the given domain. This record is used to configure HTTPS * settings for your domain, enabling secure communication over SSL/TLS. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Target for the HTTPS record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordHTTPS(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordHTTPS(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Create a new HTTPS record for the given domain. This record is used to configure HTTPS + * Create a new HTTPS record for the given domain. This record is used to configure HTTPS * settings for your domain, enabling secure communication over SSL/TLS. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Target for the HTTPS record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordHTTPS(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordHTTPS( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordHTTPS( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2822,8 +3658,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/https'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/https'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2842,56 +3680,92 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Update an existing HTTPS record for the given domain. This endpoint allows you to modify - * the properties of an HTTPS record associated with your domain, including the name (subdomain), + * Update an existing HTTPS record for the given domain. This endpoint allows you to modify + * the properties of an HTTPS record associated with your domain, including the name (subdomain), * target value, TTL, and optional comment. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Target for the HTTPS record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordHTTPS(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordHTTPS(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Update an existing HTTPS record for the given domain. This endpoint allows you to modify - * the properties of an HTTPS record associated with your domain, including the name (subdomain), + * Update an existing HTTPS record for the given domain. This endpoint allows you to modify + * the properties of an HTTPS record associated with your domain, including the name (subdomain), * target value, TTL, and optional comment. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Target for the HTTPS record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordHTTPS(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordHTTPS( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordHTTPS( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -2899,10 +3773,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -2910,11 +3784,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -2925,8 +3803,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/https/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/https/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2945,58 +3824,94 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new MX record for the given domain. MX records are used to define the mail servers responsible + * Create a new MX record for the given domain. MX records are used to define the mail servers responsible * for accepting email messages for the domain. Multiple MX records can be created with different priorities. - * The priority parameter determines the order in which mail servers are used, with lower values indicating + * The priority parameter determines the order in which mail servers are used, with lower values indicating * higher priority. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Mail server domain for this MX record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} params.priority - MX priority. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - MX priority. Lower values are tried first. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordMX(params: { domainId: string, name: string, value: string, ttl: number, priority: number, comment?: string }): Promise; + createRecordMX(params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }): Promise; /** - * Create a new MX record for the given domain. MX records are used to define the mail servers responsible + * Create a new MX record for the given domain. MX records are used to define the mail servers responsible * for accepting email messages for the domain. Multiple MX records can be created with different priorities. - * The priority parameter determines the order in which mail servers are used, with lower values indicating + * The priority parameter determines the order in which mail servers are used, with lower values indicating * higher priority. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Mail server domain for this MX record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} priority - MX priority. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - MX priority. Lower values are tried first. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordMX(domainId: string, name: string, value: string, ttl: number, priority: number, comment?: string): Promise; createRecordMX( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, priority: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + priority: number, + comment?: string, + ): Promise; + createRecordMX( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, priority: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, priority: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -3004,10 +3919,10 @@ export class Domains { value: rest[1] as string, ttl: rest[2] as number, priority: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; @@ -3015,8 +3930,10 @@ export class Domains { const priority = params.priority; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3028,10 +3945,14 @@ export class Domains { throw new AppwriteException('Missing required parameter: "ttl"'); } if (typeof priority === 'undefined') { - throw new AppwriteException('Missing required parameter: "priority"'); + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); } - - const apiPath = '/domains/{domainId}/records/mx'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/mx'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3053,15 +3974,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3071,13 +3987,21 @@ export class Domains { * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Mail server domain for this MX record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} params.priority - MX priority. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - MX priority. Lower values are tried first. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordMX(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, comment?: string }): Promise; + updateRecordMX(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }): Promise; /** * Update an existing MX record for the given domain. * @@ -3085,22 +4009,60 @@ export class Domains { * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Mail server domain for this MX record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} priority - MX priority. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - MX priority. Lower values are tried first. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordMX(domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, comment?: string): Promise; updateRecordMX( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + priority: number, + comment?: string, + ): Promise; + updateRecordMX( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -3109,10 +4071,10 @@ export class Domains { value: rest[2] as string, ttl: rest[3] as number, priority: rest[4] as number, - comment: rest[5] as string + comment: rest[5] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -3121,11 +4083,15 @@ export class Domains { const priority = params.priority; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3137,10 +4103,13 @@ export class Domains { throw new AppwriteException('Missing required parameter: "ttl"'); } if (typeof priority === 'undefined') { - throw new AppwriteException('Missing required parameter: "priority"'); + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); } - - const apiPath = '/domains/{domainId}/records/mx/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/mx/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3162,70 +4131,103 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new NS record for the given domain. NS records specify the nameservers that are used + * Create a new NS record for the given domain. NS records specify the nameservers that are used * to resolve the domain name to IP addresses. Each domain can have multiple NS records. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Nameserver target for this NS record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordNS(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + createRecordNS(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Create a new NS record for the given domain. NS records specify the nameservers that are used + * Create a new NS record for the given domain. NS records specify the nameservers that are used * to resolve the domain name to IP addresses. Each domain can have multiple NS records. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Nameserver target for this NS record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordNS(domainId: string, name: string, value: string, ttl: number, comment?: string): Promise; createRecordNS( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordNS( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, value: rest[1] as string, ttl: rest[2] as number, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3236,8 +4238,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/ns'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/ns'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3256,58 +4260,94 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Update an existing NS record for the given domain. This endpoint allows you to modify - * the properties of an NS (nameserver) record associated with your domain. You can update - * the record name (subdomain), target nameserver value, TTL, and add or modify comments + * Update an existing NS record for the given domain. This endpoint allows you to modify + * the properties of an NS (nameserver) record associated with your domain. You can update + * the record name (subdomain), target nameserver value, TTL, and add or modify comments * for better record management. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain). * @param {string} params.value - Nameserver target for this NS record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordNS(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordNS(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** - * Update an existing NS record for the given domain. This endpoint allows you to modify - * the properties of an NS (nameserver) record associated with your domain. You can update - * the record name (subdomain), target nameserver value, TTL, and add or modify comments + * Update an existing NS record for the given domain. This endpoint allows you to modify + * the properties of an NS (nameserver) record associated with your domain. You can update + * the record name (subdomain), target nameserver value, TTL, and add or modify comments * for better record management. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain). * @param {string} value - Nameserver target for this NS record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordNS(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordNS( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordNS( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -3315,10 +4355,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -3326,11 +4366,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3341,8 +4385,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/ns/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/ns/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3361,60 +4406,106 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new SRV record for the given domain. SRV records are used to define the location - * of servers for specific services. For example, they can be used to specify which server + * Create a new SRV record for the given domain. SRV records are used to define the location + * of servers for specific services. For example, they can be used to specify which server * handles a specific service like SIP or XMPP for the domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (service name). * @param {string} params.value - Target hostname for this SRV record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} params.priority - Record priority. - * @param {number} params.weight - Record weight. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - Record priority. Lower values are tried first. + * @param {number} params.weight - Record weight, used to share load between targets of equal priority. * @param {number} params.port - Port number for the service. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordSRV(params: { domainId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }): Promise; + createRecordSRV(params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }): Promise; /** - * Create a new SRV record for the given domain. SRV records are used to define the location - * of servers for specific services. For example, they can be used to specify which server + * Create a new SRV record for the given domain. SRV records are used to define the location + * of servers for specific services. For example, they can be used to specify which server * handles a specific service like SIP or XMPP for the domain. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (service name). * @param {string} value - Target hostname for this SRV record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} priority - Record priority. - * @param {number} weight - Record weight. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - Record priority. Lower values are tried first. + * @param {number} weight - Record weight, used to share load between targets of equal priority. * @param {number} port - Port number for the service. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordSRV(domainId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string): Promise; createRecordSRV( - paramsOrFirst: { domainId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?, (number)?, (number)?, (string)?] + domainId: string, + name: string, + value: string, + ttl: number, + priority: number, + weight: number, + port: number, + comment?: string, + ): Promise; + createRecordSRV( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, number?, number?, number?, string?] ): Promise { - let params: { domainId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }; + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -3424,10 +4515,10 @@ export class Domains { priority: rest[3] as number, weight: rest[4] as number, port: rest[5] as number, - comment: rest[6] as string + comment: rest[6] as string, }; } - + const domainId = params.domainId; const name = params.name; const value = params.value; @@ -3437,8 +4528,10 @@ export class Domains { const port = params.port; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3450,7 +4543,9 @@ export class Domains { throw new AppwriteException('Missing required parameter: "ttl"'); } if (typeof priority === 'undefined') { - throw new AppwriteException('Missing required parameter: "priority"'); + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); } if (typeof weight === 'undefined') { throw new AppwriteException('Missing required parameter: "weight"'); @@ -3458,8 +4553,10 @@ export class Domains { if (typeof port === 'undefined') { throw new AppwriteException('Missing required parameter: "port"'); } - - const apiPath = '/domains/{domainId}/records/srv'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/srv'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3487,20 +4584,15 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an existing SRV record for the given domain. - * + * * Required parameters: * - domainId: Domain unique ID * - recordId: DNS record unique ID @@ -3510,7 +4602,7 @@ export class Domains { * - priority: Record priority * - weight: Record weight * - port: Port number for the service - * + * * Optional parameters: * - comment: A comment for this record * @@ -3518,18 +4610,28 @@ export class Domains { * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (service name). * @param {string} params.value - Target hostname for this SRV record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} params.priority - Record priority. - * @param {number} params.weight - Record weight. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - Record priority. Lower values are tried first. + * @param {number} params.weight - Record weight, used to share load between targets of equal priority. * @param {number} params.port - Port number for the service. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordSRV(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }): Promise; + updateRecordSRV(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }): Promise; /** * Update an existing SRV record for the given domain. - * + * * Required parameters: * - domainId: Domain unique ID * - recordId: DNS record unique ID @@ -3539,7 +4641,7 @@ export class Domains { * - priority: Record priority * - weight: Record weight * - port: Port number for the service - * + * * Optional parameters: * - comment: A comment for this record * @@ -3547,24 +4649,79 @@ export class Domains { * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (service name). * @param {string} value - Target hostname for this SRV record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. - * @param {number} priority - Record priority. - * @param {number} weight - Record weight. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - Record priority. Lower values are tried first. + * @param {number} weight - Record weight, used to share load between targets of equal priority. * @param {number} port - Port number for the service. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordSRV(domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string): Promise; updateRecordSRV( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (number)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + priority: number, + weight: number, + port: number, + comment?: string, + ): Promise; + updateRecordSRV( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + number?, + number?, + number?, + string?, + ] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -3575,10 +4732,10 @@ export class Domains { priority: rest[4] as number, weight: rest[5] as number, port: rest[6] as number, - comment: rest[7] as string + comment: rest[7] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -3589,11 +4746,15 @@ export class Domains { const port = params.port; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3605,7 +4766,9 @@ export class Domains { throw new AppwriteException('Missing required parameter: "ttl"'); } if (typeof priority === 'undefined') { - throw new AppwriteException('Missing required parameter: "priority"'); + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); } if (typeof weight === 'undefined') { throw new AppwriteException('Missing required parameter: "weight"'); @@ -3613,8 +4776,9 @@ export class Domains { if (typeof port === 'undefined') { throw new AppwriteException('Missing required parameter: "port"'); } - - const apiPath = '/domains/{domainId}/records/srv/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/srv/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3642,72 +4806,105 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Create a new TXT record for the given domain. TXT records can be used - * to provide additional information about your domain, such as domain + * Create a new TXT record for the given domain. TXT records can be used + * to provide additional information about your domain, such as domain * verification records, SPF records, or DKIM records. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain) for the TXT record. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.value - TXT record value. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - createRecordTXT(params: { domainId: string, name: string, ttl: number, value?: string, comment?: string }): Promise; + createRecordTXT(params: { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + }): Promise; /** - * Create a new TXT record for the given domain. TXT records can be used - * to provide additional information about your domain, such as domain + * Create a new TXT record for the given domain. TXT records can be used + * to provide additional information about your domain, such as domain * verification records, SPF records, or DKIM records. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain) for the TXT record. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} value - TXT record value. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRecordTXT(domainId: string, name: string, ttl: number, value?: string, comment?: string): Promise; createRecordTXT( - paramsOrFirst: { domainId: string, name: string, ttl: number, value?: string, comment?: string } | string, - ...rest: [(string)?, (number)?, (string)?, (string)?] + domainId: string, + name: string, + ttl: number, + value?: string, + comment?: string, + ): Promise; + createRecordTXT( + paramsOrFirst: + | { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + } + | string, + ...rest: [string?, number?, string?, string?] ): Promise { - let params: { domainId: string, name: string, ttl: number, value?: string, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, name: string, ttl: number, value?: string, comment?: string }; + let params: { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, name: rest[0] as string, ttl: rest[1] as number, value: rest[2] as string, - comment: rest[3] as string + comment: rest[3] as string, }; } - + const domainId = params.domainId; const name = params.name; const ttl = params.ttl; const value = params.value; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3715,8 +4912,10 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/txt'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/records/txt'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3735,20 +4934,15 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an existing TXT record for the given domain. - * + * * Update the TXT record details for a specific domain by providing the domain ID, * record ID, and the new record configuration including name, value, TTL, and an optional comment. * @@ -3756,15 +4950,22 @@ export class Domains { * @param {string} params.recordId - DNS record unique ID. * @param {string} params.name - Record name (subdomain) for the TXT record. * @param {string} params.value - TXT record value. - * @param {number} params.ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} params.comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} */ - updateRecordTXT(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; + updateRecordTXT(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; /** * Update an existing TXT record for the given domain. - * + * * Update the TXT record details for a specific domain by providing the domain ID, * record ID, and the new record configuration including name, value, TTL, and an optional comment. * @@ -3772,21 +4973,55 @@ export class Domains { * @param {string} recordId - DNS record unique ID. * @param {string} name - Record name (subdomain) for the TXT record. * @param {string} value - TXT record value. - * @param {number} ttl - Time to live, in seconds. Must be greater than 0. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. * @param {string} comment - A comment for this record. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecordTXT(domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string): Promise; updateRecordTXT( - paramsOrFirst: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?] + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordTXT( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] ): Promise { - let params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }; + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; } else { params = { domainId: paramsOrFirst as string, @@ -3794,10 +5029,10 @@ export class Domains { name: rest[1] as string, value: rest[2] as string, ttl: rest[3] as number, - comment: rest[4] as string + comment: rest[4] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; const name = params.name; @@ -3805,11 +5040,15 @@ export class Domains { const ttl = params.ttl; const comment = params.comment; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3820,8 +5059,9 @@ export class Domains { if (typeof ttl === 'undefined') { throw new AppwriteException('Missing required parameter: "ttl"'); } - - const apiPath = '/domains/{domainId}/records/txt/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/txt/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3840,20 +5080,15 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** * Get a single DNS record for a given domain by record ID. - * + * * This endpoint allows you to retrieve a specific DNS record associated with a domain * using its unique identifier. The record contains information about the DNS configuration * such as type, value, and TTL settings. @@ -3863,10 +5098,13 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getRecord(params: { domainId: string, recordId: string }): Promise; + getRecord(params: { + domainId: string; + recordId: string; + }): Promise; /** * Get a single DNS record for a given domain by record ID. - * + * * This endpoint allows you to retrieve a specific DNS record associated with a domain * using its unique identifier. The record contains information about the DNS configuration * such as type, value, and TTL settings. @@ -3879,49 +5117,56 @@ export class Domains { */ getRecord(domainId: string, recordId: string): Promise; getRecord( - paramsOrFirst: { domainId: string, recordId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { domainId: string; recordId: string } | string, + ...rest: [string?] ): Promise { - let params: { domainId: string, recordId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string }; + let params: { domainId: string; recordId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + }; } else { params = { domainId: paramsOrFirst as string, - recordId: rest[0] as string + recordId: rest[0] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } - - const apiPath = '/domains/{domainId}/records/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record + * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record * from a specific domain. * * @param {string} params.domainId - Domain unique ID. @@ -3929,9 +5174,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteRecord(params: { domainId: string, recordId: string }): Promise<{}>; + deleteRecord(params: { domainId: string; recordId: string }): Promise<{}>; /** - * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record + * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record * from a specific domain. * * @param {string} domainId - Domain unique ID. @@ -3942,51 +5187,59 @@ export class Domains { */ deleteRecord(domainId: string, recordId: string): Promise<{}>; deleteRecord( - paramsOrFirst: { domainId: string, recordId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { domainId: string; recordId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { domainId: string, recordId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, recordId: string }; + let params: { domainId: string; recordId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + }; } else { params = { domainId: paramsOrFirst as string, - recordId: rest[0] as string + recordId: rest[0] as string, }; } - + const domainId = params.domainId; const recordId = params.recordId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - if (typeof recordId === 'undefined') { - throw new AppwriteException('Missing required parameter: "recordId"'); + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); } - - const apiPath = '/domains/{domainId}/records/{recordId}'.replace('{domainId}', encodeURIComponent(String(domainId))).replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPath = '/domains/{domainId}/records/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Update the team ID for a specific domain. This endpoint requires admin access. - * + * Update the team ID for a specific domain. The caller must administer the current + * team and be an owner of the destination team. + * * Updating the team ID will transfer ownership and access control of the domain * and all its DNS records to the new team. * @@ -3995,10 +5248,14 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - updateTeam(params: { domainId: string, teamId: string }): Promise; + updateTeam(params: { + domainId: string; + teamId: string; + }): Promise; /** - * Update the team ID for a specific domain. This endpoint requires admin access. - * + * Update the team ID for a specific domain. The caller must administer the current + * team and be an owner of the destination team. + * * Updating the team ID will transfer ownership and access control of the domain * and all its DNS records to the new team. * @@ -4010,31 +5267,42 @@ export class Domains { */ updateTeam(domainId: string, teamId: string): Promise; updateTeam( - paramsOrFirst: { domainId: string, teamId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { domainId: string; teamId: string } | string, + ...rest: [string?] ): Promise { - let params: { domainId: string, teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, teamId: string }; + let params: { domainId: string; teamId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + teamId: string; + }; } else { params = { domainId: paramsOrFirst as string, - teamId: rest[0] as string + teamId: rest[0] as string, }; } - + const domainId = params.domainId; const teamId = params.teamId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/domains/{domainId}/team'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/team'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof teamId !== 'undefined') { payload['teamId'] = teamId; @@ -4044,15 +5312,10 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4062,7 +5325,9 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - getTransferStatus(params: { domainId: string }): Promise; + getTransferStatus(params: { + domainId: string; + }): Promise; /** * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. * @@ -4073,39 +5338,42 @@ export class Domains { */ getTransferStatus(domainId: string): Promise; getTransferStatus( - paramsOrFirst: { domainId: string } | string + paramsOrFirst: { domainId: string } | string, ): Promise { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/transfers/status'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/transfers/status'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4127,40 +5395,41 @@ export class Domains { * @deprecated Use the object parameter style method for a better developer experience. */ getZone(domainId: string): Promise<{}>; - getZone( - paramsOrFirst: { domainId: string } | string - ): Promise<{}> { + getZone(paramsOrFirst: { domainId: string } | string): Promise<{}> { let params: { domainId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domainId: string }; } else { params = { - domainId: paramsOrFirst as string + domainId: paramsOrFirst as string, }; } - + const domainId = params.domainId; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } - - const apiPath = '/domains/{domainId}/zone'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/zone'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'text/plain', - } + accept: 'text/plain', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4172,7 +5441,10 @@ export class Domains { * @throws {AppwriteException} * @returns {Promise} */ - updateZone(params: { domainId: string, content: string }): Promise; + updateZone(params: { + domainId: string; + content: string; + }): Promise; /** * Update the DNS zone for the given domain using the provided zone file content. * All parsed records are imported and then the main domain document is returned. @@ -4185,31 +5457,44 @@ export class Domains { */ updateZone(domainId: string, content: string): Promise; updateZone( - paramsOrFirst: { domainId: string, content: string } | string, - ...rest: [(string)?] + paramsOrFirst: { domainId: string; content: string } | string, + ...rest: [string?] ): Promise { - let params: { domainId: string, content: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domainId: string, content: string }; + let params: { domainId: string; content: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + content: string; + }; } else { params = { domainId: paramsOrFirst as string, - content: rest[0] as string + content: rest[0] as string, }; } - + const domainId = params.domainId; const content = params.content; - if (typeof domainId === 'undefined') { - throw new AppwriteException('Missing required parameter: "domainId"'); + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - - const apiPath = '/domains/{domainId}/zone'.replace('{domainId}', encodeURIComponent(String(domainId))); + const apiPath = '/domains/{domainId}/zone'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); const payload: Payload = {}; if (typeof content !== 'undefined') { payload['content'] = content; @@ -4219,14 +5504,9 @@ export class Domains { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index 7eac1e80..29f3f00c 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,9 +1,7 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; - export class Embeddings { client: Client; @@ -13,17 +11,20 @@ export class Embeddings { /** * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. - * + * * * @param {string[]} params.texts - Array of text to generate embeddings. * @param {EmbeddingModel} params.model - The embedding model to use for generating vector embeddings. * @throws {AppwriteException} * @returns {Promise} */ - createTextEmbeddings(params: { texts: string[], model?: EmbeddingModel }): Promise; + createTextEmbeddings(params: { + texts: string[]; + model?: EmbeddingModel; + }): Promise; /** * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. - * + * * * @param {string[]} texts - Array of text to generate embeddings. * @param {EmbeddingModel} model - The embedding model to use for generating vector embeddings. @@ -31,29 +32,38 @@ export class Embeddings { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextEmbeddings(texts: string[], model?: EmbeddingModel): Promise; createTextEmbeddings( - paramsOrFirst: { texts: string[], model?: EmbeddingModel } | string[], - ...rest: [(EmbeddingModel)?] + texts: string[], + model?: EmbeddingModel, + ): Promise; + createTextEmbeddings( + paramsOrFirst: { texts: string[]; model?: EmbeddingModel } | string[], + ...rest: [EmbeddingModel?] ): Promise { - let params: { texts: string[], model?: EmbeddingModel }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { texts: string[], model?: EmbeddingModel }; + let params: { texts: string[]; model?: EmbeddingModel }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + texts: string[]; + model?: EmbeddingModel; + }; } else { params = { texts: paramsOrFirst as string[], - model: rest[0] as EmbeddingModel + model: rest[0] as EmbeddingModel, }; } - + const texts = params.texts; const model = params.model; if (typeof texts === 'undefined') { throw new AppwriteException('Missing required parameter: "texts"'); } - const apiPath = '/embeddings/text'; const payload: Payload = {}; if (typeof texts !== 'undefined') { @@ -67,14 +77,9 @@ export class Embeddings { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 56dd6c2f..c91f7e93 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,5 +1,10 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; import type { Models } from '../models'; import { Runtime } from '../enums/runtime'; @@ -9,7 +14,6 @@ import { TemplateReferenceType } from '../enums/template-reference-type'; import { VCSReferenceType } from '../enums/vcs-reference-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; import { ExecutionMethod } from '../enums/execution-method'; - export class Functions { client: Client; @@ -26,7 +30,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the project's functions. You can use the query params to filter your results. * @@ -37,28 +45,41 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/functions'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -74,15 +95,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -113,7 +129,30 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + create(params: { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }): Promise; /** * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. * @@ -143,15 +182,135 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (ProjectKeyScopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + functionId: string, + name: string, + runtime: Runtime, + execute?: string[], + events?: string[], + schedule?: string, + timeout?: number, + enabled?: boolean, + logging?: boolean, + entrypoint?: string, + commands?: string, + scopes?: ProjectKeyScopes[], + installationId?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + ): Promise; + create( + paramsOrFirst: + | { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + } + | string, + ...rest: [ + string?, + Runtime?, + string[]?, + string[]?, + string?, + number?, + boolean?, + boolean?, + string?, + string?, + ProjectKeyScopes[]?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ] ): Promise { - let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; } else { params = { functionId: paramsOrFirst as string, @@ -175,10 +334,10 @@ export class Functions { providerPaths: rest[17] as string[], buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, - deploymentRetention: rest[20] as number + deploymentRetention: rest[20] as number, }; } - + const functionId = params.functionId; const name = params.name; const runtime = params.runtime; @@ -203,15 +362,18 @@ export class Functions { const deploymentRetention = params.deploymentRetention; if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof runtime === 'undefined') { - throw new AppwriteException('Missing required parameter: "runtime"'); + throw new AppwriteException( + 'Missing required parameter: "runtime"', + ); } - const apiPath = '/functions'; const payload: Payload = {}; if (typeof functionId !== 'undefined') { @@ -285,15 +447,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -303,56 +460,56 @@ export class Functions { * @returns {Promise} */ listRuntimes(): Promise { - const apiPath = '/functions/runtimes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * List allowed function specifications for this instance. * - * @param {string} params.type - Specification type to list. Can be one of: runtimes, builds. + * @param {string} params.type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. * @throws {AppwriteException} * @returns {Promise} */ - listSpecifications(params?: { type?: string }): Promise; + listSpecifications(params?: { + type?: string; + }): Promise; /** * List allowed function specifications for this instance. * - * @param {string} type - Specification type to list. Can be one of: runtimes, builds. + * @param {string} type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ listSpecifications(type?: string): Promise; listSpecifications( - paramsOrFirst?: { type?: string } | string + paramsOrFirst?: { type?: string } | string, ): Promise { let params: { type?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { type?: string }; } else { params = { - type: paramsOrFirst as string + type: paramsOrFirst as string, }; } - - const type = params.type; + const type = params.type; const apiPath = '/functions/specifications'; const payload: Payload = {}; @@ -363,15 +520,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -385,7 +537,13 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listTemplates(params?: { runtimes?: Runtime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean }): Promise; + listTemplates(params?: { + runtimes?: Runtime[]; + useCases?: FunctionTemplateUseCase[]; + limit?: number; + offset?: number; + total?: boolean; + }): Promise; /** * List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. * @@ -398,32 +556,67 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTemplates(runtimes?: Runtime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean): Promise; listTemplates( - paramsOrFirst?: { runtimes?: Runtime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean } | Runtime[], - ...rest: [(FunctionTemplateUseCase[])?, (number)?, (number)?, (boolean)?] + runtimes?: Runtime[], + useCases?: FunctionTemplateUseCase[], + limit?: number, + offset?: number, + total?: boolean, + ): Promise; + listTemplates( + paramsOrFirst?: + | { + runtimes?: Runtime[]; + useCases?: FunctionTemplateUseCase[]; + limit?: number; + offset?: number; + total?: boolean; + } + | Runtime[], + ...rest: [FunctionTemplateUseCase[]?, number?, number?, boolean?] ): Promise { - let params: { runtimes?: Runtime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('runtimes' in paramsOrFirst || 'useCases' in paramsOrFirst || 'limit' in paramsOrFirst || 'offset' in paramsOrFirst || 'total' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { runtimes?: Runtime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean }; + let params: { + runtimes?: Runtime[]; + useCases?: FunctionTemplateUseCase[]; + limit?: number; + offset?: number; + total?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('runtimes' in paramsOrFirst || + 'useCases' in paramsOrFirst || + 'limit' in paramsOrFirst || + 'offset' in paramsOrFirst || + 'total' in paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + runtimes?: Runtime[]; + useCases?: FunctionTemplateUseCase[]; + limit?: number; + offset?: number; + total?: boolean; + }; } else { params = { runtimes: paramsOrFirst as Runtime[], useCases: rest[0] as FunctionTemplateUseCase[], limit: rest[1] as number, offset: rest[2] as number, - total: rest[3] as boolean + total: rest[3] as boolean, }; } - + const runtimes = params.runtimes; const useCases = params.useCases; const limit = params.limit; const offset = params.offset; const total = params.total; - const apiPath = '/functions/templates'; const payload: Payload = {}; if (typeof runtimes !== 'undefined') { @@ -445,15 +638,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -463,7 +651,9 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getTemplate(params: { templateId: string }): Promise; + getTemplate(params: { + templateId: string; + }): Promise; /** * Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. * @@ -474,39 +664,42 @@ export class Functions { */ getTemplate(templateId: string): Promise; getTemplate( - paramsOrFirst: { templateId: string } | string + paramsOrFirst: { templateId: string } | string, ): Promise { let params: { templateId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { templateId: string }; } else { params = { - templateId: paramsOrFirst as string + templateId: paramsOrFirst as string, }; } - + const templateId = params.templateId; - if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + if (typeof templateId === 'undefined' || templateId === '') { + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - - const apiPath = '/functions/templates/{templateId}'.replace('{templateId}', encodeURIComponent(String(templateId))); + const apiPath = '/functions/templates/{templateId}'.replace( + '{templateId}', + encodeURIComponent(String(templateId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -527,39 +720,42 @@ export class Functions { */ get(functionId: string): Promise; get( - paramsOrFirst: { functionId: string } | string + paramsOrFirst: { functionId: string } | string, ): Promise { let params: { functionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { functionId: string }; } else { params = { - functionId: paramsOrFirst as string + functionId: paramsOrFirst as string, }; } - + const functionId = params.functionId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -590,7 +786,30 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + update(params: { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }): Promise; /** * Update function by its unique ID. * @@ -620,15 +839,135 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (ProjectKeyScopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + functionId: string, + name: string, + runtime?: Runtime, + execute?: string[], + events?: string[], + schedule?: string, + timeout?: number, + enabled?: boolean, + logging?: boolean, + entrypoint?: string, + commands?: string, + scopes?: ProjectKeyScopes[], + installationId?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + ): Promise; + update( + paramsOrFirst: + | { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + } + | string, + ...rest: [ + string?, + Runtime?, + string[]?, + string[]?, + string?, + number?, + boolean?, + boolean?, + string?, + string?, + ProjectKeyScopes[]?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ] ): Promise { - let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; } else { params = { functionId: paramsOrFirst as string, @@ -652,10 +991,10 @@ export class Functions { providerPaths: rest[17] as string[], buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, - deploymentRetention: rest[20] as number + deploymentRetention: rest[20] as number, }; } - + const functionId = params.functionId; const name = params.name; const runtime = params.runtime; @@ -679,14 +1018,18 @@ export class Functions { const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/functions/{functionId}'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -756,15 +1099,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -784,40 +1122,42 @@ export class Functions { * @deprecated Use the object parameter style method for a better developer experience. */ delete(functionId: string): Promise<{}>; - delete( - paramsOrFirst: { functionId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { functionId: string } | string): Promise<{}> { let params: { functionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { functionId: string }; } else { params = { - functionId: paramsOrFirst as string + functionId: paramsOrFirst as string, }; } - + const functionId = params.functionId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -828,7 +1168,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - updateFunctionDeployment(params: { functionId: string, deploymentId: string }): Promise; + updateFunctionDeployment(params: { + functionId: string; + deploymentId: string; + }): Promise; /** * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. * @@ -838,33 +1181,49 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFunctionDeployment(functionId: string, deploymentId: string): Promise; updateFunctionDeployment( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + functionId: string, + deploymentId: string, + ): Promise; + updateFunctionDeployment( + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/deployment'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { payload['deploymentId'] = deploymentId; @@ -874,15 +1233,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -895,7 +1249,12 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listDeployments(params: { functionId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listDeployments(params: { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the function's code deployments. You can use the query params to filter your results. * @@ -907,34 +1266,64 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listDeployments(functionId: string, queries?: string[], search?: string, total?: boolean): Promise; listDeployments( - paramsOrFirst: { functionId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + functionId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listDeployments( + paramsOrFirst: + | { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { functionId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const functionId = params.functionId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/deployments'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -949,22 +1338,17 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. - * + * * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). - * + * * Use the "command" param to set the entrypoint used to execute your code. * * @param {string} params.functionId - Function ID. @@ -975,12 +1359,19 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createDeployment(params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void }): Promise; + createDeployment(params: { + functionId: string; + code: File; + activate: boolean; + entrypoint?: string; + commands?: string; + onProgress?: (progress: UploadProgress) => void; + }): Promise; /** * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. - * + * * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). - * + * * Use the "command" param to set the entrypoint used to execute your code. * * @param {string} functionId - Function ID. @@ -992,45 +1383,91 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise; createDeployment( - paramsOrFirst: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(File)?, (boolean)?, (string)?, (string)?,((progress: UploadProgress) => void)?] + functionId: string, + code: File, + activate: boolean, + entrypoint?: string, + commands?: string, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createDeployment( + paramsOrFirst: + | { + functionId: string; + code: File; + activate: boolean; + entrypoint?: string; + commands?: string; + onProgress?: (progress: UploadProgress) => void; + } + | string, + ...rest: [ + File?, + boolean?, + string?, + string?, + ((progress: UploadProgress) => void)?, + ] ): Promise { - let params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; - let onProgress: ((progress: UploadProgress) => void); - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; - onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + let params: { + functionId: string; + code: File; + activate: boolean; + entrypoint?: string; + commands?: string; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + code: File; + activate: boolean; + entrypoint?: string; + commands?: string; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; } else { params = { functionId: paramsOrFirst as string, code: rest[0] as File, activate: rest[1] as boolean, entrypoint: rest[2] as string, - commands: rest[3] as string + commands: rest[3] as string, }; - onProgress = rest[4] as ((progress: UploadProgress) => void); + onProgress = rest[4] as (progress: UploadProgress) => void; } - + const functionId = params.functionId; const code = params.code; const activate = params.activate; const entrypoint = params.entrypoint; const commands = params.commands; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } if (typeof activate === 'undefined') { - throw new AppwriteException('Missing required parameter: "activate"'); + throw new AppwriteException( + 'Missing required parameter: "activate"', + ); } - - const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/deployments'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof entrypoint !== 'undefined') { payload['entrypoint'] = entrypoint; @@ -1049,15 +1486,15 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'multipart/form-data', - 'accept': 'application/json', - } + accept: 'application/json', + }; return this.client.chunkedUpload( 'post', uri, apiHeaders, payload, - onProgress + onProgress, ); } @@ -1070,7 +1507,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createDuplicateDeployment(params: { functionId: string, deploymentId: string, buildId?: string }): Promise; + createDuplicateDeployment(params: { + functionId: string; + deploymentId: string; + buildId?: string; + }): Promise; /** * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * @@ -1081,35 +1522,59 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDuplicateDeployment(functionId: string, deploymentId: string, buildId?: string): Promise; createDuplicateDeployment( - paramsOrFirst: { functionId: string, deploymentId: string, buildId?: string } | string, - ...rest: [(string)?, (string)?] + functionId: string, + deploymentId: string, + buildId?: string, + ): Promise; + createDuplicateDeployment( + paramsOrFirst: + | { functionId: string; deploymentId: string; buildId?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { functionId: string, deploymentId: string, buildId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, buildId?: string }; + let params: { + functionId: string; + deploymentId: string; + buildId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + buildId?: string; + }; } else { params = { functionId: paramsOrFirst as string, deploymentId: rest[0] as string, - buildId: rest[1] as string + buildId: rest[1] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; const buildId = params.buildId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/deployments/duplicate'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { payload['deploymentId'] = deploymentId; @@ -1122,20 +1587,15 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. * * @param {string} params.functionId - Function ID. @@ -1148,10 +1608,18 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createTemplateDeployment(params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise; + createTemplateDeployment(params: { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. * * @param {string} functionId - Function ID. @@ -1165,15 +1633,60 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise; createTemplateDeployment( - paramsOrFirst: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] + functionId: string, + repository: string, + owner: string, + rootDirectory: string, + type: TemplateReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createTemplateDeployment( + paramsOrFirst: + | { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + TemplateReferenceType?, + string?, + boolean?, + ] ): Promise { - let params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + let params: { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, @@ -1182,10 +1695,10 @@ export class Functions { rootDirectory: rest[2] as string, type: rest[3] as TemplateReferenceType, reference: rest[4] as string, - activate: rest[5] as boolean + activate: rest[5] as boolean, }; } - + const functionId = params.functionId; const repository = params.repository; const owner = params.owner; @@ -1194,26 +1707,36 @@ export class Functions { const reference = params.reference; const activate = params.activate; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof repository === 'undefined') { - throw new AppwriteException('Missing required parameter: "repository"'); + throw new AppwriteException( + 'Missing required parameter: "repository"', + ); } if (typeof owner === 'undefined') { throw new AppwriteException('Missing required parameter: "owner"'); } if (typeof rootDirectory === 'undefined') { - throw new AppwriteException('Missing required parameter: "rootDirectory"'); + throw new AppwriteException( + 'Missing required parameter: "rootDirectory"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/deployments/template'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof repository !== 'undefined') { payload['repository'] = repository; @@ -1238,20 +1761,15 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a deployment when a function is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} params.functionId - Function ID. @@ -1261,10 +1779,15 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createVcsDeployment(params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise; + createVcsDeployment(params: { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment when a function is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} functionId - Function ID. @@ -1275,40 +1798,72 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(functionId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise; createVcsDeployment( - paramsOrFirst: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] + functionId: string, + type: VCSReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createVcsDeployment( + paramsOrFirst: + | { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [VCSReferenceType?, string?, boolean?] ): Promise { - let params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + let params: { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, type: rest[0] as VCSReferenceType, reference: rest[1] as string, - activate: rest[2] as boolean + activate: rest[2] as boolean, }; } - + const functionId = params.functionId; const type = params.type; const reference = params.reference; const activate = params.activate; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/deployments/vcs'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -1324,15 +1879,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1343,7 +1893,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getDeployment(params: { functionId: string, deploymentId: string }): Promise; + getDeployment(params: { + functionId: string; + deploymentId: string; + }): Promise; /** * Get a function deployment by its unique ID. * @@ -1353,47 +1906,60 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeployment(functionId: string, deploymentId: string): Promise; getDeployment( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + functionId: string, + deploymentId: string, + ): Promise; + getDeployment( + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); + } + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1404,7 +1970,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDeployment(params: { functionId: string, deploymentId: string }): Promise<{}>; + deleteDeployment(params: { + functionId: string; + deploymentId: string; + }): Promise<{}>; /** * Delete a code deployment by its unique ID. * @@ -1416,45 +1985,56 @@ export class Functions { */ deleteDeployment(functionId: string, deploymentId: string): Promise<{}>; deleteDeployment( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); + } + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1467,7 +2047,12 @@ export class Functions { * @throws {AppwriteException} * @returns {string} */ - getDeploymentDownload(params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }): string; + getDeploymentDownload(params: { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }): string; /** * Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -1479,37 +2064,72 @@ export class Functions { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeploymentDownload(functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string): string; getDeploymentDownload( - paramsOrFirst: { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string } | string, - ...rest: [(string)?, (DeploymentDownloadType)?, (string)?] + functionId: string, + deploymentId: string, + type?: DeploymentDownloadType, + token?: string, + ): string; + getDeploymentDownload( + paramsOrFirst: + | { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + } + | string, + ...rest: [string?, DeploymentDownloadType?, string?] ): string { - let params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; + let params: { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; } else { params = { functionId: paramsOrFirst as string, deploymentId: rest[0] as string, type: rest[1] as DeploymentDownloadType, - token: rest[2] as string + token: rest[2] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; const type = params.type; const token = params.token; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); + } + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = + '/functions/{functionId}/deployments/{deploymentId}/download' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -1519,18 +2139,12 @@ export class Functions { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } @@ -1542,7 +2156,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - updateDeploymentStatus(params: { functionId: string, deploymentId: string }): Promise; + updateDeploymentStatus(params: { + functionId: string; + deploymentId: string; + }): Promise; /** * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * @@ -1552,48 +2169,62 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDeploymentStatus(functionId: string, deploymentId: string): Promise; updateDeploymentStatus( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + functionId: string, + deploymentId: string, + ): Promise; + updateDeploymentStatus( + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); + } + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = + '/functions/{functionId}/deployments/{deploymentId}/status' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1605,7 +2236,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listExecutions(params: { functionId: string, queries?: string[], total?: boolean }): Promise; + listExecutions(params: { + functionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the current user function execution logs. You can use the query params to filter your results. * @@ -1616,32 +2251,50 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listExecutions(functionId: string, queries?: string[], total?: boolean): Promise; listExecutions( - paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + functionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listExecutions( + paramsOrFirst: + | { functionId: string; queries?: string[]; total?: boolean } + | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { functionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], total?: boolean }; + let params: { functionId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const functionId = params.functionId; const queries = params.queries; const total = params.total; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/executions'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1653,15 +2306,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1677,7 +2325,15 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createExecution(params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }): Promise; + createExecution(params: { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + }): Promise; /** * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * @@ -1692,15 +2348,60 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise; createExecution( - paramsOrFirst: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (ExecutionMethod)?, (object)?, (string)?] + functionId: string, + body?: string, + async?: boolean, + xpath?: string, + method?: ExecutionMethod, + headers?: object, + scheduledAt?: string, + ): Promise; + createExecution( + paramsOrFirst: + | { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + ExecutionMethod?, + object?, + string?, + ] ): Promise { - let params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + let params: { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + }; } else { params = { functionId: paramsOrFirst as string, @@ -1709,10 +2410,10 @@ export class Functions { xpath: rest[2] as string, method: rest[3] as ExecutionMethod, headers: rest[4] as object, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const functionId = params.functionId; const body = params.body; const async = params.async; @@ -1721,11 +2422,15 @@ export class Functions { const headers = params.headers; const scheduledAt = params.scheduledAt; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/executions'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof body !== 'undefined') { payload['body'] = body; @@ -1750,15 +2455,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1769,7 +2469,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getExecution(params: { functionId: string, executionId: string }): Promise; + getExecution(params: { + functionId: string; + executionId: string; + }): Promise; /** * Get a function execution log by its unique ID. * @@ -1779,47 +2482,57 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getExecution(functionId: string, executionId: string): Promise; getExecution( - paramsOrFirst: { functionId: string, executionId: string } | string, - ...rest: [(string)?] + functionId: string, + executionId: string, + ): Promise; + getExecution( + paramsOrFirst: { functionId: string; executionId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, executionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + let params: { functionId: string; executionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + executionId: string; + }; } else { params = { functionId: paramsOrFirst as string, - executionId: rest[0] as string + executionId: rest[0] as string, }; } - + const functionId = params.functionId; const executionId = params.executionId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - if (typeof executionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "executionId"'); + if (typeof executionId === 'undefined' || executionId === '') { + throw new AppwriteException( + 'Missing required parameter: "executionId"', + ); } - - const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{executionId}', encodeURIComponent(String(executionId))); + const apiPath = '/functions/{functionId}/executions/{executionId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{executionId}', encodeURIComponent(String(executionId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1830,7 +2543,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteExecution(params: { functionId: string, executionId: string }): Promise<{}>; + deleteExecution(params: { + functionId: string; + executionId: string; + }): Promise<{}>; /** * Delete a function execution by its unique ID. * @@ -1842,45 +2558,53 @@ export class Functions { */ deleteExecution(functionId: string, executionId: string): Promise<{}>; deleteExecution( - paramsOrFirst: { functionId: string, executionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { functionId: string; executionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { functionId: string, executionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + let params: { functionId: string; executionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + executionId: string; + }; } else { params = { functionId: paramsOrFirst as string, - executionId: rest[0] as string + executionId: rest[0] as string, }; } - + const functionId = params.functionId; const executionId = params.executionId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - if (typeof executionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "executionId"'); + if (typeof executionId === 'undefined' || executionId === '') { + throw new AppwriteException( + 'Missing required parameter: "executionId"', + ); } - - const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{executionId}', encodeURIComponent(String(executionId))); + const apiPath = '/functions/{functionId}/executions/{executionId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{executionId}', encodeURIComponent(String(executionId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1892,7 +2616,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params: { functionId: string, queries?: string[], total?: boolean }): Promise; + listVariables(params: { + functionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all variables of a specific function. * @@ -1903,32 +2631,50 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(functionId: string, queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + functionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listVariables( + paramsOrFirst: + | { functionId: string; queries?: string[]; total?: boolean } + | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { functionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], total?: boolean }; + let params: { functionId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const functionId = params.functionId; const queries = params.queries; const total = params.total; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/variables'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1940,15 +2686,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1956,55 +2697,95 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }): Promise; /** * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(functionId: string, variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { functionId: string, variableId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + functionId: string, + variableId: string, + key: string, + value: string, + secret?: boolean, + ): Promise; + createVariable( + paramsOrFirst: + | { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; + let params: { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const functionId = params.functionId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -2012,8 +2793,10 @@ export class Functions { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } - - const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', encodeURIComponent(String(functionId))); + const apiPath = '/functions/{functionId}/variables'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); const payload: Payload = {}; if (typeof variableId !== 'undefined') { payload['variableId'] = variableId; @@ -2032,15 +2815,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2051,7 +2829,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getVariable(params: { functionId: string, variableId: string }): Promise; + getVariable(params: { + functionId: string; + variableId: string; + }): Promise; /** * Get a variable by its unique ID. * @@ -2061,47 +2842,57 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getVariable(functionId: string, variableId: string): Promise; getVariable( - paramsOrFirst: { functionId: string, variableId: string } | string, - ...rest: [(string)?] + functionId: string, + variableId: string, + ): Promise; + getVariable( + paramsOrFirst: { functionId: string; variableId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + let params: { functionId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + }; } else { params = { functionId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const functionId = params.functionId; const variableId = params.variableId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/functions/{functionId}/variables/{variableId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2109,58 +2900,99 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }): Promise; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(functionId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + functionId: string, + variableId: string, + key?: string, + value?: string, + secret?: boolean, + ): Promise; + updateVariable( + paramsOrFirst: + | { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + let params: { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const functionId = params.functionId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/functions/{functionId}/variables/{variableId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2176,15 +3008,10 @@ export class Functions { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -2195,7 +3022,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteVariable(params: { functionId: string, variableId: string }): Promise<{}>; + deleteVariable(params: { + functionId: string; + variableId: string; + }): Promise<{}>; /** * Delete a variable by its unique ID. * @@ -2207,44 +3037,52 @@ export class Functions { */ deleteVariable(functionId: string, variableId: string): Promise<{}>; deleteVariable( - paramsOrFirst: { functionId: string, variableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { functionId: string; variableId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { functionId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + let params: { functionId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + }; } else { params = { functionId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const functionId = params.functionId; const variableId = params.variableId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + if (typeof functionId === 'undefined' || functionId === '') { + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/functions/{functionId}/variables/{variableId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 0823f622..819fe851 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -1,7 +1,4 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - +import { AppwriteException, Client, type Payload } from '../client'; export class Graphql { client: Client; @@ -27,25 +24,27 @@ export class Graphql { * @deprecated Use the object parameter style method for a better developer experience. */ query(query: object): Promise<{}>; - query( - paramsOrFirst: { query: object } | object - ): Promise<{}> { + query(paramsOrFirst: { query: object } | object): Promise<{}> { let params: { query: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'query' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { query: object }; } else { params = { - query: paramsOrFirst as object + query: paramsOrFirst as object, }; } - + const query = params.query; if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } - const apiPath = '/graphql'; const payload: Payload = {}; if (typeof query !== 'undefined') { @@ -57,15 +56,10 @@ export class Graphql { 'X-Appwrite-Project': this.client.config.project, 'x-sdk-graphql': 'true', 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -85,25 +79,27 @@ export class Graphql { * @deprecated Use the object parameter style method for a better developer experience. */ mutation(query: object): Promise<{}>; - mutation( - paramsOrFirst: { query: object } | object - ): Promise<{}> { + mutation(paramsOrFirst: { query: object } | object): Promise<{}> { let params: { query: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'query' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { query: object }; } else { params = { - query: paramsOrFirst as object + query: paramsOrFirst as object, }; } - + const query = params.query; if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } - const apiPath = '/graphql/mutation'; const payload: Payload = {}; if (typeof query !== 'undefined') { @@ -115,14 +111,9 @@ export class Graphql { 'X-Appwrite-Project': this.client.config.project, 'x-sdk-graphql': 'true', 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/locale.ts b/src/services/locale.ts index 41583e29..04a517f5 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Locale { client: Client; @@ -12,29 +10,23 @@ export class Locale { /** * Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. - * + * * ([IP Geolocation by DB-IP](https://db-ip.com)) * * @throws {AppwriteException} * @returns {Promise} */ get(): Promise { - const apiPath = '/locale'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -44,22 +36,16 @@ export class Locale { * @returns {Promise} */ listCodes(): Promise { - const apiPath = '/locale/codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -69,22 +55,16 @@ export class Locale { * @returns {Promise} */ listContinents(): Promise { - const apiPath = '/locale/continents'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -94,22 +74,16 @@ export class Locale { * @returns {Promise} */ listCountries(): Promise { - const apiPath = '/locale/countries'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -119,22 +93,16 @@ export class Locale { * @returns {Promise} */ listCountriesEU(): Promise { - const apiPath = '/locale/countries/eu'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -144,22 +112,16 @@ export class Locale { * @returns {Promise} */ listCountriesPhones(): Promise { - const apiPath = '/locale/countries/phones'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -169,22 +131,16 @@ export class Locale { * @returns {Promise} */ listCurrencies(): Promise { - const apiPath = '/locale/currencies'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -194,21 +150,15 @@ export class Locale { * @returns {Promise} */ listLanguages(): Promise { - const apiPath = '/locale/languages'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/manager.ts b/src/services/manager.ts index 227b2fd7..b8efaa18 100644 --- a/src/services/manager.ts +++ b/src/services/manager.ts @@ -1,5 +1,4 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { BlockResourceType } from '../enums/block-resource-type'; @@ -7,7 +6,6 @@ import { BlockMode } from '../enums/block-mode'; import { Region } from '../enums/region'; import { CacheTarget } from '../enums/cache-target'; import { CacheDatabase } from '../enums/cache-database'; - export class Manager { client: Client; @@ -27,7 +25,14 @@ export class Manager { * @throws {AppwriteException} * @returns {Promise} */ - createBlock(params: { projectId: string, resourceType: BlockResourceType, resourceId?: string, mode?: BlockMode, reason?: string, expiredAt?: string }): Promise; + createBlock(params: { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + mode?: BlockMode; + reason?: string; + expiredAt?: string; + }): Promise; /** * Creates a new resource block. * @@ -41,15 +46,49 @@ export class Manager { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBlock(projectId: string, resourceType: BlockResourceType, resourceId?: string, mode?: BlockMode, reason?: string, expiredAt?: string): Promise; createBlock( - paramsOrFirst: { projectId: string, resourceType: BlockResourceType, resourceId?: string, mode?: BlockMode, reason?: string, expiredAt?: string } | string, - ...rest: [(BlockResourceType)?, (string)?, (BlockMode)?, (string)?, (string)?] + projectId: string, + resourceType: BlockResourceType, + resourceId?: string, + mode?: BlockMode, + reason?: string, + expiredAt?: string, + ): Promise; + createBlock( + paramsOrFirst: + | { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + mode?: BlockMode; + reason?: string; + expiredAt?: string; + } + | string, + ...rest: [BlockResourceType?, string?, BlockMode?, string?, string?] ): Promise { - let params: { projectId: string, resourceType: BlockResourceType, resourceId?: string, mode?: BlockMode, reason?: string, expiredAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, resourceType: BlockResourceType, resourceId?: string, mode?: BlockMode, reason?: string, expiredAt?: string }; + let params: { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + mode?: BlockMode; + reason?: string; + expiredAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + mode?: BlockMode; + reason?: string; + expiredAt?: string; + }; } else { params = { projectId: paramsOrFirst as string, @@ -57,10 +96,10 @@ export class Manager { resourceId: rest[1] as string, mode: rest[2] as BlockMode, reason: rest[3] as string, - expiredAt: rest[4] as string + expiredAt: rest[4] as string, }; } - + const projectId = params.projectId; const resourceType = params.resourceType; const resourceId = params.resourceId; @@ -69,12 +108,15 @@ export class Manager { const expiredAt = params.expiredAt; if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } - const apiPath = '/manager/blocks'; const payload: Payload = {}; if (typeof projectId !== 'undefined') { @@ -99,15 +141,10 @@ export class Manager { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -119,7 +156,11 @@ export class Manager { * @throws {AppwriteException} * @returns {Promise} */ - deleteBlock(params: { projectId: string, resourceType: BlockResourceType, resourceId?: string }): Promise; + deleteBlock(params: { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + }): Promise; /** * Deletes resource blocks for a project. * @@ -130,34 +171,59 @@ export class Manager { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBlock(projectId: string, resourceType: BlockResourceType, resourceId?: string): Promise; deleteBlock( - paramsOrFirst: { projectId: string, resourceType: BlockResourceType, resourceId?: string } | string, - ...rest: [(BlockResourceType)?, (string)?] + projectId: string, + resourceType: BlockResourceType, + resourceId?: string, + ): Promise; + deleteBlock( + paramsOrFirst: + | { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + } + | string, + ...rest: [BlockResourceType?, string?] ): Promise { - let params: { projectId: string, resourceType: BlockResourceType, resourceId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, resourceType: BlockResourceType, resourceId?: string }; + let params: { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + resourceType: BlockResourceType; + resourceId?: string; + }; } else { params = { projectId: paramsOrFirst as string, resourceType: rest[0] as BlockResourceType, - resourceId: rest[1] as string + resourceId: rest[1] as string, }; } - + const projectId = params.projectId; const resourceType = params.resourceType; const resourceId = params.resourceId; if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } - const apiPath = '/manager/blocks'; const payload: Payload = {}; if (typeof projectId !== 'undefined') { @@ -173,15 +239,10 @@ export class Manager { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -202,38 +263,41 @@ export class Manager { */ listBlocks(projectId: string): Promise; listBlocks( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - - const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } + const projectId = params.projectId; - const apiPath = '/manager/blocks/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + const apiPath = '/manager/blocks/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -249,7 +313,15 @@ export class Manager { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteCache(params?: { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string }): Promise<{}>; + deleteCache(params?: { + region?: Region; + cache?: CacheTarget; + all?: boolean; + database?: CacheDatabase; + projectId?: string; + collectionId?: string; + documentId?: string; + }): Promise<{}>; /** * Clears internal cache. * @@ -264,15 +336,68 @@ export class Manager { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteCache(region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string): Promise<{}>; deleteCache( - paramsOrFirst?: { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string } | Region, - ...rest: [(CacheTarget)?, (boolean)?, (CacheDatabase)?, (string)?, (string)?, (string)?] + region?: Region, + cache?: CacheTarget, + all?: boolean, + database?: CacheDatabase, + projectId?: string, + collectionId?: string, + documentId?: string, + ): Promise<{}>; + deleteCache( + paramsOrFirst?: + | { + region?: Region; + cache?: CacheTarget; + all?: boolean; + database?: CacheDatabase; + projectId?: string; + collectionId?: string; + documentId?: string; + } + | Region, + ...rest: [ + CacheTarget?, + boolean?, + CacheDatabase?, + string?, + string?, + string?, + ] ): Promise<{}> { - let params: { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('region' in paramsOrFirst || 'cache' in paramsOrFirst || 'all' in paramsOrFirst || 'database' in paramsOrFirst || 'projectId' in paramsOrFirst || 'collectionId' in paramsOrFirst || 'documentId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string }; + let params: { + region?: Region; + cache?: CacheTarget; + all?: boolean; + database?: CacheDatabase; + projectId?: string; + collectionId?: string; + documentId?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('region' in paramsOrFirst || + 'cache' in paramsOrFirst || + 'all' in paramsOrFirst || + 'database' in paramsOrFirst || + 'projectId' in paramsOrFirst || + 'collectionId' in paramsOrFirst || + 'documentId' in paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + region?: Region; + cache?: CacheTarget; + all?: boolean; + database?: CacheDatabase; + projectId?: string; + collectionId?: string; + documentId?: string; + }; } else { params = { region: paramsOrFirst as Region, @@ -281,10 +406,10 @@ export class Manager { database: rest[2] as CacheDatabase, projectId: rest[3] as string, collectionId: rest[4] as string, - documentId: rest[5] as string + documentId: rest[5] as string, }; } - + const region = params.region; const cache = params.cache; const all = params.all; @@ -293,7 +418,6 @@ export class Manager { const collectionId = params.collectionId; const documentId = params.documentId; - const apiPath = '/manager/cache'; const payload: Payload = {}; if (typeof region !== 'undefined') { @@ -321,15 +445,10 @@ export class Manager { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -342,7 +461,14 @@ export class Manager { * @throws {AppwriteException} * @returns {Promise>} */ - updateUserStatus(params: { status: boolean, userId?: string, email?: string, reason?: string }): Promise>; + updateUserStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + status: boolean; + userId?: string; + email?: string; + reason?: string; + }): Promise>; /** * Updates a console user status using a user ID or email address. * @@ -354,24 +480,54 @@ export class Manager { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUserStatus(status: boolean, userId?: string, email?: string, reason?: string): Promise>; - updateUserStatus( - paramsOrFirst: { status: boolean, userId?: string, email?: string, reason?: string } | boolean, - ...rest: [(string)?, (string)?, (string)?] + updateUserStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + status: boolean, + userId?: string, + email?: string, + reason?: string, + ): Promise>; + updateUserStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + status: boolean; + userId?: string; + email?: string; + reason?: string; + } + | boolean, + ...rest: [string?, string?, string?] ): Promise> { - let params: { status: boolean, userId?: string, email?: string, reason?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { status: boolean, userId?: string, email?: string, reason?: string }; + let params: { + status: boolean; + userId?: string; + email?: string; + reason?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + status: boolean; + userId?: string; + email?: string; + reason?: string; + }; } else { params = { status: paramsOrFirst as boolean, userId: rest[0] as string, email: rest[1] as string, - reason: rest[2] as string + reason: rest[2] as string, }; } - + const status = params.status; const userId = params.userId; const email = params.email; @@ -380,7 +536,6 @@ export class Manager { if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } - const apiPath = '/manager/users/status'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -399,14 +554,9 @@ export class Manager { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 7b3ab3e0..7787c49c 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,10 +1,8 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; import { SmtpEncryption } from '../enums/smtp-encryption'; - export class Messaging { client: Client; @@ -21,7 +19,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listMessages(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listMessages(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all messages from the current Appwrite project. * @@ -32,28 +34,41 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMessages(queries?: string[], search?: string, total?: boolean): Promise; listMessages( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMessages( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/messaging/messages'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -69,15 +84,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -98,7 +108,20 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createEmail(params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }): Promise; + createEmail(params: { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + }): Promise; /** * Create a new email message. * @@ -118,15 +141,85 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmail(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string): Promise; createEmail( - paramsOrFirst: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (boolean)?, (boolean)?, (string)?] + messageId: string, + subject: string, + content: string, + topics?: string[], + users?: string[], + targets?: string[], + cc?: string[], + bcc?: string[], + attachments?: string[], + draft?: boolean, + html?: boolean, + scheduledAt?: string, + ): Promise; + createEmail( + paramsOrFirst: + | { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + string[]?, + string[]?, + string[]?, + string[]?, + string[]?, + boolean?, + boolean?, + string?, + ] ): Promise { - let params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -140,10 +233,10 @@ export class Messaging { attachments: rest[7] as string[], draft: rest[8] as boolean, html: rest[9] as boolean, - scheduledAt: rest[10] as string + scheduledAt: rest[10] as string, }; } - + const messageId = params.messageId; const subject = params.subject; const content = params.content; @@ -158,15 +251,20 @@ export class Messaging { const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } if (typeof subject === 'undefined') { - throw new AppwriteException('Missing required parameter: "subject"'); + throw new AppwriteException( + 'Missing required parameter: "subject"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - const apiPath = '/messaging/messages/email'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -210,20 +308,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -240,10 +333,23 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateEmail(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }): Promise; + updateEmail(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + }): Promise; /** * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -261,15 +367,85 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise; updateEmail( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (boolean)?, (string[])?, (string[])?, (string)?, (string[])?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + subject?: string, + content?: string, + draft?: boolean, + html?: boolean, + cc?: string[], + bcc?: string[], + scheduledAt?: string, + attachments?: string[], + ): Promise; + updateEmail( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + } + | string, + ...rest: [ + string[]?, + string[]?, + string[]?, + string?, + string?, + boolean?, + boolean?, + string[]?, + string[]?, + string?, + string[]?, + ] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + }; } else { params = { messageId: paramsOrFirst as string, @@ -283,10 +459,10 @@ export class Messaging { cc: rest[7] as string[], bcc: rest[8] as string[], scheduledAt: rest[9] as string, - attachments: rest[10] as string[] + attachments: rest[10] as string[], }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -300,11 +476,15 @@ export class Messaging { const scheduledAt = params.scheduledAt; const attachments = params.attachments; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/email/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; @@ -344,15 +524,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -380,7 +555,27 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createPush(params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise; + createPush(params: { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }): Promise; /** * Create a new push notification. * @@ -407,15 +602,120 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPush(messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise; createPush( - paramsOrFirst: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, - ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + messageId: string, + title?: string, + body?: string, + topics?: string[], + users?: string[], + targets?: string[], + data?: object, + action?: string, + image?: string, + icon?: string, + sound?: string, + color?: string, + tag?: string, + badge?: number, + draft?: boolean, + scheduledAt?: string, + contentAvailable?: boolean, + critical?: boolean, + priority?: MessagePriority, + ): Promise; + createPush( + paramsOrFirst: + | { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + string[]?, + string[]?, + object?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + MessagePriority?, + ] ): Promise { - let params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + let params: { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; } else { params = { messageId: paramsOrFirst as string, @@ -436,10 +736,10 @@ export class Messaging { scheduledAt: rest[14] as string, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, - priority: rest[17] as MessagePriority + priority: rest[17] as MessagePriority, }; } - + const messageId = params.messageId; const title = params.title; const body = params.body; @@ -461,9 +761,10 @@ export class Messaging { const priority = params.priority; if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - const apiPath = '/messaging/messages/push'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -528,20 +829,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -565,10 +861,30 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updatePush(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise; + updatePush(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }): Promise; /** * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -593,15 +909,120 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise; updatePush( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + title?: string, + body?: string, + data?: object, + action?: string, + image?: string, + icon?: string, + sound?: string, + color?: string, + tag?: string, + badge?: number, + draft?: boolean, + scheduledAt?: string, + contentAvailable?: boolean, + critical?: boolean, + priority?: MessagePriority, + ): Promise; + updatePush( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + } + | string, + ...rest: [ + string[]?, + string[]?, + string[]?, + string?, + string?, + object?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + MessagePriority?, + ] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; } else { params = { messageId: paramsOrFirst as string, @@ -622,10 +1043,10 @@ export class Messaging { scheduledAt: rest[14] as string, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, - priority: rest[17] as MessagePriority + priority: rest[17] as MessagePriority, }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -646,11 +1067,15 @@ export class Messaging { const critical = params.critical; const priority = params.priority; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/push/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; @@ -711,15 +1136,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -736,7 +1156,15 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. */ - createSms(params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise; + createSms(params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Create a new SMS message. * @@ -751,15 +1179,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSms(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise; createSms( - paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + messageId: string, + content: string, + topics?: string[], + users?: string[], + targets?: string[], + draft?: boolean, + scheduledAt?: string, + ): Promise; + createSms( + paramsOrFirst: + | { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] ): Promise { - let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -768,10 +1234,10 @@ export class Messaging { users: rest[2] as string[], targets: rest[3] as string[], draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const content = params.content; const topics = params.topics; @@ -781,12 +1247,15 @@ export class Messaging { const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - const apiPath = '/messaging/messages/sms'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -815,15 +1284,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -839,7 +1303,15 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSMS(params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise; + createSMS(params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Create a new SMS message. * @@ -854,15 +1326,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSMS(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise; createSMS( - paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + messageId: string, + content: string, + topics?: string[], + users?: string[], + targets?: string[], + draft?: boolean, + scheduledAt?: string, + ): Promise; + createSMS( + paramsOrFirst: + | { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] ): Promise { - let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -871,10 +1381,10 @@ export class Messaging { users: rest[2] as string[], targets: rest[3] as string[], draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const content = params.content; const topics = params.topics; @@ -884,12 +1394,15 @@ export class Messaging { const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - const apiPath = '/messaging/messages/sms'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -918,20 +1431,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -944,10 +1452,18 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ - updateSms(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise; + updateSms(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -960,15 +1476,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSms(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise; updateSms( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + content?: string, + draft?: boolean, + scheduledAt?: string, + ): Promise; + updateSms( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string[]?, string[]?, string[]?, string?, boolean?, string?] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -977,10 +1531,10 @@ export class Messaging { targets: rest[2] as string[], content: rest[3] as string, draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -989,11 +1543,15 @@ export class Messaging { const draft = params.draft; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/sms/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; @@ -1018,20 +1576,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -1043,10 +1596,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSMS(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise; + updateSMS(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -1059,15 +1620,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMS(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise; updateSMS( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + content?: string, + draft?: boolean, + scheduledAt?: string, + ): Promise; + updateSMS( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string[]?, string[]?, string[]?, string?, boolean?, string?] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -1076,10 +1675,10 @@ export class Messaging { targets: rest[2] as string[], content: rest[3] as string, draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -1088,11 +1687,15 @@ export class Messaging { const draft = params.draft; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/sms/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; @@ -1117,20 +1720,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Get a message by its unique ID. - * + * * * @param {string} params.messageId - Message ID. * @throws {AppwriteException} @@ -1139,7 +1737,7 @@ export class Messaging { getMessage(params: { messageId: string }): Promise; /** * Get a message by its unique ID. - * + * * * @param {string} messageId - Message ID. * @throws {AppwriteException} @@ -1148,39 +1746,42 @@ export class Messaging { */ getMessage(messageId: string): Promise; getMessage( - paramsOrFirst: { messageId: string } | string + paramsOrFirst: { messageId: string } | string, ): Promise { let params: { messageId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { messageId: string }; } else { params = { - messageId: paramsOrFirst as string + messageId: paramsOrFirst as string, }; } - + const messageId = params.messageId; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1200,40 +1801,42 @@ export class Messaging { * @deprecated Use the object parameter style method for a better developer experience. */ delete(messageId: string): Promise<{}>; - delete( - paramsOrFirst: { messageId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { messageId: string } | string): Promise<{}> { let params: { messageId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { messageId: string }; } else { params = { - messageId: paramsOrFirst as string + messageId: paramsOrFirst as string, }; } - + const messageId = params.messageId; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1245,7 +1848,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listTargets(params: { messageId: string, queries?: string[], total?: boolean }): Promise; + listTargets(params: { + messageId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of the targets associated with a message. * @@ -1256,32 +1863,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTargets(messageId: string, queries?: string[], total?: boolean): Promise; listTargets( - paramsOrFirst: { messageId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + messageId: string, + queries?: string[], + total?: boolean, + ): Promise; + listTargets( + paramsOrFirst: + { messageId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { messageId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, queries?: string[], total?: boolean }; + let params: { messageId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { messageId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const messageId = params.messageId; const queries = params.queries; const total = params.total; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + if (typeof messageId === 'undefined' || messageId === '') { + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/{messageId}/targets'.replace('{messageId}', encodeURIComponent(String(messageId))); + const apiPath = '/messaging/messages/{messageId}/targets'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1293,15 +1917,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1313,7 +1932,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listProviders(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listProviders(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all providers from the current Appwrite project. * @@ -1324,28 +1947,41 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listProviders(queries?: string[], search?: string, total?: boolean): Promise; listProviders( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listProviders( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/messaging/providers'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1361,15 +1997,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1387,7 +2018,16 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. */ - createApnsProvider(params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise; + createApnsProvider(params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }): Promise; /** * Create a new Apple Push Notification service provider. * @@ -1403,15 +2043,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise; createApnsProvider( - paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + providerId: string, + name: string, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + enabled?: boolean, + ): Promise; + createApnsProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + let params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1421,10 +2111,10 @@ export class Messaging { teamId: rest[3] as string, bundleId: rest[4] as string, sandbox: rest[5] as boolean, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const authKey = params.authKey; @@ -1435,12 +2125,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/apns'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1472,15 +2163,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1497,7 +2183,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createAPNSProvider(params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise; + createAPNSProvider(params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }): Promise; /** * Create a new Apple Push Notification service provider. * @@ -1513,15 +2208,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAPNSProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise; createAPNSProvider( - paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + providerId: string, + name: string, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + enabled?: boolean, + ): Promise; + createAPNSProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + let params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1531,10 +2276,10 @@ export class Messaging { teamId: rest[3] as string, bundleId: rest[4] as string, sandbox: rest[5] as boolean, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const authKey = params.authKey; @@ -1545,12 +2290,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/apns'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1582,15 +2328,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1608,7 +2349,16 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. */ - updateApnsProvider(params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise; + updateApnsProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }): Promise; /** * Update a Apple Push Notification service provider by its unique ID. * @@ -1624,15 +2374,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise; updateApnsProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + enabled?: boolean, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + ): Promise; + updateApnsProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1642,10 +2442,10 @@ export class Messaging { authKeyId: rest[3] as string, teamId: rest[4] as string, bundleId: rest[5] as string, - sandbox: rest[6] as boolean + sandbox: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -1655,11 +2455,15 @@ export class Messaging { const bundleId = params.bundleId; const sandbox = params.sandbox; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/apns/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1687,15 +2491,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1712,7 +2511,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateAPNSProvider(params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise; + updateAPNSProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }): Promise; /** * Update a Apple Push Notification service provider by its unique ID. * @@ -1728,15 +2536,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAPNSProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise; updateAPNSProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + enabled?: boolean, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + ): Promise; + updateAPNSProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1746,10 +2604,10 @@ export class Messaging { authKeyId: rest[3] as string, teamId: rest[4] as string, bundleId: rest[5] as string, - sandbox: rest[6] as boolean + sandbox: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -1759,11 +2617,15 @@ export class Messaging { const bundleId = params.bundleId; const sandbox = params.sandbox; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/apns/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1791,15 +2653,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1813,7 +2670,12 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. */ - createFcmProvider(params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise; + createFcmProvider(params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }): Promise; /** * Create a new Firebase Cloud Messaging provider. * @@ -1825,36 +2687,63 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise; createFcmProvider( - paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, - ...rest: [(string)?, (object)?, (boolean)?] + providerId: string, + name: string, + serviceAccountJSON?: object, + enabled?: boolean, + ): Promise; + createFcmProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + } + | string, + ...rest: [string?, object?, boolean?] ): Promise { - let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + let params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const serviceAccountJSON = params.serviceAccountJSON; const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/fcm'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1874,15 +2763,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1895,7 +2779,12 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createFCMProvider(params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise; + createFCMProvider(params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }): Promise; /** * Create a new Firebase Cloud Messaging provider. * @@ -1907,36 +2796,63 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFCMProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise; createFCMProvider( - paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, - ...rest: [(string)?, (object)?, (boolean)?] + providerId: string, + name: string, + serviceAccountJSON?: object, + enabled?: boolean, + ): Promise; + createFCMProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + } + | string, + ...rest: [string?, object?, boolean?] ): Promise { - let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + let params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const serviceAccountJSON = params.serviceAccountJSON; const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/fcm'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1956,15 +2872,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1978,7 +2889,12 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. */ - updateFcmProvider(params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise; + updateFcmProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }): Promise; /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -1990,34 +2906,64 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise; updateFcmProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, - ...rest: [(string)?, (boolean)?, (object)?] + providerId: string, + name?: string, + enabled?: boolean, + serviceAccountJSON?: object, + ): Promise; + updateFcmProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + } + | string, + ...rest: [string?, boolean?, object?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object + serviceAccountJSON: rest[2] as object, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const serviceAccountJSON = params.serviceAccountJSON; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/fcm/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2033,15 +2979,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2054,7 +2995,12 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateFCMProvider(params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise; + updateFCMProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }): Promise; /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -2066,34 +3012,64 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFCMProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise; updateFCMProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, - ...rest: [(string)?, (boolean)?, (object)?] + providerId: string, + name?: string, + enabled?: boolean, + serviceAccountJSON?: object, + ): Promise; + updateFCMProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + } + | string, + ...rest: [string?, boolean?, object?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object + serviceAccountJSON: rest[2] as object, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const serviceAccountJSON = params.serviceAccountJSON; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/fcm/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2109,15 +3085,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2136,7 +3107,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createMailgunProvider(params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createMailgunProvider(params: { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Mailgun provider. * @@ -2154,15 +3136,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMailgunProvider(providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createMailgunProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + apiKey?: string, + domain?: string, + isEuRegion?: boolean, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createMailgunProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + boolean?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2174,10 +3216,10 @@ export class Messaging { fromEmail: rest[5] as string, replyToName: rest[6] as string, replyToEmail: rest[7] as string, - enabled: rest[8] as boolean + enabled: rest[8] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2190,12 +3232,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/mailgun'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -2233,15 +3276,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2260,7 +3298,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateMailgunProvider(params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateMailgunProvider(params: { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update a Mailgun provider by its unique ID. * @@ -2278,15 +3327,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMailgunProvider(providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateMailgunProvider( - paramsOrFirst: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + apiKey?: string, + domain?: string, + isEuRegion?: boolean, + enabled?: boolean, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateMailgunProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + boolean?, + boolean?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2298,10 +3407,10 @@ export class Messaging { fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, - replyToEmail: rest[8] as string + replyToEmail: rest[8] as string, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2313,11 +3422,15 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/mailgun/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/mailgun/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2351,15 +3464,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2374,7 +3482,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createMsg91Provider(params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }): Promise; + createMsg91Provider(params: { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + }): Promise; /** * Create a new MSG91 provider. * @@ -2388,15 +3503,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise; createMsg91Provider( - paramsOrFirst: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + templateId?: string, + senderId?: string, + authKey?: string, + enabled?: boolean, + ): Promise; + createMsg91Provider( + paramsOrFirst: + | { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2404,10 +3553,10 @@ export class Messaging { templateId: rest[1] as string, senderId: rest[2] as string, authKey: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const templateId = params.templateId; @@ -2416,12 +3565,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/msg91'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -2447,15 +3597,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2470,7 +3615,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateMsg91Provider(params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }): Promise; + updateMsg91Provider(params: { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + }): Promise; /** * Update a MSG91 provider by its unique ID. * @@ -2484,15 +3636,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise; updateMsg91Provider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + templateId?: string, + senderId?: string, + authKey?: string, + ): Promise; + updateMsg91Provider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2500,10 +3686,10 @@ export class Messaging { enabled: rest[1] as boolean, templateId: rest[2] as string, senderId: rest[3] as string, - authKey: rest[4] as string + authKey: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -2511,11 +3697,15 @@ export class Messaging { const senderId = params.senderId; const authKey = params.authKey; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/msg91/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2537,15 +3727,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2562,7 +3747,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createResendProvider(params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createResendProvider(params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Resend provider. * @@ -2578,15 +3772,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createResendProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createResendProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createResendProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2596,10 +3840,10 @@ export class Messaging { fromEmail: rest[3] as string, replyToName: rest[4] as string, replyToEmail: rest[5] as string, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2610,12 +3854,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/resend'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -2647,15 +3892,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2672,7 +3912,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateResendProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateResendProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update a Resend provider by its unique ID. * @@ -2688,15 +3937,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateResendProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateResendProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateResendProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2706,10 +4005,10 @@ export class Messaging { fromName: rest[3] as string, fromEmail: rest[4] as string, replyToName: rest[5] as string, - replyToEmail: rest[6] as string + replyToEmail: rest[6] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -2719,11 +4018,15 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/resend/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/resend/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2751,15 +4054,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2776,7 +4074,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSendgridProvider(params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSendgridProvider(params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Sendgrid provider. * @@ -2792,15 +4099,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSendgridProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSendgridProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSendgridProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2810,10 +4167,10 @@ export class Messaging { fromEmail: rest[3] as string, replyToName: rest[4] as string, replyToEmail: rest[5] as string, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2824,12 +4181,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/sendgrid'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -2861,15 +4219,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2886,7 +4239,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSendgridProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateSendgridProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update a Sendgrid provider by its unique ID. * @@ -2902,15 +4264,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateSendgridProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateSendgridProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2920,10 +4332,10 @@ export class Messaging { fromName: rest[3] as string, fromEmail: rest[4] as string, replyToName: rest[5] as string, - replyToEmail: rest[6] as string + replyToEmail: rest[6] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -2933,11 +4345,15 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2965,15 +4381,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2992,7 +4403,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSesProvider(params: { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSesProvider(params: { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Amazon SES provider. * @@ -3010,15 +4432,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSesProvider(providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSesProvider( - paramsOrFirst: { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + accessKey?: string, + secretKey?: string, + region?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSesProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3030,10 +4512,10 @@ export class Messaging { fromEmail: rest[5] as string, replyToName: rest[6] as string, replyToEmail: rest[7] as string, - enabled: rest[8] as boolean + enabled: rest[8] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const accessKey = params.accessKey; @@ -3046,12 +4528,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/ses'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -3089,15 +4572,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3116,7 +4594,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSesProvider(params: { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateSesProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update an Amazon SES provider by its unique ID. * @@ -3134,15 +4623,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSesProvider(providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateSesProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + accessKey?: string, + secretKey?: string, + region?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateSesProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3154,10 +4703,10 @@ export class Messaging { fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, - replyToEmail: rest[8] as string + replyToEmail: rest[8] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -3169,11 +4718,15 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/ses/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/ses/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3207,15 +4760,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3239,7 +4787,22 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. */ - createSmtpProvider(params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSmtpProvider(params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new SMTP provider. * @@ -3261,15 +4824,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSmtpProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSmtpProvider( - paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + host: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSmtpProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3285,10 +4928,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3305,7 +4948,9 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3313,7 +4958,6 @@ export class Messaging { if (typeof host === 'undefined') { throw new AppwriteException('Missing required parameter: "host"'); } - const apiPath = '/messaging/providers/smtp'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -3363,15 +5007,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3394,7 +5033,22 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSMTPProvider(params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSMTPProvider(params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new SMTP provider. * @@ -3416,15 +5070,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSMTPProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSMTPProvider( - paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + host: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSMTPProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3440,10 +5174,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3460,7 +5194,9 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3468,7 +5204,6 @@ export class Messaging { if (typeof host === 'undefined') { throw new AppwriteException('Missing required parameter: "host"'); } - const apiPath = '/messaging/providers/smtp'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -3518,15 +5253,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3550,7 +5280,22 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. */ - updateSmtpProvider(params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + updateSmtpProvider(params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Update a SMTP provider by its unique ID. * @@ -3572,15 +5317,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSmtpProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; updateSmtpProvider( - paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + host?: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + updateSmtpProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3596,10 +5421,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3615,11 +5440,15 @@ export class Messaging { const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/smtp/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3665,15 +5494,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3696,7 +5520,22 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSMTPProvider(params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + updateSMTPProvider(params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Update a SMTP provider by its unique ID. * @@ -3718,15 +5557,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMTPProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; updateSMTPProvider( - paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + host?: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + updateSMTPProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3742,10 +5661,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3761,11 +5680,15 @@ export class Messaging { const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/smtp/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3811,15 +5734,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3834,7 +5752,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTelesignProvider(params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }): Promise; + createTelesignProvider(params: { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + }): Promise; /** * Create a new Telesign provider. * @@ -3848,15 +5773,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTelesignProvider(providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean): Promise; createTelesignProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + customerId?: string, + apiKey?: string, + enabled?: boolean, + ): Promise; + createTelesignProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3864,10 +5823,10 @@ export class Messaging { from: rest[1] as string, customerId: rest[2] as string, apiKey: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; @@ -3876,12 +5835,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/telesign'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -3907,15 +5867,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3930,7 +5885,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTelesignProvider(params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }): Promise; + updateTelesignProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + }): Promise; /** * Update a Telesign provider by its unique ID. * @@ -3944,15 +5906,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTelesignProvider(providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string): Promise; updateTelesignProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + customerId?: string, + apiKey?: string, + from?: string, + ): Promise; + updateTelesignProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3960,10 +5956,10 @@ export class Messaging { enabled: rest[1] as boolean, customerId: rest[2] as string, apiKey: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -3971,11 +5967,15 @@ export class Messaging { const apiKey = params.apiKey; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/telesign/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/telesign/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -3997,15 +5997,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4020,7 +6015,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTextmagicProvider(params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }): Promise; + createTextmagicProvider(params: { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + }): Promise; /** * Create a new Textmagic provider. * @@ -4034,15 +6036,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextmagicProvider(providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean): Promise; createTextmagicProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + username?: string, + apiKey?: string, + enabled?: boolean, + ): Promise; + createTextmagicProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4050,10 +6086,10 @@ export class Messaging { from: rest[1] as string, username: rest[2] as string, apiKey: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; @@ -4062,12 +6098,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/textmagic'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -4093,15 +6130,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4116,7 +6148,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTextmagicProvider(params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }): Promise; + updateTextmagicProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + }): Promise; /** * Update a Textmagic provider by its unique ID. * @@ -4130,15 +6169,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextmagicProvider(providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string): Promise; updateTextmagicProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + username?: string, + apiKey?: string, + from?: string, + ): Promise; + updateTextmagicProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4146,10 +6219,10 @@ export class Messaging { enabled: rest[1] as boolean, username: rest[2] as string, apiKey: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -4157,11 +6230,15 @@ export class Messaging { const apiKey = params.apiKey; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/textmagic/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/textmagic/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4183,15 +6260,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4206,7 +6278,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTwilioProvider(params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }): Promise; + createTwilioProvider(params: { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + }): Promise; /** * Create a new Twilio provider. * @@ -4220,15 +6299,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTwilioProvider(providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean): Promise; createTwilioProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + accountSid?: string, + authToken?: string, + enabled?: boolean, + ): Promise; + createTwilioProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4236,10 +6349,10 @@ export class Messaging { from: rest[1] as string, accountSid: rest[2] as string, authToken: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; @@ -4248,12 +6361,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/twilio'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -4279,15 +6393,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4302,7 +6411,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTwilioProvider(params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }): Promise; + updateTwilioProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + }): Promise; /** * Update a Twilio provider by its unique ID. * @@ -4316,15 +6432,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTwilioProvider(providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string): Promise; updateTwilioProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + accountSid?: string, + authToken?: string, + from?: string, + ): Promise; + updateTwilioProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4332,10 +6482,10 @@ export class Messaging { enabled: rest[1] as boolean, accountSid: rest[2] as string, authToken: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -4343,11 +6493,15 @@ export class Messaging { const authToken = params.authToken; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/twilio/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/twilio/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4369,15 +6523,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4392,7 +6541,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createVonageProvider(params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise; + createVonageProvider(params: { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }): Promise; /** * Create a new Vonage provider. * @@ -4406,15 +6562,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVonageProvider(providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean): Promise; createVonageProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + apiKey?: string, + apiSecret?: string, + enabled?: boolean, + ): Promise; + createVonageProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4422,10 +6612,10 @@ export class Messaging { from: rest[1] as string, apiKey: rest[2] as string, apiSecret: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; @@ -4434,12 +6624,13 @@ export class Messaging { const enabled = params.enabled; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/vonage'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -4465,15 +6656,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4488,7 +6674,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateVonageProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }): Promise; + updateVonageProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + }): Promise; /** * Update a Vonage provider by its unique ID. * @@ -4502,15 +6695,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVonageProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string): Promise; updateVonageProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + apiKey?: string, + apiSecret?: string, + from?: string, + ): Promise; + updateVonageProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4518,10 +6745,10 @@ export class Messaging { enabled: rest[1] as boolean, apiKey: rest[2] as string, apiSecret: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -4529,11 +6756,15 @@ export class Messaging { const apiSecret = params.apiSecret; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/vonage/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/vonage/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4555,20 +6786,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Get a provider by its unique ID. - * + * * * @param {string} params.providerId - Provider ID. * @throws {AppwriteException} @@ -4577,7 +6803,7 @@ export class Messaging { getProvider(params: { providerId: string }): Promise; /** * Get a provider by its unique ID. - * + * * * @param {string} providerId - Provider ID. * @throws {AppwriteException} @@ -4586,39 +6812,42 @@ export class Messaging { */ getProvider(providerId: string): Promise; getProvider( - paramsOrFirst: { providerId: string } | string + paramsOrFirst: { providerId: string } | string, ): Promise { let params: { providerId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { providerId: string }; } else { params = { - providerId: paramsOrFirst as string + providerId: paramsOrFirst as string, }; } - + const providerId = params.providerId; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4639,39 +6868,43 @@ export class Messaging { */ deleteProvider(providerId: string): Promise<{}>; deleteProvider( - paramsOrFirst: { providerId: string } | string + paramsOrFirst: { providerId: string } | string, ): Promise<{}> { let params: { providerId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { providerId: string }; } else { params = { - providerId: paramsOrFirst as string + providerId: paramsOrFirst as string, }; } - + const providerId = params.providerId; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/messaging/providers/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -4683,7 +6916,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listTopics(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listTopics(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all topics from the current Appwrite project. * @@ -4694,28 +6931,41 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTopics(queries?: string[], search?: string, total?: boolean): Promise; listTopics( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listTopics( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/messaging/topics'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -4731,15 +6981,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4751,7 +6996,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTopic(params: { topicId: string, name: string, subscribe?: string[] }): Promise; + createTopic(params: { + topicId: string; + name: string; + subscribe?: string[]; + }): Promise; /** * Create a new topic. * @@ -4762,34 +7011,48 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTopic(topicId: string, name: string, subscribe?: string[]): Promise; createTopic( - paramsOrFirst: { topicId: string, name: string, subscribe?: string[] } | string, - ...rest: [(string)?, (string[])?] + topicId: string, + name: string, + subscribe?: string[], + ): Promise; + createTopic( + paramsOrFirst: + { topicId: string; name: string; subscribe?: string[] } | string, + ...rest: [string?, string[]?] ): Promise { - let params: { topicId: string, name: string, subscribe?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, name: string, subscribe?: string[] }; + let params: { topicId: string; name: string; subscribe?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + name: string; + subscribe?: string[]; + }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, - subscribe: rest[1] as string[] + subscribe: rest[1] as string[], }; } - + const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/topics'; const payload: Payload = {}; if (typeof topicId !== 'undefined') { @@ -4806,20 +7069,15 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get a topic by its unique ID. - * + * * * @param {string} params.topicId - Topic ID. * @throws {AppwriteException} @@ -4828,7 +7086,7 @@ export class Messaging { getTopic(params: { topicId: string }): Promise; /** * Get a topic by its unique ID. - * + * * * @param {string} topicId - Topic ID. * @throws {AppwriteException} @@ -4837,44 +7095,47 @@ export class Messaging { */ getTopic(topicId: string): Promise; getTopic( - paramsOrFirst: { topicId: string } | string + paramsOrFirst: { topicId: string } | string, ): Promise { let params: { topicId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { topicId: string }; } else { params = { - topicId: paramsOrFirst as string + topicId: paramsOrFirst as string, }; } - + const topicId = params.topicId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', encodeURIComponent(String(topicId))); + const apiPath = '/messaging/topics/{topicId}'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Update a topic by its unique ID. - * + * * * @param {string} params.topicId - Topic ID. * @param {string} params.name - Topic Name. @@ -4882,10 +7143,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTopic(params: { topicId: string, name?: string, subscribe?: string[] }): Promise; + updateTopic(params: { + topicId: string; + name?: string; + subscribe?: string[]; + }): Promise; /** * Update a topic by its unique ID. - * + * * * @param {string} topicId - Topic ID. * @param {string} name - Topic Name. @@ -4894,32 +7159,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTopic(topicId: string, name?: string, subscribe?: string[]): Promise; updateTopic( - paramsOrFirst: { topicId: string, name?: string, subscribe?: string[] } | string, - ...rest: [(string)?, (string[])?] + topicId: string, + name?: string, + subscribe?: string[], + ): Promise; + updateTopic( + paramsOrFirst: + { topicId: string; name?: string; subscribe?: string[] } | string, + ...rest: [string?, string[]?] ): Promise { - let params: { topicId: string, name?: string, subscribe?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, name?: string, subscribe?: string[] }; + let params: { topicId: string; name?: string; subscribe?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + name?: string; + subscribe?: string[]; + }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, - subscribe: rest[1] as string[] + subscribe: rest[1] as string[], }; } - + const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', encodeURIComponent(String(topicId))); + const apiPath = '/messaging/topics/{topicId}'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4932,15 +7214,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4960,40 +7237,42 @@ export class Messaging { * @deprecated Use the object parameter style method for a better developer experience. */ deleteTopic(topicId: string): Promise<{}>; - deleteTopic( - paramsOrFirst: { topicId: string } | string - ): Promise<{}> { + deleteTopic(paramsOrFirst: { topicId: string } | string): Promise<{}> { let params: { topicId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { topicId: string }; } else { params = { - topicId: paramsOrFirst as string + topicId: paramsOrFirst as string, }; } - + const topicId = params.topicId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', encodeURIComponent(String(topicId))); + const apiPath = '/messaging/topics/{topicId}'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -5006,7 +7285,12 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listSubscribers(params: { topicId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listSubscribers(params: { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all subscribers from the current Appwrite project. * @@ -5018,34 +7302,64 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSubscribers(topicId: string, queries?: string[], search?: string, total?: boolean): Promise; listSubscribers( - paramsOrFirst: { topicId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + topicId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listSubscribers( + paramsOrFirst: + | { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { topicId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { topicId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const topicId = params.topicId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', encodeURIComponent(String(topicId))); + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -5060,15 +7374,10 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5080,7 +7389,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSubscriber(params: { topicId: string, subscriberId: string, targetId: string }): Promise; + createSubscriber(params: { + topicId: string; + subscriberId: string; + targetId: string; + }): Promise; /** * Create a new subscriber. * @@ -5091,38 +7404,60 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise; createSubscriber( - paramsOrFirst: { topicId: string, subscriberId: string, targetId: string } | string, - ...rest: [(string)?, (string)?] + topicId: string, + subscriberId: string, + targetId: string, + ): Promise; + createSubscriber( + paramsOrFirst: + | { topicId: string; subscriberId: string; targetId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { topicId: string, subscriberId: string, targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string, targetId: string }; + let params: { topicId: string; subscriberId: string; targetId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + subscriberId: string; + targetId: string; + }; } else { params = { topicId: paramsOrFirst as string, subscriberId: rest[0] as string, - targetId: rest[1] as string + targetId: rest[1] as string, }; } - + const topicId = params.topicId; const subscriberId = params.subscriberId; const targetId = params.targetId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } if (typeof subscriberId === 'undefined') { - throw new AppwriteException('Missing required parameter: "subscriberId"'); + throw new AppwriteException( + 'Missing required parameter: "subscriberId"', + ); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } - - const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', encodeURIComponent(String(topicId))); + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); const payload: Payload = {}; if (typeof subscriberId !== 'undefined') { payload['subscriberId'] = subscriberId; @@ -5135,30 +7470,28 @@ export class Messaging { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get a subscriber by its unique ID. - * + * * * @param {string} params.topicId - Topic ID. The topic ID subscribed to. * @param {string} params.subscriberId - Subscriber ID. * @throws {AppwriteException} * @returns {Promise} */ - getSubscriber(params: { topicId: string, subscriberId: string }): Promise; + getSubscriber(params: { + topicId: string; + subscriberId: string; + }): Promise; /** * Get a subscriber by its unique ID. - * + * * * @param {string} topicId - Topic ID. The topic ID subscribed to. * @param {string} subscriberId - Subscriber ID. @@ -5166,47 +7499,60 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getSubscriber(topicId: string, subscriberId: string): Promise; getSubscriber( - paramsOrFirst: { topicId: string, subscriberId: string } | string, - ...rest: [(string)?] + topicId: string, + subscriberId: string, + ): Promise; + getSubscriber( + paramsOrFirst: { topicId: string; subscriberId: string } | string, + ...rest: [string?] ): Promise { - let params: { topicId: string, subscriberId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + let params: { topicId: string; subscriberId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + subscriberId: string; + }; } else { params = { topicId: paramsOrFirst as string, - subscriberId: rest[0] as string + subscriberId: rest[0] as string, }; } - + const topicId = params.topicId; const subscriberId = params.subscriberId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); - } - if (typeof subscriberId === 'undefined') { - throw new AppwriteException('Missing required parameter: "subscriberId"'); - } - - const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', encodeURIComponent(String(topicId))).replace('{subscriberId}', encodeURIComponent(String(subscriberId))); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); + } + if (typeof subscriberId === 'undefined' || subscriberId === '') { + throw new AppwriteException( + 'Missing required parameter: "subscriberId"', + ); + } + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replace('{topicId}', encodeURIComponent(String(topicId))) + .replace( + '{subscriberId}', + encodeURIComponent(String(subscriberId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5217,7 +7563,10 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSubscriber(params: { topicId: string, subscriberId: string }): Promise<{}>; + deleteSubscriber(params: { + topicId: string; + subscriberId: string; + }): Promise<{}>; /** * Delete a subscriber by its unique ID. * @@ -5229,44 +7578,55 @@ export class Messaging { */ deleteSubscriber(topicId: string, subscriberId: string): Promise<{}>; deleteSubscriber( - paramsOrFirst: { topicId: string, subscriberId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { topicId: string; subscriberId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { topicId: string, subscriberId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + let params: { topicId: string; subscriberId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + subscriberId: string; + }; } else { params = { topicId: paramsOrFirst as string, - subscriberId: rest[0] as string + subscriberId: rest[0] as string, }; } - + const topicId = params.topicId; const subscriberId = params.subscriberId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); - } - if (typeof subscriberId === 'undefined') { - throw new AppwriteException('Missing required parameter: "subscriberId"'); - } - - const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', encodeURIComponent(String(topicId))).replace('{subscriberId}', encodeURIComponent(String(subscriberId))); + if (typeof topicId === 'undefined' || topicId === '') { + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); + } + if (typeof subscriberId === 'undefined' || subscriberId === '') { + throw new AppwriteException( + 'Missing required parameter: "subscriberId"', + ); + } + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replace('{topicId}', encodeURIComponent(String(topicId))) + .replace( + '{subscriberId}', + encodeURIComponent(String(subscriberId)), + ); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/migrations.ts b/src/services/migrations.ts index 9e882c63..92dd613b 100644 --- a/src/services/migrations.ts +++ b/src/services/migrations.ts @@ -1,5 +1,4 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { AppwriteMigrationResource } from '../enums/appwrite-migration-resource'; @@ -7,7 +6,6 @@ import { OnDuplicate } from '../enums/on-duplicate'; import { FirebaseMigrationResource } from '../enums/firebase-migration-resource'; import { NHostMigrationResource } from '../enums/n-host-migration-resource'; import { SupabaseMigrationResource } from '../enums/supabase-migration-resource'; - export class Migrations { client: Client; @@ -24,7 +22,11 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * List all migrations in the current project. This endpoint returns a list of all migrations including their status, progress, and any errors that occurred during the migration process. * @@ -35,28 +37,41 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/migrations'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -72,19 +87,14 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Migrate data from another Appwrite project to your current project. This endpoint allows you to migrate resources like databases, collections, documents, users, and files from an existing Appwrite project. + * Migrate data from another Appwrite project to your current project. This endpoint allows you to migrate resources like databases, collections, documents, users, and files from an existing Appwrite project. * * @param {AppwriteMigrationResource[]} params.resources - List of resources to migrate * @param {string} params.endpoint - Source Appwrite endpoint @@ -94,9 +104,15 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createAppwriteMigration(params: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate }): Promise; + createAppwriteMigration(params: { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectId: string; + apiKey: string; + onDuplicate?: OnDuplicate; + }): Promise; /** - * Migrate data from another Appwrite project to your current project. This endpoint allows you to migrate resources like databases, collections, documents, users, and files from an existing Appwrite project. + * Migrate data from another Appwrite project to your current project. This endpoint allows you to migrate resources like databases, collections, documents, users, and files from an existing Appwrite project. * * @param {AppwriteMigrationResource[]} resources - List of resources to migrate * @param {string} endpoint - Source Appwrite endpoint @@ -107,25 +123,60 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAppwriteMigration(resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate): Promise; createAppwriteMigration( - paramsOrFirst: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate } | AppwriteMigrationResource[], - ...rest: [(string)?, (string)?, (string)?, (OnDuplicate)?] + resources: AppwriteMigrationResource[], + endpoint: string, + projectId: string, + apiKey: string, + onDuplicate?: OnDuplicate, + ): Promise; + createAppwriteMigration( + paramsOrFirst: + | { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectId: string; + apiKey: string; + onDuplicate?: OnDuplicate; + } + | AppwriteMigrationResource[], + ...rest: [string?, string?, string?, OnDuplicate?] ): Promise { - let params: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'endpoint' in paramsOrFirst || 'projectId' in paramsOrFirst || 'apiKey' in paramsOrFirst || 'onDuplicate' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate }; + let params: { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectId: string; + apiKey: string; + onDuplicate?: OnDuplicate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || + 'endpoint' in paramsOrFirst || + 'projectId' in paramsOrFirst || + 'apiKey' in paramsOrFirst || + 'onDuplicate' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectId: string; + apiKey: string; + onDuplicate?: OnDuplicate; + }; } else { params = { resources: paramsOrFirst as AppwriteMigrationResource[], endpoint: rest[0] as string, projectId: rest[1] as string, apiKey: rest[2] as string, - onDuplicate: rest[3] as OnDuplicate + onDuplicate: rest[3] as OnDuplicate, }; } - + const resources = params.resources; const endpoint = params.endpoint; const projectId = params.projectId; @@ -133,18 +184,23 @@ export class Migrations { const onDuplicate = params.onDuplicate; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof endpoint === 'undefined') { - throw new AppwriteException('Missing required parameter: "endpoint"'); + throw new AppwriteException( + 'Missing required parameter: "endpoint"', + ); } if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof apiKey === 'undefined') { throw new AppwriteException('Missing required parameter: "apiKey"'); } - const apiPath = '/migrations/appwrite'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -167,15 +223,10 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -188,7 +239,12 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - getAppwriteReport(params: { resources: AppwriteMigrationResource[], endpoint: string, projectID: string, key: string }): Promise; + getAppwriteReport(params: { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectID: string; + key: string; + }): Promise; /** * Generate a report of the data in an Appwrite project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. * @@ -200,42 +256,77 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAppwriteReport(resources: AppwriteMigrationResource[], endpoint: string, projectID: string, key: string): Promise; getAppwriteReport( - paramsOrFirst: { resources: AppwriteMigrationResource[], endpoint: string, projectID: string, key: string } | AppwriteMigrationResource[], - ...rest: [(string)?, (string)?, (string)?] + resources: AppwriteMigrationResource[], + endpoint: string, + projectID: string, + key: string, + ): Promise; + getAppwriteReport( + paramsOrFirst: + | { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectID: string; + key: string; + } + | AppwriteMigrationResource[], + ...rest: [string?, string?, string?] ): Promise { - let params: { resources: AppwriteMigrationResource[], endpoint: string, projectID: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'endpoint' in paramsOrFirst || 'projectID' in paramsOrFirst || 'key' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: AppwriteMigrationResource[], endpoint: string, projectID: string, key: string }; + let params: { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectID: string; + key: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || + 'endpoint' in paramsOrFirst || + 'projectID' in paramsOrFirst || + 'key' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: AppwriteMigrationResource[]; + endpoint: string; + projectID: string; + key: string; + }; } else { params = { resources: paramsOrFirst as AppwriteMigrationResource[], endpoint: rest[0] as string, projectID: rest[1] as string, - key: rest[2] as string + key: rest[2] as string, }; } - + const resources = params.resources; const endpoint = params.endpoint; const projectID = params.projectID; const key = params.key; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof endpoint === 'undefined') { - throw new AppwriteException('Missing required parameter: "endpoint"'); + throw new AppwriteException( + 'Missing required parameter: "endpoint"', + ); } if (typeof projectID === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectID"'); + throw new AppwriteException( + 'Missing required parameter: "projectID"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - const apiPath = '/migrations/appwrite/report'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -254,15 +345,10 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -281,7 +367,18 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createCSVExport(params: { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], delimiter?: string, enclosure?: string, escape?: string, header?: boolean, notify?: boolean }): Promise; + createCSVExport(params: { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + delimiter?: string; + enclosure?: string; + escape?: string; + header?: boolean; + notify?: boolean; + }): Promise; /** * Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete. * @@ -299,15 +396,75 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCSVExport(databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], delimiter?: string, enclosure?: string, escape?: string, header?: boolean, notify?: boolean): Promise; createCSVExport( - paramsOrFirst: { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], delimiter?: string, enclosure?: string, escape?: string, header?: boolean, notify?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + filename: string, + columns?: string[], + queries?: string[], + delimiter?: string, + enclosure?: string, + escape?: string, + header?: boolean, + notify?: boolean, + ): Promise; + createCSVExport( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + delimiter?: string; + enclosure?: string; + escape?: string; + header?: boolean; + notify?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + string[]?, + string?, + string?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], delimiter?: string, enclosure?: string, escape?: string, header?: boolean, notify?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], delimiter?: string, enclosure?: string, escape?: string, header?: boolean, notify?: boolean }; + let params: { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + delimiter?: string; + enclosure?: string; + escape?: string; + header?: boolean; + notify?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + delimiter?: string; + enclosure?: string; + escape?: string; + header?: boolean; + notify?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -319,10 +476,10 @@ export class Migrations { enclosure: rest[5] as string, escape: rest[6] as string, header: rest[7] as boolean, - notify: rest[8] as boolean + notify: rest[8] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const filename = params.filename; @@ -335,15 +492,20 @@ export class Migrations { const notify = params.notify; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof filename === 'undefined') { - throw new AppwriteException('Missing required parameter: "filename"'); + throw new AppwriteException( + 'Missing required parameter: "filename"', + ); } - const apiPath = '/migrations/csv/exports'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -381,15 +543,10 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -404,7 +561,14 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createCSVImport(params: { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }): Promise; + createCSVImport(params: { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + }): Promise; /** * Import documents from a CSV file into your Appwrite database. This endpoint allows you to import documents from a CSV file uploaded to Appwrite Storage bucket. * @@ -418,15 +582,49 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCSVImport(bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate): Promise; createCSVImport( - paramsOrFirst: { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?, (OnDuplicate)?] + bucketId: string, + fileId: string, + databaseId: string, + collectionId: string, + internalFile?: boolean, + onDuplicate?: OnDuplicate, + ): Promise; + createCSVImport( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + } + | string, + ...rest: [string?, string?, string?, boolean?, OnDuplicate?] ): Promise { - let params: { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; + let params: { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -434,10 +632,10 @@ export class Migrations { databaseId: rest[1] as string, collectionId: rest[2] as string, internalFile: rest[3] as boolean, - onDuplicate: rest[4] as OnDuplicate + onDuplicate: rest[4] as OnDuplicate, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const databaseId = params.databaseId; @@ -446,18 +644,23 @@ export class Migrations { const onDuplicate = params.onDuplicate; if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - const apiPath = '/migrations/csv/imports'; const payload: Payload = {}; if (typeof bucketId !== 'undefined') { @@ -483,28 +686,26 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Migrate data from a Firebase project to your Appwrite project. This endpoint allows you to migrate resources like authentication and other supported services from a Firebase project. + * Migrate data from a Firebase project to your Appwrite project. This endpoint allows you to migrate resources like authentication and other supported services from a Firebase project. * * @param {FirebaseMigrationResource[]} params.resources - List of resources to migrate * @param {string} params.serviceAccount - JSON of the Firebase service account credentials * @throws {AppwriteException} * @returns {Promise} */ - createFirebaseMigration(params: { resources: FirebaseMigrationResource[], serviceAccount: string }): Promise; + createFirebaseMigration(params: { + resources: FirebaseMigrationResource[]; + serviceAccount: string; + }): Promise; /** - * Migrate data from a Firebase project to your Appwrite project. This endpoint allows you to migrate resources like authentication and other supported services from a Firebase project. + * Migrate data from a Firebase project to your Appwrite project. This endpoint allows you to migrate resources like authentication and other supported services from a Firebase project. * * @param {FirebaseMigrationResource[]} resources - List of resources to migrate * @param {string} serviceAccount - JSON of the Firebase service account credentials @@ -512,32 +713,51 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFirebaseMigration(resources: FirebaseMigrationResource[], serviceAccount: string): Promise; createFirebaseMigration( - paramsOrFirst: { resources: FirebaseMigrationResource[], serviceAccount: string } | FirebaseMigrationResource[], - ...rest: [(string)?] + resources: FirebaseMigrationResource[], + serviceAccount: string, + ): Promise; + createFirebaseMigration( + paramsOrFirst: + | { resources: FirebaseMigrationResource[]; serviceAccount: string } + | FirebaseMigrationResource[], + ...rest: [string?] ): Promise { - let params: { resources: FirebaseMigrationResource[], serviceAccount: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'serviceAccount' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: FirebaseMigrationResource[], serviceAccount: string }; + let params: { + resources: FirebaseMigrationResource[]; + serviceAccount: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || 'serviceAccount' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: FirebaseMigrationResource[]; + serviceAccount: string; + }; } else { params = { resources: paramsOrFirst as FirebaseMigrationResource[], - serviceAccount: rest[0] as string + serviceAccount: rest[0] as string, }; } - + const resources = params.resources; const serviceAccount = params.serviceAccount; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof serviceAccount === 'undefined') { - throw new AppwriteException('Missing required parameter: "serviceAccount"'); + throw new AppwriteException( + 'Missing required parameter: "serviceAccount"', + ); } - const apiPath = '/migrations/firebase'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -551,15 +771,10 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -570,7 +785,10 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - getFirebaseReport(params: { resources: FirebaseMigrationResource[], serviceAccount: string }): Promise; + getFirebaseReport(params: { + resources: FirebaseMigrationResource[]; + serviceAccount: string; + }): Promise; /** * Generate a report of the data in a Firebase project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. * @@ -580,32 +798,51 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getFirebaseReport(resources: FirebaseMigrationResource[], serviceAccount: string): Promise; getFirebaseReport( - paramsOrFirst: { resources: FirebaseMigrationResource[], serviceAccount: string } | FirebaseMigrationResource[], - ...rest: [(string)?] + resources: FirebaseMigrationResource[], + serviceAccount: string, + ): Promise; + getFirebaseReport( + paramsOrFirst: + | { resources: FirebaseMigrationResource[]; serviceAccount: string } + | FirebaseMigrationResource[], + ...rest: [string?] ): Promise { - let params: { resources: FirebaseMigrationResource[], serviceAccount: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'serviceAccount' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: FirebaseMigrationResource[], serviceAccount: string }; + let params: { + resources: FirebaseMigrationResource[]; + serviceAccount: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || 'serviceAccount' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: FirebaseMigrationResource[]; + serviceAccount: string; + }; } else { params = { resources: paramsOrFirst as FirebaseMigrationResource[], - serviceAccount: rest[0] as string + serviceAccount: rest[0] as string, }; } - + const resources = params.resources; const serviceAccount = params.serviceAccount; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof serviceAccount === 'undefined') { - throw new AppwriteException('Missing required parameter: "serviceAccount"'); + throw new AppwriteException( + 'Missing required parameter: "serviceAccount"', + ); } - const apiPath = '/migrations/firebase/report'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -618,20 +855,15 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Export documents to a JSON file from your Appwrite database. This endpoint allows you to export documents to a JSON file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete. - * + * * * @param {string} params.databaseId - Database ID containing the source collection. * @param {string} params.collectionId - Collection ID to export documents from. @@ -642,10 +874,17 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createJSONExport(params: { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], notify?: boolean }): Promise; + createJSONExport(params: { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + notify?: boolean; + }): Promise; /** * Export documents to a JSON file from your Appwrite database. This endpoint allows you to export documents to a JSON file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete. - * + * * * @param {string} databaseId - Database ID containing the source collection. * @param {string} collectionId - Collection ID to export documents from. @@ -657,15 +896,49 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createJSONExport(databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], notify?: boolean): Promise; createJSONExport( - paramsOrFirst: { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], notify?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + filename: string, + columns?: string[], + queries?: string[], + notify?: boolean, + ): Promise; + createJSONExport( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + notify?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], notify?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, filename: string, columns?: string[], queries?: string[], notify?: boolean }; + let params: { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + notify?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + filename: string; + columns?: string[]; + queries?: string[]; + notify?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -673,10 +946,10 @@ export class Migrations { filename: rest[1] as string, columns: rest[2] as string[], queries: rest[3] as string[], - notify: rest[4] as boolean + notify: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const filename = params.filename; @@ -685,15 +958,20 @@ export class Migrations { const notify = params.notify; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof filename === 'undefined') { - throw new AppwriteException('Missing required parameter: "filename"'); + throw new AppwriteException( + 'Missing required parameter: "filename"', + ); } - const apiPath = '/migrations/json/exports'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -719,20 +997,15 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Import documents from a JSON file into your Appwrite database. This endpoint allows you to import documents from a JSON file uploaded to Appwrite Storage bucket. - * + * * * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} params.fileId - File ID. @@ -743,10 +1016,17 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createJSONImport(params: { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }): Promise; + createJSONImport(params: { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + }): Promise; /** * Import documents from a JSON file into your Appwrite database. This endpoint allows you to import documents from a JSON file uploaded to Appwrite Storage bucket. - * + * * * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} fileId - File ID. @@ -758,15 +1038,49 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createJSONImport(bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate): Promise; createJSONImport( - paramsOrFirst: { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?, (OnDuplicate)?] + bucketId: string, + fileId: string, + databaseId: string, + collectionId: string, + internalFile?: boolean, + onDuplicate?: OnDuplicate, + ): Promise; + createJSONImport( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + } + | string, + ...rest: [string?, string?, string?, boolean?, OnDuplicate?] ): Promise { - let params: { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, databaseId: string, collectionId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; + let params: { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + databaseId: string; + collectionId: string; + internalFile?: boolean; + onDuplicate?: OnDuplicate; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -774,10 +1088,10 @@ export class Migrations { databaseId: rest[1] as string, collectionId: rest[2] as string, internalFile: rest[3] as boolean, - onDuplicate: rest[4] as OnDuplicate + onDuplicate: rest[4] as OnDuplicate, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const databaseId = params.databaseId; @@ -786,18 +1100,23 @@ export class Migrations { const onDuplicate = params.onDuplicate; if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - const apiPath = '/migrations/json/imports'; const payload: Payload = {}; if (typeof bucketId !== 'undefined') { @@ -823,19 +1142,14 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Migrate data from an NHost project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from an NHost project. + * Migrate data from an NHost project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from an NHost project. * * @param {NHostMigrationResource[]} params.resources - List of resources to migrate * @param {string} params.subdomain - Source's Subdomain @@ -848,9 +1162,18 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createNHostMigration(params: { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number }): Promise; + createNHostMigration(params: { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + }): Promise; /** - * Migrate data from an NHost project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from an NHost project. + * Migrate data from an NHost project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from an NHost project. * * @param {NHostMigrationResource[]} resources - List of resources to migrate * @param {string} subdomain - Source's Subdomain @@ -864,15 +1187,65 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createNHostMigration(resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number): Promise; createNHostMigration( - paramsOrFirst: { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number } | NHostMigrationResource[], - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?] + resources: NHostMigrationResource[], + subdomain: string, + region: string, + adminSecret: string, + database: string, + username: string, + password: string, + port?: number, + ): Promise; + createNHostMigration( + paramsOrFirst: + | { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + } + | NHostMigrationResource[], + ...rest: [string?, string?, string?, string?, string?, string?, number?] ): Promise { - let params: { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'subdomain' in paramsOrFirst || 'region' in paramsOrFirst || 'adminSecret' in paramsOrFirst || 'database' in paramsOrFirst || 'username' in paramsOrFirst || 'password' in paramsOrFirst || 'port' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number }; + let params: { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || + 'subdomain' in paramsOrFirst || + 'region' in paramsOrFirst || + 'adminSecret' in paramsOrFirst || + 'database' in paramsOrFirst || + 'username' in paramsOrFirst || + 'password' in paramsOrFirst || + 'port' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + }; } else { params = { resources: paramsOrFirst as NHostMigrationResource[], @@ -882,10 +1255,10 @@ export class Migrations { database: rest[3] as string, username: rest[4] as string, password: rest[5] as string, - port: rest[6] as number + port: rest[6] as number, }; } - + const resources = params.resources; const subdomain = params.subdomain; const region = params.region; @@ -896,27 +1269,38 @@ export class Migrations { const port = params.port; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof subdomain === 'undefined') { - throw new AppwriteException('Missing required parameter: "subdomain"'); + throw new AppwriteException( + 'Missing required parameter: "subdomain"', + ); } if (typeof region === 'undefined') { throw new AppwriteException('Missing required parameter: "region"'); } if (typeof adminSecret === 'undefined') { - throw new AppwriteException('Missing required parameter: "adminSecret"'); + throw new AppwriteException( + 'Missing required parameter: "adminSecret"', + ); } if (typeof database === 'undefined') { - throw new AppwriteException('Missing required parameter: "database"'); + throw new AppwriteException( + 'Missing required parameter: "database"', + ); } if (typeof username === 'undefined') { - throw new AppwriteException('Missing required parameter: "username"'); + throw new AppwriteException( + 'Missing required parameter: "username"', + ); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/migrations/nhost'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -948,19 +1332,14 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Generate a detailed report of the data in an NHost project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. + * Generate a detailed report of the data in an NHost project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. * * @param {NHostMigrationResource[]} params.resources - List of resources to migrate. * @param {string} params.subdomain - Source's Subdomain. @@ -973,9 +1352,18 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - getNHostReport(params: { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number }): Promise; + getNHostReport(params: { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + }): Promise; /** - * Generate a detailed report of the data in an NHost project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. + * Generate a detailed report of the data in an NHost project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. * * @param {NHostMigrationResource[]} resources - List of resources to migrate. * @param {string} subdomain - Source's Subdomain. @@ -989,15 +1377,65 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getNHostReport(resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number): Promise; getNHostReport( - paramsOrFirst: { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number } | NHostMigrationResource[], - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?] + resources: NHostMigrationResource[], + subdomain: string, + region: string, + adminSecret: string, + database: string, + username: string, + password: string, + port?: number, + ): Promise; + getNHostReport( + paramsOrFirst: + | { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + } + | NHostMigrationResource[], + ...rest: [string?, string?, string?, string?, string?, string?, number?] ): Promise { - let params: { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'subdomain' in paramsOrFirst || 'region' in paramsOrFirst || 'adminSecret' in paramsOrFirst || 'database' in paramsOrFirst || 'username' in paramsOrFirst || 'password' in paramsOrFirst || 'port' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: NHostMigrationResource[], subdomain: string, region: string, adminSecret: string, database: string, username: string, password: string, port?: number }; + let params: { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || + 'subdomain' in paramsOrFirst || + 'region' in paramsOrFirst || + 'adminSecret' in paramsOrFirst || + 'database' in paramsOrFirst || + 'username' in paramsOrFirst || + 'password' in paramsOrFirst || + 'port' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: NHostMigrationResource[]; + subdomain: string; + region: string; + adminSecret: string; + database: string; + username: string; + password: string; + port?: number; + }; } else { params = { resources: paramsOrFirst as NHostMigrationResource[], @@ -1007,10 +1445,10 @@ export class Migrations { database: rest[3] as string, username: rest[4] as string, password: rest[5] as string, - port: rest[6] as number + port: rest[6] as number, }; } - + const resources = params.resources; const subdomain = params.subdomain; const region = params.region; @@ -1021,27 +1459,38 @@ export class Migrations { const port = params.port; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof subdomain === 'undefined') { - throw new AppwriteException('Missing required parameter: "subdomain"'); + throw new AppwriteException( + 'Missing required parameter: "subdomain"', + ); } if (typeof region === 'undefined') { throw new AppwriteException('Missing required parameter: "region"'); } if (typeof adminSecret === 'undefined') { - throw new AppwriteException('Missing required parameter: "adminSecret"'); + throw new AppwriteException( + 'Missing required parameter: "adminSecret"', + ); } if (typeof database === 'undefined') { - throw new AppwriteException('Missing required parameter: "database"'); + throw new AppwriteException( + 'Missing required parameter: "database"', + ); } if (typeof username === 'undefined') { - throw new AppwriteException('Missing required parameter: "username"'); + throw new AppwriteException( + 'Missing required parameter: "username"', + ); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/migrations/nhost/report'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -1072,19 +1521,14 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Migrate data from a Supabase project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from a Supabase project. + * Migrate data from a Supabase project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from a Supabase project. * * @param {SupabaseMigrationResource[]} params.resources - List of resources to migrate * @param {string} params.endpoint - Source's Supabase Endpoint @@ -1096,9 +1540,17 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - createSupabaseMigration(params: { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number }): Promise; + createSupabaseMigration(params: { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + }): Promise; /** - * Migrate data from a Supabase project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from a Supabase project. + * Migrate data from a Supabase project to your Appwrite project. This endpoint allows you to migrate resources like authentication, databases, and other supported services from a Supabase project. * * @param {SupabaseMigrationResource[]} resources - List of resources to migrate * @param {string} endpoint - Source's Supabase Endpoint @@ -1111,15 +1563,60 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSupabaseMigration(resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number): Promise; createSupabaseMigration( - paramsOrFirst: { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number } | SupabaseMigrationResource[], - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (number)?] + resources: SupabaseMigrationResource[], + endpoint: string, + apiKey: string, + databaseHost: string, + username: string, + password: string, + port?: number, + ): Promise; + createSupabaseMigration( + paramsOrFirst: + | { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + } + | SupabaseMigrationResource[], + ...rest: [string?, string?, string?, string?, string?, number?] ): Promise { - let params: { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'endpoint' in paramsOrFirst || 'apiKey' in paramsOrFirst || 'databaseHost' in paramsOrFirst || 'username' in paramsOrFirst || 'password' in paramsOrFirst || 'port' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number }; + let params: { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || + 'endpoint' in paramsOrFirst || + 'apiKey' in paramsOrFirst || + 'databaseHost' in paramsOrFirst || + 'username' in paramsOrFirst || + 'password' in paramsOrFirst || + 'port' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + }; } else { params = { resources: paramsOrFirst as SupabaseMigrationResource[], @@ -1128,10 +1625,10 @@ export class Migrations { databaseHost: rest[2] as string, username: rest[3] as string, password: rest[4] as string, - port: rest[5] as number + port: rest[5] as number, }; } - + const resources = params.resources; const endpoint = params.endpoint; const apiKey = params.apiKey; @@ -1141,24 +1638,33 @@ export class Migrations { const port = params.port; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof endpoint === 'undefined') { - throw new AppwriteException('Missing required parameter: "endpoint"'); + throw new AppwriteException( + 'Missing required parameter: "endpoint"', + ); } if (typeof apiKey === 'undefined') { throw new AppwriteException('Missing required parameter: "apiKey"'); } if (typeof databaseHost === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseHost"'); + throw new AppwriteException( + 'Missing required parameter: "databaseHost"', + ); } if (typeof username === 'undefined') { - throw new AppwriteException('Missing required parameter: "username"'); + throw new AppwriteException( + 'Missing required parameter: "username"', + ); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/migrations/supabase'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -1187,19 +1693,14 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Generate a report of the data in a Supabase project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. + * Generate a report of the data in a Supabase project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. * * @param {SupabaseMigrationResource[]} params.resources - List of resources to migrate * @param {string} params.endpoint - Source's Supabase Endpoint. @@ -1211,9 +1712,17 @@ export class Migrations { * @throws {AppwriteException} * @returns {Promise} */ - getSupabaseReport(params: { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number }): Promise; + getSupabaseReport(params: { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + }): Promise; /** - * Generate a report of the data in a Supabase project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. + * Generate a report of the data in a Supabase project before migrating. This endpoint analyzes the source project and returns information about the resources that can be migrated. * * @param {SupabaseMigrationResource[]} resources - List of resources to migrate * @param {string} endpoint - Source's Supabase Endpoint. @@ -1226,15 +1735,60 @@ export class Migrations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getSupabaseReport(resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number): Promise; getSupabaseReport( - paramsOrFirst: { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number } | SupabaseMigrationResource[], - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (number)?] + resources: SupabaseMigrationResource[], + endpoint: string, + apiKey: string, + databaseHost: string, + username: string, + password: string, + port?: number, + ): Promise; + getSupabaseReport( + paramsOrFirst: + | { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + } + | SupabaseMigrationResource[], + ...rest: [string?, string?, string?, string?, string?, number?] ): Promise { - let params: { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'endpoint' in paramsOrFirst || 'apiKey' in paramsOrFirst || 'databaseHost' in paramsOrFirst || 'username' in paramsOrFirst || 'password' in paramsOrFirst || 'port' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: SupabaseMigrationResource[], endpoint: string, apiKey: string, databaseHost: string, username: string, password: string, port?: number }; + let params: { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('resources' in paramsOrFirst || + 'endpoint' in paramsOrFirst || + 'apiKey' in paramsOrFirst || + 'databaseHost' in paramsOrFirst || + 'username' in paramsOrFirst || + 'password' in paramsOrFirst || + 'port' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + resources: SupabaseMigrationResource[]; + endpoint: string; + apiKey: string; + databaseHost: string; + username: string; + password: string; + port?: number; + }; } else { params = { resources: paramsOrFirst as SupabaseMigrationResource[], @@ -1243,10 +1797,10 @@ export class Migrations { databaseHost: rest[2] as string, username: rest[3] as string, password: rest[4] as string, - port: rest[5] as number + port: rest[5] as number, }; } - + const resources = params.resources; const endpoint = params.endpoint; const apiKey = params.apiKey; @@ -1256,24 +1810,33 @@ export class Migrations { const port = params.port; if (typeof resources === 'undefined') { - throw new AppwriteException('Missing required parameter: "resources"'); + throw new AppwriteException( + 'Missing required parameter: "resources"', + ); } if (typeof endpoint === 'undefined') { - throw new AppwriteException('Missing required parameter: "endpoint"'); + throw new AppwriteException( + 'Missing required parameter: "endpoint"', + ); } if (typeof apiKey === 'undefined') { throw new AppwriteException('Missing required parameter: "apiKey"'); } if (typeof databaseHost === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseHost"'); + throw new AppwriteException( + 'Missing required parameter: "databaseHost"', + ); } if (typeof username === 'undefined') { - throw new AppwriteException('Missing required parameter: "username"'); + throw new AppwriteException( + 'Missing required parameter: "username"', + ); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/migrations/supabase/report'; const payload: Payload = {}; if (typeof resources !== 'undefined') { @@ -1301,19 +1864,14 @@ export class Migrations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Get a migration by its unique ID. This endpoint returns detailed information about a specific migration including its current status, progress, and any errors that occurred during the migration process. + * Get a migration by its unique ID. This endpoint returns detailed information about a specific migration including its current status, progress, and any errors that occurred during the migration process. * * @param {string} params.migrationId - Migration unique ID. * @throws {AppwriteException} @@ -1321,7 +1879,7 @@ export class Migrations { */ get(params: { migrationId: string }): Promise; /** - * Get a migration by its unique ID. This endpoint returns detailed information about a specific migration including its current status, progress, and any errors that occurred during the migration process. + * Get a migration by its unique ID. This endpoint returns detailed information about a specific migration including its current status, progress, and any errors that occurred during the migration process. * * @param {string} migrationId - Migration unique ID. * @throws {AppwriteException} @@ -1330,39 +1888,42 @@ export class Migrations { */ get(migrationId: string): Promise; get( - paramsOrFirst: { migrationId: string } | string + paramsOrFirst: { migrationId: string } | string, ): Promise { let params: { migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { migrationId: string }; } else { params = { - migrationId: paramsOrFirst as string + migrationId: paramsOrFirst as string, }; } - + const migrationId = params.migrationId; - if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); + if (typeof migrationId === 'undefined' || migrationId === '') { + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); } - - const apiPath = '/migrations/{migrationId}'.replace('{migrationId}', encodeURIComponent(String(migrationId))); + const apiPath = '/migrations/{migrationId}'.replace( + '{migrationId}', + encodeURIComponent(String(migrationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1383,44 +1944,47 @@ export class Migrations { */ retry(migrationId: string): Promise; retry( - paramsOrFirst: { migrationId: string } | string + paramsOrFirst: { migrationId: string } | string, ): Promise { let params: { migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { migrationId: string }; } else { params = { - migrationId: paramsOrFirst as string + migrationId: paramsOrFirst as string, }; } - + const migrationId = params.migrationId; - if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); + if (typeof migrationId === 'undefined' || migrationId === '') { + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); } - - const apiPath = '/migrations/{migrationId}'.replace('{migrationId}', encodeURIComponent(String(migrationId))); + const apiPath = '/migrations/{migrationId}'.replace( + '{migrationId}', + encodeURIComponent(String(migrationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** - * Delete a migration by its unique ID. This endpoint allows you to remove a migration from your project's migration history. + * Delete a migration by its unique ID. This endpoint allows you to remove a migration from your project's migration history. * * @param {string} params.migrationId - Migration ID. * @throws {AppwriteException} @@ -1428,7 +1992,7 @@ export class Migrations { */ delete(params: { migrationId: string }): Promise<{}>; /** - * Delete a migration by its unique ID. This endpoint allows you to remove a migration from your project's migration history. + * Delete a migration by its unique ID. This endpoint allows you to remove a migration from your project's migration history. * * @param {string} migrationId - Migration ID. * @throws {AppwriteException} @@ -1436,39 +2000,41 @@ export class Migrations { * @deprecated Use the object parameter style method for a better developer experience. */ delete(migrationId: string): Promise<{}>; - delete( - paramsOrFirst: { migrationId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { migrationId: string } | string): Promise<{}> { let params: { migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { migrationId: string }; } else { params = { - migrationId: paramsOrFirst as string + migrationId: paramsOrFirst as string, }; } - + const migrationId = params.migrationId; - if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); + if (typeof migrationId === 'undefined' || migrationId === '') { + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); } - - const apiPath = '/migrations/{migrationId}'.replace('{migrationId}', encodeURIComponent(String(migrationId))); + const apiPath = '/migrations/{migrationId}'.replace( + '{migrationId}', + encodeURIComponent(String(migrationId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/mongo.ts b/src/services/mongo.ts index 5c9d7fbe..06435ef5 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Mongo { client: Client; @@ -17,7 +15,9 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[] }): Promise; + list(params?: { + queries?: string[]; + }): Promise; /** * List all dedicated databases. Results support pagination. * @@ -28,20 +28,24 @@ export class Mongo { */ list(queries?: string[]): Promise; list( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/mongo'; const payload: Payload = {}; @@ -52,15 +56,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -72,7 +71,6 @@ export class Mongo { * @param {string} params.specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {string} params.standbyRegion - Standby region for a cross-region replica. When set, a replica is provisioned in this region for cross-region high availability. Must differ from the database region. * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds. * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} params.idleTimeoutMinutes - Minutes of inactivity before container scales to zero. @@ -80,11 +78,26 @@ export class Mongo { * @param {number} params.pitrRetentionDays - Number of days to retain PITR data. * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. - * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }): Promise; + create(params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }): Promise; /** * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. * @@ -94,7 +107,6 @@ export class Mongo { * @param {string} specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {string} standbyRegion - Standby region for a cross-region replica. When set, a replica is provisioned in this region for cross-region high availability. Must differ from the database region. * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds. * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} idleTimeoutMinutes - Minutes of inactivity before container scales to zero. @@ -102,20 +114,100 @@ export class Mongo { * @param {number} pitrRetentionDays - Number of days to retain PITR data. * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. - * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?] + databaseId: string, + name: string, + version?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + ] ): Promise { - let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; + let params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -124,41 +216,41 @@ export class Mongo { specification: rest[2] as string, replicas: rest[3] as number, syncMode: rest[4] as string, - standbyRegion: rest[5] as string, - networkIdleTimeoutSeconds: rest[6] as number, - networkIPAllowlist: rest[7] as string[], - idleTimeoutMinutes: rest[8] as number, - pitr: rest[9] as boolean, - pitrRetentionDays: rest[10] as number, - storageAutoscaling: rest[11] as boolean, - storageAutoscalingThresholdPercent: rest[12] as number, - storageAutoscalingMaxGb: rest[13] as number + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, }; } - + const databaseId = params.databaseId; const name = params.name; const version = params.version; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - const standbyRegion = params.standbyRegion; const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; const networkIPAllowlist = params.networkIPAllowlist; const idleTimeoutMinutes = params.idleTimeoutMinutes; const pitr = params.pitr; const pitrRetentionDays = params.pitrRetentionDays; const storageAutoscaling = params.storageAutoscaling; - const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/mongo'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -179,9 +271,6 @@ export class Mongo { if (typeof syncMode !== 'undefined') { payload['syncMode'] = syncMode; } - if (typeof standbyRegion !== 'undefined') { - payload['standbyRegion'] = standbyRegion; - } if (typeof networkIdleTimeoutSeconds !== 'undefined') { payload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; } @@ -201,7 +290,8 @@ export class Mongo { payload['storageAutoscaling'] = storageAutoscaling; } if (typeof storageAutoscalingThresholdPercent !== 'undefined') { - payload['storageAutoscalingThresholdPercent'] = storageAutoscalingThresholdPercent; + payload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; } if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; @@ -211,40 +301,29 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. * * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/mongo/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -265,39 +344,42 @@ export class Mongo { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -309,8 +391,6 @@ export class Mongo { * @param {string} params.specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {number} params.crossRegionReplicas - Number of cross-region standby replicas (0-1). Cross-region replication is enabled when greater than 0. - * @param {string} params.standbyRegion - Standby region for the cross-region replica. Required when enabling cross-region replication and no standby region is already configured. Must differ from the database region. * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} params.idleTimeoutMinutes - Minutes before container scales to zero. @@ -329,7 +409,29 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }): Promise; + update(params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }): Promise; /** * Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. * @@ -339,8 +441,6 @@ export class Mongo { * @param {string} specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {number} crossRegionReplicas - Number of cross-region standby replicas (0-1). Cross-region replication is enabled when greater than 0. - * @param {string} standbyRegion - Standby region for the cross-region replica. Required when enabling cross-region replication and no standby region is already configured. Must differ from the database region. * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} idleTimeoutMinutes - Minutes before container scales to zero. @@ -360,15 +460,130 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (number)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?] + databaseId: string, + name?: string, + status?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + metricsTraceSampleRate?: number, + metricsSlowQueryLogThresholdMs?: number, + sqlApiEnabled?: boolean, + sqlApiAllowedStatements?: string[], + sqlApiMaxRows?: number, + sqlApiMaxBytes?: number, + sqlApiTimeoutSeconds?: number, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + number?, + number?, + boolean?, + string[]?, + number?, + number?, + number?, + ] ): Promise { - let params: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }; + let params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -377,55 +592,57 @@ export class Mongo { specification: rest[2] as string, replicas: rest[3] as number, syncMode: rest[4] as string, - crossRegionReplicas: rest[5] as number, - standbyRegion: rest[6] as string, - networkIdleTimeoutSeconds: rest[7] as number, - networkIPAllowlist: rest[8] as string[], - idleTimeoutMinutes: rest[9] as number, - pitr: rest[10] as boolean, - pitrRetentionDays: rest[11] as number, - storageAutoscaling: rest[12] as boolean, - storageAutoscalingThresholdPercent: rest[13] as number, - storageAutoscalingMaxGb: rest[14] as number, - metricsTraceSampleRate: rest[15] as number, - metricsSlowQueryLogThresholdMs: rest[16] as number, - sqlApiEnabled: rest[17] as boolean, - sqlApiAllowedStatements: rest[18] as string[], - sqlApiMaxRows: rest[19] as number, - sqlApiMaxBytes: rest[20] as number, - sqlApiTimeoutSeconds: rest[21] as number + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + metricsTraceSampleRate: rest[13] as number, + metricsSlowQueryLogThresholdMs: rest[14] as number, + sqlApiEnabled: rest[15] as boolean, + sqlApiAllowedStatements: rest[16] as string[], + sqlApiMaxRows: rest[17] as number, + sqlApiMaxBytes: rest[18] as number, + sqlApiTimeoutSeconds: rest[19] as number, }; } - + const databaseId = params.databaseId; const name = params.name; const status = params.status; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - const crossRegionReplicas = params.crossRegionReplicas; - const standbyRegion = params.standbyRegion; const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; const networkIPAllowlist = params.networkIPAllowlist; const idleTimeoutMinutes = params.idleTimeoutMinutes; const pitr = params.pitr; const pitrRetentionDays = params.pitrRetentionDays; const storageAutoscaling = params.storageAutoscaling; - const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; const metricsTraceSampleRate = params.metricsTraceSampleRate; - const metricsSlowQueryLogThresholdMs = params.metricsSlowQueryLogThresholdMs; + const metricsSlowQueryLogThresholdMs = + params.metricsSlowQueryLogThresholdMs; const sqlApiEnabled = params.sqlApiEnabled; const sqlApiAllowedStatements = params.sqlApiAllowedStatements; const sqlApiMaxRows = params.sqlApiMaxRows; const sqlApiMaxBytes = params.sqlApiMaxBytes; const sqlApiTimeoutSeconds = params.sqlApiTimeoutSeconds; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -442,12 +659,6 @@ export class Mongo { if (typeof syncMode !== 'undefined') { payload['syncMode'] = syncMode; } - if (typeof crossRegionReplicas !== 'undefined') { - payload['crossRegionReplicas'] = crossRegionReplicas; - } - if (typeof standbyRegion !== 'undefined') { - payload['standbyRegion'] = standbyRegion; - } if (typeof networkIdleTimeoutSeconds !== 'undefined') { payload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; } @@ -467,7 +678,8 @@ export class Mongo { payload['storageAutoscaling'] = storageAutoscaling; } if (typeof storageAutoscalingThresholdPercent !== 'undefined') { - payload['storageAutoscalingThresholdPercent'] = storageAutoscalingThresholdPercent; + payload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; } if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; @@ -476,7 +688,8 @@ export class Mongo { payload['metricsTraceSampleRate'] = metricsTraceSampleRate; } if (typeof metricsSlowQueryLogThresholdMs !== 'undefined') { - payload['metricsSlowQueryLogThresholdMs'] = metricsSlowQueryLogThresholdMs; + payload['metricsSlowQueryLogThresholdMs'] = + metricsSlowQueryLogThresholdMs; } if (typeof sqlApiEnabled !== 'undefined') { payload['sqlApiEnabled'] = sqlApiEnabled; @@ -498,15 +711,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -526,41 +734,42 @@ export class Mongo { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -571,7 +780,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - listBackups(params: { databaseId: string, queries?: string[] }): Promise; + listBackups(params: { + databaseId: string; + queries?: string[]; + }): Promise; /** * List all backups for a dedicated database. Results can be filtered by status and type. * @@ -581,30 +793,44 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBackups(databaseId: string, queries?: string[]): Promise; listBackups( - paramsOrFirst: { databaseId: string, queries?: string[] } | string, - ...rest: [(string[])?] + databaseId: string, + queries?: string[], + ): Promise; + listBackups( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { databaseId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[] }; + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; } else { params = { databaseId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const databaseId = params.databaseId; const queries = params.queries; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -613,15 +839,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -632,7 +853,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - createBackup(params: { databaseId: string, type?: string }): Promise; + createBackup(params: { + databaseId: string; + type?: string; + }): Promise; /** * Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. * @@ -642,30 +866,44 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBackup(databaseId: string, type?: string): Promise; createBackup( - paramsOrFirst: { databaseId: string, type?: string } | string, - ...rest: [(string)?] + databaseId: string, + type?: string, + ): Promise; + createBackup( + paramsOrFirst: { databaseId: string; type?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, type?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, type?: string }; + let params: { databaseId: string; type?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - type: rest[0] as string + type: rest[0] as string, }; } - + const databaseId = params.databaseId; const type = params.type; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -675,15 +913,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -694,7 +927,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - listBackupPolicies(params: { databaseId: string, queries?: string[] }): Promise; + listBackupPolicies(params: { + databaseId: string; + queries?: string[]; + }): Promise; /** * List scheduled backup policies for a dedicated database. * @@ -704,30 +940,44 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBackupPolicies(databaseId: string, queries?: string[]): Promise; listBackupPolicies( - paramsOrFirst: { databaseId: string, queries?: string[] } | string, - ...rest: [(string[])?] + databaseId: string, + queries?: string[], + ): Promise; + listBackupPolicies( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { databaseId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[] }; + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; } else { params = { databaseId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const databaseId = params.databaseId; const queries = params.queries; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/policies'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -736,15 +986,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -760,7 +1005,15 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - createBackupPolicy(params: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }): Promise; + createBackupPolicy(params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }): Promise; /** * Create a scheduled backup policy for a dedicated database. * @@ -775,15 +1028,53 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBackupPolicy(databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean): Promise; createBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (boolean)?] + databaseId: string, + policyId: string, + name: string, + schedule: string, + retention: number, + type?: string, + enabled?: boolean, + ): Promise; + createBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, string?, boolean?] ): Promise { - let params: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }; + let params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -792,10 +1083,10 @@ export class Mongo { schedule: rest[2] as string, retention: rest[3] as number, type: rest[4] as string, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; const name = params.name; @@ -804,23 +1095,33 @@ export class Mongo { const type = params.type; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof schedule === 'undefined') { - throw new AppwriteException('Missing required parameter: "schedule"'); + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); } if (typeof retention === 'undefined') { - throw new AppwriteException('Missing required parameter: "retention"'); + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/policies'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof policyId !== 'undefined') { payload['policyId'] = policyId; @@ -845,15 +1146,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -864,7 +1160,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - getBackupPolicy(params: { databaseId: string, policyId: string }): Promise; + getBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise; /** * Get a scheduled backup policy for a dedicated database. * @@ -874,47 +1173,57 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBackupPolicy(databaseId: string, policyId: string): Promise; getBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string } | string, - ...rest: [(string)?] + databaseId: string, + policyId: string, + ): Promise; + getBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string }; + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - policyId: rest[0] as string + policyId: rest[0] as string, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -929,7 +1238,14 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - updateBackupPolicy(params: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }): Promise; + updateBackupPolicy(params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }): Promise; /** * Update a scheduled backup policy for a dedicated database. * @@ -943,15 +1259,49 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBackupPolicy(databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean): Promise; updateBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (boolean)?] + databaseId: string, + policyId: string, + name?: string, + schedule?: string, + retention?: number, + enabled?: boolean, + ): Promise; + updateBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, boolean?] ): Promise { - let params: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }; + let params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -959,10 +1309,10 @@ export class Mongo { name: rest[1] as string, schedule: rest[2] as string, retention: rest[3] as number, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; const name = params.name; @@ -970,14 +1320,19 @@ export class Mongo { const retention = params.retention; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -996,15 +1351,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1015,7 +1365,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteBackupPolicy(params: { databaseId: string, policyId: string }): Promise<{}>; + deleteBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise<{}>; /** * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. * @@ -1027,46 +1380,53 @@ export class Mongo { */ deleteBackupPolicy(databaseId: string, policyId: string): Promise<{}>; deleteBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string }; + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - policyId: rest[0] as string + policyId: rest[0] as string, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1083,7 +1443,16 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - updateBackupStorage(params: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }): Promise; + updateBackupStorage(params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }): Promise; /** * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. * @@ -1099,15 +1468,57 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBackupStorage(databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string): Promise; updateBackupStorage( - paramsOrFirst: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + databaseId: string, + provider: string, + bucket: string, + accessKey: string, + secretKey: string, + region?: string, + prefix?: string, + endpoint?: string, + ): Promise; + updateBackupStorage( + paramsOrFirst: + | { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?, string?] ): Promise { - let params: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }; + let params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1117,10 +1528,10 @@ export class Mongo { secretKey: rest[3] as string, region: rest[4] as string, prefix: rest[5] as string, - endpoint: rest[6] as string + endpoint: rest[6] as string, }; } - + const databaseId = params.databaseId; const provider = params.provider; const bucket = params.bucket; @@ -1130,23 +1541,33 @@ export class Mongo { const prefix = params.prefix; const endpoint = params.endpoint; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); } if (typeof bucket === 'undefined') { throw new AppwriteException('Missing required parameter: "bucket"'); } if (typeof accessKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "accessKey"'); + throw new AppwriteException( + 'Missing required parameter: "accessKey"', + ); } if (typeof secretKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretKey"'); + throw new AppwriteException( + 'Missing required parameter: "secretKey"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/storage'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/backups/storage'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof provider !== 'undefined') { payload['provider'] = provider; @@ -1174,15 +1595,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1193,7 +1609,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - getBackup(params: { databaseId: string, backupId: string }): Promise; + getBackup(params: { + databaseId: string; + backupId: string; + }): Promise; /** * Get details of a specific database backup including its status, size, and timestamps. * @@ -1203,47 +1622,57 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBackup(databaseId: string, backupId: string): Promise; getBackup( - paramsOrFirst: { databaseId: string, backupId: string } | string, - ...rest: [(string)?] + databaseId: string, + backupId: string, + ): Promise; + getBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, backupId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, backupId: string }; + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - backupId: rest[0] as string + backupId: rest[0] as string, }; } - + const databaseId = params.databaseId; const backupId = params.backupId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof backupId === 'undefined') { - throw new AppwriteException('Missing required parameter: "backupId"'); + if (typeof backupId === 'undefined' || backupId === '') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/{backupId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{backupId}', encodeURIComponent(String(backupId))); + const apiPath = '/mongo/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1254,7 +1683,7 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteBackup(params: { databaseId: string, backupId: string }): Promise<{}>; + deleteBackup(params: { databaseId: string; backupId: string }): Promise<{}>; /** * Delete a database backup. This will permanently remove the backup from storage and cannot be undone. * @@ -1266,46 +1695,53 @@ export class Mongo { */ deleteBackup(databaseId: string, backupId: string): Promise<{}>; deleteBackup( - paramsOrFirst: { databaseId: string, backupId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, backupId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, backupId: string }; + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - backupId: rest[0] as string + backupId: rest[0] as string, }; } - + const databaseId = params.databaseId; const backupId = params.backupId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof backupId === 'undefined') { - throw new AppwriteException('Missing required parameter: "backupId"'); + if (typeof backupId === 'undefined' || backupId === '') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); } - - const apiPath = '/mongo/{databaseId}/backups/{backupId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{backupId}', encodeURIComponent(String(backupId))); + const apiPath = '/mongo/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1315,7 +1751,9 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - listBranches(params: { databaseId: string }): Promise; + listBranches(params: { + databaseId: string; + }): Promise; /** * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. * @@ -1324,41 +1762,46 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBranches(databaseId: string): Promise; listBranches( - paramsOrFirst: { databaseId: string } | string + databaseId: string, + ): Promise; + listBranches( + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/branches'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1370,7 +1813,11 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - createBranch(params: { databaseId: string, branchId?: string, ttl?: number }): Promise; + createBranch(params: { + databaseId: string; + branchId?: string; + ttl?: number; + }): Promise; /** * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. * @@ -1381,32 +1828,49 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBranch(databaseId: string, branchId?: string, ttl?: number): Promise; createBranch( - paramsOrFirst: { databaseId: string, branchId?: string, ttl?: number } | string, - ...rest: [(string)?, (number)?] + databaseId: string, + branchId?: string, + ttl?: number, + ): Promise; + createBranch( + paramsOrFirst: + { databaseId: string; branchId?: string; ttl?: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { databaseId: string, branchId?: string, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, branchId?: string, ttl?: number }; + let params: { databaseId: string; branchId?: string; ttl?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId?: string; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, branchId: rest[0] as string, - ttl: rest[1] as number + ttl: rest[1] as number, }; } - + const databaseId = params.databaseId; const branchId = params.branchId; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/branches'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof branchId !== 'undefined') { payload['branchId'] = branchId; @@ -1419,15 +1883,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1438,7 +1897,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - deleteBranch(params: { databaseId: string, branchId: string }): Promise; + deleteBranch(params: { + databaseId: string; + branchId: string; + }): Promise; /** * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. * @@ -1448,115 +1910,135 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBranch(databaseId: string, branchId: string): Promise; deleteBranch( - paramsOrFirst: { databaseId: string, branchId: string } | string, - ...rest: [(string)?] + databaseId: string, + branchId: string, + ): Promise; + deleteBranch( + paramsOrFirst: { databaseId: string; branchId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, branchId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, branchId: string }; + let params: { databaseId: string; branchId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - branchId: rest[0] as string + branchId: rest[0] as string, }; } - + const databaseId = params.databaseId; const branchId = params.branchId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof branchId === 'undefined') { - throw new AppwriteException('Missing required parameter: "branchId"'); + if (typeof branchId === 'undefined' || branchId === '') { + throw new AppwriteException( + 'Missing required parameter: "branchId"', + ); } - - const apiPath = '/mongo/{databaseId}/branches/{branchId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{branchId}', encodeURIComponent(String(branchId))); + const apiPath = '/mongo/{databaseId}/branches/{branchId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{branchId}', encodeURIComponent(String(branchId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. * * @param {string} params.databaseId - Database ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateCredentials(params: { databaseId: string }): Promise; + updateCredentials(params: { + databaseId: string; + }): Promise; /** - * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. * * @param {string} databaseId - Database ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCredentials(databaseId: string): Promise; updateCredentials( - paramsOrFirst: { databaseId: string } | string - ): Promise { + databaseId: string, + ): Promise; + updateCredentials( + paramsOrFirst: { databaseId: string } | string, + ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/credentials'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/credentials'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -1564,30 +2046,45 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { payload['targetReplicaId'] = targetReplicaId; @@ -1597,15 +2094,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1617,7 +2109,11 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - updateMaintenance(params: { databaseId: string, day: string, hourUtc: number }): Promise; + updateMaintenance(params: { + databaseId: string; + day: string; + hourUtc: number; + }): Promise; /** * Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. * @@ -1628,38 +2124,57 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMaintenance(databaseId: string, day: string, hourUtc: number): Promise; updateMaintenance( - paramsOrFirst: { databaseId: string, day: string, hourUtc: number } | string, - ...rest: [(string)?, (number)?] + databaseId: string, + day: string, + hourUtc: number, + ): Promise; + updateMaintenance( + paramsOrFirst: + { databaseId: string; day: string; hourUtc: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { databaseId: string, day: string, hourUtc: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, day: string, hourUtc: number }; + let params: { databaseId: string; day: string; hourUtc: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + day: string; + hourUtc: number; + }; } else { params = { databaseId: paramsOrFirst as string, day: rest[0] as string, - hourUtc: rest[1] as number + hourUtc: rest[1] as number, }; } - + const databaseId = params.databaseId; const day = params.day; const hourUtc = params.hourUtc; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof day === 'undefined') { throw new AppwriteException('Missing required parameter: "day"'); } if (typeof hourUtc === 'undefined') { - throw new AppwriteException('Missing required parameter: "hourUtc"'); + throw new AppwriteException( + 'Missing required parameter: "hourUtc"', + ); } - - const apiPath = '/mongo/{databaseId}/maintenance'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/maintenance'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof day !== 'undefined') { payload['day'] = day; @@ -1672,15 +2187,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1692,7 +2202,11 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - createMigration(params: { databaseId: string, targetType: string, specification?: string }): Promise; + createMigration(params: { + databaseId: string; + targetType: string; + specification?: string; + }): Promise; /** * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. * @@ -1703,35 +2217,59 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMigration(databaseId: string, targetType: string, specification?: string): Promise; createMigration( - paramsOrFirst: { databaseId: string, targetType: string, specification?: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + targetType: string, + specification?: string, + ): Promise; + createMigration( + paramsOrFirst: + | { databaseId: string; targetType: string; specification?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, targetType: string, specification?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetType: string, specification?: string }; + let params: { + databaseId: string; + targetType: string; + specification?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetType: string; + specification?: string; + }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string + specification: rest[1] as string, }; } - + const databaseId = params.databaseId; const targetType = params.targetType; const specification = params.specification; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof targetType === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetType"'); + throw new AppwriteException( + 'Missing required parameter: "targetType"', + ); } - - const apiPath = '/mongo/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetType !== 'undefined') { payload['targetType'] = targetType; @@ -1744,15 +2282,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1765,7 +2298,12 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -1777,34 +2315,64 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -1819,15 +2387,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1837,7 +2400,9 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - getPitr(params: { databaseId: string }): Promise; + getPitr(params: { + databaseId: string; + }): Promise; /** * Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. * @@ -1848,39 +2413,42 @@ export class Mongo { */ getPitr(databaseId: string): Promise; getPitr( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/pitr'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/pitr'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1890,7 +2458,9 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -1901,39 +2471,42 @@ export class Mongo { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1947,7 +2520,13 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - listRestorations(params: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }): Promise; + listRestorations(params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }): Promise; /** * List all restorations for a dedicated database. Results can be filtered by status and type. * @@ -1960,36 +2539,70 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRestorations(databaseId: string, status?: string, type?: string, limit?: number, offset?: number): Promise; listRestorations( - paramsOrFirst: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?] + databaseId: string, + status?: string, + type?: string, + limit?: number, + offset?: number, + ): Promise; + listRestorations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, type: rest[1] as string, limit: rest[2] as number, - offset: rest[3] as number + offset: rest[3] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const type = params.type; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/restorations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2007,15 +2620,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2024,50 +2632,94 @@ export class Mongo { * @param {string} params.databaseId - Database ID. * @param {string} params.type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. * @param {string} params.backupId - Backup ID to restore from (required for backup type). + * @param {string} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. * @param {string} params.targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. * @throws {AppwriteException} * @returns {Promise} */ - createRestoration(params: { databaseId: string, type?: string, backupId?: string, targetTime?: string }): Promise; + createRestoration(params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }): Promise; /** * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. * * @param {string} databaseId - Database ID. * @param {string} type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. * @param {string} backupId - Backup ID to restore from (required for backup type). + * @param {string} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. * @param {string} targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRestoration(databaseId: string, type?: string, backupId?: string, targetTime?: string): Promise; createRestoration( - paramsOrFirst: { databaseId: string, type?: string, backupId?: string, targetTime?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + type?: string, + backupId?: string, + targetDatabaseId?: string, + targetTime?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { databaseId: string, type?: string, backupId?: string, targetTime?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, type?: string, backupId?: string, targetTime?: string }; + let params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; } else { params = { databaseId: paramsOrFirst as string, type: rest[0] as string, backupId: rest[1] as string, - targetTime: rest[2] as string + targetDatabaseId: rest[2] as string, + targetTime: rest[3] as string, }; } - + const databaseId = params.databaseId; const type = params.type; const backupId = params.backupId; + const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/restorations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -2075,6 +2727,9 @@ export class Mongo { if (typeof backupId !== 'undefined') { payload['backupId'] = backupId; } + if (typeof targetDatabaseId !== 'undefined') { + payload['targetDatabaseId'] = targetDatabaseId; + } if (typeof targetTime !== 'undefined') { payload['targetTime'] = targetTime; } @@ -2083,15 +2738,10 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2102,7 +2752,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - getRestoration(params: { databaseId: string, restorationId: string }): Promise; + getRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise; /** * Get details of a specific database restoration including its status, type, and timestamps. * @@ -2112,47 +2765,60 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRestoration(databaseId: string, restorationId: string): Promise; getRestoration( - paramsOrFirst: { databaseId: string, restorationId: string } | string, - ...rest: [(string)?] + databaseId: string, + restorationId: string, + ): Promise; + getRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, restorationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, restorationId: string }; + let params: { databaseId: string; restorationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + restorationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - restorationId: rest[0] as string + restorationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const restorationId = params.restorationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof restorationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "restorationId"'); - } - - const apiPath = '/mongo/{databaseId}/restorations/{restorationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{restorationId}', encodeURIComponent(String(restorationId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = '/mongo/{databaseId}/restorations/{restorationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2173,39 +2839,42 @@ export class Mongo { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mongo/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2216,7 +2885,10 @@ export class Mongo { * @throws {AppwriteException} * @returns {Promise} */ - createUpgrade(params: { databaseId: string, targetVersion: string }): Promise; + createUpgrade(params: { + databaseId: string; + targetVersion: string; + }): Promise; /** * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. * @@ -2226,33 +2898,49 @@ export class Mongo { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUpgrade(databaseId: string, targetVersion: string): Promise; createUpgrade( - paramsOrFirst: { databaseId: string, targetVersion: string } | string, - ...rest: [(string)?] + databaseId: string, + targetVersion: string, + ): Promise; + createUpgrade( + paramsOrFirst: { databaseId: string; targetVersion: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetVersion: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetVersion: string }; + let params: { databaseId: string; targetVersion: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetVersion: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetVersion: rest[0] as string + targetVersion: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetVersion = params.targetVersion; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof targetVersion === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetVersion"'); + throw new AppwriteException( + 'Missing required parameter: "targetVersion"', + ); } - - const apiPath = '/mongo/{databaseId}/upgrades'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mongo/{databaseId}/upgrades'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetVersion !== 'undefined') { payload['targetVersion'] = targetVersion; @@ -2262,14 +2950,9 @@ export class Mongo { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index c9d2c7a8..2e09c583 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Mysql { client: Client; @@ -17,7 +15,9 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[] }): Promise; + list(params?: { + queries?: string[]; + }): Promise; /** * List all dedicated databases. Results support pagination. * @@ -28,20 +28,24 @@ export class Mysql { */ list(queries?: string[]): Promise; list( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/mysql'; const payload: Payload = {}; @@ -52,15 +56,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -72,7 +71,6 @@ export class Mysql { * @param {string} params.specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {string} params.standbyRegion - Standby region for a cross-region replica. When set, a replica is provisioned in this region for cross-region high availability. Must differ from the database region. * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds. * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} params.idleTimeoutMinutes - Minutes of inactivity before container scales to zero. @@ -80,11 +78,26 @@ export class Mysql { * @param {number} params.pitrRetentionDays - Number of days to retain PITR data. * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. - * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }): Promise; + create(params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }): Promise; /** * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. * @@ -94,7 +107,6 @@ export class Mysql { * @param {string} specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {string} standbyRegion - Standby region for a cross-region replica. When set, a replica is provisioned in this region for cross-region high availability. Must differ from the database region. * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds. * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} idleTimeoutMinutes - Minutes of inactivity before container scales to zero. @@ -102,20 +114,100 @@ export class Mysql { * @param {number} pitrRetentionDays - Number of days to retain PITR data. * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. - * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?] + databaseId: string, + name: string, + version?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + ] ): Promise { - let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; + let params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -124,41 +216,41 @@ export class Mysql { specification: rest[2] as string, replicas: rest[3] as number, syncMode: rest[4] as string, - standbyRegion: rest[5] as string, - networkIdleTimeoutSeconds: rest[6] as number, - networkIPAllowlist: rest[7] as string[], - idleTimeoutMinutes: rest[8] as number, - pitr: rest[9] as boolean, - pitrRetentionDays: rest[10] as number, - storageAutoscaling: rest[11] as boolean, - storageAutoscalingThresholdPercent: rest[12] as number, - storageAutoscalingMaxGb: rest[13] as number + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, }; } - + const databaseId = params.databaseId; const name = params.name; const version = params.version; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - const standbyRegion = params.standbyRegion; const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; const networkIPAllowlist = params.networkIPAllowlist; const idleTimeoutMinutes = params.idleTimeoutMinutes; const pitr = params.pitr; const pitrRetentionDays = params.pitrRetentionDays; const storageAutoscaling = params.storageAutoscaling; - const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/mysql'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -179,9 +271,6 @@ export class Mysql { if (typeof syncMode !== 'undefined') { payload['syncMode'] = syncMode; } - if (typeof standbyRegion !== 'undefined') { - payload['standbyRegion'] = standbyRegion; - } if (typeof networkIdleTimeoutSeconds !== 'undefined') { payload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; } @@ -201,7 +290,8 @@ export class Mysql { payload['storageAutoscaling'] = storageAutoscaling; } if (typeof storageAutoscalingThresholdPercent !== 'undefined') { - payload['storageAutoscalingThresholdPercent'] = storageAutoscalingThresholdPercent; + payload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; } if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; @@ -211,40 +301,29 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. * * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/mysql/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -265,39 +344,42 @@ export class Mysql { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -309,8 +391,6 @@ export class Mysql { * @param {string} params.specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {number} params.crossRegionReplicas - Number of cross-region standby replicas (0-1). Cross-region replication is enabled when greater than 0. - * @param {string} params.standbyRegion - Standby region for the cross-region replica. Required when enabling cross-region replication and no standby region is already configured. Must differ from the database region. * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} params.idleTimeoutMinutes - Minutes before container scales to zero. @@ -329,7 +409,29 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }): Promise; + update(params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }): Promise; /** * Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. * @@ -339,8 +441,6 @@ export class Mysql { * @param {string} specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {number} crossRegionReplicas - Number of cross-region standby replicas (0-1). Cross-region replication is enabled when greater than 0. - * @param {string} standbyRegion - Standby region for the cross-region replica. Required when enabling cross-region replication and no standby region is already configured. Must differ from the database region. * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} idleTimeoutMinutes - Minutes before container scales to zero. @@ -360,15 +460,130 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (number)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?] + databaseId: string, + name?: string, + status?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + metricsTraceSampleRate?: number, + metricsSlowQueryLogThresholdMs?: number, + sqlApiEnabled?: boolean, + sqlApiAllowedStatements?: string[], + sqlApiMaxRows?: number, + sqlApiMaxBytes?: number, + sqlApiTimeoutSeconds?: number, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + number?, + number?, + boolean?, + string[]?, + number?, + number?, + number?, + ] ): Promise { - let params: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }; + let params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -377,55 +592,57 @@ export class Mysql { specification: rest[2] as string, replicas: rest[3] as number, syncMode: rest[4] as string, - crossRegionReplicas: rest[5] as number, - standbyRegion: rest[6] as string, - networkIdleTimeoutSeconds: rest[7] as number, - networkIPAllowlist: rest[8] as string[], - idleTimeoutMinutes: rest[9] as number, - pitr: rest[10] as boolean, - pitrRetentionDays: rest[11] as number, - storageAutoscaling: rest[12] as boolean, - storageAutoscalingThresholdPercent: rest[13] as number, - storageAutoscalingMaxGb: rest[14] as number, - metricsTraceSampleRate: rest[15] as number, - metricsSlowQueryLogThresholdMs: rest[16] as number, - sqlApiEnabled: rest[17] as boolean, - sqlApiAllowedStatements: rest[18] as string[], - sqlApiMaxRows: rest[19] as number, - sqlApiMaxBytes: rest[20] as number, - sqlApiTimeoutSeconds: rest[21] as number + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + metricsTraceSampleRate: rest[13] as number, + metricsSlowQueryLogThresholdMs: rest[14] as number, + sqlApiEnabled: rest[15] as boolean, + sqlApiAllowedStatements: rest[16] as string[], + sqlApiMaxRows: rest[17] as number, + sqlApiMaxBytes: rest[18] as number, + sqlApiTimeoutSeconds: rest[19] as number, }; } - + const databaseId = params.databaseId; const name = params.name; const status = params.status; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - const crossRegionReplicas = params.crossRegionReplicas; - const standbyRegion = params.standbyRegion; const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; const networkIPAllowlist = params.networkIPAllowlist; const idleTimeoutMinutes = params.idleTimeoutMinutes; const pitr = params.pitr; const pitrRetentionDays = params.pitrRetentionDays; const storageAutoscaling = params.storageAutoscaling; - const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; const metricsTraceSampleRate = params.metricsTraceSampleRate; - const metricsSlowQueryLogThresholdMs = params.metricsSlowQueryLogThresholdMs; + const metricsSlowQueryLogThresholdMs = + params.metricsSlowQueryLogThresholdMs; const sqlApiEnabled = params.sqlApiEnabled; const sqlApiAllowedStatements = params.sqlApiAllowedStatements; const sqlApiMaxRows = params.sqlApiMaxRows; const sqlApiMaxBytes = params.sqlApiMaxBytes; const sqlApiTimeoutSeconds = params.sqlApiTimeoutSeconds; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -442,12 +659,6 @@ export class Mysql { if (typeof syncMode !== 'undefined') { payload['syncMode'] = syncMode; } - if (typeof crossRegionReplicas !== 'undefined') { - payload['crossRegionReplicas'] = crossRegionReplicas; - } - if (typeof standbyRegion !== 'undefined') { - payload['standbyRegion'] = standbyRegion; - } if (typeof networkIdleTimeoutSeconds !== 'undefined') { payload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; } @@ -467,7 +678,8 @@ export class Mysql { payload['storageAutoscaling'] = storageAutoscaling; } if (typeof storageAutoscalingThresholdPercent !== 'undefined') { - payload['storageAutoscalingThresholdPercent'] = storageAutoscalingThresholdPercent; + payload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; } if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; @@ -476,7 +688,8 @@ export class Mysql { payload['metricsTraceSampleRate'] = metricsTraceSampleRate; } if (typeof metricsSlowQueryLogThresholdMs !== 'undefined') { - payload['metricsSlowQueryLogThresholdMs'] = metricsSlowQueryLogThresholdMs; + payload['metricsSlowQueryLogThresholdMs'] = + metricsSlowQueryLogThresholdMs; } if (typeof sqlApiEnabled !== 'undefined') { payload['sqlApiEnabled'] = sqlApiEnabled; @@ -498,15 +711,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -526,41 +734,42 @@ export class Mysql { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -571,7 +780,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - listBackups(params: { databaseId: string, queries?: string[] }): Promise; + listBackups(params: { + databaseId: string; + queries?: string[]; + }): Promise; /** * List all backups for a dedicated database. Results can be filtered by status and type. * @@ -581,30 +793,44 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBackups(databaseId: string, queries?: string[]): Promise; listBackups( - paramsOrFirst: { databaseId: string, queries?: string[] } | string, - ...rest: [(string[])?] + databaseId: string, + queries?: string[], + ): Promise; + listBackups( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { databaseId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[] }; + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; } else { params = { databaseId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const databaseId = params.databaseId; const queries = params.queries; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -613,15 +839,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -632,7 +853,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - createBackup(params: { databaseId: string, type?: string }): Promise; + createBackup(params: { + databaseId: string; + type?: string; + }): Promise; /** * Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. * @@ -642,30 +866,44 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBackup(databaseId: string, type?: string): Promise; createBackup( - paramsOrFirst: { databaseId: string, type?: string } | string, - ...rest: [(string)?] + databaseId: string, + type?: string, + ): Promise; + createBackup( + paramsOrFirst: { databaseId: string; type?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, type?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, type?: string }; + let params: { databaseId: string; type?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - type: rest[0] as string + type: rest[0] as string, }; } - + const databaseId = params.databaseId; const type = params.type; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -675,15 +913,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -694,7 +927,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - listBackupPolicies(params: { databaseId: string, queries?: string[] }): Promise; + listBackupPolicies(params: { + databaseId: string; + queries?: string[]; + }): Promise; /** * List scheduled backup policies for a dedicated database. * @@ -704,30 +940,44 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBackupPolicies(databaseId: string, queries?: string[]): Promise; listBackupPolicies( - paramsOrFirst: { databaseId: string, queries?: string[] } | string, - ...rest: [(string[])?] + databaseId: string, + queries?: string[], + ): Promise; + listBackupPolicies( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { databaseId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[] }; + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; } else { params = { databaseId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const databaseId = params.databaseId; const queries = params.queries; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/policies'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -736,15 +986,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -760,7 +1005,15 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - createBackupPolicy(params: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }): Promise; + createBackupPolicy(params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }): Promise; /** * Create a scheduled backup policy for a dedicated database. * @@ -775,15 +1028,53 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBackupPolicy(databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean): Promise; createBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (boolean)?] + databaseId: string, + policyId: string, + name: string, + schedule: string, + retention: number, + type?: string, + enabled?: boolean, + ): Promise; + createBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, string?, boolean?] ): Promise { - let params: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }; + let params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -792,10 +1083,10 @@ export class Mysql { schedule: rest[2] as string, retention: rest[3] as number, type: rest[4] as string, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; const name = params.name; @@ -804,23 +1095,33 @@ export class Mysql { const type = params.type; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof schedule === 'undefined') { - throw new AppwriteException('Missing required parameter: "schedule"'); + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); } if (typeof retention === 'undefined') { - throw new AppwriteException('Missing required parameter: "retention"'); + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/policies'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof policyId !== 'undefined') { payload['policyId'] = policyId; @@ -845,15 +1146,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -864,7 +1160,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - getBackupPolicy(params: { databaseId: string, policyId: string }): Promise; + getBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise; /** * Get a scheduled backup policy for a dedicated database. * @@ -874,47 +1173,57 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBackupPolicy(databaseId: string, policyId: string): Promise; getBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string } | string, - ...rest: [(string)?] + databaseId: string, + policyId: string, + ): Promise; + getBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string }; + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - policyId: rest[0] as string + policyId: rest[0] as string, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -929,7 +1238,14 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - updateBackupPolicy(params: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }): Promise; + updateBackupPolicy(params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }): Promise; /** * Update a scheduled backup policy for a dedicated database. * @@ -943,15 +1259,49 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBackupPolicy(databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean): Promise; updateBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (boolean)?] + databaseId: string, + policyId: string, + name?: string, + schedule?: string, + retention?: number, + enabled?: boolean, + ): Promise; + updateBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, boolean?] ): Promise { - let params: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }; + let params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -959,10 +1309,10 @@ export class Mysql { name: rest[1] as string, schedule: rest[2] as string, retention: rest[3] as number, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; const name = params.name; @@ -970,14 +1320,19 @@ export class Mysql { const retention = params.retention; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -996,15 +1351,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1015,7 +1365,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteBackupPolicy(params: { databaseId: string, policyId: string }): Promise<{}>; + deleteBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise<{}>; /** * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. * @@ -1027,46 +1380,53 @@ export class Mysql { */ deleteBackupPolicy(databaseId: string, policyId: string): Promise<{}>; deleteBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string }; + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - policyId: rest[0] as string + policyId: rest[0] as string, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1083,7 +1443,16 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - updateBackupStorage(params: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }): Promise; + updateBackupStorage(params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }): Promise; /** * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. * @@ -1099,15 +1468,57 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBackupStorage(databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string): Promise; updateBackupStorage( - paramsOrFirst: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + databaseId: string, + provider: string, + bucket: string, + accessKey: string, + secretKey: string, + region?: string, + prefix?: string, + endpoint?: string, + ): Promise; + updateBackupStorage( + paramsOrFirst: + | { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?, string?] ): Promise { - let params: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }; + let params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1117,10 +1528,10 @@ export class Mysql { secretKey: rest[3] as string, region: rest[4] as string, prefix: rest[5] as string, - endpoint: rest[6] as string + endpoint: rest[6] as string, }; } - + const databaseId = params.databaseId; const provider = params.provider; const bucket = params.bucket; @@ -1130,23 +1541,33 @@ export class Mysql { const prefix = params.prefix; const endpoint = params.endpoint; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); } if (typeof bucket === 'undefined') { throw new AppwriteException('Missing required parameter: "bucket"'); } if (typeof accessKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "accessKey"'); + throw new AppwriteException( + 'Missing required parameter: "accessKey"', + ); } if (typeof secretKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretKey"'); + throw new AppwriteException( + 'Missing required parameter: "secretKey"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/storage'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/backups/storage'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof provider !== 'undefined') { payload['provider'] = provider; @@ -1174,15 +1595,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1193,7 +1609,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - getBackup(params: { databaseId: string, backupId: string }): Promise; + getBackup(params: { + databaseId: string; + backupId: string; + }): Promise; /** * Get details of a specific database backup including its status, size, and timestamps. * @@ -1203,47 +1622,57 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBackup(databaseId: string, backupId: string): Promise; getBackup( - paramsOrFirst: { databaseId: string, backupId: string } | string, - ...rest: [(string)?] + databaseId: string, + backupId: string, + ): Promise; + getBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, backupId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, backupId: string }; + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - backupId: rest[0] as string + backupId: rest[0] as string, }; } - + const databaseId = params.databaseId; const backupId = params.backupId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof backupId === 'undefined') { - throw new AppwriteException('Missing required parameter: "backupId"'); + if (typeof backupId === 'undefined' || backupId === '') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/{backupId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{backupId}', encodeURIComponent(String(backupId))); + const apiPath = '/mysql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1254,7 +1683,7 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteBackup(params: { databaseId: string, backupId: string }): Promise<{}>; + deleteBackup(params: { databaseId: string; backupId: string }): Promise<{}>; /** * Delete a database backup. This will permanently remove the backup from storage and cannot be undone. * @@ -1266,46 +1695,53 @@ export class Mysql { */ deleteBackup(databaseId: string, backupId: string): Promise<{}>; deleteBackup( - paramsOrFirst: { databaseId: string, backupId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, backupId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, backupId: string }; + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - backupId: rest[0] as string + backupId: rest[0] as string, }; } - + const databaseId = params.databaseId; const backupId = params.backupId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof backupId === 'undefined') { - throw new AppwriteException('Missing required parameter: "backupId"'); + if (typeof backupId === 'undefined' || backupId === '') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); } - - const apiPath = '/mysql/{databaseId}/backups/{backupId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{backupId}', encodeURIComponent(String(backupId))); + const apiPath = '/mysql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1315,7 +1751,9 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - listBranches(params: { databaseId: string }): Promise; + listBranches(params: { + databaseId: string; + }): Promise; /** * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. * @@ -1324,41 +1762,46 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBranches(databaseId: string): Promise; listBranches( - paramsOrFirst: { databaseId: string } | string + databaseId: string, + ): Promise; + listBranches( + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/branches'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1370,7 +1813,11 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - createBranch(params: { databaseId: string, branchId?: string, ttl?: number }): Promise; + createBranch(params: { + databaseId: string; + branchId?: string; + ttl?: number; + }): Promise; /** * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. * @@ -1381,32 +1828,49 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBranch(databaseId: string, branchId?: string, ttl?: number): Promise; createBranch( - paramsOrFirst: { databaseId: string, branchId?: string, ttl?: number } | string, - ...rest: [(string)?, (number)?] + databaseId: string, + branchId?: string, + ttl?: number, + ): Promise; + createBranch( + paramsOrFirst: + { databaseId: string; branchId?: string; ttl?: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { databaseId: string, branchId?: string, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, branchId?: string, ttl?: number }; + let params: { databaseId: string; branchId?: string; ttl?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId?: string; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, branchId: rest[0] as string, - ttl: rest[1] as number + ttl: rest[1] as number, }; } - + const databaseId = params.databaseId; const branchId = params.branchId; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/branches'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof branchId !== 'undefined') { payload['branchId'] = branchId; @@ -1419,15 +1883,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1438,7 +1897,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - deleteBranch(params: { databaseId: string, branchId: string }): Promise; + deleteBranch(params: { + databaseId: string; + branchId: string; + }): Promise; /** * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. * @@ -1448,102 +1910,119 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBranch(databaseId: string, branchId: string): Promise; deleteBranch( - paramsOrFirst: { databaseId: string, branchId: string } | string, - ...rest: [(string)?] + databaseId: string, + branchId: string, + ): Promise; + deleteBranch( + paramsOrFirst: { databaseId: string; branchId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, branchId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, branchId: string }; + let params: { databaseId: string; branchId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - branchId: rest[0] as string + branchId: rest[0] as string, }; } - + const databaseId = params.databaseId; const branchId = params.branchId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof branchId === 'undefined') { - throw new AppwriteException('Missing required parameter: "branchId"'); + if (typeof branchId === 'undefined' || branchId === '') { + throw new AppwriteException( + 'Missing required parameter: "branchId"', + ); } - - const apiPath = '/mysql/{databaseId}/branches/{branchId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{branchId}', encodeURIComponent(String(branchId))); + const apiPath = '/mysql/{databaseId}/branches/{branchId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{branchId}', encodeURIComponent(String(branchId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. * * @param {string} params.databaseId - Database ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateCredentials(params: { databaseId: string }): Promise; + updateCredentials(params: { + databaseId: string; + }): Promise; /** - * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. * * @param {string} databaseId - Database ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCredentials(databaseId: string): Promise; updateCredentials( - paramsOrFirst: { databaseId: string } | string - ): Promise { + databaseId: string, + ): Promise; + updateCredentials( + paramsOrFirst: { databaseId: string } | string, + ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/credentials'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/credentials'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1556,7 +2035,12 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - createExecution(params: { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number }): Promise; + createExecution(params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }): Promise; /** * Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. * @@ -1568,37 +2052,67 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createExecution(databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number): Promise; createExecution( - paramsOrFirst: { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number } | string, - ...rest: [(string)?, (object)?, (number)?] + databaseId: string, + sql: string, + bindings?: object, + timeoutSeconds?: number, + ): Promise; + createExecution( + paramsOrFirst: + | { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + } + | string, + ...rest: [string?, object?, number?] ): Promise { - let params: { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number }; + let params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, bindings: rest[1] as object, - timeoutSeconds: rest[2] as number + timeoutSeconds: rest[2] as number, }; } - + const databaseId = params.databaseId; const sql = params.sql; const bindings = params.bindings; const timeoutSeconds = params.timeoutSeconds; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof sql === 'undefined') { throw new AppwriteException('Missing required parameter: "sql"'); } - - const apiPath = '/mysql/{databaseId}/executions'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/executions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof sql !== 'undefined') { payload['sql'] = sql; @@ -1614,28 +2128,26 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -1643,30 +2155,45 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { payload['targetReplicaId'] = targetReplicaId; @@ -1676,15 +2203,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1696,7 +2218,11 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - updateMaintenance(params: { databaseId: string, day: string, hourUtc: number }): Promise; + updateMaintenance(params: { + databaseId: string; + day: string; + hourUtc: number; + }): Promise; /** * Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. * @@ -1707,38 +2233,57 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMaintenance(databaseId: string, day: string, hourUtc: number): Promise; updateMaintenance( - paramsOrFirst: { databaseId: string, day: string, hourUtc: number } | string, - ...rest: [(string)?, (number)?] + databaseId: string, + day: string, + hourUtc: number, + ): Promise; + updateMaintenance( + paramsOrFirst: + { databaseId: string; day: string; hourUtc: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { databaseId: string, day: string, hourUtc: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, day: string, hourUtc: number }; + let params: { databaseId: string; day: string; hourUtc: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + day: string; + hourUtc: number; + }; } else { params = { databaseId: paramsOrFirst as string, day: rest[0] as string, - hourUtc: rest[1] as number + hourUtc: rest[1] as number, }; } - + const databaseId = params.databaseId; const day = params.day; const hourUtc = params.hourUtc; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof day === 'undefined') { throw new AppwriteException('Missing required parameter: "day"'); } if (typeof hourUtc === 'undefined') { - throw new AppwriteException('Missing required parameter: "hourUtc"'); + throw new AppwriteException( + 'Missing required parameter: "hourUtc"', + ); } - - const apiPath = '/mysql/{databaseId}/maintenance'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/maintenance'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof day !== 'undefined') { payload['day'] = day; @@ -1751,15 +2296,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1771,7 +2311,11 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - createMigration(params: { databaseId: string, targetType: string, specification?: string }): Promise; + createMigration(params: { + databaseId: string; + targetType: string; + specification?: string; + }): Promise; /** * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. * @@ -1782,35 +2326,59 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMigration(databaseId: string, targetType: string, specification?: string): Promise; createMigration( - paramsOrFirst: { databaseId: string, targetType: string, specification?: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + targetType: string, + specification?: string, + ): Promise; + createMigration( + paramsOrFirst: + | { databaseId: string; targetType: string; specification?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, targetType: string, specification?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetType: string, specification?: string }; + let params: { + databaseId: string; + targetType: string; + specification?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetType: string; + specification?: string; + }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string + specification: rest[1] as string, }; } - + const databaseId = params.databaseId; const targetType = params.targetType; const specification = params.specification; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof targetType === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetType"'); + throw new AppwriteException( + 'Missing required parameter: "targetType"', + ); } - - const apiPath = '/mysql/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetType !== 'undefined') { payload['targetType'] = targetType; @@ -1823,15 +2391,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1844,7 +2407,12 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -1856,34 +2424,64 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -1898,15 +2496,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1916,7 +2509,9 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - getPitr(params: { databaseId: string }): Promise; + getPitr(params: { + databaseId: string; + }): Promise; /** * Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. * @@ -1927,39 +2522,42 @@ export class Mysql { */ getPitr(databaseId: string): Promise; getPitr( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/pitr'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/pitr'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1969,7 +2567,9 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - getPooler(params: { databaseId: string }): Promise; + getPooler(params: { + databaseId: string; + }): Promise; /** * Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. * @@ -1980,39 +2580,42 @@ export class Mysql { */ getPooler(databaseId: string): Promise; getPooler( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/pooler'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2030,7 +2633,17 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - updatePooler(params: { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string }): Promise; + updatePooler(params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }): Promise; /** * Update the connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. * @@ -2047,15 +2660,70 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePooler(databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string): Promise; updatePooler( - paramsOrFirst: { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string } | string, - ...rest: [(string)?, (number)?, (number)?, (boolean)?, (string)?, (string)?, (string)?, (string)?] + databaseId: string, + mode?: string, + maxConnections?: number, + defaultPoolSize?: number, + readWriteSplitting?: boolean, + poolerCpuRequest?: string, + poolerCpuLimit?: string, + poolerMemoryRequest?: string, + poolerMemoryLimit?: string, + ): Promise; + updatePooler( + paramsOrFirst: + | { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + } + | string, + ...rest: [ + string?, + number?, + number?, + boolean?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string }; + let params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2066,10 +2734,10 @@ export class Mysql { poolerCpuRequest: rest[4] as string, poolerCpuLimit: rest[5] as string, poolerMemoryRequest: rest[6] as string, - poolerMemoryLimit: rest[7] as string + poolerMemoryLimit: rest[7] as string, }; } - + const databaseId = params.databaseId; const mode = params.mode; const maxConnections = params.maxConnections; @@ -2080,11 +2748,15 @@ export class Mysql { const poolerMemoryRequest = params.poolerMemoryRequest; const poolerMemoryLimit = params.poolerMemoryLimit; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/pooler'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof mode !== 'undefined') { payload['mode'] = mode; @@ -2115,15 +2787,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2133,7 +2800,9 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -2144,39 +2813,42 @@ export class Mysql { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2190,7 +2862,13 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - listRestorations(params: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }): Promise; + listRestorations(params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }): Promise; /** * List all restorations for a dedicated database. Results can be filtered by status and type. * @@ -2203,36 +2881,70 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRestorations(databaseId: string, status?: string, type?: string, limit?: number, offset?: number): Promise; listRestorations( - paramsOrFirst: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?] + databaseId: string, + status?: string, + type?: string, + limit?: number, + offset?: number, + ): Promise; + listRestorations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, type: rest[1] as string, limit: rest[2] as number, - offset: rest[3] as number + offset: rest[3] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const type = params.type; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/restorations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2250,15 +2962,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2267,50 +2974,94 @@ export class Mysql { * @param {string} params.databaseId - Database ID. * @param {string} params.type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. * @param {string} params.backupId - Backup ID to restore from (required for backup type). + * @param {string} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. * @param {string} params.targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. * @throws {AppwriteException} * @returns {Promise} */ - createRestoration(params: { databaseId: string, type?: string, backupId?: string, targetTime?: string }): Promise; + createRestoration(params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }): Promise; /** * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. * * @param {string} databaseId - Database ID. * @param {string} type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. * @param {string} backupId - Backup ID to restore from (required for backup type). + * @param {string} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. * @param {string} targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRestoration(databaseId: string, type?: string, backupId?: string, targetTime?: string): Promise; createRestoration( - paramsOrFirst: { databaseId: string, type?: string, backupId?: string, targetTime?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + type?: string, + backupId?: string, + targetDatabaseId?: string, + targetTime?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { databaseId: string, type?: string, backupId?: string, targetTime?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, type?: string, backupId?: string, targetTime?: string }; + let params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; } else { params = { databaseId: paramsOrFirst as string, type: rest[0] as string, backupId: rest[1] as string, - targetTime: rest[2] as string + targetDatabaseId: rest[2] as string, + targetTime: rest[3] as string, }; } - + const databaseId = params.databaseId; const type = params.type; const backupId = params.backupId; + const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/restorations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -2318,6 +3069,9 @@ export class Mysql { if (typeof backupId !== 'undefined') { payload['backupId'] = backupId; } + if (typeof targetDatabaseId !== 'undefined') { + payload['targetDatabaseId'] = targetDatabaseId; + } if (typeof targetTime !== 'undefined') { payload['targetTime'] = targetTime; } @@ -2326,15 +3080,10 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2345,7 +3094,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - getRestoration(params: { databaseId: string, restorationId: string }): Promise; + getRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise; /** * Get details of a specific database restoration including its status, type, and timestamps. * @@ -2355,47 +3107,60 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRestoration(databaseId: string, restorationId: string): Promise; getRestoration( - paramsOrFirst: { databaseId: string, restorationId: string } | string, - ...rest: [(string)?] + databaseId: string, + restorationId: string, + ): Promise; + getRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, restorationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, restorationId: string }; + let params: { databaseId: string; restorationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + restorationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - restorationId: rest[0] as string + restorationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const restorationId = params.restorationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof restorationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "restorationId"'); - } - - const apiPath = '/mysql/{databaseId}/restorations/{restorationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{restorationId}', encodeURIComponent(String(restorationId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = '/mysql/{databaseId}/restorations/{restorationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2416,39 +3181,42 @@ export class Mysql { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/mysql/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2459,7 +3227,10 @@ export class Mysql { * @throws {AppwriteException} * @returns {Promise} */ - createUpgrade(params: { databaseId: string, targetVersion: string }): Promise; + createUpgrade(params: { + databaseId: string; + targetVersion: string; + }): Promise; /** * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. * @@ -2469,33 +3240,49 @@ export class Mysql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUpgrade(databaseId: string, targetVersion: string): Promise; createUpgrade( - paramsOrFirst: { databaseId: string, targetVersion: string } | string, - ...rest: [(string)?] + databaseId: string, + targetVersion: string, + ): Promise; + createUpgrade( + paramsOrFirst: { databaseId: string; targetVersion: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetVersion: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetVersion: string }; + let params: { databaseId: string; targetVersion: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetVersion: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetVersion: rest[0] as string + targetVersion: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetVersion = params.targetVersion; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof targetVersion === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetVersion"'); + throw new AppwriteException( + 'Missing required parameter: "targetVersion"', + ); } - - const apiPath = '/mysql/{databaseId}/upgrades'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/mysql/{databaseId}/upgrades'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetVersion !== 'undefined') { payload['targetVersion'] = targetVersion; @@ -2505,14 +3292,9 @@ export class Mysql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/notifications.ts b/src/services/notifications.ts index af7416ca..70e75f29 100644 --- a/src/services/notifications.ts +++ b/src/services/notifications.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Notifications { client: Client; @@ -12,7 +10,7 @@ export class Notifications { /** * Get the list of notifications for the currently logged in console user. Use queries to filter the results by attributes such as read status, view timestamps, or creation date. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: read, type, channel, messageId, projectId, resourceType, resourceId, parentResourceType, parentResourceId, firstSeen, lastSeen * @throws {AppwriteException} @@ -21,7 +19,7 @@ export class Notifications { list(params?: { queries?: string[] }): Promise; /** * Get the list of notifications for the currently logged in console user. Use queries to filter the results by attributes such as read status, view timestamps, or creation date. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: read, type, channel, messageId, projectId, resourceType, resourceId, parentResourceType, parentResourceId, firstSeen, lastSeen * @throws {AppwriteException} @@ -30,20 +28,24 @@ export class Notifications { */ list(queries?: string[]): Promise; list( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/notifications'; const payload: Payload = {}; @@ -54,30 +56,28 @@ export class Notifications { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Update a notification by its unique ID. Use the `read` parameter to mark the notification as read or unread. - * + * * * @param {string} params.notificationId - Notification ID. * @param {boolean} params.read - Notification read status. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { notificationId: string, read: boolean }): Promise; + update(params: { + notificationId: string; + read: boolean; + }): Promise; /** * Update a notification by its unique ID. Use the `read` parameter to mark the notification as read or unread. - * + * * * @param {string} notificationId - Notification ID. * @param {boolean} read - Notification read status. @@ -87,31 +87,42 @@ export class Notifications { */ update(notificationId: string, read: boolean): Promise; update( - paramsOrFirst: { notificationId: string, read: boolean } | string, - ...rest: [(boolean)?] + paramsOrFirst: { notificationId: string; read: boolean } | string, + ...rest: [boolean?] ): Promise { - let params: { notificationId: string, read: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { notificationId: string, read: boolean }; + let params: { notificationId: string; read: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + notificationId: string; + read: boolean; + }; } else { params = { notificationId: paramsOrFirst as string, - read: rest[0] as boolean + read: rest[0] as boolean, }; } - + const notificationId = params.notificationId; const read = params.read; - if (typeof notificationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "notificationId"'); + if (typeof notificationId === 'undefined' || notificationId === '') { + throw new AppwriteException( + 'Missing required parameter: "notificationId"', + ); } if (typeof read === 'undefined') { throw new AppwriteException('Missing required parameter: "read"'); } - - const apiPath = '/notifications/{notificationId}'.replace('{notificationId}', encodeURIComponent(String(notificationId))); + const apiPath = '/notifications/{notificationId}'.replace( + '{notificationId}', + encodeURIComponent(String(notificationId)), + ); const payload: Payload = {}; if (typeof read !== 'undefined') { payload['read'] = read; @@ -121,14 +132,9 @@ export class Notifications { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 7079ec80..921f6903 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Oauth2 { client: Client; @@ -19,7 +17,11 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - approve(params: { grantId: string, authorizationDetails?: string, scope?: string }): Promise; + approve(params: { + grantId: string; + authorizationDetails?: string; + scope?: string; + }): Promise; /** * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. * @@ -30,32 +32,54 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - approve(grantId: string, authorizationDetails?: string, scope?: string): Promise; approve( - paramsOrFirst: { grantId: string, authorizationDetails?: string, scope?: string } | string, - ...rest: [(string)?, (string)?] + grantId: string, + authorizationDetails?: string, + scope?: string, + ): Promise; + approve( + paramsOrFirst: + | { grantId: string; authorizationDetails?: string; scope?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { grantId: string, authorizationDetails?: string, scope?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { grantId: string, authorizationDetails?: string, scope?: string }; + let params: { + grantId: string; + authorizationDetails?: string; + scope?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + grantId: string; + authorizationDetails?: string; + scope?: string; + }; } else { params = { grantId: paramsOrFirst as string, authorizationDetails: rest[0] as string, - scope: rest[1] as string + scope: rest[1] as string, }; } - + const grantId = params.grantId; const authorizationDetails = params.authorizationDetails; const scope = params.scope; if (typeof grantId === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantId"'); + throw new AppwriteException( + 'Missing required parameter: "grantId"', + ); } - - const apiPath = '/oauth2/{project_id}/approve'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/approve'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof grantId !== 'undefined') { payload['grant_id'] = grantId; @@ -70,15 +94,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -101,7 +120,22 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - authorize(params?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }): Promise; + authorize(params?: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }): Promise; /** * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. * @@ -123,15 +157,96 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - authorize(clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string): Promise; authorize( - paramsOrFirst?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?, (string)?] + clientId?: string, + redirectUri?: string, + responseType?: string, + scope?: string, + state?: string, + nonce?: string, + codeChallenge?: string, + codeChallengeMethod?: string, + prompt?: string, + maxAge?: number, + authorizationDetails?: string, + resource?: string, + audience?: string, + requestUri?: string, + ): Promise; + authorize( + paramsOrFirst?: + | { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + let params: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; } else { params = { clientId: paramsOrFirst as string, @@ -147,10 +262,10 @@ export class Oauth2 { authorizationDetails: rest[9] as string, resource: rest[10] as string, audience: rest[11] as string, - requestUri: rest[12] as string + requestUri: rest[12] as string, }; } - + const clientId = params.clientId; const redirectUri = params.redirectUri; const responseType = params.responseType; @@ -166,8 +281,10 @@ export class Oauth2 { const audience = params.audience; const requestUri = params.requestUri; - - const apiPath = '/oauth2/{project_id}/authorize'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/authorize'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof clientId !== 'undefined') { payload['client_id'] = clientId; @@ -214,15 +331,10 @@ export class Oauth2 { const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -245,7 +357,22 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - authorizePost(params?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }): Promise; + authorizePost(params?: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }): Promise; /** * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. * @@ -267,15 +394,96 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - authorizePost(clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string): Promise; authorizePost( - paramsOrFirst?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?, (string)?] + clientId?: string, + redirectUri?: string, + responseType?: string, + scope?: string, + state?: string, + nonce?: string, + codeChallenge?: string, + codeChallengeMethod?: string, + prompt?: string, + maxAge?: number, + authorizationDetails?: string, + resource?: string, + audience?: string, + requestUri?: string, + ): Promise; + authorizePost( + paramsOrFirst?: + | { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + let params: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; } else { params = { clientId: paramsOrFirst as string, @@ -291,10 +499,10 @@ export class Oauth2 { authorizationDetails: rest[9] as string, resource: rest[10] as string, audience: rest[11] as string, - requestUri: rest[12] as string + requestUri: rest[12] as string, }; } - + const clientId = params.clientId; const redirectUri = params.redirectUri; const responseType = params.responseType; @@ -310,8 +518,10 @@ export class Oauth2 { const audience = params.audience; const requestUri = params.requestUri; - - const apiPath = '/oauth2/{project_id}/authorize'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/authorize'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof clientId !== 'undefined') { payload['client_id'] = clientId; @@ -359,15 +569,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -381,7 +586,13 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - createDeviceAuthorization(params?: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }): Promise; + createDeviceAuthorization(params?: { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + }): Promise; /** * Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. * @@ -394,33 +605,66 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeviceAuthorization(clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string): Promise; createDeviceAuthorization( - paramsOrFirst?: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + clientId?: string, + scope?: string, + authorizationDetails?: string, + resource?: string, + audience?: string, + ): Promise; + createDeviceAuthorization( + paramsOrFirst?: + | { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }; + let params: { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; } else { params = { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, resource: rest[2] as string, - audience: rest[3] as string + audience: rest[3] as string, }; } - + const clientId = params.clientId; const scope = params.scope; const authorizationDetails = params.authorizationDetails; const resource = params.resource; const audience = params.audience; - - const apiPath = '/oauth2/{project_id}/device_authorization'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/device_authorization'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof clientId !== 'undefined') { payload['client_id'] = clientId; @@ -441,15 +685,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -470,25 +709,33 @@ export class Oauth2 { */ createGrant(userCode: string): Promise; createGrant( - paramsOrFirst: { userCode: string } | string + paramsOrFirst: { userCode: string } | string, ): Promise { let params: { userCode: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userCode: string }; } else { params = { - userCode: paramsOrFirst as string + userCode: paramsOrFirst as string, }; } - + const userCode = params.userCode; if (typeof userCode === 'undefined') { - throw new AppwriteException('Missing required parameter: "userCode"'); + throw new AppwriteException( + 'Missing required parameter: "userCode"', + ); } - - const apiPath = '/oauth2/{project_id}/grants'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/grants'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof userCode !== 'undefined') { payload['user_code'] = userCode; @@ -497,15 +744,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -526,38 +768,43 @@ export class Oauth2 { */ getGrant(grantId: string): Promise; getGrant( - paramsOrFirst: { grantId: string } | string + paramsOrFirst: { grantId: string } | string, ): Promise { let params: { grantId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { grantId: string }; } else { params = { - grantId: paramsOrFirst as string + grantId: paramsOrFirst as string, }; } - - const grantId = params.grantId; - if (typeof grantId === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantId"'); - } + const grantId = params.grantId; - const apiPath = '/oauth2/{project_id}/grants/{grant_id}'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))).replace('{grant_id}', encodeURIComponent(String(grantId))); + if (typeof grantId === 'undefined' || grantId === '') { + throw new AppwriteException( + 'Missing required parameter: "grantId"', + ); + } + const apiPath = '/oauth2/{project_id}/grants/{grant_id}' + .replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ) + .replace('{grant_id}', encodeURIComponent(String(grantId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -572,7 +819,14 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise<{}>} */ - logout(params?: { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string }): Promise<{}>; + logout(params?: { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + }): Promise<{}>; /** * OpenID Connect RP-Initiated Logout. Ends the user session and revokes the tokens issued to the app identified by the `id_token_hint`, then redirects the user to `post_logout_redirect_uri` when it matches a URI registered on the app. * @@ -586,15 +840,50 @@ export class Oauth2 { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - logout(idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string): Promise<{}>; logout( - paramsOrFirst?: { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] + idTokenHint?: string, + logoutHint?: string, + clientId?: string, + postLogoutRedirectUri?: string, + state?: string, + uiLocales?: string, + ): Promise<{}>; + logout( + paramsOrFirst?: + | { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?] ): Promise<{}> { - let params: { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string }; + let params: { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + }; } else { params = { idTokenHint: paramsOrFirst as string, @@ -602,10 +891,10 @@ export class Oauth2 { clientId: rest[1] as string, postLogoutRedirectUri: rest[2] as string, state: rest[3] as string, - uiLocales: rest[4] as string + uiLocales: rest[4] as string, }; } - + const idTokenHint = params.idTokenHint; const logoutHint = params.logoutHint; const clientId = params.clientId; @@ -613,8 +902,10 @@ export class Oauth2 { const state = params.state; const uiLocales = params.uiLocales; - - const apiPath = '/oauth2/{project_id}/logout'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/logout'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof idTokenHint !== 'undefined') { payload['id_token_hint'] = idTokenHint; @@ -637,15 +928,10 @@ export class Oauth2 { const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -660,7 +946,14 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise<{}>} */ - logoutPost(params?: { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string }): Promise<{}>; + logoutPost(params?: { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + }): Promise<{}>; /** * OpenID Connect RP-Initiated Logout. Ends the user session and revokes the tokens issued to the app identified by the `id_token_hint`, then redirects the user to `post_logout_redirect_uri` when it matches a URI registered on the app. * @@ -674,15 +967,50 @@ export class Oauth2 { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - logoutPost(idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string): Promise<{}>; logoutPost( - paramsOrFirst?: { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] + idTokenHint?: string, + logoutHint?: string, + clientId?: string, + postLogoutRedirectUri?: string, + state?: string, + uiLocales?: string, + ): Promise<{}>; + logoutPost( + paramsOrFirst?: + | { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?] ): Promise<{}> { - let params: { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { idTokenHint?: string, logoutHint?: string, clientId?: string, postLogoutRedirectUri?: string, state?: string, uiLocales?: string }; + let params: { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + idTokenHint?: string; + logoutHint?: string; + clientId?: string; + postLogoutRedirectUri?: string; + state?: string; + uiLocales?: string; + }; } else { params = { idTokenHint: paramsOrFirst as string, @@ -690,10 +1018,10 @@ export class Oauth2 { clientId: rest[1] as string, postLogoutRedirectUri: rest[2] as string, state: rest[3] as string, - uiLocales: rest[4] as string + uiLocales: rest[4] as string, }; } - + const idTokenHint = params.idTokenHint; const logoutHint = params.logoutHint; const clientId = params.clientId; @@ -701,8 +1029,10 @@ export class Oauth2 { const state = params.state; const uiLocales = params.uiLocales; - - const apiPath = '/oauth2/{project_id}/logout'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/logout'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof idTokenHint !== 'undefined') { payload['id_token_hint'] = idTokenHint; @@ -726,15 +1056,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -746,7 +1071,11 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - listOrganizations(params?: { limit?: number, offset?: number, search?: string }): Promise; + listOrganizations(params?: { + limit?: number; + offset?: number; + search?: string; + }): Promise; /** * List the organizations the OAuth2 access token can access. Resolves the token's `organization` authorization details, expanding the `*` wildcard into the concrete set of organizations the user can see. * @@ -757,29 +1086,45 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOrganizations(limit?: number, offset?: number, search?: string): Promise; listOrganizations( - paramsOrFirst?: { limit?: number, offset?: number, search?: string } | number, - ...rest: [(number)?, (string)?] + limit?: number, + offset?: number, + search?: string, + ): Promise; + listOrganizations( + paramsOrFirst?: + { limit?: number; offset?: number; search?: string } | number, + ...rest: [number?, string?] ): Promise { - let params: { limit?: number, offset?: number, search?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { limit?: number, offset?: number, search?: string }; + let params: { limit?: number; offset?: number; search?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + limit?: number; + offset?: number; + search?: string; + }; } else { params = { limit: paramsOrFirst as number, offset: rest[0] as number, - search: rest[1] as string + search: rest[1] as string, }; } - + const limit = params.limit; const offset = params.offset; const search = params.search; - - const apiPath = '/oauth2/{project_id}/organizations'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/organizations'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof limit !== 'undefined') { payload['limit'] = limit; @@ -793,15 +1138,10 @@ export class Oauth2 { const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -823,7 +1163,21 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - createPAR(params: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }): Promise; + createPAR(params: { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + }): Promise; /** * Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. * @@ -844,15 +1198,90 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPAR(clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string): Promise; createPAR( - paramsOrFirst: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?] + clientId: string, + redirectUri: string, + responseType: string, + scope?: string, + state?: string, + nonce?: string, + codeChallenge?: string, + codeChallengeMethod?: string, + prompt?: string, + maxAge?: number, + authorizationDetails?: string, + resource?: string, + audience?: string, + ): Promise; + createPAR( + paramsOrFirst: + | { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + string?, + string?, + string?, + ] ): Promise { - let params: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }; + let params: { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; } else { params = { clientId: paramsOrFirst as string, @@ -867,10 +1296,10 @@ export class Oauth2 { maxAge: rest[8] as number, authorizationDetails: rest[9] as string, resource: rest[10] as string, - audience: rest[11] as string + audience: rest[11] as string, }; } - + const clientId = params.clientId; const redirectUri = params.redirectUri; const responseType = params.responseType; @@ -886,16 +1315,24 @@ export class Oauth2 { const audience = params.audience; if (typeof clientId === 'undefined') { - throw new AppwriteException('Missing required parameter: "clientId"'); + throw new AppwriteException( + 'Missing required parameter: "clientId"', + ); } if (typeof redirectUri === 'undefined') { - throw new AppwriteException('Missing required parameter: "redirectUri"'); + throw new AppwriteException( + 'Missing required parameter: "redirectUri"', + ); } if (typeof responseType === 'undefined') { - throw new AppwriteException('Missing required parameter: "responseType"'); + throw new AppwriteException( + 'Missing required parameter: "responseType"', + ); } - - const apiPath = '/oauth2/{project_id}/par'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/par'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof clientId !== 'undefined') { payload['client_id'] = clientId; @@ -940,15 +1377,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -960,7 +1392,11 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - listProjects(params?: { limit?: number, offset?: number, search?: string }): Promise; + listProjects(params?: { + limit?: number; + offset?: number; + search?: string; + }): Promise; /** * List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. * @@ -971,29 +1407,45 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listProjects(limit?: number, offset?: number, search?: string): Promise; listProjects( - paramsOrFirst?: { limit?: number, offset?: number, search?: string } | number, - ...rest: [(number)?, (string)?] + limit?: number, + offset?: number, + search?: string, + ): Promise; + listProjects( + paramsOrFirst?: + { limit?: number; offset?: number; search?: string } | number, + ...rest: [number?, string?] ): Promise { - let params: { limit?: number, offset?: number, search?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { limit?: number, offset?: number, search?: string }; + let params: { limit?: number; offset?: number; search?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + limit?: number; + offset?: number; + search?: string; + }; } else { params = { limit: paramsOrFirst as number, offset: rest[0] as number, - search: rest[1] as string + search: rest[1] as string, }; } - + const limit = params.limit; const offset = params.offset; const search = params.search; - - const apiPath = '/oauth2/{project_id}/projects'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/projects'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof limit !== 'undefined') { payload['limit'] = limit; @@ -1007,15 +1459,10 @@ export class Oauth2 { const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1036,25 +1483,33 @@ export class Oauth2 { */ reject(grantId: string): Promise; reject( - paramsOrFirst: { grantId: string } | string + paramsOrFirst: { grantId: string } | string, ): Promise { let params: { grantId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { grantId: string }; } else { params = { - grantId: paramsOrFirst as string + grantId: paramsOrFirst as string, }; } - + const grantId = params.grantId; if (typeof grantId === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantId"'); + throw new AppwriteException( + 'Missing required parameter: "grantId"', + ); } - - const apiPath = '/oauth2/{project_id}/reject'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/reject'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof grantId !== 'undefined') { payload['grant_id'] = grantId; @@ -1063,15 +1518,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1084,7 +1534,12 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise<{}>} */ - revoke(params: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }): Promise<{}>; + revoke(params: { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }): Promise<{}>; /** * Revoke an OAuth2 access token or refresh token. * @@ -1096,24 +1551,50 @@ export class Oauth2 { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - revoke(token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string): Promise<{}>; revoke( - paramsOrFirst: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + token: string, + tokenTypeHint?: string, + clientId?: string, + clientSecret?: string, + ): Promise<{}>; + revoke( + paramsOrFirst: + | { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }; + let params: { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }; } else { params = { token: paramsOrFirst as string, tokenTypeHint: rest[0] as string, clientId: rest[1] as string, - clientSecret: rest[2] as string + clientSecret: rest[2] as string, }; } - + const token = params.token; const tokenTypeHint = params.tokenTypeHint; const clientId = params.clientId; @@ -1122,8 +1603,10 @@ export class Oauth2 { if (typeof token === 'undefined') { throw new AppwriteException('Missing required parameter: "token"'); } - - const apiPath = '/oauth2/{project_id}/revoke'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/revoke'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof token !== 'undefined') { payload['token'] = token; @@ -1141,15 +1624,10 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1168,7 +1646,18 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - createToken(params: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }): Promise; + createToken(params: { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + }): Promise; /** * Exchange an OAuth2 authorization code, refresh token, or device code for access and refresh tokens. * @@ -1186,15 +1675,75 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createToken(grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string): Promise; createToken( - paramsOrFirst: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + grantType: string, + code?: string, + refreshToken?: string, + deviceCode?: string, + clientId?: string, + clientSecret?: string, + codeVerifier?: string, + redirectUri?: string, + resource?: string, + audience?: string, + ): Promise; + createToken( + paramsOrFirst: + | { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }; + let params: { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + }; } else { params = { grantType: paramsOrFirst as string, @@ -1206,10 +1755,10 @@ export class Oauth2 { codeVerifier: rest[5] as string, redirectUri: rest[6] as string, resource: rest[7] as string, - audience: rest[8] as string + audience: rest[8] as string, }; } - + const grantType = params.grantType; const code = params.code; const refreshToken = params.refreshToken; @@ -1222,10 +1771,14 @@ export class Oauth2 { const audience = params.audience; if (typeof grantType === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantType"'); + throw new AppwriteException( + 'Missing required parameter: "grantType"', + ); } - - const apiPath = '/oauth2/{project_id}/token'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const apiPath = '/oauth2/{project_id}/token'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); const payload: Payload = {}; if (typeof grantType !== 'undefined') { payload['grant_type'] = grantType; @@ -1261,14 +1814,9 @@ export class Oauth2 { const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 4a9ee5f9..8e96a636 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,10 +1,8 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { OrganizationKeyScopes } from '../enums/organization-key-scopes'; import { Region } from '../enums/region'; - export class Organization { client: Client; @@ -18,23 +16,19 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise>} */ - get(): Promise> { - + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise> { const apiPath = '/organization'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -44,7 +38,9 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise>} */ - update(params: { name: string }): Promise>; + update< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { name: string }): Promise>; /** * Update the current organization's name. * @@ -53,26 +49,31 @@ export class Organization { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(name: string): Promise>; update( - paramsOrFirst: { name: string } | string + name: string, + ): Promise>; + update( + paramsOrFirst: { name: string } | string, ): Promise> { let params: { name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { name: string }; } else { params = { - name: paramsOrFirst as string + name: paramsOrFirst as string, }; } - + const name = params.name; if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/organization'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -83,15 +84,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -101,7 +97,6 @@ export class Organization { * @returns {Promise<{}>} */ delete(): Promise<{}> { - const apiPath = '/organization'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -109,14 +104,10 @@ export class Organization { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -127,7 +118,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params?: { queries?: string[], total?: boolean }): Promise; + listInstallations(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * List app installations on the organization. Any organization member can read installations. * @@ -137,26 +131,36 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(queries?: string[], total?: boolean): Promise; listInstallations( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/organization/installations'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -169,15 +173,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -188,7 +187,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createInstallation(params: { appId: string, authorizationDetails?: string }): Promise; + createInstallation(params: { + appId: string; + authorizationDetails?: string; + }): Promise; /** * Install an app on the organization. Only organization members with the owner role can install apps. The installation is granted the scopes the app currently requests. * @@ -198,29 +200,39 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInstallation(appId: string, authorizationDetails?: string): Promise; createInstallation( - paramsOrFirst: { appId: string, authorizationDetails?: string } | string, - ...rest: [(string)?] + appId: string, + authorizationDetails?: string, + ): Promise; + createInstallation( + paramsOrFirst: + { appId: string; authorizationDetails?: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, authorizationDetails?: string }; + let params: { appId: string; authorizationDetails?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + authorizationDetails?: string; + }; } else { params = { appId: paramsOrFirst as string, - authorizationDetails: rest[0] as string + authorizationDetails: rest[0] as string, }; } - + const appId = params.appId; const authorizationDetails = params.authorizationDetails; if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - const apiPath = '/organization/installations'; const payload: Payload = {}; if (typeof appId !== 'undefined') { @@ -234,15 +246,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -252,7 +259,9 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { installationId: string }): Promise; + getInstallation(params: { + installationId: string; + }): Promise; /** * Get an app installation on the organization by its unique ID. Any organization member can read installations. * @@ -263,39 +272,42 @@ export class Organization { */ getInstallation(installationId: string): Promise; getInstallation( - paramsOrFirst: { installationId: string } | string + paramsOrFirst: { installationId: string } | string, ): Promise { let params: { installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { installationId: string }; } else { params = { - installationId: paramsOrFirst as string + installationId: paramsOrFirst as string, }; } - + const installationId = params.installationId; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = '/organization/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -306,7 +318,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateInstallation(params: { installationId: string, authorizationDetails?: string }): Promise; + updateInstallation(params: { + installationId: string; + authorizationDetails?: string; + }): Promise; /** * Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. * @@ -316,30 +331,45 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateInstallation(installationId: string, authorizationDetails?: string): Promise; updateInstallation( - paramsOrFirst: { installationId: string, authorizationDetails?: string } | string, - ...rest: [(string)?] + installationId: string, + authorizationDetails?: string, + ): Promise; + updateInstallation( + paramsOrFirst: + { installationId: string; authorizationDetails?: string } | string, + ...rest: [string?] ): Promise { - let params: { installationId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, authorizationDetails?: string }; + let params: { installationId: string; authorizationDetails?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + authorizationDetails?: string; + }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string + authorizationDetails: rest[0] as string, }; } - + const installationId = params.installationId; const authorizationDetails = params.authorizationDetails; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = '/organization/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; if (typeof authorizationDetails !== 'undefined') { payload['authorizationDetails'] = authorizationDetails; @@ -349,15 +379,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -378,40 +403,43 @@ export class Organization { */ deleteInstallation(installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { installationId: string } | string + paramsOrFirst: { installationId: string } | string, ): Promise<{}> { let params: { installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { installationId: string }; } else { params = { - installationId: paramsOrFirst as string + installationId: paramsOrFirst as string, }; } - + const installationId = params.installationId; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = '/organization/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -422,7 +450,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listKeys(params?: { queries?: string[], total?: boolean }): Promise; + listKeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all API keys from the current organization. * @@ -434,24 +465,31 @@ export class Organization { */ listKeys(queries?: string[], total?: boolean): Promise; listKeys( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/organization/keys'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -464,15 +502,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -485,7 +518,12 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createKey(params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }): Promise; + createKey(params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }): Promise; /** * Create a new organization API key. * @@ -497,24 +535,50 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createKey(keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string): Promise; createKey( - paramsOrFirst: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (OrganizationKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: OrganizationKeyScopes[], + expire?: string, + ): Promise; + createKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, OrganizationKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as OrganizationKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; @@ -529,7 +593,6 @@ export class Organization { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - const apiPath = '/organization/keys'; const payload: Payload = {}; if (typeof keyId !== 'undefined') { @@ -549,15 +612,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -577,40 +635,39 @@ export class Organization { * @deprecated Use the object parameter style method for a better developer experience. */ getKey(keyId: string): Promise; - getKey( - paramsOrFirst: { keyId: string } | string - ): Promise { + getKey(paramsOrFirst: { keyId: string } | string): Promise { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - + const keyId = params.keyId; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/organization/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -623,7 +680,12 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }): Promise; + updateKey(params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * @@ -635,30 +697,56 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (OrganizationKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: OrganizationKeyScopes[], + expire?: string, + ): Promise; + updateKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, OrganizationKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as OrganizationKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; const expire = params.expire; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } if (typeof name === 'undefined') { @@ -667,8 +755,10 @@ export class Organization { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - - const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/organization/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -684,15 +774,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -712,40 +797,40 @@ export class Organization { * @deprecated Use the object parameter style method for a better developer experience. */ deleteKey(keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { keyId: string } | string - ): Promise<{}> { + deleteKey(paramsOrFirst: { keyId: string } | string): Promise<{}> { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - + const keyId = params.keyId; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/organization/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -757,7 +842,11 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listMemberships(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listMemberships(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all memberships from the current organization. * @@ -768,28 +857,41 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMemberships(queries?: string[], search?: string, total?: boolean): Promise; listMemberships( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMemberships( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/organization/memberships'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -805,15 +907,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -828,7 +925,14 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createMembership(params: { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise; + createMembership(params: { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }): Promise; /** * Invite a new member to join the current organization. An email with a link to join the organization will be sent to the new member's email address. If member doesn't exist in the project it will be automatically created. * @@ -842,15 +946,49 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMembership(roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise; createMembership( - paramsOrFirst: { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string[], - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] + roles: string[], + email?: string, + userId?: string, + phone?: string, + url?: string, + name?: string, + ): Promise; + createMembership( + paramsOrFirst: + | { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + } + | string[], + ...rest: [string?, string?, string?, string?, string?] ): Promise { - let params: { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + let params: { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; } else { params = { roles: paramsOrFirst as string[], @@ -858,10 +996,10 @@ export class Organization { userId: rest[1] as string, phone: rest[2] as string, url: rest[3] as string, - name: rest[4] as string + name: rest[4] as string, }; } - + const roles = params.roles; const email = params.email; const userId = params.userId; @@ -872,7 +1010,6 @@ export class Organization { if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - const apiPath = '/organization/memberships'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -898,15 +1035,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -927,39 +1059,42 @@ export class Organization { */ getMembership(membershipId: string): Promise; getMembership( - paramsOrFirst: { membershipId: string } | string + paramsOrFirst: { membershipId: string } | string, ): Promise { let params: { membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { membershipId: string }; } else { params = { - membershipId: paramsOrFirst as string + membershipId: paramsOrFirst as string, }; } - + const membershipId = params.membershipId; - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } - - const apiPath = '/organization/memberships/{membershipId}'.replace('{membershipId}', encodeURIComponent(String(membershipId))); + const apiPath = '/organization/memberships/{membershipId}'.replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -970,7 +1105,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateMembership(params: { membershipId: string, roles: string[] }): Promise; + updateMembership(params: { + membershipId: string; + roles: string[]; + }): Promise; /** * Modify the roles of a member in the current organization. * @@ -980,33 +1118,47 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembership(membershipId: string, roles: string[]): Promise; updateMembership( - paramsOrFirst: { membershipId: string, roles: string[] } | string, - ...rest: [(string[])?] + membershipId: string, + roles: string[], + ): Promise; + updateMembership( + paramsOrFirst: { membershipId: string; roles: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { membershipId: string, roles: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { membershipId: string, roles: string[] }; + let params: { membershipId: string; roles: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + membershipId: string; + roles: string[]; + }; } else { params = { membershipId: paramsOrFirst as string, - roles: rest[0] as string[] + roles: rest[0] as string[], }; } - + const membershipId = params.membershipId; const roles = params.roles; - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - - const apiPath = '/organization/memberships/{membershipId}'.replace('{membershipId}', encodeURIComponent(String(membershipId))); + const apiPath = '/organization/memberships/{membershipId}'.replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: Payload = {}; if (typeof roles !== 'undefined') { payload['roles'] = roles; @@ -1016,15 +1168,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1045,39 +1192,43 @@ export class Organization { */ deleteMembership(membershipId: string): Promise<{}>; deleteMembership( - paramsOrFirst: { membershipId: string } | string + paramsOrFirst: { membershipId: string } | string, ): Promise<{}> { let params: { membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { membershipId: string }; } else { params = { - membershipId: paramsOrFirst as string + membershipId: paramsOrFirst as string, }; } - + const membershipId = params.membershipId; - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } - - const apiPath = '/organization/memberships/{membershipId}'.replace('{membershipId}', encodeURIComponent(String(membershipId))); + const apiPath = '/organization/memberships/{membershipId}'.replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1089,7 +1240,11 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listProjects(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listProjects(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all projects. You can use the query params to filter your results. * @@ -1100,28 +1255,41 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listProjects(queries?: string[], search?: string, total?: boolean): Promise; listProjects( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listProjects( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/organization/projects'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1137,15 +1305,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1157,7 +1320,11 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createProject(params: { projectId: string, name: string, region?: Region }): Promise; + createProject(params: { + projectId: string; + name: string; + region?: Region; + }): Promise; /** * Create a new project. * @@ -1168,34 +1335,48 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createProject(projectId: string, name: string, region?: Region): Promise; createProject( - paramsOrFirst: { projectId: string, name: string, region?: Region } | string, - ...rest: [(string)?, (Region)?] + projectId: string, + name: string, + region?: Region, + ): Promise; + createProject( + paramsOrFirst: + { projectId: string; name: string; region?: Region } | string, + ...rest: [string?, Region?] ): Promise { - let params: { projectId: string, name: string, region?: Region }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string, region?: Region }; + let params: { projectId: string; name: string; region?: Region }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + name: string; + region?: Region; + }; } else { params = { projectId: paramsOrFirst as string, name: rest[0] as string, - region: rest[1] as Region + region: rest[1] as Region, }; } - + const projectId = params.projectId; const name = params.name; const region = params.region; if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/organization/projects'; const payload: Payload = {}; if (typeof projectId !== 'undefined') { @@ -1212,15 +1393,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1241,38 +1417,42 @@ export class Organization { */ getProject(projectId: string): Promise; getProject( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - + const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/organization/projects/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1283,7 +1463,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateProject(params: { projectId: string, name: string }): Promise; + updateProject(params: { + projectId: string; + name: string; + }): Promise; /** * Update a project by its unique ID. * @@ -1295,31 +1478,42 @@ export class Organization { */ updateProject(projectId: string, name: string): Promise; updateProject( - paramsOrFirst: { projectId: string, name: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; name: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string }; + let params: { projectId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + name: string; + }; } else { params = { projectId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const projectId = params.projectId; const name = params.name; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/organization/projects/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1329,15 +1523,10 @@ export class Organization { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1357,39 +1546,41 @@ export class Organization { * @deprecated Use the object parameter style method for a better developer experience. */ deleteProject(projectId: string): Promise<{}>; - deleteProject( - paramsOrFirst: { projectId: string } | string - ): Promise<{}> { + deleteProject(paramsOrFirst: { projectId: string } | string): Promise<{}> { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - + const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/organization/projects/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/organizations.ts b/src/services/organizations.ts index 295c6510..81bfa975 100644 --- a/src/services/organizations.ts +++ b/src/services/organizations.ts @@ -1,10 +1,9 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { Platform } from '../enums/platform'; -import { Addon } from '../enums/addon'; - +import { AddonKey } from '../enums/addon-key'; export class Organizations { client: Client; @@ -20,7 +19,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - list(params?: { queries?: string[], search?: string }): Promise>; + list< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params?: { + queries?: string[]; + search?: string; + }): Promise>; /** * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * @@ -30,26 +34,36 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string): Promise>; list( - paramsOrFirst?: { queries?: string[], search?: string } | string[], - ...rest: [(string)?] + queries?: string[], + search?: string, + ): Promise>; + list( + paramsOrFirst?: { queries?: string[]; search?: string } | string[], + ...rest: [string?] ): Promise> { - let params: { queries?: string[], search?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + let params: { queries?: string[]; search?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + }; } else { params = { queries: paramsOrFirst as string[], - search: rest[0] as string + search: rest[0] as string, }; } - + const queries = params.queries; const search = params.search; - const apiPath = '/organizations'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -62,20 +76,15 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new organization. - * + * * * @param {string} params.organizationId - Organization 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 - Organization name. Max length: 128 chars. @@ -90,10 +99,25 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise | Models.PaymentAuthentication>} */ - create(params: { organizationId: string, name: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number, platform?: Platform }): Promise | Models.PaymentAuthentication>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + name: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + platform?: Platform; + }): Promise< + Models.Organization | Models.PaymentAuthentication + >; /** * Create a new organization. - * + * * * @param {string} organizationId - Organization 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 - Organization name. Max length: 128 chars. @@ -109,15 +133,77 @@ export class Organizations { * @returns {Promise | Models.PaymentAuthentication>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(organizationId: string, name: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number, platform?: Platform): Promise | Models.PaymentAuthentication>; create( - paramsOrFirst: { organizationId: string, name: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number, platform?: Platform } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string)?, (number)?, (Platform)?] - ): Promise | Models.PaymentAuthentication> { - let params: { organizationId: string, name: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number, platform?: Platform }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, name: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number, platform?: Platform }; + organizationId: string, + name: string, + billingPlan: string, + paymentMethodId?: string, + billingAddressId?: string, + invites?: string[], + couponId?: string, + taxId?: string, + budget?: number, + platform?: Platform, + ): Promise | Models.PaymentAuthentication>; + create( + paramsOrFirst: + | { + organizationId: string; + name: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + platform?: Platform; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string[]?, + string?, + string?, + number?, + Platform?, + ] + ): Promise< + Models.Organization | Models.PaymentAuthentication + > { + let params: { + organizationId: string; + name: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + platform?: Platform; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + name: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + platform?: Platform; + }; } else { params = { organizationId: paramsOrFirst as string, @@ -129,10 +215,10 @@ export class Organizations { couponId: rest[5] as string, taxId: rest[6] as string, budget: rest[7] as number, - platform: rest[8] as Platform + platform: rest[8] as Platform, }; } - + const organizationId = params.organizationId; const name = params.name; const billingPlan = params.billingPlan; @@ -145,15 +231,18 @@ export class Organizations { const platform = params.platform; if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof billingPlan === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingPlan"'); + throw new AppwriteException( + 'Missing required parameter: "billingPlan"', + ); } - const apiPath = '/organizations'; const payload: Payload = {}; if (typeof organizationId !== 'undefined') { @@ -191,15 +280,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -213,7 +297,13 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - estimationCreateOrganization(params: { billingPlan: string, paymentMethodId?: string, invites?: string[], couponId?: string, platform?: Platform }): Promise; + estimationCreateOrganization(params: { + billingPlan: string; + paymentMethodId?: string; + invites?: string[]; + couponId?: string; + platform?: Platform; + }): Promise; /** * Get estimation for creating an organization. * @@ -226,25 +316,55 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - estimationCreateOrganization(billingPlan: string, paymentMethodId?: string, invites?: string[], couponId?: string, platform?: Platform): Promise; estimationCreateOrganization( - paramsOrFirst: { billingPlan: string, paymentMethodId?: string, invites?: string[], couponId?: string, platform?: Platform } | string, - ...rest: [(string)?, (string[])?, (string)?, (Platform)?] + billingPlan: string, + paymentMethodId?: string, + invites?: string[], + couponId?: string, + platform?: Platform, + ): Promise; + estimationCreateOrganization( + paramsOrFirst: + | { + billingPlan: string; + paymentMethodId?: string; + invites?: string[]; + couponId?: string; + platform?: Platform; + } + | string, + ...rest: [string?, string[]?, string?, Platform?] ): Promise { - let params: { billingPlan: string, paymentMethodId?: string, invites?: string[], couponId?: string, platform?: Platform }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { billingPlan: string, paymentMethodId?: string, invites?: string[], couponId?: string, platform?: Platform }; + let params: { + billingPlan: string; + paymentMethodId?: string; + invites?: string[]; + couponId?: string; + platform?: Platform; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + billingPlan: string; + paymentMethodId?: string; + invites?: string[]; + couponId?: string; + platform?: Platform; + }; } else { params = { billingPlan: paramsOrFirst as string, paymentMethodId: rest[0] as string, invites: rest[1] as string[], couponId: rest[2] as string, - platform: rest[3] as Platform + platform: rest[3] as Platform, }; } - + const billingPlan = params.billingPlan; const paymentMethodId = params.paymentMethodId; const invites = params.invites; @@ -252,9 +372,10 @@ export class Organizations { const platform = params.platform; if (typeof billingPlan === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingPlan"'); + throw new AppwriteException( + 'Missing required parameter: "billingPlan"', + ); } - const apiPath = '/organizations/estimations/create-organization'; const payload: Payload = {}; if (typeof billingPlan !== 'undefined') { @@ -277,15 +398,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -305,46 +421,47 @@ export class Organizations { * @deprecated Use the object parameter style method for a better developer experience. */ delete(organizationId: string): Promise<{}>; - delete( - paramsOrFirst: { organizationId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { organizationId: string } | string): Promise<{}> { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * List all billing addons for an organization. - * + * * * @param {string} params.organizationId - Organization ID * @throws {AppwriteException} @@ -353,7 +470,7 @@ export class Organizations { listAddons(params: { organizationId: string }): Promise; /** * List all billing addons for an organization. - * + * * * @param {string} organizationId - Organization ID * @throws {AppwriteException} @@ -362,44 +479,47 @@ export class Organizations { */ listAddons(organizationId: string): Promise; listAddons( - paramsOrFirst: { organizationId: string } | string + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/addons'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/addons'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create the BAA billing addon for an organization. - * + * * * @param {string} params.organizationId - Organization ID * @throws {AppwriteException} @@ -408,7 +528,7 @@ export class Organizations { createBaaAddon(params: { organizationId: string }): Promise; /** * Create the BAA billing addon for an organization. - * + * * * @param {string} organizationId - Organization ID * @throws {AppwriteException} @@ -417,54 +537,59 @@ export class Organizations { */ createBaaAddon(organizationId: string): Promise; createBaaAddon( - paramsOrFirst: { organizationId: string } | string + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/addons/baa'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/addons/baa'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a Premium Geo DB addon for an organization. - * + * * * @param {string} params.organizationId - Organization ID * @throws {AppwriteException} * @returns {Promise} */ - createPremiumGeoDBAddon(params: { organizationId: string }): Promise; + createPremiumGeoDBAddon(params: { + organizationId: string; + }): Promise; /** * Create a Premium Geo DB addon for an organization. - * + * * * @param {string} organizationId - Organization ID * @throws {AppwriteException} @@ -473,55 +598,62 @@ export class Organizations { */ createPremiumGeoDBAddon(organizationId: string): Promise; createPremiumGeoDBAddon( - paramsOrFirst: { organizationId: string } | string + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/addons/premium-geo-db'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = + '/organizations/{organizationId}/addons/premium-geo-db'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get the details of a billing addon for an organization. - * + * * * @param {string} params.organizationId - Organization ID * @param {string} params.addonId - Addon ID * @throws {AppwriteException} * @returns {Promise} */ - getAddon(params: { organizationId: string, addonId: string }): Promise; + getAddon(params: { + organizationId: string; + addonId: string; + }): Promise; /** * Get the details of a billing addon for an organization. - * + * * * @param {string} organizationId - Organization ID * @param {string} addonId - Addon ID @@ -531,60 +663,73 @@ export class Organizations { */ getAddon(organizationId: string, addonId: string): Promise; getAddon( - paramsOrFirst: { organizationId: string, addonId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { organizationId: string; addonId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, addonId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, addonId: string }; + let params: { organizationId: string; addonId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + addonId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - addonId: rest[0] as string + addonId: rest[0] as string, }; } - + const organizationId = params.organizationId; const addonId = params.addonId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof addonId === 'undefined') { - throw new AppwriteException('Missing required parameter: "addonId"'); - } - - const apiPath = '/organizations/{organizationId}/addons/{addonId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{addonId}', encodeURIComponent(String(addonId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof addonId === 'undefined' || addonId === '') { + throw new AppwriteException( + 'Missing required parameter: "addonId"', + ); + } + const apiPath = '/organizations/{organizationId}/addons/{addonId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{addonId}', encodeURIComponent(String(addonId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Delete a billing addon for an organization. - * + * * * @param {string} params.organizationId - Organization ID * @param {string} params.addonId - Addon ID * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteAddon(params: { organizationId: string, addonId: string }): Promise<{}>; + deleteAddon(params: { + organizationId: string; + addonId: string; + }): Promise<{}>; /** * Delete a billing addon for an organization. - * + * * * @param {string} organizationId - Organization ID * @param {string} addonId - Addon ID @@ -594,61 +739,74 @@ export class Organizations { */ deleteAddon(organizationId: string, addonId: string): Promise<{}>; deleteAddon( - paramsOrFirst: { organizationId: string, addonId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { organizationId: string; addonId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { organizationId: string, addonId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, addonId: string }; + let params: { organizationId: string; addonId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + addonId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - addonId: rest[0] as string + addonId: rest[0] as string, }; } - + const organizationId = params.organizationId; const addonId = params.addonId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof addonId === 'undefined') { - throw new AppwriteException('Missing required parameter: "addonId"'); - } - - const apiPath = '/organizations/{organizationId}/addons/{addonId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{addonId}', encodeURIComponent(String(addonId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof addonId === 'undefined' || addonId === '') { + throw new AppwriteException( + 'Missing required parameter: "addonId"', + ); + } + const apiPath = '/organizations/{organizationId}/addons/{addonId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{addonId}', encodeURIComponent(String(addonId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Confirm payment for a billing addon for an organization. - * + * * * @param {string} params.organizationId - Organization ID * @param {string} params.addonId - Addon ID * @throws {AppwriteException} * @returns {Promise} */ - confirmAddonPayment(params: { organizationId: string, addonId: string }): Promise; + confirmAddonPayment(params: { + organizationId: string; + addonId: string; + }): Promise; /** * Confirm payment for a billing addon for an organization. - * + * * * @param {string} organizationId - Organization ID * @param {string} addonId - Addon ID @@ -656,111 +814,139 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - confirmAddonPayment(organizationId: string, addonId: string): Promise; confirmAddonPayment( - paramsOrFirst: { organizationId: string, addonId: string } | string, - ...rest: [(string)?] + organizationId: string, + addonId: string, + ): Promise; + confirmAddonPayment( + paramsOrFirst: { organizationId: string; addonId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, addonId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, addonId: string }; + let params: { organizationId: string; addonId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + addonId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - addonId: rest[0] as string + addonId: rest[0] as string, }; } - + const organizationId = params.organizationId; const addonId = params.addonId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof addonId === 'undefined') { - throw new AppwriteException('Missing required parameter: "addonId"'); - } - - const apiPath = '/organizations/{organizationId}/addons/{addonId}/confirmations'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{addonId}', encodeURIComponent(String(addonId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof addonId === 'undefined' || addonId === '') { + throw new AppwriteException( + 'Missing required parameter: "addonId"', + ); + } + const apiPath = + '/organizations/{organizationId}/addons/{addonId}/confirmations' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{addonId}', encodeURIComponent(String(addonId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get the price details for a billing addon for an organization. - * + * * * @param {string} params.organizationId - Organization ID - * @param {Addon} params.addon - Addon key identifier (e.g. baa). + * @param {AddonKey} params.addon - Addon key identifier (e.g. baa). * @throws {AppwriteException} * @returns {Promise} */ - getAddonPrice(params: { organizationId: string, addon: Addon }): Promise; + getAddonPrice(params: { + organizationId: string; + addon: AddonKey; + }): Promise; /** * Get the price details for a billing addon for an organization. - * + * * * @param {string} organizationId - Organization ID - * @param {Addon} addon - Addon key identifier (e.g. baa). + * @param {AddonKey} addon - Addon key identifier (e.g. baa). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAddonPrice(organizationId: string, addon: Addon): Promise; getAddonPrice( - paramsOrFirst: { organizationId: string, addon: Addon } | string, - ...rest: [(Addon)?] + organizationId: string, + addon: AddonKey, + ): Promise; + getAddonPrice( + paramsOrFirst: { organizationId: string; addon: AddonKey } | string, + ...rest: [AddonKey?] ): Promise { - let params: { organizationId: string, addon: Addon }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, addon: Addon }; + let params: { organizationId: string; addon: AddonKey }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + addon: AddonKey; + }; } else { params = { organizationId: paramsOrFirst as string, - addon: rest[0] as Addon + addon: rest[0] as AddonKey, }; } - + const organizationId = params.organizationId; const addon = params.addon; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof addon === 'undefined') { throw new AppwriteException('Missing required parameter: "addon"'); } - - const apiPath = '/organizations/{organizationId}/addons/{addon}/price'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{addon}', encodeURIComponent(String(addon))); + const apiPath = '/organizations/{organizationId}/addons/{addon}/price' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{addon}', encodeURIComponent(String(addon))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -771,7 +957,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - listAggregations(params: { organizationId: string, queries?: string[] }): Promise; + listAggregations(params: { + organizationId: string; + queries?: string[]; + }): Promise; /** * Get a list of all aggregations for an organization. * @@ -781,30 +970,44 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listAggregations(organizationId: string, queries?: string[]): Promise; listAggregations( - paramsOrFirst: { organizationId: string, queries?: string[] } | string, - ...rest: [(string[])?] + organizationId: string, + queries?: string[], + ): Promise; + listAggregations( + paramsOrFirst: { organizationId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { organizationId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, queries?: string[] }; + let params: { organizationId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + queries?: string[]; + }; } else { params = { organizationId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const organizationId = params.organizationId; const queries = params.queries; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/aggregations'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/aggregations'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -813,15 +1016,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -834,7 +1032,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getAggregation(params: { organizationId: string, aggregationId: string, limit?: number, offset?: number }): Promise; + getAggregation(params: { + organizationId: string; + aggregationId: string; + limit?: number; + offset?: number; + }): Promise; /** * Get a specific aggregation using it's aggregation ID. * @@ -846,37 +1049,75 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAggregation(organizationId: string, aggregationId: string, limit?: number, offset?: number): Promise; getAggregation( - paramsOrFirst: { organizationId: string, aggregationId: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + organizationId: string, + aggregationId: string, + limit?: number, + offset?: number, + ): Promise; + getAggregation( + paramsOrFirst: + | { + organizationId: string; + aggregationId: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { organizationId: string, aggregationId: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, aggregationId: string, limit?: number, offset?: number }; + let params: { + organizationId: string; + aggregationId: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + aggregationId: string; + limit?: number; + offset?: number; + }; } else { params = { organizationId: paramsOrFirst as string, aggregationId: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const organizationId = params.organizationId; const aggregationId = params.aggregationId; const limit = params.limit; const offset = params.offset; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof aggregationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "aggregationId"'); - } - - const apiPath = '/organizations/{organizationId}/aggregations/{aggregationId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{aggregationId}', encodeURIComponent(String(aggregationId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof aggregationId === 'undefined' || aggregationId === '') { + throw new AppwriteException( + 'Missing required parameter: "aggregationId"', + ); + } + const apiPath = + '/organizations/{organizationId}/aggregations/{aggregationId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace( + '{aggregationId}', + encodeURIComponent(String(aggregationId)), + ); const payload: Payload = {}; if (typeof limit !== 'undefined') { payload['limit'] = limit; @@ -888,15 +1129,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -907,7 +1143,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - setBillingAddress(params: { organizationId: string, billingAddressId: string }): Promise>; + setBillingAddress< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + billingAddressId: string; + }): Promise>; /** * Set a billing address for an organization. * @@ -917,33 +1158,55 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - setBillingAddress(organizationId: string, billingAddressId: string): Promise>; - setBillingAddress( - paramsOrFirst: { organizationId: string, billingAddressId: string } | string, - ...rest: [(string)?] + setBillingAddress< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + billingAddressId: string, + ): Promise>; + setBillingAddress< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { organizationId: string; billingAddressId: string } | string, + ...rest: [string?] ): Promise> { - let params: { organizationId: string, billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingAddressId: string }; + let params: { organizationId: string; billingAddressId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + billingAddressId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - billingAddressId: rest[0] as string + billingAddressId: rest[0] as string, }; } - + const organizationId = params.organizationId; const billingAddressId = params.billingAddressId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } - - const apiPath = '/organizations/{organizationId}/billing-address'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + throw new AppwriteException( + 'Missing required parameter: "billingAddressId"', + ); + } + const apiPath = + '/organizations/{organizationId}/billing-address'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof billingAddressId !== 'undefined') { payload['billingAddressId'] = billingAddressId; @@ -953,15 +1216,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -982,40 +1240,44 @@ export class Organizations { */ deleteBillingAddress(organizationId: string): Promise<{}>; deleteBillingAddress( - paramsOrFirst: { organizationId: string } | string + paramsOrFirst: { organizationId: string } | string, ): Promise<{}> { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/billing-address'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = + '/organizations/{organizationId}/billing-address'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1026,7 +1288,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getBillingAddress(params: { organizationId: string, billingAddressId: string }): Promise; + getBillingAddress(params: { + organizationId: string; + billingAddressId: string; + }): Promise; /** * Get a billing address using it's ID. * @@ -1036,47 +1301,68 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBillingAddress(organizationId: string, billingAddressId: string): Promise; getBillingAddress( - paramsOrFirst: { organizationId: string, billingAddressId: string } | string, - ...rest: [(string)?] + organizationId: string, + billingAddressId: string, + ): Promise; + getBillingAddress( + paramsOrFirst: + { organizationId: string; billingAddressId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, billingAddressId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingAddressId: string }; + let params: { organizationId: string; billingAddressId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + billingAddressId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - billingAddressId: rest[0] as string + billingAddressId: rest[0] as string, }; } - + const organizationId = params.organizationId; const billingAddressId = params.billingAddressId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof billingAddressId === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingAddressId"'); - } - - const apiPath = '/organizations/{organizationId}/billing-addresses/{billingAddressId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{billingAddressId}', encodeURIComponent(String(billingAddressId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if ( + typeof billingAddressId === 'undefined' || + billingAddressId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "billingAddressId"', + ); + } + const apiPath = + '/organizations/{organizationId}/billing-addresses/{billingAddressId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace( + '{billingAddressId}', + encodeURIComponent(String(billingAddressId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1087,7 +1373,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - setBillingEmail(params: { organizationId: string, billingEmail: string }): Promise>; + setBillingEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + billingEmail: string; + }): Promise>; /** * Set the current billing email for the organization. * @@ -1097,33 +1388,54 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - setBillingEmail(organizationId: string, billingEmail: string): Promise>; - setBillingEmail( - paramsOrFirst: { organizationId: string, billingEmail: string } | string, - ...rest: [(string)?] + setBillingEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + billingEmail: string, + ): Promise>; + setBillingEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { organizationId: string; billingEmail: string } | string, + ...rest: [string?] ): Promise> { - let params: { organizationId: string, billingEmail: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingEmail: string }; + let params: { organizationId: string; billingEmail: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + billingEmail: string; + }; } else { params = { organizationId: paramsOrFirst as string, - billingEmail: rest[0] as string + billingEmail: rest[0] as string, }; } - + const organizationId = params.organizationId; const billingEmail = params.billingEmail; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof billingEmail === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingEmail"'); + throw new AppwriteException( + 'Missing required parameter: "billingEmail"', + ); } - - const apiPath = '/organizations/{organizationId}/billing-email'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/billing-email'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof billingEmail !== 'undefined') { payload['billingEmail'] = billingEmail; @@ -1133,15 +1445,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1153,7 +1460,13 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - updateBudget(params: { organizationId: string, budget?: number, alerts?: number[] }): Promise>; + updateBudget< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + budget?: number; + alerts?: number[]; + }): Promise>; /** * Update the budget limit for an organization. * @@ -1164,35 +1477,61 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBudget(organizationId: string, budget?: number, alerts?: number[]): Promise>; - updateBudget( - paramsOrFirst: { organizationId: string, budget?: number, alerts?: number[] } | string, - ...rest: [(number)?, (number[])?] + updateBudget< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + budget?: number, + alerts?: number[], + ): Promise>; + updateBudget< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { organizationId: string; budget?: number; alerts?: number[] } + | string, + ...rest: [number?, number[]?] ): Promise> { - let params: { organizationId: string, budget?: number, alerts?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, budget?: number, alerts?: number[] }; + let params: { + organizationId: string; + budget?: number; + alerts?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + budget?: number; + alerts?: number[]; + }; } else { params = { organizationId: paramsOrFirst as string, budget: rest[0] as number, - alerts: rest[1] as number[] + alerts: rest[1] as number[], }; } - + const organizationId = params.organizationId; const budget = params.budget; const alerts = params.alerts; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof budget === 'undefined') { throw new AppwriteException('Missing required parameter: "budget"'); } - - const apiPath = '/organizations/{organizationId}/budget'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/budget'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof budget !== 'undefined') { payload['budget'] = budget; @@ -1205,30 +1544,28 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * List all credits for an organization. - * + * * * @param {string} params.organizationId - Organization 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: teamId, couponId, credits, expiration, status * @throws {AppwriteException} * @returns {Promise} */ - listCredits(params: { organizationId: string, queries?: string[] }): Promise; + listCredits(params: { + organizationId: string; + queries?: string[]; + }): Promise; /** * List all credits for an organization. - * + * * * @param {string} organizationId - Organization 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: teamId, couponId, credits, expiration, status @@ -1236,30 +1573,44 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listCredits(organizationId: string, queries?: string[]): Promise; listCredits( - paramsOrFirst: { organizationId: string, queries?: string[] } | string, - ...rest: [(string[])?] + organizationId: string, + queries?: string[], + ): Promise; + listCredits( + paramsOrFirst: { organizationId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { organizationId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, queries?: string[] }; + let params: { organizationId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + queries?: string[]; + }; } else { params = { organizationId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const organizationId = params.organizationId; const queries = params.queries; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/credits'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/credits'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1268,15 +1619,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1287,7 +1633,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - addCredit(params: { organizationId: string, couponId: string }): Promise; + addCredit(params: { + organizationId: string; + couponId: string; + }): Promise; /** * Add credit to an organization using a coupon. * @@ -1299,31 +1648,44 @@ export class Organizations { */ addCredit(organizationId: string, couponId: string): Promise; addCredit( - paramsOrFirst: { organizationId: string, couponId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { organizationId: string; couponId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, couponId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, couponId: string }; + let params: { organizationId: string; couponId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + couponId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - couponId: rest[0] as string + couponId: rest[0] as string, }; } - + const organizationId = params.organizationId; const couponId = params.couponId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof couponId === 'undefined') { - throw new AppwriteException('Missing required parameter: "couponId"'); + throw new AppwriteException( + 'Missing required parameter: "couponId"', + ); } - - const apiPath = '/organizations/{organizationId}/credits'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/credits'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof couponId !== 'undefined') { payload['couponId'] = couponId; @@ -1333,15 +1695,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1351,7 +1708,9 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getAvailableCredits(params: { organizationId: string }): Promise; + getAvailableCredits(params: { + organizationId: string; + }): Promise; /** * Get total available valid credits for an organization. * @@ -1360,41 +1719,47 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAvailableCredits(organizationId: string): Promise; getAvailableCredits( - paramsOrFirst: { organizationId: string } | string + organizationId: string, + ): Promise; + getAvailableCredits( + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/credits/available'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = + '/organizations/{organizationId}/credits/available'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1405,7 +1770,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getCredit(params: { organizationId: string, creditId: string }): Promise; + getCredit(params: { + organizationId: string; + creditId: string; + }): Promise; /** * Get credit details. * @@ -1417,45 +1785,55 @@ export class Organizations { */ getCredit(organizationId: string, creditId: string): Promise; getCredit( - paramsOrFirst: { organizationId: string, creditId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { organizationId: string; creditId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, creditId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, creditId: string }; + let params: { organizationId: string; creditId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + creditId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - creditId: rest[0] as string + creditId: rest[0] as string, }; } - + const organizationId = params.organizationId; const creditId = params.creditId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof creditId === 'undefined') { - throw new AppwriteException('Missing required parameter: "creditId"'); - } - - const apiPath = '/organizations/{organizationId}/credits/{creditId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{creditId}', encodeURIComponent(String(creditId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof creditId === 'undefined' || creditId === '') { + throw new AppwriteException( + 'Missing required parameter: "creditId"', + ); + } + const apiPath = '/organizations/{organizationId}/credits/{creditId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{creditId}', encodeURIComponent(String(creditId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1465,7 +1843,9 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - estimationDeleteOrganization(params: { organizationId: string }): Promise; + estimationDeleteOrganization(params: { + organizationId: string; + }): Promise; /** * Get estimation for deleting an organization. * @@ -1474,42 +1854,48 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - estimationDeleteOrganization(organizationId: string): Promise; estimationDeleteOrganization( - paramsOrFirst: { organizationId: string } | string + organizationId: string, + ): Promise; + estimationDeleteOrganization( + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/estimations/delete-organization'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = + '/organizations/{organizationId}/estimations/delete-organization'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1522,7 +1908,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - estimationUpdatePlan(params: { organizationId: string, billingPlan: string, invites?: string[], couponId?: string }): Promise; + estimationUpdatePlan(params: { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + }): Promise; /** * Get estimation for updating the organization plan. * @@ -1534,37 +1925,70 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - estimationUpdatePlan(organizationId: string, billingPlan: string, invites?: string[], couponId?: string): Promise; estimationUpdatePlan( - paramsOrFirst: { organizationId: string, billingPlan: string, invites?: string[], couponId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + organizationId: string, + billingPlan: string, + invites?: string[], + couponId?: string, + ): Promise; + estimationUpdatePlan( + paramsOrFirst: + | { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise { - let params: { organizationId: string, billingPlan: string, invites?: string[], couponId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingPlan: string, invites?: string[], couponId?: string }; + let params: { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + }; } else { params = { organizationId: paramsOrFirst as string, billingPlan: rest[0] as string, invites: rest[1] as string[], - couponId: rest[2] as string + couponId: rest[2] as string, }; } - + const organizationId = params.organizationId; const billingPlan = params.billingPlan; const invites = params.invites; const couponId = params.couponId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof billingPlan === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingPlan"'); - } - - const apiPath = '/organizations/{organizationId}/estimations/update-plan'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + throw new AppwriteException( + 'Missing required parameter: "billingPlan"', + ); + } + const apiPath = + '/organizations/{organizationId}/estimations/update-plan'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof billingPlan !== 'undefined') { payload['billingPlan'] = billingPlan; @@ -1580,20 +2004,15 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform. - * + * * * @param {string} params.organizationId - Organization Unique ID * @param {string} params.reason - Feedback reason @@ -1603,10 +2022,16 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - createDowngradeFeedback(params: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }): Promise; + createDowngradeFeedback(params: { + organizationId: string; + reason: string; + message: string; + fromPlanId: string; + toPlanId: string; + }): Promise; /** * Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform. - * + * * * @param {string} organizationId - Organization Unique ID * @param {string} reason - Feedback reason @@ -1617,48 +2042,89 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDowngradeFeedback(organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string): Promise; createDowngradeFeedback( - paramsOrFirst: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + organizationId: string, + reason: string, + message: string, + fromPlanId: string, + toPlanId: string, + ): Promise; + createDowngradeFeedback( + paramsOrFirst: + | { + organizationId: string; + reason: string; + message: string; + fromPlanId: string; + toPlanId: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, reason: string, message: string, fromPlanId: string, toPlanId: string }; + let params: { + organizationId: string; + reason: string; + message: string; + fromPlanId: string; + toPlanId: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + reason: string; + message: string; + fromPlanId: string; + toPlanId: string; + }; } else { params = { organizationId: paramsOrFirst as string, reason: rest[0] as string, message: rest[1] as string, fromPlanId: rest[2] as string, - toPlanId: rest[3] as string + toPlanId: rest[3] as string, }; } - + const organizationId = params.organizationId; const reason = params.reason; const message = params.message; const fromPlanId = params.fromPlanId; const toPlanId = params.toPlanId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof reason === 'undefined') { throw new AppwriteException('Missing required parameter: "reason"'); } if (typeof message === 'undefined') { - throw new AppwriteException('Missing required parameter: "message"'); + throw new AppwriteException( + 'Missing required parameter: "message"', + ); } if (typeof fromPlanId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fromPlanId"'); + throw new AppwriteException( + 'Missing required parameter: "fromPlanId"', + ); } if (typeof toPlanId === 'undefined') { - throw new AppwriteException('Missing required parameter: "toPlanId"'); - } - - const apiPath = '/organizations/{organizationId}/feedbacks/downgrade'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + throw new AppwriteException( + 'Missing required parameter: "toPlanId"', + ); + } + const apiPath = + '/organizations/{organizationId}/feedbacks/downgrade'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof reason !== 'undefined') { payload['reason'] = reason; @@ -1677,15 +2143,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1696,7 +2157,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - listInvoices(params: { organizationId: string, queries?: string[] }): Promise; + listInvoices(params: { + organizationId: string; + queries?: string[]; + }): Promise; /** * List all invoices for an organization. * @@ -1706,30 +2170,44 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInvoices(organizationId: string, queries?: string[]): Promise; listInvoices( - paramsOrFirst: { organizationId: string, queries?: string[] } | string, - ...rest: [(string[])?] + organizationId: string, + queries?: string[], + ): Promise; + listInvoices( + paramsOrFirst: { organizationId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { organizationId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, queries?: string[] }; + let params: { organizationId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + queries?: string[]; + }; } else { params = { organizationId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const organizationId = params.organizationId; const queries = params.queries; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/invoices'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/invoices'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1738,15 +2216,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1757,7 +2230,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getInvoice(params: { organizationId: string, invoiceId: string }): Promise; + getInvoice(params: { + organizationId: string; + invoiceId: string; + }): Promise; /** * Get an invoice by its unique ID. * @@ -1767,47 +2243,60 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getInvoice(organizationId: string, invoiceId: string): Promise; getInvoice( - paramsOrFirst: { organizationId: string, invoiceId: string } | string, - ...rest: [(string)?] + organizationId: string, + invoiceId: string, + ): Promise; + getInvoice( + paramsOrFirst: { organizationId: string; invoiceId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, invoiceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, invoiceId: string }; + let params: { organizationId: string; invoiceId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + invoiceId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - invoiceId: rest[0] as string + invoiceId: rest[0] as string, }; } - + const organizationId = params.organizationId; const invoiceId = params.invoiceId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); - } - - const apiPath = '/organizations/{organizationId}/invoices/{invoiceId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); + } + const apiPath = '/organizations/{organizationId}/invoices/{invoiceId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{invoiceId}', encodeURIComponent(String(invoiceId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1818,7 +2307,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {string} */ - getInvoiceDownload(params: { organizationId: string, invoiceId: string }): string; + getInvoiceDownload(params: { + organizationId: string; + invoiceId: string; + }): string; /** * Download invoice in PDF * @@ -1830,46 +2322,56 @@ export class Organizations { */ getInvoiceDownload(organizationId: string, invoiceId: string): string; getInvoiceDownload( - paramsOrFirst: { organizationId: string, invoiceId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { organizationId: string; invoiceId: string } | string, + ...rest: [string?] ): string { - let params: { organizationId: string, invoiceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, invoiceId: string }; + let params: { organizationId: string; invoiceId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + invoiceId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - invoiceId: rest[0] as string + invoiceId: rest[0] as string, }; } - + const organizationId = params.organizationId; const invoiceId = params.invoiceId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); - } - - const apiPath = '/organizations/{organizationId}/invoices/{invoiceId}/download'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); + } + const apiPath = + '/organizations/{organizationId}/invoices/{invoiceId}/download' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{invoiceId}', encodeURIComponent(String(invoiceId))); const payload: 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', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } @@ -1882,7 +2384,11 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - createInvoicePayment(params: { organizationId: string, invoiceId: string, paymentMethodId: string }): Promise; + createInvoicePayment(params: { + organizationId: string; + invoiceId: string; + paymentMethodId: string; + }): Promise; /** * Initiate payment for failed invoice to pay live from console * @@ -1893,38 +2399,71 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInvoicePayment(organizationId: string, invoiceId: string, paymentMethodId: string): Promise; createInvoicePayment( - paramsOrFirst: { organizationId: string, invoiceId: string, paymentMethodId: string } | string, - ...rest: [(string)?, (string)?] + organizationId: string, + invoiceId: string, + paymentMethodId: string, + ): Promise; + createInvoicePayment( + paramsOrFirst: + | { + organizationId: string; + invoiceId: string; + paymentMethodId: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { organizationId: string, invoiceId: string, paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, invoiceId: string, paymentMethodId: string }; + let params: { + organizationId: string; + invoiceId: string; + paymentMethodId: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + invoiceId: string; + paymentMethodId: string; + }; } else { params = { organizationId: paramsOrFirst as string, invoiceId: rest[0] as string, - paymentMethodId: rest[1] as string + paymentMethodId: rest[1] as string, }; } - + const organizationId = params.organizationId; const invoiceId = params.invoiceId; const paymentMethodId = params.paymentMethodId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); } if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/organizations/{organizationId}/invoices/{invoiceId}/payments'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); + } + const apiPath = + '/organizations/{organizationId}/invoices/{invoiceId}/payments' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{invoiceId}', encodeURIComponent(String(invoiceId))); const payload: Payload = {}; if (typeof paymentMethodId !== 'undefined') { payload['paymentMethodId'] = paymentMethodId; @@ -1934,15 +2473,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1953,7 +2487,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - validateInvoice(params: { organizationId: string, invoiceId: string }): Promise; + validateInvoice(params: { + organizationId: string; + invoiceId: string; + }): Promise; /** * Validates the payment linked with the invoice and updates the invoice status if the payment status is changed. * @@ -1963,48 +2500,62 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - validateInvoice(organizationId: string, invoiceId: string): Promise; validateInvoice( - paramsOrFirst: { organizationId: string, invoiceId: string } | string, - ...rest: [(string)?] + organizationId: string, + invoiceId: string, + ): Promise; + validateInvoice( + paramsOrFirst: { organizationId: string; invoiceId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, invoiceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, invoiceId: string }; + let params: { organizationId: string; invoiceId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + invoiceId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - invoiceId: rest[0] as string + invoiceId: rest[0] as string, }; } - + const organizationId = params.organizationId; const invoiceId = params.invoiceId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); - } - - const apiPath = '/organizations/{organizationId}/invoices/{invoiceId}/status'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); + } + const apiPath = + '/organizations/{organizationId}/invoices/{invoiceId}/status' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{invoiceId}', encodeURIComponent(String(invoiceId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2015,7 +2566,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {string} */ - getInvoiceView(params: { organizationId: string, invoiceId: string }): string; + getInvoiceView(params: { + organizationId: string; + invoiceId: string; + }): string; /** * View invoice in PDF * @@ -2027,46 +2581,56 @@ export class Organizations { */ getInvoiceView(organizationId: string, invoiceId: string): string; getInvoiceView( - paramsOrFirst: { organizationId: string, invoiceId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { organizationId: string; invoiceId: string } | string, + ...rest: [string?] ): string { - let params: { organizationId: string, invoiceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, invoiceId: string }; + let params: { organizationId: string; invoiceId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + invoiceId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - invoiceId: rest[0] as string + invoiceId: rest[0] as string, }; } - + const organizationId = params.organizationId; const invoiceId = params.invoiceId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof invoiceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "invoiceId"'); - } - - const apiPath = '/organizations/{organizationId}/invoices/{invoiceId}/view'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{invoiceId}', encodeURIComponent(String(invoiceId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof invoiceId === 'undefined' || invoiceId === '') { + throw new AppwriteException( + 'Missing required parameter: "invoiceId"', + ); + } + const apiPath = + '/organizations/{organizationId}/invoices/{invoiceId}/view' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace('{invoiceId}', encodeURIComponent(String(invoiceId))); const payload: 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', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } @@ -2078,7 +2642,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - setDefaultPaymentMethod(params: { organizationId: string, paymentMethodId: string }): Promise>; + setDefaultPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + paymentMethodId: string; + }): Promise>; /** * Set a organization's default payment method. * @@ -2088,33 +2657,55 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - setDefaultPaymentMethod(organizationId: string, paymentMethodId: string): Promise>; - setDefaultPaymentMethod( - paramsOrFirst: { organizationId: string, paymentMethodId: string } | string, - ...rest: [(string)?] + setDefaultPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + paymentMethodId: string, + ): Promise>; + setDefaultPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { organizationId: string; paymentMethodId: string } | string, + ...rest: [string?] ): Promise> { - let params: { organizationId: string, paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, paymentMethodId: string }; + let params: { organizationId: string; paymentMethodId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + paymentMethodId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - paymentMethodId: rest[0] as string + paymentMethodId: rest[0] as string, }; } - + const organizationId = params.organizationId; const paymentMethodId = params.paymentMethodId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/organizations/{organizationId}/payment-method'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); + } + const apiPath = + '/organizations/{organizationId}/payment-method'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof paymentMethodId !== 'undefined') { payload['paymentMethodId'] = paymentMethodId; @@ -2124,15 +2715,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2142,7 +2728,11 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - deleteDefaultPaymentMethod(params: { organizationId: string }): Promise>; + deleteDefaultPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + }): Promise>; /** * Delete the default payment method for an organization. * @@ -2151,57 +2741,70 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDefaultPaymentMethod(organizationId: string): Promise>; - deleteDefaultPaymentMethod( - paramsOrFirst: { organizationId: string } | string + deleteDefaultPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(organizationId: string): Promise>; + deleteDefaultPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { organizationId: string } | string, ): Promise> { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/payment-method'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = + '/organizations/{organizationId}/payment-method'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Set an organization's backup payment method. - * + * * * @param {string} params.organizationId - Organization ID * @param {string} params.paymentMethodId - Unique ID of payment method * @throws {AppwriteException} * @returns {Promise>} */ - setBackupPaymentMethod(params: { organizationId: string, paymentMethodId: string }): Promise>; + setBackupPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + paymentMethodId: string; + }): Promise>; /** * Set an organization's backup payment method. - * + * * * @param {string} organizationId - Organization ID * @param {string} paymentMethodId - Unique ID of payment method @@ -2209,33 +2812,55 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - setBackupPaymentMethod(organizationId: string, paymentMethodId: string): Promise>; - setBackupPaymentMethod( - paramsOrFirst: { organizationId: string, paymentMethodId: string } | string, - ...rest: [(string)?] + setBackupPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + paymentMethodId: string, + ): Promise>; + setBackupPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { organizationId: string; paymentMethodId: string } | string, + ...rest: [string?] ): Promise> { - let params: { organizationId: string, paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, paymentMethodId: string }; + let params: { organizationId: string; paymentMethodId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + paymentMethodId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - paymentMethodId: rest[0] as string + paymentMethodId: rest[0] as string, }; } - + const organizationId = params.organizationId; const paymentMethodId = params.paymentMethodId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/organizations/{organizationId}/payment-method/backup'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); + } + const apiPath = + '/organizations/{organizationId}/payment-method/backup'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof paymentMethodId !== 'undefined') { payload['paymentMethodId'] = paymentMethodId; @@ -2245,15 +2870,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2263,7 +2883,11 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - deleteBackupPaymentMethod(params: { organizationId: string }): Promise>; + deleteBackupPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + }): Promise>; /** * Delete a backup payment method for an organization. * @@ -2272,42 +2896,50 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBackupPaymentMethod(organizationId: string): Promise>; - deleteBackupPaymentMethod( - paramsOrFirst: { organizationId: string } | string + deleteBackupPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(organizationId: string): Promise>; + deleteBackupPaymentMethod< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { organizationId: string } | string, ): Promise> { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/payment-method/backup'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = + '/organizations/{organizationId}/payment-method/backup'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -2318,7 +2950,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getPaymentMethod(params: { organizationId: string, paymentMethodId: string }): Promise; + getPaymentMethod(params: { + organizationId: string; + paymentMethodId: string; + }): Promise; /** * Get an organization's payment method using it's payment method ID. * @@ -2328,47 +2963,65 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPaymentMethod(organizationId: string, paymentMethodId: string): Promise; getPaymentMethod( - paramsOrFirst: { organizationId: string, paymentMethodId: string } | string, - ...rest: [(string)?] + organizationId: string, + paymentMethodId: string, + ): Promise; + getPaymentMethod( + paramsOrFirst: + { organizationId: string; paymentMethodId: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, paymentMethodId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, paymentMethodId: string }; + let params: { organizationId: string; paymentMethodId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + paymentMethodId: string; + }; } else { params = { organizationId: paramsOrFirst as string, - paymentMethodId: rest[0] as string + paymentMethodId: rest[0] as string, }; } - + const organizationId = params.organizationId; const paymentMethodId = params.paymentMethodId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof paymentMethodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "paymentMethodId"'); - } - - const apiPath = '/organizations/{organizationId}/payment-methods/{paymentMethodId}'.replace('{organizationId}', encodeURIComponent(String(organizationId))).replace('{paymentMethodId}', encodeURIComponent(String(paymentMethodId))); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + if (typeof paymentMethodId === 'undefined' || paymentMethodId === '') { + throw new AppwriteException( + 'Missing required parameter: "paymentMethodId"', + ); + } + const apiPath = + '/organizations/{organizationId}/payment-methods/{paymentMethodId}' + .replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ) + .replace( + '{paymentMethodId}', + encodeURIComponent(String(paymentMethodId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2389,39 +3042,42 @@ export class Organizations { */ getPlan(organizationId: string): Promise; getPlan( - paramsOrFirst: { organizationId: string } | string + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/plan'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/plan'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2438,7 +3094,18 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - updatePlan(params: { organizationId: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number }): Promise>; + updatePlan< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + }): Promise>; /** * Update the billing plan for an organization. * @@ -2454,15 +3121,69 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePlan(organizationId: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number): Promise>; - updatePlan( - paramsOrFirst: { organizationId: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (string[])?, (string)?, (string)?, (number)?] + updatePlan< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + billingPlan: string, + paymentMethodId?: string, + billingAddressId?: string, + invites?: string[], + couponId?: string, + taxId?: string, + budget?: number, + ): Promise>; + updatePlan< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + organizationId: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + string[]?, + string?, + string?, + number?, + ] ): Promise> { - let params: { organizationId: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingPlan: string, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number }; + let params: { + organizationId: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + billingPlan: string; + paymentMethodId?: string; + billingAddressId?: string; + invites?: string[]; + couponId?: string; + taxId?: string; + budget?: number; + }; } else { params = { organizationId: paramsOrFirst as string, @@ -2472,10 +3193,10 @@ export class Organizations { invites: rest[3] as string[], couponId: rest[4] as string, taxId: rest[5] as string, - budget: rest[6] as number + budget: rest[6] as number, }; } - + const organizationId = params.organizationId; const billingPlan = params.billingPlan; const paymentMethodId = params.paymentMethodId; @@ -2485,14 +3206,20 @@ export class Organizations { const taxId = params.taxId; const budget = params.budget; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof billingPlan === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingPlan"'); + throw new AppwriteException( + 'Missing required parameter: "billingPlan"', + ); } - - const apiPath = '/organizations/{organizationId}/plan'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/plan'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof billingPlan !== 'undefined') { payload['billingPlan'] = billingPlan; @@ -2520,15 +3247,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2538,7 +3260,11 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - cancelDowngrade(params: { organizationId: string }): Promise>; + cancelDowngrade< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + }): Promise>; /** * Cancel the downgrade initiated for an organization. * @@ -2547,47 +3273,54 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - cancelDowngrade(organizationId: string): Promise>; - cancelDowngrade( - paramsOrFirst: { organizationId: string } | string + cancelDowngrade< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(organizationId: string): Promise>; + cancelDowngrade< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { organizationId: string } | string, ): Promise> { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/plan/cancel'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/plan/cancel'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a billing plan estimation for upgrading or downgrading an organization plan. - * + * * * @param {string} params.organizationId - Organization ID * @param {string} params.billingPlan - Target billing plan @@ -2596,10 +3329,15 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - createPlanEstimation(params: { organizationId: string, billingPlan: string, invites?: string[], couponId?: string }): Promise; + createPlanEstimation(params: { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + }): Promise; /** * Create a billing plan estimation for upgrading or downgrading an organization plan. - * + * * * @param {string} organizationId - Organization ID * @param {string} billingPlan - Target billing plan @@ -2609,37 +3347,70 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPlanEstimation(organizationId: string, billingPlan: string, invites?: string[], couponId?: string): Promise; createPlanEstimation( - paramsOrFirst: { organizationId: string, billingPlan: string, invites?: string[], couponId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + organizationId: string, + billingPlan: string, + invites?: string[], + couponId?: string, + ): Promise; + createPlanEstimation( + paramsOrFirst: + | { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise { - let params: { organizationId: string, billingPlan: string, invites?: string[], couponId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, billingPlan: string, invites?: string[], couponId?: string }; + let params: { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + billingPlan: string; + invites?: string[]; + couponId?: string; + }; } else { params = { organizationId: paramsOrFirst as string, billingPlan: rest[0] as string, invites: rest[1] as string[], - couponId: rest[2] as string + couponId: rest[2] as string, }; } - + const organizationId = params.organizationId; const billingPlan = params.billingPlan; const invites = params.invites; const couponId = params.couponId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof billingPlan === 'undefined') { - throw new AppwriteException('Missing required parameter: "billingPlan"'); - } - - const apiPath = '/organizations/{organizationId}/plan/estimations'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + throw new AppwriteException( + 'Missing required parameter: "billingPlan"', + ); + } + const apiPath = + '/organizations/{organizationId}/plan/estimations'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof billingPlan !== 'undefined') { payload['billingPlan'] = billingPlan; @@ -2655,15 +3426,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2673,7 +3439,9 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - listRegions(params: { organizationId: string }): Promise; + listRegions(params: { + organizationId: string; + }): Promise; /** * Get all available regions for an organization. * @@ -2684,39 +3452,42 @@ export class Organizations { */ listRegions(organizationId: string): Promise; listRegions( - paramsOrFirst: { organizationId: string } | string + paramsOrFirst: { organizationId: string } | string, ): Promise { let params: { organizationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { organizationId: string }; } else { params = { - organizationId: paramsOrFirst as string + organizationId: paramsOrFirst as string, }; } - + const organizationId = params.organizationId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/regions'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/regions'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2727,7 +3498,10 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getScopes(params: { organizationId: string, projectId?: string }): Promise; + getScopes(params: { + organizationId: string; + projectId?: string; + }): Promise; /** * Get Scopes * @@ -2737,30 +3511,44 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getScopes(organizationId: string, projectId?: string): Promise; getScopes( - paramsOrFirst: { organizationId: string, projectId?: string } | string, - ...rest: [(string)?] + organizationId: string, + projectId?: string, + ): Promise; + getScopes( + paramsOrFirst: { organizationId: string; projectId?: string } | string, + ...rest: [string?] ): Promise { - let params: { organizationId: string, projectId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, projectId?: string }; + let params: { organizationId: string; projectId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + projectId?: string; + }; } else { params = { organizationId: paramsOrFirst as string, - projectId: rest[0] as string + projectId: rest[0] as string, }; } - + const organizationId = params.organizationId; const projectId = params.projectId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/roles'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/roles'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof projectId !== 'undefined') { payload['projectId'] = projectId; @@ -2769,15 +3557,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2788,7 +3571,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - setBillingTaxId(params: { organizationId: string, taxId?: string }): Promise>; + setBillingTaxId< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + taxId?: string; + }): Promise>; /** * Set an organization's billing tax ID. * @@ -2798,33 +3586,51 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - setBillingTaxId(organizationId: string, taxId?: string): Promise>; - setBillingTaxId( - paramsOrFirst: { organizationId: string, taxId?: string } | string, - ...rest: [(string)?] + setBillingTaxId< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + taxId?: string, + ): Promise>; + setBillingTaxId< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { organizationId: string; taxId?: string } | string, + ...rest: [string?] ): Promise> { - let params: { organizationId: string, taxId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, taxId?: string }; + let params: { organizationId: string; taxId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + taxId?: string; + }; } else { params = { organizationId: paramsOrFirst as string, - taxId: rest[0] as string + taxId: rest[0] as string, }; } - + const organizationId = params.organizationId; const taxId = params.taxId; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } if (typeof taxId === 'undefined') { throw new AppwriteException('Missing required parameter: "taxId"'); } - - const apiPath = '/organizations/{organizationId}/taxId'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/taxId'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof taxId !== 'undefined') { payload['taxId'] = taxId; @@ -2834,15 +3640,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2854,7 +3655,11 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise} */ - getUsage(params: { organizationId: string, startDate?: string, endDate?: string }): Promise; + getUsage(params: { + organizationId: string; + startDate?: string; + endDate?: string; + }): Promise; /** * Get the usage data for an organization. * @@ -2865,32 +3670,54 @@ export class Organizations { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getUsage(organizationId: string, startDate?: string, endDate?: string): Promise; getUsage( - paramsOrFirst: { organizationId: string, startDate?: string, endDate?: string } | string, - ...rest: [(string)?, (string)?] + organizationId: string, + startDate?: string, + endDate?: string, + ): Promise; + getUsage( + paramsOrFirst: + | { organizationId: string; startDate?: string; endDate?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { organizationId: string, startDate?: string, endDate?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, startDate?: string, endDate?: string }; + let params: { + organizationId: string; + startDate?: string; + endDate?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + startDate?: string; + endDate?: string; + }; } else { params = { organizationId: paramsOrFirst as string, startDate: rest[0] as string, - endDate: rest[1] as string + endDate: rest[1] as string, }; } - + const organizationId = params.organizationId; const startDate = params.startDate; const endDate = params.endDate; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/usage'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/usage'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof startDate !== 'undefined') { payload['startDate'] = startDate; @@ -2902,15 +3729,10 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2921,7 +3743,12 @@ export class Organizations { * @throws {AppwriteException} * @returns {Promise>} */ - validatePayment(params: { organizationId: string, invites?: string[] }): Promise>; + validatePayment< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + organizationId: string; + invites?: string[]; + }): Promise>; /** * Validate payment for team after creation or upgrade. * @@ -2931,30 +3758,48 @@ export class Organizations { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - validatePayment(organizationId: string, invites?: string[]): Promise>; - validatePayment( - paramsOrFirst: { organizationId: string, invites?: string[] } | string, - ...rest: [(string[])?] + validatePayment< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + organizationId: string, + invites?: string[], + ): Promise>; + validatePayment< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { organizationId: string; invites?: string[] } | string, + ...rest: [string[]?] ): Promise> { - let params: { organizationId: string, invites?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, invites?: string[] }; + let params: { organizationId: string; invites?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + organizationId: string; + invites?: string[]; + }; } else { params = { organizationId: paramsOrFirst as string, - invites: rest[0] as string[] + invites: rest[0] as string[], }; } - + const organizationId = params.organizationId; const invites = params.invites; - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); } - - const apiPath = '/organizations/{organizationId}/validate'.replace('{organizationId}', encodeURIComponent(String(organizationId))); + const apiPath = '/organizations/{organizationId}/validate'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); const payload: Payload = {}; if (typeof invites !== 'undefined') { payload['invites'] = invites; @@ -2964,14 +3809,9 @@ export class Organizations { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index 529f5522..a0870687 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Postgresql { client: Client; @@ -17,7 +15,9 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[] }): Promise; + list(params?: { + queries?: string[]; + }): Promise; /** * List all dedicated databases. Results support pagination. * @@ -28,20 +28,24 @@ export class Postgresql { */ list(queries?: string[]): Promise; list( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/postgresql'; const payload: Payload = {}; @@ -52,15 +56,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -72,7 +71,6 @@ export class Postgresql { * @param {string} params.specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {string} params.standbyRegion - Standby region for a cross-region replica. When set, a replica is provisioned in this region for cross-region high availability. Must differ from the database region. * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds. * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} params.idleTimeoutMinutes - Minutes of inactivity before container scales to zero. @@ -80,11 +78,26 @@ export class Postgresql { * @param {number} params.pitrRetentionDays - Number of days to retain PITR data. * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. - * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }): Promise; + create(params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }): Promise; /** * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. * @@ -94,7 +107,6 @@ export class Postgresql { * @param {string} specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {string} standbyRegion - Standby region for a cross-region replica. When set, a replica is provisioned in this region for cross-region high availability. Must differ from the database region. * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds. * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} idleTimeoutMinutes - Minutes of inactivity before container scales to zero. @@ -102,20 +114,100 @@ export class Postgresql { * @param {number} pitrRetentionDays - Number of days to retain PITR data. * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. - * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?] + databaseId: string, + name: string, + version?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + ] ): Promise { - let params: { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, version?: string, specification?: string, replicas?: number, syncMode?: string, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number }; + let params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -124,41 +216,41 @@ export class Postgresql { specification: rest[2] as string, replicas: rest[3] as number, syncMode: rest[4] as string, - standbyRegion: rest[5] as string, - networkIdleTimeoutSeconds: rest[6] as number, - networkIPAllowlist: rest[7] as string[], - idleTimeoutMinutes: rest[8] as number, - pitr: rest[9] as boolean, - pitrRetentionDays: rest[10] as number, - storageAutoscaling: rest[11] as boolean, - storageAutoscalingThresholdPercent: rest[12] as number, - storageAutoscalingMaxGb: rest[13] as number + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, }; } - + const databaseId = params.databaseId; const name = params.name; const version = params.version; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - const standbyRegion = params.standbyRegion; const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; const networkIPAllowlist = params.networkIPAllowlist; const idleTimeoutMinutes = params.idleTimeoutMinutes; const pitr = params.pitr; const pitrRetentionDays = params.pitrRetentionDays; const storageAutoscaling = params.storageAutoscaling; - const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/postgresql'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -179,9 +271,6 @@ export class Postgresql { if (typeof syncMode !== 'undefined') { payload['syncMode'] = syncMode; } - if (typeof standbyRegion !== 'undefined') { - payload['standbyRegion'] = standbyRegion; - } if (typeof networkIdleTimeoutSeconds !== 'undefined') { payload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; } @@ -201,7 +290,8 @@ export class Postgresql { payload['storageAutoscaling'] = storageAutoscaling; } if (typeof storageAutoscalingThresholdPercent !== 'undefined') { - payload['storageAutoscalingThresholdPercent'] = storageAutoscalingThresholdPercent; + payload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; } if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; @@ -211,40 +301,29 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. * * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/postgresql/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -265,39 +344,42 @@ export class Postgresql { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -309,8 +391,6 @@ export class Postgresql { * @param {string} params.specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {number} params.crossRegionReplicas - Number of cross-region standby replicas (0-1). Cross-region replication is enabled when greater than 0. - * @param {string} params.standbyRegion - Standby region for the cross-region replica. Required when enabling cross-region replication and no standby region is already configured. Must differ from the database region. * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} params.idleTimeoutMinutes - Minutes before container scales to zero. @@ -329,7 +409,29 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }): Promise; + update(params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }): Promise; /** * Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. * @@ -339,8 +441,6 @@ export class Postgresql { * @param {string} specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. - * @param {number} crossRegionReplicas - Number of cross-region standby replicas (0-1). Cross-region replication is enabled when greater than 0. - * @param {string} standbyRegion - Standby region for the cross-region replica. Required when enabling cross-region replication and no standby region is already configured. Must differ from the database region. * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. * @param {number} idleTimeoutMinutes - Minutes before container scales to zero. @@ -360,15 +460,130 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (number)?, (string)?, (number)?, (string[])?, (number)?, (boolean)?, (number)?, (boolean)?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?] + databaseId: string, + name?: string, + status?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + metricsTraceSampleRate?: number, + metricsSlowQueryLogThresholdMs?: number, + sqlApiEnabled?: boolean, + sqlApiAllowedStatements?: string[], + sqlApiMaxRows?: number, + sqlApiMaxBytes?: number, + sqlApiTimeoutSeconds?: number, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + number?, + number?, + boolean?, + string[]?, + number?, + number?, + number?, + ] ): Promise { - let params: { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, status?: string, specification?: string, replicas?: number, syncMode?: string, crossRegionReplicas?: number, standbyRegion?: string, networkIdleTimeoutSeconds?: number, networkIPAllowlist?: string[], idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, storageAutoscalingMaxGb?: number, metricsTraceSampleRate?: number, metricsSlowQueryLogThresholdMs?: number, sqlApiEnabled?: boolean, sqlApiAllowedStatements?: string[], sqlApiMaxRows?: number, sqlApiMaxBytes?: number, sqlApiTimeoutSeconds?: number }; + let params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -377,55 +592,57 @@ export class Postgresql { specification: rest[2] as string, replicas: rest[3] as number, syncMode: rest[4] as string, - crossRegionReplicas: rest[5] as number, - standbyRegion: rest[6] as string, - networkIdleTimeoutSeconds: rest[7] as number, - networkIPAllowlist: rest[8] as string[], - idleTimeoutMinutes: rest[9] as number, - pitr: rest[10] as boolean, - pitrRetentionDays: rest[11] as number, - storageAutoscaling: rest[12] as boolean, - storageAutoscalingThresholdPercent: rest[13] as number, - storageAutoscalingMaxGb: rest[14] as number, - metricsTraceSampleRate: rest[15] as number, - metricsSlowQueryLogThresholdMs: rest[16] as number, - sqlApiEnabled: rest[17] as boolean, - sqlApiAllowedStatements: rest[18] as string[], - sqlApiMaxRows: rest[19] as number, - sqlApiMaxBytes: rest[20] as number, - sqlApiTimeoutSeconds: rest[21] as number + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + metricsTraceSampleRate: rest[13] as number, + metricsSlowQueryLogThresholdMs: rest[14] as number, + sqlApiEnabled: rest[15] as boolean, + sqlApiAllowedStatements: rest[16] as string[], + sqlApiMaxRows: rest[17] as number, + sqlApiMaxBytes: rest[18] as number, + sqlApiTimeoutSeconds: rest[19] as number, }; } - + const databaseId = params.databaseId; const name = params.name; const status = params.status; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - const crossRegionReplicas = params.crossRegionReplicas; - const standbyRegion = params.standbyRegion; const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; const networkIPAllowlist = params.networkIPAllowlist; const idleTimeoutMinutes = params.idleTimeoutMinutes; const pitr = params.pitr; const pitrRetentionDays = params.pitrRetentionDays; const storageAutoscaling = params.storageAutoscaling; - const storageAutoscalingThresholdPercent = params.storageAutoscalingThresholdPercent; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; const metricsTraceSampleRate = params.metricsTraceSampleRate; - const metricsSlowQueryLogThresholdMs = params.metricsSlowQueryLogThresholdMs; + const metricsSlowQueryLogThresholdMs = + params.metricsSlowQueryLogThresholdMs; const sqlApiEnabled = params.sqlApiEnabled; const sqlApiAllowedStatements = params.sqlApiAllowedStatements; const sqlApiMaxRows = params.sqlApiMaxRows; const sqlApiMaxBytes = params.sqlApiMaxBytes; const sqlApiTimeoutSeconds = params.sqlApiTimeoutSeconds; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -442,12 +659,6 @@ export class Postgresql { if (typeof syncMode !== 'undefined') { payload['syncMode'] = syncMode; } - if (typeof crossRegionReplicas !== 'undefined') { - payload['crossRegionReplicas'] = crossRegionReplicas; - } - if (typeof standbyRegion !== 'undefined') { - payload['standbyRegion'] = standbyRegion; - } if (typeof networkIdleTimeoutSeconds !== 'undefined') { payload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; } @@ -467,7 +678,8 @@ export class Postgresql { payload['storageAutoscaling'] = storageAutoscaling; } if (typeof storageAutoscalingThresholdPercent !== 'undefined') { - payload['storageAutoscalingThresholdPercent'] = storageAutoscalingThresholdPercent; + payload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; } if (typeof storageAutoscalingMaxGb !== 'undefined') { payload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; @@ -476,7 +688,8 @@ export class Postgresql { payload['metricsTraceSampleRate'] = metricsTraceSampleRate; } if (typeof metricsSlowQueryLogThresholdMs !== 'undefined') { - payload['metricsSlowQueryLogThresholdMs'] = metricsSlowQueryLogThresholdMs; + payload['metricsSlowQueryLogThresholdMs'] = + metricsSlowQueryLogThresholdMs; } if (typeof sqlApiEnabled !== 'undefined') { payload['sqlApiEnabled'] = sqlApiEnabled; @@ -498,15 +711,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -526,41 +734,42 @@ export class Postgresql { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -571,7 +780,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - listBackups(params: { databaseId: string, queries?: string[] }): Promise; + listBackups(params: { + databaseId: string; + queries?: string[]; + }): Promise; /** * List all backups for a dedicated database. Results can be filtered by status and type. * @@ -581,30 +793,44 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBackups(databaseId: string, queries?: string[]): Promise; listBackups( - paramsOrFirst: { databaseId: string, queries?: string[] } | string, - ...rest: [(string[])?] + databaseId: string, + queries?: string[], + ): Promise; + listBackups( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { databaseId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[] }; + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; } else { params = { databaseId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const databaseId = params.databaseId; const queries = params.queries; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -613,15 +839,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -632,7 +853,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createBackup(params: { databaseId: string, type?: string }): Promise; + createBackup(params: { + databaseId: string; + type?: string; + }): Promise; /** * Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. * @@ -642,30 +866,44 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBackup(databaseId: string, type?: string): Promise; createBackup( - paramsOrFirst: { databaseId: string, type?: string } | string, - ...rest: [(string)?] + databaseId: string, + type?: string, + ): Promise; + createBackup( + paramsOrFirst: { databaseId: string; type?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, type?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, type?: string }; + let params: { databaseId: string; type?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - type: rest[0] as string + type: rest[0] as string, }; } - + const databaseId = params.databaseId; const type = params.type; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -675,15 +913,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -694,7 +927,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - listBackupPolicies(params: { databaseId: string, queries?: string[] }): Promise; + listBackupPolicies(params: { + databaseId: string; + queries?: string[]; + }): Promise; /** * List scheduled backup policies for a dedicated database. * @@ -704,30 +940,44 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBackupPolicies(databaseId: string, queries?: string[]): Promise; listBackupPolicies( - paramsOrFirst: { databaseId: string, queries?: string[] } | string, - ...rest: [(string[])?] + databaseId: string, + queries?: string[], + ): Promise; + listBackupPolicies( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { databaseId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[] }; + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; } else { params = { databaseId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const databaseId = params.databaseId; const queries = params.queries; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/policies'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -736,15 +986,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -760,7 +1005,15 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createBackupPolicy(params: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }): Promise; + createBackupPolicy(params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }): Promise; /** * Create a scheduled backup policy for a dedicated database. * @@ -775,15 +1028,53 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBackupPolicy(databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean): Promise; createBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (string)?, (boolean)?] + databaseId: string, + policyId: string, + name: string, + schedule: string, + retention: number, + type?: string, + enabled?: boolean, + ): Promise; + createBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, string?, boolean?] ): Promise { - let params: { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string, name: string, schedule: string, retention: number, type?: string, enabled?: boolean }; + let params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -792,10 +1083,10 @@ export class Postgresql { schedule: rest[2] as string, retention: rest[3] as number, type: rest[4] as string, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; const name = params.name; @@ -804,23 +1095,33 @@ export class Postgresql { const type = params.type; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof schedule === 'undefined') { - throw new AppwriteException('Missing required parameter: "schedule"'); + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); } if (typeof retention === 'undefined') { - throw new AppwriteException('Missing required parameter: "retention"'); + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/policies'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof policyId !== 'undefined') { payload['policyId'] = policyId; @@ -845,15 +1146,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -864,7 +1160,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - getBackupPolicy(params: { databaseId: string, policyId: string }): Promise; + getBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise; /** * Get a scheduled backup policy for a dedicated database. * @@ -874,47 +1173,57 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBackupPolicy(databaseId: string, policyId: string): Promise; getBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string } | string, - ...rest: [(string)?] + databaseId: string, + policyId: string, + ): Promise; + getBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string }; + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - policyId: rest[0] as string + policyId: rest[0] as string, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -929,7 +1238,14 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - updateBackupPolicy(params: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }): Promise; + updateBackupPolicy(params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }): Promise; /** * Update a scheduled backup policy for a dedicated database. * @@ -943,15 +1259,49 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBackupPolicy(databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean): Promise; updateBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (boolean)?] + databaseId: string, + policyId: string, + name?: string, + schedule?: string, + retention?: number, + enabled?: boolean, + ): Promise; + updateBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, boolean?] ): Promise { - let params: { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string, name?: string, schedule?: string, retention?: number, enabled?: boolean }; + let params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -959,10 +1309,10 @@ export class Postgresql { name: rest[1] as string, schedule: rest[2] as string, retention: rest[3] as number, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; const name = params.name; @@ -970,14 +1320,19 @@ export class Postgresql { const retention = params.retention; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -996,15 +1351,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1015,7 +1365,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteBackupPolicy(params: { databaseId: string, policyId: string }): Promise<{}>; + deleteBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise<{}>; /** * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. * @@ -1027,46 +1380,53 @@ export class Postgresql { */ deleteBackupPolicy(databaseId: string, policyId: string): Promise<{}>; deleteBackupPolicy( - paramsOrFirst: { databaseId: string, policyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, policyId: string }; + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - policyId: rest[0] as string + policyId: rest[0] as string, }; } - + const databaseId = params.databaseId; const policyId = params.policyId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + if (typeof policyId === 'undefined' || policyId === '') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1083,7 +1443,16 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - updateBackupStorage(params: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }): Promise; + updateBackupStorage(params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }): Promise; /** * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. * @@ -1099,15 +1468,57 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBackupStorage(databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string): Promise; updateBackupStorage( - paramsOrFirst: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + databaseId: string, + provider: string, + bucket: string, + accessKey: string, + secretKey: string, + region?: string, + prefix?: string, + endpoint?: string, + ): Promise; + updateBackupStorage( + paramsOrFirst: + | { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?, string?] ): Promise { - let params: { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, provider: string, bucket: string, accessKey: string, secretKey: string, region?: string, prefix?: string, endpoint?: string }; + let params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1117,10 +1528,10 @@ export class Postgresql { secretKey: rest[3] as string, region: rest[4] as string, prefix: rest[5] as string, - endpoint: rest[6] as string + endpoint: rest[6] as string, }; } - + const databaseId = params.databaseId; const provider = params.provider; const bucket = params.bucket; @@ -1130,23 +1541,33 @@ export class Postgresql { const prefix = params.prefix; const endpoint = params.endpoint; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); } if (typeof bucket === 'undefined') { throw new AppwriteException('Missing required parameter: "bucket"'); } if (typeof accessKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "accessKey"'); + throw new AppwriteException( + 'Missing required parameter: "accessKey"', + ); } if (typeof secretKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretKey"'); + throw new AppwriteException( + 'Missing required parameter: "secretKey"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/storage'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/backups/storage'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof provider !== 'undefined') { payload['provider'] = provider; @@ -1174,15 +1595,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1193,7 +1609,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - getBackup(params: { databaseId: string, backupId: string }): Promise; + getBackup(params: { + databaseId: string; + backupId: string; + }): Promise; /** * Get details of a specific database backup including its status, size, and timestamps. * @@ -1203,47 +1622,57 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBackup(databaseId: string, backupId: string): Promise; getBackup( - paramsOrFirst: { databaseId: string, backupId: string } | string, - ...rest: [(string)?] + databaseId: string, + backupId: string, + ): Promise; + getBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, backupId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, backupId: string }; + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - backupId: rest[0] as string + backupId: rest[0] as string, }; } - + const databaseId = params.databaseId; const backupId = params.backupId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof backupId === 'undefined') { - throw new AppwriteException('Missing required parameter: "backupId"'); + if (typeof backupId === 'undefined' || backupId === '') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/{backupId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{backupId}', encodeURIComponent(String(backupId))); + const apiPath = '/postgresql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1254,7 +1683,7 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteBackup(params: { databaseId: string, backupId: string }): Promise<{}>; + deleteBackup(params: { databaseId: string; backupId: string }): Promise<{}>; /** * Delete a database backup. This will permanently remove the backup from storage and cannot be undone. * @@ -1266,46 +1695,53 @@ export class Postgresql { */ deleteBackup(databaseId: string, backupId: string): Promise<{}>; deleteBackup( - paramsOrFirst: { databaseId: string, backupId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, backupId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, backupId: string }; + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - backupId: rest[0] as string + backupId: rest[0] as string, }; } - + const databaseId = params.databaseId; const backupId = params.backupId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof backupId === 'undefined') { - throw new AppwriteException('Missing required parameter: "backupId"'); + if (typeof backupId === 'undefined' || backupId === '') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); } - - const apiPath = '/postgresql/{databaseId}/backups/{backupId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{backupId}', encodeURIComponent(String(backupId))); + const apiPath = '/postgresql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1315,7 +1751,9 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - listBranches(params: { databaseId: string }): Promise; + listBranches(params: { + databaseId: string; + }): Promise; /** * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. * @@ -1324,41 +1762,46 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBranches(databaseId: string): Promise; listBranches( - paramsOrFirst: { databaseId: string } | string + databaseId: string, + ): Promise; + listBranches( + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/branches'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1370,7 +1813,11 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createBranch(params: { databaseId: string, branchId?: string, ttl?: number }): Promise; + createBranch(params: { + databaseId: string; + branchId?: string; + ttl?: number; + }): Promise; /** * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. * @@ -1381,32 +1828,49 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBranch(databaseId: string, branchId?: string, ttl?: number): Promise; createBranch( - paramsOrFirst: { databaseId: string, branchId?: string, ttl?: number } | string, - ...rest: [(string)?, (number)?] + databaseId: string, + branchId?: string, + ttl?: number, + ): Promise; + createBranch( + paramsOrFirst: + { databaseId: string; branchId?: string; ttl?: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { databaseId: string, branchId?: string, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, branchId?: string, ttl?: number }; + let params: { databaseId: string; branchId?: string; ttl?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId?: string; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, branchId: rest[0] as string, - ttl: rest[1] as number + ttl: rest[1] as number, }; } - + const databaseId = params.databaseId; const branchId = params.branchId; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/branches'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof branchId !== 'undefined') { payload['branchId'] = branchId; @@ -1419,15 +1883,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1438,7 +1897,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - deleteBranch(params: { databaseId: string, branchId: string }): Promise; + deleteBranch(params: { + databaseId: string; + branchId: string; + }): Promise; /** * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. * @@ -1448,102 +1910,119 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBranch(databaseId: string, branchId: string): Promise; deleteBranch( - paramsOrFirst: { databaseId: string, branchId: string } | string, - ...rest: [(string)?] + databaseId: string, + branchId: string, + ): Promise; + deleteBranch( + paramsOrFirst: { databaseId: string; branchId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, branchId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, branchId: string }; + let params: { databaseId: string; branchId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - branchId: rest[0] as string + branchId: rest[0] as string, }; } - + const databaseId = params.databaseId; const branchId = params.branchId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof branchId === 'undefined') { - throw new AppwriteException('Missing required parameter: "branchId"'); + if (typeof branchId === 'undefined' || branchId === '') { + throw new AppwriteException( + 'Missing required parameter: "branchId"', + ); } - - const apiPath = '/postgresql/{databaseId}/branches/{branchId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{branchId}', encodeURIComponent(String(branchId))); + const apiPath = '/postgresql/{databaseId}/branches/{branchId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{branchId}', encodeURIComponent(String(branchId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. * * @param {string} params.databaseId - Database ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateCredentials(params: { databaseId: string }): Promise; + updateCredentials(params: { + databaseId: string; + }): Promise; /** - * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. * * @param {string} databaseId - Database ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCredentials(databaseId: string): Promise; updateCredentials( - paramsOrFirst: { databaseId: string } | string - ): Promise { + databaseId: string, + ): Promise; + updateCredentials( + paramsOrFirst: { databaseId: string } | string, + ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/credentials'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/credentials'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1556,7 +2035,12 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createExecution(params: { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number }): Promise; + createExecution(params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }): Promise; /** * Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. * @@ -1568,37 +2052,67 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createExecution(databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number): Promise; createExecution( - paramsOrFirst: { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number } | string, - ...rest: [(string)?, (object)?, (number)?] + databaseId: string, + sql: string, + bindings?: object, + timeoutSeconds?: number, + ): Promise; + createExecution( + paramsOrFirst: + | { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + } + | string, + ...rest: [string?, object?, number?] ): Promise { - let params: { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, sql: string, bindings?: object, timeoutSeconds?: number }; + let params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, bindings: rest[1] as object, - timeoutSeconds: rest[2] as number + timeoutSeconds: rest[2] as number, }; } - + const databaseId = params.databaseId; const sql = params.sql; const bindings = params.bindings; const timeoutSeconds = params.timeoutSeconds; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof sql === 'undefined') { throw new AppwriteException('Missing required parameter: "sql"'); } - - const apiPath = '/postgresql/{databaseId}/executions'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/executions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof sql !== 'undefined') { payload['sql'] = sql; @@ -1614,15 +2128,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1632,7 +2141,9 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - listExtensions(params: { databaseId: string }): Promise; + listExtensions(params: { + databaseId: string; + }): Promise; /** * List installed and available extensions for a PostgreSQL database. * @@ -1641,41 +2152,46 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listExtensions(databaseId: string): Promise; listExtensions( - paramsOrFirst: { databaseId: string } | string + databaseId: string, + ): Promise; + listExtensions( + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/extensions'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/extensions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1686,7 +2202,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createExtension(params: { databaseId: string, name: string }): Promise; + createExtension(params: { + databaseId: string; + name: string; + }): Promise; /** * Install a database extension. Only available for PostgreSQL databases. The install runs asynchronously; poll the extensions list endpoint for status. * @@ -1696,33 +2215,47 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createExtension(databaseId: string, name: string): Promise; createExtension( - paramsOrFirst: { databaseId: string, name: string } | string, - ...rest: [(string)?] + databaseId: string, + name: string, + ): Promise; + createExtension( + paramsOrFirst: { databaseId: string; name: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string }; + let params: { databaseId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + }; } else { params = { databaseId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const databaseId = params.databaseId; const name = params.name; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/postgresql/{databaseId}/extensions'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/extensions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1732,15 +2265,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1751,7 +2279,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - deleteExtension(params: { databaseId: string, extensionName: string }): Promise; + deleteExtension(params: { + databaseId: string; + extensionName: string; + }): Promise; /** * Uninstall a database extension from a PostgreSQL database. The uninstall runs asynchronously; poll the extensions list endpoint for status. * @@ -1761,61 +2292,77 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteExtension(databaseId: string, extensionName: string): Promise; deleteExtension( - paramsOrFirst: { databaseId: string, extensionName: string } | string, - ...rest: [(string)?] + databaseId: string, + extensionName: string, + ): Promise; + deleteExtension( + paramsOrFirst: { databaseId: string; extensionName: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, extensionName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, extensionName: string }; + let params: { databaseId: string; extensionName: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + extensionName: string; + }; } else { params = { databaseId: paramsOrFirst as string, - extensionName: rest[0] as string + extensionName: rest[0] as string, }; } - + const databaseId = params.databaseId; const extensionName = params.extensionName; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof extensionName === 'undefined') { - throw new AppwriteException('Missing required parameter: "extensionName"'); - } - - const apiPath = '/postgresql/{databaseId}/extensions/{extensionName}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{extensionName}', encodeURIComponent(String(extensionName))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof extensionName === 'undefined' || extensionName === '') { + throw new AppwriteException( + 'Missing required parameter: "extensionName"', + ); + } + const apiPath = '/postgresql/{databaseId}/extensions/{extensionName}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{extensionName}', + encodeURIComponent(String(extensionName)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -1823,30 +2370,45 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { payload['targetReplicaId'] = targetReplicaId; @@ -1856,15 +2418,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1876,7 +2433,11 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - updateMaintenance(params: { databaseId: string, day: string, hourUtc: number }): Promise; + updateMaintenance(params: { + databaseId: string; + day: string; + hourUtc: number; + }): Promise; /** * Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. * @@ -1887,38 +2448,57 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMaintenance(databaseId: string, day: string, hourUtc: number): Promise; updateMaintenance( - paramsOrFirst: { databaseId: string, day: string, hourUtc: number } | string, - ...rest: [(string)?, (number)?] + databaseId: string, + day: string, + hourUtc: number, + ): Promise; + updateMaintenance( + paramsOrFirst: + { databaseId: string; day: string; hourUtc: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { databaseId: string, day: string, hourUtc: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, day: string, hourUtc: number }; + let params: { databaseId: string; day: string; hourUtc: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + day: string; + hourUtc: number; + }; } else { params = { databaseId: paramsOrFirst as string, day: rest[0] as string, - hourUtc: rest[1] as number + hourUtc: rest[1] as number, }; } - + const databaseId = params.databaseId; const day = params.day; const hourUtc = params.hourUtc; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof day === 'undefined') { throw new AppwriteException('Missing required parameter: "day"'); } if (typeof hourUtc === 'undefined') { - throw new AppwriteException('Missing required parameter: "hourUtc"'); + throw new AppwriteException( + 'Missing required parameter: "hourUtc"', + ); } - - const apiPath = '/postgresql/{databaseId}/maintenance'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/maintenance'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof day !== 'undefined') { payload['day'] = day; @@ -1931,15 +2511,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1951,7 +2526,11 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createMigration(params: { databaseId: string, targetType: string, specification?: string }): Promise; + createMigration(params: { + databaseId: string; + targetType: string; + specification?: string; + }): Promise; /** * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. * @@ -1962,35 +2541,59 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMigration(databaseId: string, targetType: string, specification?: string): Promise; createMigration( - paramsOrFirst: { databaseId: string, targetType: string, specification?: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + targetType: string, + specification?: string, + ): Promise; + createMigration( + paramsOrFirst: + | { databaseId: string; targetType: string; specification?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, targetType: string, specification?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetType: string, specification?: string }; + let params: { + databaseId: string; + targetType: string; + specification?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetType: string; + specification?: string; + }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string + specification: rest[1] as string, }; } - + const databaseId = params.databaseId; const targetType = params.targetType; const specification = params.specification; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof targetType === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetType"'); + throw new AppwriteException( + 'Missing required parameter: "targetType"', + ); } - - const apiPath = '/postgresql/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetType !== 'undefined') { payload['targetType'] = targetType; @@ -2003,15 +2606,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2024,7 +2622,12 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -2036,34 +2639,64 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2078,15 +2711,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2096,7 +2724,9 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - getPitr(params: { databaseId: string }): Promise; + getPitr(params: { + databaseId: string; + }): Promise; /** * Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. * @@ -2107,39 +2737,42 @@ export class Postgresql { */ getPitr(databaseId: string): Promise; getPitr( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/pitr'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/pitr'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2149,7 +2782,9 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - getPooler(params: { databaseId: string }): Promise; + getPooler(params: { + databaseId: string; + }): Promise; /** * Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. * @@ -2160,39 +2795,42 @@ export class Postgresql { */ getPooler(databaseId: string): Promise; getPooler( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/pooler'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2210,7 +2848,17 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - updatePooler(params: { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string }): Promise; + updatePooler(params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }): Promise; /** * Update the connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. * @@ -2227,15 +2875,70 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePooler(databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string): Promise; updatePooler( - paramsOrFirst: { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string } | string, - ...rest: [(string)?, (number)?, (number)?, (boolean)?, (string)?, (string)?, (string)?, (string)?] + databaseId: string, + mode?: string, + maxConnections?: number, + defaultPoolSize?: number, + readWriteSplitting?: boolean, + poolerCpuRequest?: string, + poolerCpuLimit?: string, + poolerMemoryRequest?: string, + poolerMemoryLimit?: string, + ): Promise; + updatePooler( + paramsOrFirst: + | { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + } + | string, + ...rest: [ + string?, + number?, + number?, + boolean?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, mode?: string, maxConnections?: number, defaultPoolSize?: number, readWriteSplitting?: boolean, poolerCpuRequest?: string, poolerCpuLimit?: string, poolerMemoryRequest?: string, poolerMemoryLimit?: string }; + let params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2246,10 +2949,10 @@ export class Postgresql { poolerCpuRequest: rest[4] as string, poolerCpuLimit: rest[5] as string, poolerMemoryRequest: rest[6] as string, - poolerMemoryLimit: rest[7] as string + poolerMemoryLimit: rest[7] as string, }; } - + const databaseId = params.databaseId; const mode = params.mode; const maxConnections = params.maxConnections; @@ -2260,11 +2963,15 @@ export class Postgresql { const poolerMemoryRequest = params.poolerMemoryRequest; const poolerMemoryLimit = params.poolerMemoryLimit; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/pooler'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof mode !== 'undefined') { payload['mode'] = mode; @@ -2295,15 +3002,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2313,7 +3015,9 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -2324,39 +3028,42 @@ export class Postgresql { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2370,7 +3077,13 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - listRestorations(params: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }): Promise; + listRestorations(params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }): Promise; /** * List all restorations for a dedicated database. Results can be filtered by status and type. * @@ -2383,36 +3096,70 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRestorations(databaseId: string, status?: string, type?: string, limit?: number, offset?: number): Promise; listRestorations( - paramsOrFirst: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?] + databaseId: string, + status?: string, + type?: string, + limit?: number, + offset?: number, + ): Promise; + listRestorations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, type?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, type: rest[1] as string, limit: rest[2] as number, - offset: rest[3] as number + offset: rest[3] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const type = params.type; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/restorations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2430,15 +3177,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2447,50 +3189,94 @@ export class Postgresql { * @param {string} params.databaseId - Database ID. * @param {string} params.type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. * @param {string} params.backupId - Backup ID to restore from (required for backup type). + * @param {string} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. * @param {string} params.targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. * @throws {AppwriteException} * @returns {Promise} */ - createRestoration(params: { databaseId: string, type?: string, backupId?: string, targetTime?: string }): Promise; + createRestoration(params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }): Promise; /** * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. * * @param {string} databaseId - Database ID. * @param {string} type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. * @param {string} backupId - Backup ID to restore from (required for backup type). + * @param {string} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. * @param {string} targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRestoration(databaseId: string, type?: string, backupId?: string, targetTime?: string): Promise; createRestoration( - paramsOrFirst: { databaseId: string, type?: string, backupId?: string, targetTime?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + type?: string, + backupId?: string, + targetDatabaseId?: string, + targetTime?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { databaseId: string, type?: string, backupId?: string, targetTime?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, type?: string, backupId?: string, targetTime?: string }; + let params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; } else { params = { databaseId: paramsOrFirst as string, type: rest[0] as string, backupId: rest[1] as string, - targetTime: rest[2] as string + targetDatabaseId: rest[2] as string, + targetTime: rest[3] as string, }; } - + const databaseId = params.databaseId; const type = params.type; const backupId = params.backupId; + const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/restorations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -2498,6 +3284,9 @@ export class Postgresql { if (typeof backupId !== 'undefined') { payload['backupId'] = backupId; } + if (typeof targetDatabaseId !== 'undefined') { + payload['targetDatabaseId'] = targetDatabaseId; + } if (typeof targetTime !== 'undefined') { payload['targetTime'] = targetTime; } @@ -2506,15 +3295,10 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2525,7 +3309,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - getRestoration(params: { databaseId: string, restorationId: string }): Promise; + getRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise; /** * Get details of a specific database restoration including its status, type, and timestamps. * @@ -2535,47 +3322,60 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRestoration(databaseId: string, restorationId: string): Promise; getRestoration( - paramsOrFirst: { databaseId: string, restorationId: string } | string, - ...rest: [(string)?] + databaseId: string, + restorationId: string, + ): Promise; + getRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, restorationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, restorationId: string }; + let params: { databaseId: string; restorationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + restorationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - restorationId: rest[0] as string + restorationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const restorationId = params.restorationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof restorationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "restorationId"'); - } - - const apiPath = '/postgresql/{databaseId}/restorations/{restorationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{restorationId}', encodeURIComponent(String(restorationId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = '/postgresql/{databaseId}/restorations/{restorationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2596,39 +3396,42 @@ export class Postgresql { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/postgresql/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2639,7 +3442,10 @@ export class Postgresql { * @throws {AppwriteException} * @returns {Promise} */ - createUpgrade(params: { databaseId: string, targetVersion: string }): Promise; + createUpgrade(params: { + databaseId: string; + targetVersion: string; + }): Promise; /** * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. * @@ -2649,33 +3455,49 @@ export class Postgresql { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUpgrade(databaseId: string, targetVersion: string): Promise; createUpgrade( - paramsOrFirst: { databaseId: string, targetVersion: string } | string, - ...rest: [(string)?] + databaseId: string, + targetVersion: string, + ): Promise; + createUpgrade( + paramsOrFirst: { databaseId: string; targetVersion: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetVersion: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetVersion: string }; + let params: { databaseId: string; targetVersion: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetVersion: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetVersion: rest[0] as string + targetVersion: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetVersion = params.targetVersion; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof targetVersion === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetVersion"'); + throw new AppwriteException( + 'Missing required parameter: "targetVersion"', + ); } - - const apiPath = '/postgresql/{databaseId}/upgrades'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/postgresql/{databaseId}/upgrades'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetVersion !== 'undefined') { payload['targetVersion'] = targetVersion; @@ -2685,14 +3507,9 @@ export class Postgresql { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index 4a745062..e0691d8f 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,9 +1,7 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { UsageRange } from '../enums/usage-range'; - export class Presences { client: Client; @@ -13,7 +11,7 @@ export class Presences { /** * List presence logs. Expired entries are filtered out automatically. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. @@ -21,10 +19,14 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + ttl?: number; + }): Promise; /** * List presence logs. Expired entries are filtered out automatically. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. @@ -33,28 +35,41 @@ export class Presences { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], total?: boolean, ttl?: number): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean, ttl?: number } | string[], - ...rest: [(boolean)?, (number)?] + queries?: string[], + total?: boolean, + ttl?: number, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; total?: boolean; ttl?: number } | string[], + ...rest: [boolean?, number?] ): Promise { - let params: { queries?: string[], total?: boolean, ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean, ttl?: number }; + let params: { queries?: string[]; total?: boolean; ttl?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + ttl?: number; + }; } else { params = { queries: paramsOrFirst as string[], total: rest[0] as boolean, - ttl: rest[1] as number + ttl: rest[1] as number, }; } - + const queries = params.queries; const total = params.total; const ttl = params.ttl; - const apiPath = '/presences'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -70,20 +85,15 @@ export class Presences { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get presence usage metrics, including the current total of online users and historical online user counts for the selected time range. - * + * * * @param {UsageRange} params.range - Date range. * @throws {AppwriteException} @@ -92,7 +102,7 @@ export class Presences { getUsage(params?: { range?: UsageRange }): Promise; /** * Get presence usage metrics, including the current total of online users and historical online user counts for the selected time range. - * + * * * @param {UsageRange} range - Date range. * @throws {AppwriteException} @@ -101,20 +111,25 @@ export class Presences { */ getUsage(range?: UsageRange): Promise; getUsage( - paramsOrFirst?: { range?: UsageRange } | UsageRange + paramsOrFirst?: { range?: UsageRange } | UsageRange, ): Promise { let params: { range?: UsageRange }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('range' in paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'range' in paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { range?: UsageRange }; } else { params = { - range: paramsOrFirst as UsageRange + range: paramsOrFirst as UsageRange, }; } - - const range = params.range; + const range = params.range; const apiPath = '/presences/usage'; const payload: Payload = {}; @@ -125,20 +140,15 @@ export class Presences { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. - * + * * * @param {string} params.presenceId - Presence unique ID. * @throws {AppwriteException} @@ -147,7 +157,7 @@ export class Presences { get(params: { presenceId: string }): Promise; /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. - * + * * * @param {string} presenceId - Presence unique ID. * @throws {AppwriteException} @@ -156,44 +166,47 @@ export class Presences { */ get(presenceId: string): Promise; get( - paramsOrFirst: { presenceId: string } | string + paramsOrFirst: { presenceId: string } | string, ): Promise { let params: { presenceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { presenceId: string }; } else { params = { - presenceId: paramsOrFirst as string + presenceId: paramsOrFirst as string, }; } - + const presenceId = params.presenceId; - if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + if (typeof presenceId === 'undefined' || presenceId === '') { + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create or update a presence log by its user ID. - * + * * * @param {string} params.presenceId - Presence unique ID. * @param {string} params.status - Presence status. @@ -203,10 +216,16 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise} */ - upsert(params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; + upsert(params: { + presenceId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + }): Promise; /** * Create or update a presence log by its user ID. - * + * * * @param {string} presenceId - Presence unique ID. * @param {string} status - Presence status. @@ -217,39 +236,73 @@ export class Presences { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsert(presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise; upsert( - paramsOrFirst: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, - ...rest: [(string)?, (string[])?, (string)?, (object)?] + presenceId: string, + status: string, + permissions?: string[], + expiresAt?: string, + metadata?: object, + ): Promise; + upsert( + paramsOrFirst: + | { + presenceId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + } + | string, + ...rest: [string?, string[]?, string?, object?] ): Promise { - let params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + let params: { + presenceId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + presenceId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + }; } else { params = { presenceId: paramsOrFirst as string, status: rest[0] as string, permissions: rest[1] as string[], expiresAt: rest[2] as string, - metadata: rest[3] as object + metadata: rest[3] as object, }; } - + const presenceId = params.presenceId; const status = params.status; const permissions = params.permissions; const expiresAt = params.expiresAt; const metadata = params.metadata; - if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + if (typeof presenceId === 'undefined' || presenceId === '') { + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -268,20 +321,15 @@ export class Presences { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * + * * * @param {string} params.presenceId - Presence unique ID. * @param {string} params.status - Presence status. @@ -292,10 +340,17 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; + update(params: { + presenceId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + }): Promise; /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * + * * * @param {string} presenceId - Presence unique ID. * @param {string} status - Presence status. @@ -307,15 +362,49 @@ export class Presences { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise; update( - paramsOrFirst: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, - ...rest: [(string)?, (string)?, (object)?, (string[])?, (boolean)?] + presenceId: string, + status?: string, + expiresAt?: string, + metadata?: object, + permissions?: string[], + purge?: boolean, + ): Promise; + update( + paramsOrFirst: + | { + presenceId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + } + | string, + ...rest: [string?, string?, object?, string[]?, boolean?] ): Promise { - let params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + let params: { + presenceId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + presenceId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + }; } else { params = { presenceId: paramsOrFirst as string, @@ -323,10 +412,10 @@ export class Presences { expiresAt: rest[1] as string, metadata: rest[2] as object, permissions: rest[3] as string[], - purge: rest[4] as boolean + purge: rest[4] as boolean, }; } - + const presenceId = params.presenceId; const status = params.status; const expiresAt = params.expiresAt; @@ -334,11 +423,15 @@ export class Presences { const permissions = params.permissions; const purge = params.purge; - if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + if (typeof presenceId === 'undefined' || presenceId === '') { + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -360,20 +453,15 @@ export class Presences { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Delete a presence log by its unique ID. - * + * * * @param {string} params.presenceId - Presence unique ID. * @throws {AppwriteException} @@ -382,7 +470,7 @@ export class Presences { delete(params: { presenceId: string }): Promise<{}>; /** * Delete a presence log by its unique ID. - * + * * * @param {string} presenceId - Presence unique ID. * @throws {AppwriteException} @@ -390,39 +478,41 @@ export class Presences { * @deprecated Use the object parameter style method for a better developer experience. */ delete(presenceId: string): Promise<{}>; - delete( - paramsOrFirst: { presenceId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { presenceId: string } | string): Promise<{}> { let params: { presenceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { presenceId: string }; } else { params = { - presenceId: paramsOrFirst as string + presenceId: paramsOrFirst as string, }; } - + const presenceId = params.presenceId; - if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + if (typeof presenceId === 'undefined' || presenceId === '') { + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/project.ts b/src/services/project.ts index a93319c5..938b96e7 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,5 +1,4 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -14,7 +13,6 @@ import { ProjectSMTPSecure } from '../enums/project-smtp-secure'; import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; import { ProjectUsageRange } from '../enums/project-usage-range'; - export class Project { client: Client; @@ -29,21 +27,16 @@ export class Project { * @returns {Promise} */ get(): Promise { - const apiPath = '/project'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -53,7 +46,6 @@ export class Project { * @returns {Promise<{}>} */ delete(): Promise<{}> { - const apiPath = '/project'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -61,27 +53,26 @@ export class Project { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. * * @param {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise} */ - updateAuthMethod(params: { methodId: ProjectAuthMethodId, enabled: boolean }): Promise; + updateAuthMethod(params: { + methodId: ProjectAuthMethodId; + enabled: boolean; + }): Promise; /** - * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. * * @param {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone * @param {boolean} enabled - Auth method status. @@ -89,33 +80,52 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAuthMethod(methodId: ProjectAuthMethodId, enabled: boolean): Promise; updateAuthMethod( - paramsOrFirst: { methodId: ProjectAuthMethodId, enabled: boolean } | ProjectAuthMethodId, - ...rest: [(boolean)?] + methodId: ProjectAuthMethodId, + enabled: boolean, + ): Promise; + updateAuthMethod( + paramsOrFirst: + | { methodId: ProjectAuthMethodId; enabled: boolean } + | ProjectAuthMethodId, + ...rest: [boolean?] ): Promise { - let params: { methodId: ProjectAuthMethodId, enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { methodId: ProjectAuthMethodId, enabled: boolean }; + let params: { methodId: ProjectAuthMethodId; enabled: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + methodId: ProjectAuthMethodId; + enabled: boolean; + }; } else { params = { methodId: paramsOrFirst as ProjectAuthMethodId, - enabled: rest[0] as boolean + enabled: rest[0] as boolean, }; } - + const methodId = params.methodId; const enabled = params.enabled; if (typeof methodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "methodId"'); + throw new AppwriteException( + 'Missing required parameter: "methodId"', + ); } if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - - const apiPath = '/project/auth-methods/{methodId}'.replace('{methodId}', encodeURIComponent(String(methodId))); + const apiPath = '/project/auth-methods/{methodId}'.replace( + '{methodId}', + encodeURIComponent(String(methodId)), + ); const payload: Payload = {}; if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; @@ -125,15 +135,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -144,7 +149,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listKeys(params?: { queries?: string[], total?: boolean }): Promise; + listKeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all API keys from the current project. * @@ -156,24 +164,31 @@ export class Project { */ listKeys(queries?: string[], total?: boolean): Promise; listKeys( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/keys'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -186,20 +201,15 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. - * + * * You can also create an ephemeral API key if you need a short-lived key instead. * * @param {string} params.keyId - Key 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. @@ -209,10 +219,15 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }): Promise; + createKey(params: { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }): Promise; /** * Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. - * + * * You can also create an ephemeral API key if you need a short-lived key instead. * * @param {string} keyId - Key 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. @@ -223,24 +238,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise; createKey( - paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: ProjectKeyScopes[], + expire?: string, + ): Promise; + createKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, ProjectKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as ProjectKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; @@ -255,7 +296,6 @@ export class Project { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - const apiPath = '/project/keys'; const payload: Payload = {}; if (typeof keyId !== 'undefined') { @@ -275,20 +315,15 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. - * + * * You can also create a standard API key if you need a longer-lived key instead. * * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. @@ -296,10 +331,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createEphemeralKey(params: { scopes: ProjectKeyScopes[], duration: number }): Promise; + createEphemeralKey(params: { + scopes: ProjectKeyScopes[]; + duration: number; + }): Promise; /** * Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. - * + * * You can also create a standard API key if you need a longer-lived key instead. * * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. @@ -308,22 +346,35 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEphemeralKey(scopes: ProjectKeyScopes[], duration: number): Promise; createEphemeralKey( - paramsOrFirst: { scopes: ProjectKeyScopes[], duration: number } | ProjectKeyScopes[], - ...rest: [(number)?] + scopes: ProjectKeyScopes[], + duration: number, + ): Promise; + createEphemeralKey( + paramsOrFirst: + | { scopes: ProjectKeyScopes[]; duration: number } + | ProjectKeyScopes[], + ...rest: [number?] ): Promise { - let params: { scopes: ProjectKeyScopes[], duration: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { scopes: ProjectKeyScopes[], duration: number }; + let params: { scopes: ProjectKeyScopes[]; duration: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + scopes: ProjectKeyScopes[]; + duration: number; + }; } else { params = { scopes: paramsOrFirst as ProjectKeyScopes[], - duration: rest[0] as number + duration: rest[0] as number, }; } - + const scopes = params.scopes; const duration = params.duration; @@ -331,9 +382,10 @@ export class Project { throw new AppwriteException('Missing required parameter: "scopes"'); } if (typeof duration === 'undefined') { - throw new AppwriteException('Missing required parameter: "duration"'); + throw new AppwriteException( + 'Missing required parameter: "duration"', + ); } - const apiPath = '/project/keys/ephemeral'; const payload: Payload = {}; if (typeof scopes !== 'undefined') { @@ -347,19 +399,14 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Get a key by its unique ID. + * Get a key by its unique ID. * * @param {string} params.keyId - Key ID. * @throws {AppwriteException} @@ -367,7 +414,7 @@ export class Project { */ getKey(params: { keyId: string }): Promise; /** - * Get a key by its unique ID. + * Get a key by its unique ID. * * @param {string} keyId - Key ID. * @throws {AppwriteException} @@ -375,40 +422,39 @@ export class Project { * @deprecated Use the object parameter style method for a better developer experience. */ getKey(keyId: string): Promise; - getKey( - paramsOrFirst: { keyId: string } | string - ): Promise { + getKey(paramsOrFirst: { keyId: string } | string): Promise { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - + const keyId = params.keyId; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/project/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/project/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -421,7 +467,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }): Promise; + updateKey(params: { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * @@ -433,30 +484,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: ProjectKeyScopes[], + expire?: string, + ): Promise; + updateKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, ProjectKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as ProjectKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; const expire = params.expire; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } if (typeof name === 'undefined') { @@ -465,8 +542,10 @@ export class Project { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - - const apiPath = '/project/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/project/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -482,15 +561,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -510,40 +584,40 @@ export class Project { * @deprecated Use the object parameter style method for a better developer experience. */ deleteKey(keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { keyId: string } | string - ): Promise<{}> { + deleteKey(paramsOrFirst: { keyId: string } | string): Promise<{}> { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - + const keyId = params.keyId; - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/project/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/project/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -564,24 +638,27 @@ export class Project { */ updateLabels(labels: string[]): Promise; updateLabels( - paramsOrFirst: { labels: string[] } | string[] + paramsOrFirst: { labels: string[] } | string[], ): Promise { let params: { labels: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { labels: string[] }; } else { params = { - labels: paramsOrFirst as string[] + labels: paramsOrFirst as string[], }; } - + const labels = params.labels; if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } - const apiPath = '/project/labels'; const payload: Payload = {}; if (typeof labels !== 'undefined') { @@ -592,15 +669,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -611,7 +683,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listMockPhones(params?: { queries?: string[], total?: boolean }): Promise; + listMockPhones(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. * @@ -621,26 +696,36 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMockPhones(queries?: string[], total?: boolean): Promise; listMockPhones( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listMockPhones( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/mock-phones'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -653,15 +738,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -672,7 +752,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createMockPhone(params: { number: string, otp: string }): Promise; + createMockPhone(params: { + number: string; + otp: string; + }): Promise; /** * Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. * @@ -684,20 +767,24 @@ export class Project { */ createMockPhone(number: string, otp: string): Promise; createMockPhone( - paramsOrFirst: { number: string, otp: string } | string, - ...rest: [(string)?] + paramsOrFirst: { number: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { number: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { number: string, otp: string }; + let params: { number: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { number: string; otp: string }; } else { params = { number: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const number = params.number; const otp = params.otp; @@ -707,7 +794,6 @@ export class Project { if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/project/mock-phones'; const payload: Payload = {}; if (typeof number !== 'undefined') { @@ -721,15 +807,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -750,39 +831,40 @@ export class Project { */ getMockPhone(number: string): Promise; getMockPhone( - paramsOrFirst: { number: string } | string + paramsOrFirst: { number: string } | string, ): Promise { let params: { number: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { number: string }; } else { params = { - number: paramsOrFirst as string + number: paramsOrFirst as string, }; } - + const number = params.number; - if (typeof number === 'undefined') { + if (typeof number === 'undefined' || number === '') { throw new AppwriteException('Missing required parameter: "number"'); } - - const apiPath = '/project/mock-phones/{number}'.replace('{number}', encodeURIComponent(String(number))); + const apiPath = '/project/mock-phones/{number}'.replace( + '{number}', + encodeURIComponent(String(number)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -793,7 +875,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateMockPhone(params: { number: string, otp: string }): Promise; + updateMockPhone(params: { + number: string; + otp: string; + }): Promise; /** * Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. * @@ -805,31 +890,37 @@ export class Project { */ updateMockPhone(number: string, otp: string): Promise; updateMockPhone( - paramsOrFirst: { number: string, otp: string } | string, - ...rest: [(string)?] + paramsOrFirst: { number: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { number: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { number: string, otp: string }; + let params: { number: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { number: string; otp: string }; } else { params = { number: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const number = params.number; const otp = params.otp; - if (typeof number === 'undefined') { + if (typeof number === 'undefined' || number === '') { throw new AppwriteException('Missing required parameter: "number"'); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - - const apiPath = '/project/mock-phones/{number}'.replace('{number}', encodeURIComponent(String(number))); + const apiPath = '/project/mock-phones/{number}'.replace( + '{number}', + encodeURIComponent(String(number)), + ); const payload: Payload = {}; if (typeof otp !== 'undefined') { payload['otp'] = otp; @@ -839,15 +930,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -867,40 +953,40 @@ export class Project { * @deprecated Use the object parameter style method for a better developer experience. */ deleteMockPhone(number: string): Promise<{}>; - deleteMockPhone( - paramsOrFirst: { number: string } | string - ): Promise<{}> { + deleteMockPhone(paramsOrFirst: { number: string } | string): Promise<{}> { let params: { number: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { number: string }; } else { params = { - number: paramsOrFirst as string + number: paramsOrFirst as string, }; } - + const number = params.number; - if (typeof number === 'undefined') { + if (typeof number === 'undefined' || number === '') { throw new AppwriteException('Missing required parameter: "number"'); } - - const apiPath = '/project/mock-phones/{number}'.replace('{number}', encodeURIComponent(String(number))); + const apiPath = '/project/mock-phones/{number}'.replace( + '{number}', + encodeURIComponent(String(number)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -911,7 +997,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listOAuth2Providers(params?: { queries?: string[], total?: boolean }): Promise; + listOAuth2Providers(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. * @@ -921,26 +1010,36 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOAuth2Providers(queries?: string[], total?: boolean): Promise; listOAuth2Providers( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listOAuth2Providers( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/oauth2'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -953,15 +1052,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -982,10 +1076,28 @@ export class Project { * @param {string} params.userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. * @param {number} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} params.defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. + * @param {string[]} params.installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Server(params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }): Promise; + updateOAuth2Server(params: { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + }): Promise; /** * Update the OAuth2 server (OIDC provider) configuration. * @@ -1004,19 +1116,110 @@ export class Project { * @param {string} userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. * @param {number} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. + * @param {string[]} installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Server(enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[]): Promise; updateOAuth2Server( - paramsOrFirst: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] } | boolean, - ...rest: [(string)?, (string[])?, (string[])?, (number)?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string)?, (number)?, (string)?, (number)?, (string[])?] + enabled: boolean, + authorizationUrl: string, + scopes?: string[], + authorizationDetailsTypes?: string[], + accessTokenDuration?: number, + refreshTokenDuration?: number, + publicAccessTokenDuration?: number, + publicRefreshTokenDuration?: number, + installationAccessTokenDuration?: number, + confidentialPkce?: boolean, + verificationUrl?: string, + userCodeLength?: number, + userCodeFormat?: string, + deviceCodeDuration?: number, + defaultScopes?: string[], + installationScopes?: string[], + ): Promise; + updateOAuth2Server( + paramsOrFirst: + | { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + } + | boolean, + ...rest: [ + string?, + string[]?, + string[]?, + number?, + number?, + number?, + number?, + number?, + boolean?, + string?, + number?, + string?, + number?, + string[]?, + string[]?, + ] ): Promise { - let params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }; + let params: { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + }; } else { params = { enabled: paramsOrFirst as boolean, @@ -1033,10 +1236,11 @@ export class Project { userCodeLength: rest[10] as number, userCodeFormat: rest[11] as string, deviceCodeDuration: rest[12] as number, - defaultScopes: rest[13] as string[] + defaultScopes: rest[13] as string[], + installationScopes: rest[14] as string[], }; } - + const enabled = params.enabled; const authorizationUrl = params.authorizationUrl; const scopes = params.scopes; @@ -1045,21 +1249,26 @@ export class Project { const refreshTokenDuration = params.refreshTokenDuration; const publicAccessTokenDuration = params.publicAccessTokenDuration; const publicRefreshTokenDuration = params.publicRefreshTokenDuration; - const installationAccessTokenDuration = params.installationAccessTokenDuration; + const installationAccessTokenDuration = + params.installationAccessTokenDuration; const confidentialPkce = params.confidentialPkce; const verificationUrl = params.verificationUrl; const userCodeLength = params.userCodeLength; const userCodeFormat = params.userCodeFormat; const deviceCodeDuration = params.deviceCodeDuration; const defaultScopes = params.defaultScopes; + const installationScopes = params.installationScopes; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } if (typeof authorizationUrl === 'undefined') { - throw new AppwriteException('Missing required parameter: "authorizationUrl"'); + throw new AppwriteException( + 'Missing required parameter: "authorizationUrl"', + ); } - const apiPath = '/project/oauth2-server'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -1087,7 +1296,8 @@ export class Project { payload['publicRefreshTokenDuration'] = publicRefreshTokenDuration; } if (typeof installationAccessTokenDuration !== 'undefined') { - payload['installationAccessTokenDuration'] = installationAccessTokenDuration; + payload['installationAccessTokenDuration'] = + installationAccessTokenDuration; } if (typeof confidentialPkce !== 'undefined') { payload['confidentialPkce'] = confidentialPkce; @@ -1107,20 +1317,18 @@ export class Project { if (typeof defaultScopes !== 'undefined') { payload['defaultScopes'] = defaultScopes; } + if (typeof installationScopes !== 'undefined') { + payload['installationScopes'] = installationScopes; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1132,7 +1340,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Amazon(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Amazon(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Amazon configuration. * @@ -1143,28 +1355,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Amazon(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Amazon( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Amazon( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/amazon'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1181,15 +1411,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1203,7 +1428,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Apple(params?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }): Promise; + updateOAuth2Apple(params?: { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Apple configuration. * @@ -1216,32 +1447,62 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Apple(serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean): Promise; updateOAuth2Apple( - paramsOrFirst?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + serviceId?: string, + keyId?: string, + teamId?: string, + p8File?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Apple( + paramsOrFirst?: + | { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; + let params: { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + }; } else { params = { serviceId: paramsOrFirst as string, keyId: rest[0] as string, teamId: rest[1] as string, p8File: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const serviceId = params.serviceId; const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; const enabled = params.enabled; - const apiPath = '/project/oauth2/apple'; const payload: Payload = {}; if (typeof serviceId !== 'undefined') { @@ -1264,15 +1525,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1284,7 +1540,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Appwrite(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Appwrite(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Appwrite configuration. * @@ -1295,28 +1555,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Appwrite(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Appwrite( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Appwrite( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/appwrite'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1333,15 +1611,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1354,7 +1627,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Auth0(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2Auth0(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Auth0 configuration. * @@ -1366,30 +1644,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Auth0(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2Auth0( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Auth0( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; - const apiPath = '/project/oauth2/auth0'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1409,15 +1713,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1430,7 +1729,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Authentik(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2Authentik(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Authentik configuration. * @@ -1442,30 +1746,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Authentik(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2Authentik( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Authentik( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; - const apiPath = '/project/oauth2/authentik'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1485,15 +1815,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1505,7 +1830,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Autodesk(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Autodesk(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Autodesk configuration. * @@ -1516,28 +1845,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Autodesk(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Autodesk( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Autodesk( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/autodesk'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1554,15 +1901,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1574,7 +1916,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Bitbucket(params?: { key?: string, secret?: string, enabled?: boolean }): Promise; + updateOAuth2Bitbucket(params?: { + key?: string; + secret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Bitbucket configuration. * @@ -1585,28 +1931,41 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Bitbucket(key?: string, secret?: string, enabled?: boolean): Promise; updateOAuth2Bitbucket( - paramsOrFirst?: { key?: string, secret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + key?: string, + secret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Bitbucket( + paramsOrFirst?: + { key?: string; secret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { key?: string, secret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { key?: string, secret?: string, enabled?: boolean }; + let params: { key?: string; secret?: string; enabled?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + key?: string; + secret?: string; + enabled?: boolean; + }; } else { params = { key: paramsOrFirst as string, secret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const key = params.key; const secret = params.secret; const enabled = params.enabled; - const apiPath = '/project/oauth2/bitbucket'; const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -1623,15 +1982,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1643,7 +1997,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Bitly(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Bitly(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Bitly configuration. * @@ -1654,28 +2012,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Bitly(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Bitly( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Bitly( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/bitly'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1692,15 +2068,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1712,7 +2083,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Box(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Box(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Box configuration. * @@ -1723,28 +2098,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Box(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Box( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Box( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/box'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1761,15 +2154,96 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + + /** + * Update the project OAuth2 Cloudflare configuration. + * + * @param {string} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Cloudflare(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Cloudflare configuration. + * + * @param {string} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Cloudflare( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Cloudflare( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; } - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + const apiPath = '/project/oauth2/cloudflare'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1781,7 +2255,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Dailymotion(params?: { apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Dailymotion(params?: { + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Dailymotion configuration. * @@ -1792,28 +2270,41 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Dailymotion(apiKey?: string, apiSecret?: string, enabled?: boolean): Promise; updateOAuth2Dailymotion( - paramsOrFirst?: { apiKey?: string, apiSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + apiKey?: string, + apiSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Dailymotion( + paramsOrFirst?: + { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { apiKey?: string, apiSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { apiKey?: string, apiSecret?: string, enabled?: boolean }; + let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }; } else { params = { apiKey: paramsOrFirst as string, apiSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const apiKey = params.apiKey; const apiSecret = params.apiSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/dailymotion'; const payload: Payload = {}; if (typeof apiKey !== 'undefined') { @@ -1830,15 +2321,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1850,7 +2336,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Discord(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Discord(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Discord configuration. * @@ -1861,28 +2351,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Discord(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Discord( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Discord( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/discord'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1899,15 +2407,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1919,7 +2422,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Disqus(params?: { publicKey?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2Disqus(params?: { + publicKey?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Disqus configuration. * @@ -1930,28 +2437,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Disqus(publicKey?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2Disqus( - paramsOrFirst?: { publicKey?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + publicKey?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Disqus( + paramsOrFirst?: + | { publicKey?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { publicKey?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { publicKey?: string, secretKey?: string, enabled?: boolean }; + let params: { + publicKey?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + publicKey?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { publicKey: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const publicKey = params.publicKey; const secretKey = params.secretKey; const enabled = params.enabled; - const apiPath = '/project/oauth2/disqus'; const payload: Payload = {}; if (typeof publicKey !== 'undefined') { @@ -1968,15 +2493,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1988,7 +2508,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Dropbox(params?: { appKey?: string, appSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Dropbox(params?: { + appKey?: string; + appSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Dropbox configuration. * @@ -1999,28 +2523,41 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Dropbox(appKey?: string, appSecret?: string, enabled?: boolean): Promise; updateOAuth2Dropbox( - paramsOrFirst?: { appKey?: string, appSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + appKey?: string, + appSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Dropbox( + paramsOrFirst?: + { appKey?: string; appSecret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { appKey?: string, appSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appKey?: string, appSecret?: string, enabled?: boolean }; + let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + appKey?: string; + appSecret?: string; + enabled?: boolean; + }; } else { params = { appKey: paramsOrFirst as string, appSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const appKey = params.appKey; const appSecret = params.appSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/dropbox'; const payload: Payload = {}; if (typeof appKey !== 'undefined') { @@ -2037,15 +2574,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2057,7 +2589,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Etsy(params?: { keyString?: string, sharedSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Etsy(params?: { + keyString?: string; + sharedSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Etsy configuration. * @@ -2068,28 +2604,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Etsy(keyString?: string, sharedSecret?: string, enabled?: boolean): Promise; updateOAuth2Etsy( - paramsOrFirst?: { keyString?: string, sharedSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + keyString?: string, + sharedSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Etsy( + paramsOrFirst?: + | { keyString?: string; sharedSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { keyString?: string, sharedSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyString?: string, sharedSecret?: string, enabled?: boolean }; + let params: { + keyString?: string; + sharedSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + keyString?: string; + sharedSecret?: string; + enabled?: boolean; + }; } else { params = { keyString: paramsOrFirst as string, sharedSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const keyString = params.keyString; const sharedSecret = params.sharedSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/etsy'; const payload: Payload = {}; if (typeof keyString !== 'undefined') { @@ -2106,15 +2660,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2126,7 +2675,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Facebook(params?: { appId?: string, appSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Facebook(params?: { + appId?: string; + appSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Facebook configuration. * @@ -2137,28 +2690,41 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Facebook(appId?: string, appSecret?: string, enabled?: boolean): Promise; updateOAuth2Facebook( - paramsOrFirst?: { appId?: string, appSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + appId?: string, + appSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Facebook( + paramsOrFirst?: + { appId?: string; appSecret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { appId?: string, appSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId?: string, appSecret?: string, enabled?: boolean }; + let params: { appId?: string; appSecret?: string; enabled?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + appId?: string; + appSecret?: string; + enabled?: boolean; + }; } else { params = { appId: paramsOrFirst as string, appSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const appId = params.appId; const appSecret = params.appSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/facebook'; const payload: Payload = {}; if (typeof appId !== 'undefined') { @@ -2175,15 +2741,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2195,7 +2756,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Figma(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Figma(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Figma configuration. * @@ -2206,28 +2771,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Figma(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Figma( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Figma( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/figma'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2244,15 +2827,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2265,7 +2843,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2FusionAuth(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2FusionAuth(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 FusionAuth configuration. * @@ -2277,30 +2860,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2FusionAuth(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2FusionAuth( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2FusionAuth( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; - const apiPath = '/project/oauth2/fusionauth'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2320,15 +2929,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2340,7 +2944,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2GitHub(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2GitHub(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 GitHub configuration. * @@ -2351,28 +2959,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2GitHub(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2GitHub( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2GitHub( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/github'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2389,15 +3015,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2410,7 +3031,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Gitlab(params?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2Gitlab(params?: { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Gitlab configuration. * @@ -2422,30 +3048,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Gitlab(applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2Gitlab( - paramsOrFirst?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + applicationId?: string, + secret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Gitlab( + paramsOrFirst?: + | { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; + let params: { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { applicationId: paramsOrFirst as string, secret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const applicationId = params.applicationId; const secret = params.secret; const endpoint = params.endpoint; const enabled = params.enabled; - const apiPath = '/project/oauth2/gitlab'; const payload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -2465,15 +3117,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2486,7 +3133,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Google(params?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }): Promise; + updateOAuth2Google(params?: { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Google configuration. * @@ -2498,30 +3150,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Google(clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean): Promise; updateOAuth2Google( - paramsOrFirst?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean } | string, - ...rest: [(string)?, (ProjectOAuth2GooglePrompt[])?, (boolean)?] + clientId?: string, + clientSecret?: string, + prompt?: ProjectOAuth2GooglePrompt[], + enabled?: boolean, + ): Promise; + updateOAuth2Google( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + } + | string, + ...rest: [string?, ProjectOAuth2GooglePrompt[]?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, prompt: rest[1] as ProjectOAuth2GooglePrompt[], - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; const enabled = params.enabled; - const apiPath = '/project/oauth2/google'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2541,15 +3219,182 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + + /** + * Update the project OAuth2 Hugging Face configuration. + * + * @param {string} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2HuggingFace(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Hugging Face configuration. + * + * @param {string} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2HuggingFace( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2HuggingFace( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; } - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + const apiPath = '/project/oauth2/huggingface'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + + /** + * Update the project OAuth2 Kakao configuration. + * + * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Kakao(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Kakao configuration. + * + * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Kakao( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Kakao( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + const apiPath = '/project/oauth2/kakao'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2563,7 +3408,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Keycloak(params?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }): Promise; + updateOAuth2Keycloak(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Keycloak configuration. * @@ -2576,32 +3427,62 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Keycloak(clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean): Promise; updateOAuth2Keycloak( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + realmName?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Keycloak( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, realmName: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const realmName = params.realmName; const enabled = params.enabled; - const apiPath = '/project/oauth2/keycloak'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2624,15 +3505,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2644,7 +3520,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Kick(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Kick(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Kick configuration. * @@ -2655,28 +3535,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Kick(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Kick( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Kick( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/kick'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2693,15 +3591,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2713,7 +3606,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Linkedin(params?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Linkedin(params?: { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Linkedin configuration. * @@ -2724,28 +3621,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Linkedin(clientId?: string, primaryClientSecret?: string, enabled?: boolean): Promise; updateOAuth2Linkedin( - paramsOrFirst?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + primaryClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Linkedin( + paramsOrFirst?: + | { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const primaryClientSecret = params.primaryClientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/linkedin'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2762,15 +3681,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2783,7 +3697,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Microsoft(params?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }): Promise; + updateOAuth2Microsoft(params?: { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Microsoft configuration. * @@ -2795,30 +3714,56 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Microsoft(applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean): Promise; updateOAuth2Microsoft( - paramsOrFirst?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + applicationId?: string, + applicationSecret?: string, + tenant?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Microsoft( + paramsOrFirst?: + | { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; + let params: { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + }; } else { params = { applicationId: paramsOrFirst as string, applicationSecret: rest[0] as string, tenant: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; const enabled = params.enabled; - const apiPath = '/project/oauth2/microsoft'; const payload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -2838,15 +3783,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2858,7 +3798,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Notion(params?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Notion(params?: { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Notion configuration. * @@ -2869,28 +3813,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Notion(oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean): Promise; updateOAuth2Notion( - paramsOrFirst?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + oauthClientId?: string, + oauthClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Notion( + paramsOrFirst?: + | { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; + let params: { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + }; } else { params = { oauthClientId: paramsOrFirst as string, oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const oauthClientId = params.oauthClientId; const oauthClientSecret = params.oauthClientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/notion'; const payload: Payload = {}; if (typeof oauthClientId !== 'undefined') { @@ -2907,15 +3873,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2933,7 +3894,17 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Oidc(params?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean }): Promise; + updateOAuth2Oidc(params?: { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Oidc configuration. * @@ -2950,15 +3921,71 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Oidc(clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean): Promise; updateOAuth2Oidc( - paramsOrFirst?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (ProjectOAuth2OidcPrompt[])?, (number)?, (boolean)?] + clientId?: string, + clientSecret?: string, + wellKnownURL?: string, + authorizationURL?: string, + tokenURL?: string, + userInfoURL?: string, + prompt?: ProjectOAuth2OidcPrompt[], + maxAge?: number, + enabled?: boolean, + ): Promise; + updateOAuth2Oidc( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + ProjectOAuth2OidcPrompt[]?, + number?, + boolean?, + ] ): Promise { - let params: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, @@ -2969,10 +3996,10 @@ export class Project { userInfoURL: rest[4] as string, prompt: rest[5] as ProjectOAuth2OidcPrompt[], maxAge: rest[6] as number, - enabled: rest[7] as boolean + enabled: rest[7] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const wellKnownURL = params.wellKnownURL; @@ -2983,7 +4010,6 @@ export class Project { const maxAge = params.maxAge; const enabled = params.enabled; - const apiPath = '/project/oauth2/oidc'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3018,15 +4044,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3040,7 +4061,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Okta(params?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }): Promise; + updateOAuth2Okta(params?: { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Okta configuration. * @@ -3053,32 +4080,62 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Okta(clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean): Promise; updateOAuth2Okta( - paramsOrFirst?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + domain?: string, + authorizationServerId?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Okta( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, domain: rest[1] as string, authorizationServerId: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; const enabled = params.enabled; - const apiPath = '/project/oauth2/okta'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3101,15 +4158,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3121,7 +4173,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Paypal(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2Paypal(params?: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Paypal configuration. * @@ -3132,28 +4188,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Paypal(clientId?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2Paypal( - paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Paypal( + paramsOrFirst?: + | { clientId?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + let params: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const secretKey = params.secretKey; const enabled = params.enabled; - const apiPath = '/project/oauth2/paypal'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3170,15 +4244,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3190,7 +4259,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2PaypalSandbox(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2PaypalSandbox(params?: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 PaypalSandbox configuration. * @@ -3201,28 +4274,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2PaypalSandbox(clientId?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2PaypalSandbox( - paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2PaypalSandbox( + paramsOrFirst?: + | { clientId?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + let params: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const secretKey = params.secretKey; const enabled = params.enabled; - const apiPath = '/project/oauth2/paypalSandbox'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3239,15 +4330,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3259,7 +4345,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Podio(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Podio(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Podio configuration. * @@ -3270,28 +4360,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Podio(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Podio( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Podio( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/podio'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3308,15 +4416,96 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + + /** + * Update the project OAuth2 Resend configuration. + * + * @param {string} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Resend(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Resend configuration. + * + * @param {string} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Resend( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Resend( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; } - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + const apiPath = '/project/oauth2/resend'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3328,7 +4517,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Salesforce(params?: { customerKey?: string, customerSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Salesforce(params?: { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Salesforce configuration. * @@ -3339,28 +4532,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Salesforce(customerKey?: string, customerSecret?: string, enabled?: boolean): Promise; updateOAuth2Salesforce( - paramsOrFirst?: { customerKey?: string, customerSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + customerKey?: string, + customerSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Salesforce( + paramsOrFirst?: + | { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { customerKey?: string, customerSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { customerKey?: string, customerSecret?: string, enabled?: boolean }; + let params: { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + }; } else { params = { customerKey: paramsOrFirst as string, customerSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const customerKey = params.customerKey; const customerSecret = params.customerSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/salesforce'; const payload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -3377,15 +4592,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3397,7 +4607,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Slack(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Slack(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Slack configuration. * @@ -3408,28 +4622,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Slack(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Slack( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Slack( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/slack'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3446,15 +4678,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3466,7 +4693,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Spotify(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Spotify(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Spotify configuration. * @@ -3477,28 +4708,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Spotify(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Spotify( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Spotify( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/spotify'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3515,15 +4764,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3535,7 +4779,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Stripe(params?: { clientId?: string, apiSecretKey?: string, enabled?: boolean }): Promise; + updateOAuth2Stripe(params?: { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Stripe configuration. * @@ -3546,28 +4794,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Stripe(clientId?: string, apiSecretKey?: string, enabled?: boolean): Promise; updateOAuth2Stripe( - paramsOrFirst?: { clientId?: string, apiSecretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + apiSecretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Stripe( + paramsOrFirst?: + | { clientId?: string; apiSecretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, apiSecretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, apiSecretKey?: string, enabled?: boolean }; + let params: { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const apiSecretKey = params.apiSecretKey; const enabled = params.enabled; - const apiPath = '/project/oauth2/stripe'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3584,15 +4850,96 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + + /** + * Update the project OAuth2 TikTok configuration. + * + * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2TikTok(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 TikTok configuration. + * + * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2TikTok( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2TikTok( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; } - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + const apiPath = '/project/oauth2/tiktok'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3604,7 +4951,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Tradeshift(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Tradeshift(params?: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Tradeshift configuration. * @@ -3615,28 +4966,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Tradeshift(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise; updateOAuth2Tradeshift( - paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + oauth2ClientId?: string, + oauth2ClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Tradeshift( + paramsOrFirst?: + | { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + let params: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; } else { params = { oauth2ClientId: paramsOrFirst as string, oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const oauth2ClientId = params.oauth2ClientId; const oauth2ClientSecret = params.oauth2ClientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/tradeshift'; const payload: Payload = {}; if (typeof oauth2ClientId !== 'undefined') { @@ -3653,15 +5026,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3673,7 +5041,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2TradeshiftSandbox(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2TradeshiftSandbox(params?: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * @@ -3684,28 +5056,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2TradeshiftSandbox(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise; updateOAuth2TradeshiftSandbox( - paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + oauth2ClientId?: string, + oauth2ClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2TradeshiftSandbox( + paramsOrFirst?: + | { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + let params: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; } else { params = { oauth2ClientId: paramsOrFirst as string, oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const oauth2ClientId = params.oauth2ClientId; const oauth2ClientSecret = params.oauth2ClientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/tradeshiftBox'; const payload: Payload = {}; if (typeof oauth2ClientId !== 'undefined') { @@ -3722,15 +5116,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3742,7 +5131,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Twitch(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Twitch(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Twitch configuration. * @@ -3753,28 +5146,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Twitch(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Twitch( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Twitch( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/twitch'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3791,15 +5202,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3811,7 +5217,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2WordPress(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2WordPress(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 WordPress configuration. * @@ -3822,28 +5232,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2WordPress(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2WordPress( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2WordPress( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/wordpress'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3860,15 +5288,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3880,7 +5303,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2X(params?: { customerKey?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2X(params?: { + customerKey?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 X configuration. * @@ -3891,28 +5318,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2X(customerKey?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2X( - paramsOrFirst?: { customerKey?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + customerKey?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2X( + paramsOrFirst?: + | { customerKey?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { customerKey?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { customerKey?: string, secretKey?: string, enabled?: boolean }; + let params: { + customerKey?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + customerKey?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { customerKey: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const customerKey = params.customerKey; const secretKey = params.secretKey; const enabled = params.enabled; - const apiPath = '/project/oauth2/x'; const payload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -3929,15 +5374,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3949,7 +5389,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Yahoo(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Yahoo(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Yahoo configuration. * @@ -3960,28 +5404,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Yahoo(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Yahoo( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Yahoo( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/yahoo'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3998,15 +5460,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4018,7 +5475,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Yandex(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Yandex(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Yandex configuration. * @@ -4029,28 +5490,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Yandex(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Yandex( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Yandex( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/yandex'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4067,15 +5546,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4087,7 +5561,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Zoho(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Zoho(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Zoho configuration. * @@ -4098,28 +5576,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Zoho(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Zoho( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Zoho( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/zoho'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4136,15 +5632,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4156,7 +5647,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Zoom(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Zoom(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Zoom configuration. * @@ -4167,28 +5662,46 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Zoom(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Zoom( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Zoom( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/zoom'; const payload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4205,15 +5718,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4221,52 +5729,201 @@ export class Project { * * @param {ProjectOAuthProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} - * @returns {Promise} - */ - getOAuth2Provider(params: { providerId: ProjectOAuthProviderId }): Promise; + * @returns {Promise} + */ + getOAuth2Provider(params: { + providerId: ProjectOAuthProviderId; + }): Promise< + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + | Models.OAuth2TikTok + | Models.OAuth2Kakao + >; /** * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. * * @param {ProjectOAuthProviderId} providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getOAuth2Provider(providerId: ProjectOAuthProviderId): Promise; getOAuth2Provider( - paramsOrFirst: { providerId: ProjectOAuthProviderId } | ProjectOAuthProviderId - ): Promise { + providerId: ProjectOAuthProviderId, + ): Promise< + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + | Models.OAuth2TikTok + | Models.OAuth2Kakao + >; + getOAuth2Provider( + paramsOrFirst: + { providerId: ProjectOAuthProviderId } | ProjectOAuthProviderId, + ): Promise< + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + | Models.OAuth2TikTok + | Models.OAuth2Kakao + > { let params: { providerId: ProjectOAuthProviderId }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('providerId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: ProjectOAuthProviderId }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'providerId' in paramsOrFirst + ) { + params = (paramsOrFirst || {}) as { + providerId: ProjectOAuthProviderId; + }; } else { params = { - providerId: paramsOrFirst as ProjectOAuthProviderId + providerId: paramsOrFirst as ProjectOAuthProviderId, }; } - + const providerId = params.providerId; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/project/oauth2/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); + const apiPath = '/project/oauth2/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4277,7 +5934,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listPlatforms(params?: { queries?: string[], total?: boolean }): Promise; + listPlatforms(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. * @@ -4287,26 +5947,36 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listPlatforms(queries?: string[], total?: boolean): Promise; listPlatforms( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listPlatforms( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/platforms'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -4319,15 +5989,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -4339,7 +6004,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + createAndroidPlatform(params: { + platformId: string; + name: string; + applicationId: string; + }): Promise; /** * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. * @@ -4350,37 +6019,54 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; createAndroidPlatform( - paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + applicationId: string, + ): Promise; + createAndroidPlatform( + paramsOrFirst: + | { platformId: string; name: string; applicationId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, applicationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + let params: { platformId: string; name: string; applicationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + applicationId: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - applicationId: rest[1] as string + applicationId: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof applicationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "applicationId"'); + throw new AppwriteException( + 'Missing required parameter: "applicationId"', + ); } - const apiPath = '/project/platforms/android'; const payload: Payload = {}; if (typeof platformId !== 'undefined') { @@ -4397,15 +6083,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4417,7 +6098,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + updateAndroidPlatform(params: { + platformId: string; + name: string; + applicationId: string; + }): Promise; /** * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. * @@ -4428,38 +6113,58 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; updateAndroidPlatform( - paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + applicationId: string, + ): Promise; + updateAndroidPlatform( + paramsOrFirst: + | { platformId: string; name: string; applicationId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, applicationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + let params: { platformId: string; name: string; applicationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + applicationId: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - applicationId: rest[1] as string + applicationId: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof applicationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "applicationId"'); + throw new AppwriteException( + 'Missing required parameter: "applicationId"', + ); } - - const apiPath = '/project/platforms/android/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/android/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4472,15 +6177,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4492,7 +6192,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + createApplePlatform(params: { + platformId: string; + name: string; + bundleIdentifier: string; + }): Promise; /** * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. * @@ -4503,37 +6207,58 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; createApplePlatform( - paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + bundleIdentifier: string, + ): Promise; + createApplePlatform( + paramsOrFirst: + | { platformId: string; name: string; bundleIdentifier: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, bundleIdentifier: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + let params: { + platformId: string; + name: string; + bundleIdentifier: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + bundleIdentifier: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - bundleIdentifier: rest[1] as string + bundleIdentifier: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const bundleIdentifier = params.bundleIdentifier; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof bundleIdentifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + throw new AppwriteException( + 'Missing required parameter: "bundleIdentifier"', + ); } - const apiPath = '/project/platforms/apple'; const payload: Payload = {}; if (typeof platformId !== 'undefined') { @@ -4550,15 +6275,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4570,7 +6290,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + updateApplePlatform(params: { + platformId: string; + name: string; + bundleIdentifier: string; + }): Promise; /** * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. * @@ -4581,38 +6305,62 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; updateApplePlatform( - paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + bundleIdentifier: string, + ): Promise; + updateApplePlatform( + paramsOrFirst: + | { platformId: string; name: string; bundleIdentifier: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, bundleIdentifier: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + let params: { + platformId: string; + name: string; + bundleIdentifier: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + bundleIdentifier: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - bundleIdentifier: rest[1] as string + bundleIdentifier: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const bundleIdentifier = params.bundleIdentifier; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof bundleIdentifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + throw new AppwriteException( + 'Missing required parameter: "bundleIdentifier"', + ); } - - const apiPath = '/project/platforms/apple/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/apple/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4625,15 +6373,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4645,7 +6388,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + createLinuxPlatform(params: { + platformId: string; + name: string; + packageName: string; + }): Promise; /** * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. * @@ -4656,37 +6403,53 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLinuxPlatform(platformId: string, name: string, packageName: string): Promise; createLinuxPlatform( - paramsOrFirst: { platformId: string, name: string, packageName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageName: string, + ): Promise; + createLinuxPlatform( + paramsOrFirst: + { platformId: string; name: string; packageName: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + let params: { platformId: string; name: string; packageName: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageName: rest[1] as string + packageName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageName = params.packageName; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageName"'); + throw new AppwriteException( + 'Missing required parameter: "packageName"', + ); } - const apiPath = '/project/platforms/linux'; const payload: Payload = {}; if (typeof platformId !== 'undefined') { @@ -4703,15 +6466,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4723,7 +6481,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + updateLinuxPlatform(params: { + platformId: string; + name: string; + packageName: string; + }): Promise; /** * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. * @@ -4734,38 +6496,57 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLinuxPlatform(platformId: string, name: string, packageName: string): Promise; updateLinuxPlatform( - paramsOrFirst: { platformId: string, name: string, packageName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageName: string, + ): Promise; + updateLinuxPlatform( + paramsOrFirst: + { platformId: string; name: string; packageName: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + let params: { platformId: string; name: string; packageName: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageName: rest[1] as string + packageName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageName = params.packageName; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageName"'); + throw new AppwriteException( + 'Missing required parameter: "packageName"', + ); } - - const apiPath = '/project/platforms/linux/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/linux/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4778,15 +6559,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4798,7 +6574,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + createWebPlatform(params: { + platformId: string; + name: string; + hostname: string; + }): Promise; /** * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. * @@ -4809,37 +6589,53 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createWebPlatform(platformId: string, name: string, hostname: string): Promise; createWebPlatform( - paramsOrFirst: { platformId: string, name: string, hostname: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + hostname: string, + ): Promise; + createWebPlatform( + paramsOrFirst: + { platformId: string; name: string; hostname: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, hostname: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + let params: { platformId: string; name: string; hostname: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + hostname: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - hostname: rest[1] as string + hostname: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const hostname = params.hostname; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof hostname === 'undefined') { - throw new AppwriteException('Missing required parameter: "hostname"'); + throw new AppwriteException( + 'Missing required parameter: "hostname"', + ); } - const apiPath = '/project/platforms/web'; const payload: Payload = {}; if (typeof platformId !== 'undefined') { @@ -4856,15 +6652,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4876,7 +6667,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + updateWebPlatform(params: { + platformId: string; + name: string; + hostname: string; + }): Promise; /** * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. * @@ -4887,38 +6682,57 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateWebPlatform(platformId: string, name: string, hostname: string): Promise; updateWebPlatform( - paramsOrFirst: { platformId: string, name: string, hostname: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + hostname: string, + ): Promise; + updateWebPlatform( + paramsOrFirst: + { platformId: string; name: string; hostname: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, hostname: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + let params: { platformId: string; name: string; hostname: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + hostname: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - hostname: rest[1] as string + hostname: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const hostname = params.hostname; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof hostname === 'undefined') { - throw new AppwriteException('Missing required parameter: "hostname"'); + throw new AppwriteException( + 'Missing required parameter: "hostname"', + ); } - - const apiPath = '/project/platforms/web/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/web/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -4931,15 +6745,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -4951,7 +6760,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + createWindowsPlatform(params: { + platformId: string; + name: string; + packageIdentifierName: string; + }): Promise; /** * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. * @@ -4962,37 +6775,62 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; createWindowsPlatform( - paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageIdentifierName: string, + ): Promise; + createWindowsPlatform( + paramsOrFirst: + | { + platformId: string; + name: string; + packageIdentifierName: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageIdentifierName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + let params: { + platformId: string; + name: string; + packageIdentifierName: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageIdentifierName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageIdentifierName: rest[1] as string + packageIdentifierName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageIdentifierName = params.packageIdentifierName; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageIdentifierName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + throw new AppwriteException( + 'Missing required parameter: "packageIdentifierName"', + ); } - const apiPath = '/project/platforms/windows'; const payload: Payload = {}; if (typeof platformId !== 'undefined') { @@ -5009,15 +6847,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -5029,7 +6862,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + updateWindowsPlatform(params: { + platformId: string; + name: string; + packageIdentifierName: string; + }): Promise; /** * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. * @@ -5040,38 +6877,66 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; updateWindowsPlatform( - paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageIdentifierName: string, + ): Promise; + updateWindowsPlatform( + paramsOrFirst: + | { + platformId: string; + name: string; + packageIdentifierName: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageIdentifierName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + let params: { + platformId: string; + name: string; + packageIdentifierName: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageIdentifierName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageIdentifierName: rest[1] as string + packageIdentifierName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageIdentifierName = params.packageIdentifierName; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageIdentifierName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + throw new AppwriteException( + 'Missing required parameter: "packageIdentifierName"', + ); } - - const apiPath = '/project/platforms/windows/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/windows/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -5084,15 +6949,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -5102,7 +6962,15 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - getPlatform(params: { platformId: string }): Promise; + getPlatform(params: { + platformId: string; + }): Promise< + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + >; /** * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. * @@ -5111,41 +6979,58 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPlatform(platformId: string): Promise; getPlatform( - paramsOrFirst: { platformId: string } | string - ): Promise { + platformId: string, + ): Promise< + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + >; + getPlatform( + paramsOrFirst: { platformId: string } | string, + ): Promise< + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + > { let params: { platformId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { platformId: string }; } else { params = { - platformId: paramsOrFirst as string + platformId: paramsOrFirst as string, }; } - + const platformId = params.platformId; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } - - const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5166,39 +7051,43 @@ export class Project { */ deletePlatform(platformId: string): Promise<{}>; deletePlatform( - paramsOrFirst: { platformId: string } | string + paramsOrFirst: { platformId: string } | string, ): Promise<{}> { let params: { platformId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { platformId: string }; } else { params = { - platformId: paramsOrFirst as string + platformId: paramsOrFirst as string, }; } - + const platformId = params.platformId; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof platformId === 'undefined' || platformId === '') { + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } - - const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); + const apiPath = '/project/platforms/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -5209,7 +7098,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listPolicies(params?: { queries?: string[], total?: boolean }): Promise; + listPolicies(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all project policies and their current configuration. * @@ -5219,26 +7111,36 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listPolicies(queries?: string[], total?: boolean): Promise; listPolicies( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listPolicies( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/policies'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -5251,15 +7153,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5269,7 +7166,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyAliasedEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyAliasedEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if aliased emails such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. * @@ -5280,24 +7179,29 @@ export class Project { */ updateDenyAliasedEmailPolicy(enabled: boolean): Promise; updateDenyAliasedEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-aliased-email'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5308,15 +7212,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5326,7 +7225,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyCorporateEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyCorporateEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if only corporate email addresses (non-free and non-disposable domains) are allowed during new user sign-ups and email updates. * @@ -5337,24 +7238,29 @@ export class Project { */ updateDenyCorporateEmailPolicy(enabled: boolean): Promise; updateDenyCorporateEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-corporate-email'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5365,15 +7271,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5383,7 +7284,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyDisposableEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyDisposableEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if disposable emails from known temporary domains are denied during new users sign-ups and email updates. * @@ -5394,24 +7297,29 @@ export class Project { */ updateDenyDisposableEmailPolicy(enabled: boolean): Promise; updateDenyDisposableEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-disposable-email'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5422,15 +7330,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5440,7 +7343,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyFreeEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyFreeEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. * @@ -5451,24 +7356,29 @@ export class Project { */ updateDenyFreeEmailPolicy(enabled: boolean): Promise; updateDenyFreeEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-free-email'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5479,15 +7389,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5502,7 +7407,14 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateMembershipPrivacyPolicy(params?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean }): Promise; + updateMembershipPrivacyPolicy(params?: { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + }): Promise; /** * Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. * @@ -5516,15 +7428,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembershipPrivacyPolicy(userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean): Promise; updateMembershipPrivacyPolicy( - paramsOrFirst?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean } | boolean, - ...rest: [(boolean)?, (boolean)?, (boolean)?, (boolean)?, (boolean)?] + userId?: boolean, + userEmail?: boolean, + userPhone?: boolean, + userName?: boolean, + userMFA?: boolean, + userAccessedAt?: boolean, + ): Promise; + updateMembershipPrivacyPolicy( + paramsOrFirst?: + | { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + } + | boolean, + ...rest: [boolean?, boolean?, boolean?, boolean?, boolean?] ): Promise { - let params: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean }; + let params: { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + }; } else { params = { userId: paramsOrFirst as boolean, @@ -5532,10 +7479,10 @@ export class Project { userPhone: rest[1] as boolean, userName: rest[2] as boolean, userMFA: rest[3] as boolean, - userAccessedAt: rest[4] as boolean + userAccessedAt: rest[4] as boolean, }; } - + const userId = params.userId; const userEmail = params.userEmail; const userPhone = params.userPhone; @@ -5543,7 +7490,6 @@ export class Project { const userMFA = params.userMFA; const userAccessedAt = params.userAccessedAt; - const apiPath = '/project/policies/membership-privacy'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -5569,15 +7515,112 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + + /** + * Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. + * + * @param {boolean} params.totp - Set to true to allow TOTP to complete an MFA challenge, or false to disable it. + * @param {boolean} params.email - Set to true to allow email to complete an MFA challenge, or false to disable it. + * @param {boolean} params.phone - Set to true to allow phone (SMS) to complete an MFA challenge, or false to disable it. + * @param {boolean} params.custom - Set to true to allow the custom factor to complete an MFA challenge, or false to disable it. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMFAFactorsPolicy(params?: { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + }): Promise; + /** + * Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. + * + * @param {boolean} totp - Set to true to allow TOTP to complete an MFA challenge, or false to disable it. + * @param {boolean} email - Set to true to allow email to complete an MFA challenge, or false to disable it. + * @param {boolean} phone - Set to true to allow phone (SMS) to complete an MFA challenge, or false to disable it. + * @param {boolean} custom - Set to true to allow the custom factor to complete an MFA challenge, or false to disable it. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFAFactorsPolicy( + totp?: boolean, + email?: boolean, + phone?: boolean, + custom?: boolean, + ): Promise; + updateMFAFactorsPolicy( + paramsOrFirst?: + | { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + } + | boolean, + ...rest: [boolean?, boolean?, boolean?] + ): Promise { + let params: { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + }; + } else { + params = { + totp: paramsOrFirst as boolean, + email: rest[0] as boolean, + phone: rest[1] as boolean, + custom: rest[2] as boolean, + }; } - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + const totp = params.totp; + const email = params.email; + const phone = params.phone; + const custom = params.custom; + + const apiPath = '/project/policies/mfa-factors'; + const payload: Payload = {}; + if (typeof totp !== 'undefined') { + payload['totp'] = totp; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof phone !== 'undefined') { + payload['phone'] = phone; + } + if (typeof custom !== 'undefined') { + payload['custom'] = custom; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5587,7 +7630,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordDictionaryPolicy(params: { enabled: boolean }): Promise; + updatePasswordDictionaryPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. * @@ -5598,24 +7643,29 @@ export class Project { */ updatePasswordDictionaryPolicy(enabled: boolean): Promise; updatePasswordDictionaryPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/password-dictionary'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5626,30 +7676,27 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. - * + * * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. * * @param {number} params.total - Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordHistoryPolicy(params: { total?: number }): Promise; + updatePasswordHistoryPolicy(params: { + total?: number; + }): Promise; /** * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. - * + * * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. * * @param {number} total - Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. @@ -5659,24 +7706,27 @@ export class Project { */ updatePasswordHistoryPolicy(total?: number): Promise; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number + paramsOrFirst?: { total?: number } | number, ): Promise { let params: { total?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { total?: number }; } else { params = { - total: paramsOrFirst as number + total: paramsOrFirst as number, }; } - + const total = params.total; if (typeof total === 'undefined') { throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/policies/password-history'; const payload: Payload = {}; if (typeof total !== 'undefined') { @@ -5687,15 +7737,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5705,7 +7750,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordPersonalDataPolicy(params: { enabled: boolean }): Promise; + updatePasswordPersonalDataPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. * @@ -5716,24 +7763,29 @@ export class Project { */ updatePasswordPersonalDataPolicy(enabled: boolean): Promise; updatePasswordPersonalDataPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/password-personal-data'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5744,15 +7796,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5766,7 +7813,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordStrengthPolicy(params?: { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean }): Promise; + updatePasswordStrengthPolicy(params?: { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + }): Promise; /** * Update the password strength requirements for users in the project. * @@ -5779,32 +7832,62 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordStrengthPolicy(min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean): Promise; updatePasswordStrengthPolicy( - paramsOrFirst?: { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean } | number, - ...rest: [(boolean)?, (boolean)?, (boolean)?, (boolean)?] + min?: number, + uppercase?: boolean, + lowercase?: boolean, + number?: boolean, + symbols?: boolean, + ): Promise; + updatePasswordStrengthPolicy( + paramsOrFirst?: + | { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + } + | number, + ...rest: [boolean?, boolean?, boolean?, boolean?] ): Promise { - let params: { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean }; + let params: { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + }; } else { params = { min: paramsOrFirst as number, uppercase: rest[0] as boolean, lowercase: rest[1] as boolean, number: rest[2] as boolean, - symbols: rest[3] as boolean + symbols: rest[3] as boolean, }; } - + const min = params.min; const uppercase = params.uppercase; const lowercase = params.lowercase; const number = params.number; const symbols = params.symbols; - const apiPath = '/project/policies/password-strength'; const payload: Payload = {}; if (typeof min !== 'undefined') { @@ -5827,15 +7910,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5845,7 +7923,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionAlertPolicy(params: { enabled: boolean }): Promise; + updateSessionAlertPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. * @@ -5856,24 +7936,29 @@ export class Project { */ updateSessionAlertPolicy(enabled: boolean): Promise; updateSessionAlertPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/session-alert'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5884,15 +7969,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5902,7 +7982,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionDurationPolicy(params: { duration: number }): Promise; + updateSessionDurationPolicy(params: { + duration: number; + }): Promise; /** * Update maximum duration how long sessions created within a project should stay active for. * @@ -5913,24 +7995,29 @@ export class Project { */ updateSessionDurationPolicy(duration: number): Promise; updateSessionDurationPolicy( - paramsOrFirst: { duration: number } | number + paramsOrFirst: { duration: number } | number, ): Promise { let params: { duration: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { duration: number }; } else { params = { - duration: paramsOrFirst as number + duration: paramsOrFirst as number, }; } - + const duration = params.duration; if (typeof duration === 'undefined') { - throw new AppwriteException('Missing required parameter: "duration"'); + throw new AppwriteException( + 'Missing required parameter: "duration"', + ); } - const apiPath = '/project/policies/session-duration'; const payload: Payload = {}; if (typeof duration !== 'undefined') { @@ -5941,15 +8028,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5959,7 +8041,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionInvalidationPolicy(params: { enabled: boolean }): Promise; + updateSessionInvalidationPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. * @@ -5970,24 +8054,29 @@ export class Project { */ updateSessionInvalidationPolicy(enabled: boolean): Promise; updateSessionInvalidationPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/session-invalidation'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { @@ -5998,15 +8087,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6016,7 +8100,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionLimitPolicy(params: { total: number }): Promise; + updateSessionLimitPolicy(params: { + total: number; + }): Promise; /** * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. * @@ -6027,24 +8113,27 @@ export class Project { */ updateSessionLimitPolicy(total: number): Promise; updateSessionLimitPolicy( - paramsOrFirst: { total: number } | number + paramsOrFirst: { total: number } | number, ): Promise { let params: { total: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { total: number }; } else { params = { - total: paramsOrFirst as number + total: paramsOrFirst as number, }; } - + const total = params.total; if (typeof total === 'undefined') { throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/policies/session-limit'; const payload: Payload = {}; if (typeof total !== 'undefined') { @@ -6055,15 +8144,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6084,24 +8168,27 @@ export class Project { */ updateUserLimitPolicy(total?: number): Promise; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number + paramsOrFirst?: { total?: number } | number, ): Promise { let params: { total?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { total?: number }; } else { params = { - total: paramsOrFirst as number + total: paramsOrFirst as number, }; } - + const total = params.total; if (typeof total === 'undefined') { throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/policies/user-limit'; const payload: Payload = {}; if (typeof total !== 'undefined') { @@ -6112,81 +8199,135 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * 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, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. - * @throws {AppwriteException} - * @returns {Promise} - */ - getPolicy(params: { policyId: ProjectPolicyId }): Promise; + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPolicy(params: { + policyId: ProjectPolicyId; + }): Promise< + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, 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, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPolicy(policyId: ProjectPolicyId): Promise; getPolicy( - paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId - ): Promise { + policyId: ProjectPolicyId, + ): Promise< + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + >; + getPolicy( + paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, + ): Promise< + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + > { let params: { policyId: ProjectPolicyId }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('policyId' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'policyId' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { policyId: ProjectPolicyId }; } else { params = { - policyId: paramsOrFirst as ProjectPolicyId + policyId: paramsOrFirst as ProjectPolicyId, }; } - + const policyId = params.policyId; if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/project/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPath = '/project/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. * * @param {ProjectProtocolId} params.protocolId - Protocol name. Can be one of: rest, graphql, websocket * @param {boolean} params.enabled - Protocol status. * @throws {AppwriteException} * @returns {Promise} */ - updateProtocol(params: { protocolId: ProjectProtocolId, enabled: boolean }): Promise; + updateProtocol(params: { + protocolId: ProjectProtocolId; + enabled: boolean; + }): Promise; /** - * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. * * @param {ProjectProtocolId} protocolId - Protocol name. Can be one of: rest, graphql, websocket * @param {boolean} enabled - Protocol status. @@ -6194,33 +8335,52 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateProtocol(protocolId: ProjectProtocolId, enabled: boolean): Promise; updateProtocol( - paramsOrFirst: { protocolId: ProjectProtocolId, enabled: boolean } | ProjectProtocolId, - ...rest: [(boolean)?] + protocolId: ProjectProtocolId, + enabled: boolean, + ): Promise; + updateProtocol( + paramsOrFirst: + | { protocolId: ProjectProtocolId; enabled: boolean } + | ProjectProtocolId, + ...rest: [boolean?] ): Promise { - let params: { protocolId: ProjectProtocolId, enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { protocolId: ProjectProtocolId, enabled: boolean }; + let params: { protocolId: ProjectProtocolId; enabled: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + protocolId: ProjectProtocolId; + enabled: boolean; + }; } else { params = { protocolId: paramsOrFirst as ProjectProtocolId, - enabled: rest[0] as boolean + enabled: rest[0] as boolean, }; } - + const protocolId = params.protocolId; const enabled = params.enabled; if (typeof protocolId === 'undefined') { - throw new AppwriteException('Missing required parameter: "protocolId"'); + throw new AppwriteException( + 'Missing required parameter: "protocolId"', + ); } if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - - const apiPath = '/project/protocols/{protocolId}'.replace('{protocolId}', encodeURIComponent(String(protocolId))); + const apiPath = '/project/protocols/{protocolId}'.replace( + '{protocolId}', + encodeURIComponent(String(protocolId)), + ); const payload: Payload = {}; if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; @@ -6230,28 +8390,26 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** - * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * * @param {ProjectServiceId} params.serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor, oauth2 * @param {boolean} params.enabled - Service status. * @throws {AppwriteException} * @returns {Promise} */ - updateService(params: { serviceId: ProjectServiceId, enabled: boolean }): Promise; + updateService(params: { + serviceId: ProjectServiceId; + enabled: boolean; + }): Promise; /** - * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * * @param {ProjectServiceId} serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor, oauth2 * @param {boolean} enabled - Service status. @@ -6259,33 +8417,52 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateService(serviceId: ProjectServiceId, enabled: boolean): Promise; updateService( - paramsOrFirst: { serviceId: ProjectServiceId, enabled: boolean } | ProjectServiceId, - ...rest: [(boolean)?] + serviceId: ProjectServiceId, + enabled: boolean, + ): Promise; + updateService( + paramsOrFirst: + | { serviceId: ProjectServiceId; enabled: boolean } + | ProjectServiceId, + ...rest: [boolean?] ): Promise { - let params: { serviceId: ProjectServiceId, enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { serviceId: ProjectServiceId, enabled: boolean }; + let params: { serviceId: ProjectServiceId; enabled: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + serviceId: ProjectServiceId; + enabled: boolean; + }; } else { params = { serviceId: paramsOrFirst as ProjectServiceId, - enabled: rest[0] as boolean + enabled: rest[0] as boolean, }; } - + const serviceId = params.serviceId; const enabled = params.enabled; if (typeof serviceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "serviceId"'); + throw new AppwriteException( + 'Missing required parameter: "serviceId"', + ); } if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - - const apiPath = '/project/services/{serviceId}'.replace('{serviceId}', encodeURIComponent(String(serviceId))); + const apiPath = '/project/services/{serviceId}'.replace( + '{serviceId}', + encodeURIComponent(String(serviceId)), + ); const payload: Payload = {}; if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; @@ -6295,15 +8472,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6322,7 +8494,18 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSMTP(params?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }): Promise; + updateSMTP(params?: { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + }): Promise; /** * Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. * @@ -6340,15 +8523,76 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMTP(host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean): Promise; updateSMTP( - paramsOrFirst?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean } | string, - ...rest: [(number)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (ProjectSMTPSecure)?, (boolean)?] + host?: string, + port?: number, + username?: string, + password?: string, + senderEmail?: string, + senderName?: string, + replyToEmail?: string, + replyToName?: string, + secure?: ProjectSMTPSecure, + enabled?: boolean, + ): Promise; + updateSMTP( + paramsOrFirst?: + | { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + } + | string, + ...rest: [ + number?, + string?, + string?, + string?, + string?, + string?, + string?, + ProjectSMTPSecure?, + boolean?, + ] ): Promise { - let params: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; + let params: { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + }; } else { params = { host: paramsOrFirst as string, @@ -6360,10 +8604,10 @@ export class Project { replyToEmail: rest[5] as string, replyToName: rest[6] as string, secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean + enabled: rest[8] as boolean, }; } - + const host = params.host; const port = params.port; const username = params.username; @@ -6375,7 +8619,6 @@ export class Project { const secure = params.secure; const enabled = params.enabled; - const apiPath = '/project/smtp'; const payload: Payload = {}; if (typeof host !== 'undefined') { @@ -6413,19 +8656,14 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** - * Send a test email to verify SMTP configuration. + * Send a test email to verify SMTP configuration. * * @param {string[]} params.emails - Array of emails to send test email to. Maximum of 10 emails are allowed. * @throws {AppwriteException} @@ -6433,7 +8671,7 @@ export class Project { */ createSMTPTest(params: { emails: string[] }): Promise<{}>; /** - * Send a test email to verify SMTP configuration. + * Send a test email to verify SMTP configuration. * * @param {string[]} emails - Array of emails to send test email to. Maximum of 10 emails are allowed. * @throws {AppwriteException} @@ -6442,24 +8680,27 @@ export class Project { */ createSMTPTest(emails: string[]): Promise<{}>; createSMTPTest( - paramsOrFirst: { emails: string[] } | string[] + paramsOrFirst: { emails: string[] } | string[], ): Promise<{}> { let params: { emails: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { emails: string[] }; } else { params = { - emails: paramsOrFirst as string[] + emails: paramsOrFirst as string[], }; } - + const emails = params.emails; if (typeof emails === 'undefined') { throw new AppwriteException('Missing required parameter: "emails"'); } - const apiPath = '/project/smtp/tests'; const payload: Payload = {}; if (typeof emails !== 'undefined') { @@ -6470,14 +8711,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -6488,7 +8725,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listEmailTemplates(params?: { queries?: string[], total?: boolean }): Promise; + listEmailTemplates(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. * @@ -6498,26 +8738,36 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listEmailTemplates(queries?: string[], total?: boolean): Promise; listEmailTemplates( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listEmailTemplates( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/templates/email'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -6530,15 +8780,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -6555,7 +8800,16 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }): Promise; + updateEmailTemplate(params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + }): Promise; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * @@ -6571,15 +8825,73 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string): Promise; updateEmailTemplate( - paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string } | ProjectEmailTemplateId, - ...rest: [(ProjectEmailTemplateLocale)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + templateId: ProjectEmailTemplateId, + locale?: ProjectEmailTemplateLocale, + subject?: string, + message?: string, + senderName?: string, + senderEmail?: string, + replyToEmail?: string, + replyToName?: string, + ): Promise; + updateEmailTemplate( + paramsOrFirst: + | { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + } + | ProjectEmailTemplateId, + ...rest: [ + ProjectEmailTemplateLocale?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst || 'subject' in paramsOrFirst || 'message' in paramsOrFirst || 'senderName' in paramsOrFirst || 'senderEmail' in paramsOrFirst || 'replyToEmail' in paramsOrFirst || 'replyToName' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; + let params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('templateId' in paramsOrFirst || + 'locale' in paramsOrFirst || + 'subject' in paramsOrFirst || + 'message' in paramsOrFirst || + 'senderName' in paramsOrFirst || + 'senderEmail' in paramsOrFirst || + 'replyToEmail' in paramsOrFirst || + 'replyToName' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, @@ -6589,10 +8901,10 @@ export class Project { senderName: rest[3] as string, senderEmail: rest[4] as string, replyToEmail: rest[5] as string, - replyToName: rest[6] as string + replyToName: rest[6] as string, }; } - + const templateId = params.templateId; const locale = params.locale; const subject = params.subject; @@ -6603,9 +8915,10 @@ export class Project { const replyToName = params.replyToName; if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - const apiPath = '/project/templates/email'; const payload: Payload = {}; if (typeof templateId !== 'undefined') { @@ -6637,15 +8950,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6656,7 +8964,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - getEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }): Promise; + getEmailTemplate(params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }): Promise; /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * @@ -6666,30 +8977,53 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale): Promise; getEmailTemplate( - paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale } | ProjectEmailTemplateId, - ...rest: [(ProjectEmailTemplateLocale)?] + templateId: ProjectEmailTemplateId, + locale?: ProjectEmailTemplateLocale, + ): Promise; + getEmailTemplate( + paramsOrFirst: + | { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + } + | ProjectEmailTemplateId, + ...rest: [ProjectEmailTemplateLocale?] ): Promise { - let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + let params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, - locale: rest[0] as ProjectEmailTemplateLocale + locale: rest[0] as ProjectEmailTemplateLocale, }; } - + const templateId = params.templateId; const locale = params.locale; if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - - const apiPath = '/project/templates/email/{templateId}'.replace('{templateId}', encodeURIComponent(String(templateId))); + const apiPath = '/project/templates/email/{templateId}'.replace( + '{templateId}', + encodeURIComponent(String(templateId)), + ); const payload: Payload = {}; if (typeof locale !== 'undefined') { payload['locale'] = locale; @@ -6698,15 +9032,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -6718,7 +9047,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - getUsage(params: { startDate: string, endDate: string, period?: ProjectUsageRange }): Promise; + getUsage(params: { + startDate: string; + endDate: string; + period?: ProjectUsageRange; + }): Promise; /** * Get comprehensive usage statistics for your project. View metrics including network requests, bandwidth, storage, function executions, database usage, and user activity. Specify a time range with startDate and endDate, and optionally set the data granularity with period (1h or 1d). The response includes both total counts and detailed breakdowns by resource, along with historical data over the specified period. * @@ -6729,34 +9062,55 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getUsage(startDate: string, endDate: string, period?: ProjectUsageRange): Promise; getUsage( - paramsOrFirst: { startDate: string, endDate: string, period?: ProjectUsageRange } | string, - ...rest: [(string)?, (ProjectUsageRange)?] + startDate: string, + endDate: string, + period?: ProjectUsageRange, + ): Promise; + getUsage( + paramsOrFirst: + | { startDate: string; endDate: string; period?: ProjectUsageRange } + | string, + ...rest: [string?, ProjectUsageRange?] ): Promise { - let params: { startDate: string, endDate: string, period?: ProjectUsageRange }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { startDate: string, endDate: string, period?: ProjectUsageRange }; + let params: { + startDate: string; + endDate: string; + period?: ProjectUsageRange; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + startDate: string; + endDate: string; + period?: ProjectUsageRange; + }; } else { params = { startDate: paramsOrFirst as string, endDate: rest[0] as string, - period: rest[1] as ProjectUsageRange + period: rest[1] as ProjectUsageRange, }; } - + const startDate = params.startDate; const endDate = params.endDate; const period = params.period; if (typeof startDate === 'undefined') { - throw new AppwriteException('Missing required parameter: "startDate"'); + throw new AppwriteException( + 'Missing required parameter: "startDate"', + ); } if (typeof endDate === 'undefined') { - throw new AppwriteException('Missing required parameter: "endDate"'); + throw new AppwriteException( + 'Missing required parameter: "endDate"', + ); } - const apiPath = '/project/usage'; const payload: Payload = {}; if (typeof startDate !== 'undefined') { @@ -6772,15 +9126,10 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -6791,7 +9140,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params?: { queries?: string[], total?: boolean }): Promise; + listVariables(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all project environment variables. * @@ -6801,26 +9153,36 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listVariables( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/project/variables'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -6833,64 +9195,92 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * * @param {string} params.variableId - Variable unique ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { variableId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { + variableId: string; + key: string; + value: string; + secret?: boolean; + }): Promise; /** * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * * @param {string} variableId - Variable unique ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { variableId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + variableId: string, + key: string, + value: string, + secret?: boolean, + ): Promise; + createVariable( + paramsOrFirst: + | { + variableId: string; + key: string; + value: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { variableId: string, key: string, value: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { variableId: string, key: string, value: string, secret?: boolean }; + let params: { + variableId: string; + key: string; + value: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + variableId: string; + key: string; + value: string; + secret?: boolean; + }; } else { params = { variableId: paramsOrFirst as string, key: rest[0] as string, value: rest[1] as string, - secret: rest[2] as boolean + secret: rest[2] as boolean, }; } - + const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -6898,7 +9288,6 @@ export class Project { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } - const apiPath = '/project/variables'; const payload: Payload = {}; if (typeof variableId !== 'undefined') { @@ -6918,19 +9307,14 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Get a variable by its unique ID. + * Get a variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} @@ -6938,7 +9322,7 @@ export class Project { */ getVariable(params: { variableId: string }): Promise; /** - * Get a variable by its unique ID. + * Get a variable by its unique ID. * * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} @@ -6947,91 +9331,129 @@ export class Project { */ getVariable(variableId: string): Promise; getVariable( - paramsOrFirst: { variableId: string } | string + paramsOrFirst: { variableId: string } | string, ): Promise { let params: { variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { variableId: string }; } else { params = { - variableId: paramsOrFirst as string + variableId: paramsOrFirst as string, }; } - + const variableId = params.variableId; - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/project/variables/{variableId}'.replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/project/variables/{variableId}'.replace( + '{variableId}', + encodeURIComponent(String(variableId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }): Promise; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { variableId: string, key?: string, value?: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + variableId: string, + key?: string, + value?: string, + secret?: boolean, + ): Promise; + updateVariable( + paramsOrFirst: + | { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { variableId: string, key?: string, value?: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { variableId: string, key?: string, value?: string, secret?: boolean }; + let params: { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; } else { params = { variableId: paramsOrFirst as string, key: rest[0] as string, value: rest[1] as string, - secret: rest[2] as boolean + secret: rest[2] as boolean, }; } - + const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/project/variables/{variableId}'.replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/project/variables/{variableId}'.replace( + '{variableId}', + encodeURIComponent(String(variableId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -7047,19 +9469,14 @@ export class Project { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Delete a variable by its unique ID. + * Delete a variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} @@ -7067,7 +9484,7 @@ export class Project { */ deleteVariable(params: { variableId: string }): Promise<{}>; /** - * Delete a variable by its unique ID. + * Delete a variable by its unique ID. * * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} @@ -7076,38 +9493,42 @@ export class Project { */ deleteVariable(variableId: string): Promise<{}>; deleteVariable( - paramsOrFirst: { variableId: string } | string + paramsOrFirst: { variableId: string } | string, ): Promise<{}> { let params: { variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { variableId: string }; } else { params = { - variableId: paramsOrFirst as string + variableId: paramsOrFirst as string, }; } - + const variableId = params.variableId; - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/project/variables/{variableId}'.replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/project/variables/{variableId}'.replace( + '{variableId}', + encodeURIComponent(String(variableId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/projects.ts b/src/services/projects.ts index ec11dbce..08737e7f 100644 --- a/src/services/projects.ts +++ b/src/services/projects.ts @@ -1,10 +1,8 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { ScheduleResourceType } from '../enums/schedule-resource-type'; import { Status } from '../enums/status'; - export class Projects { client: Client; @@ -14,7 +12,7 @@ export class Projects { /** * List all billing addons for a project. - * + * * * @param {string} params.projectId - Project ID * @throws {AppwriteException} @@ -23,7 +21,7 @@ export class Projects { listAddons(params: { projectId: string }): Promise; /** * List all billing addons for a project. - * + * * * @param {string} projectId - Project ID * @throws {AppwriteException} @@ -32,53 +30,58 @@ export class Projects { */ listAddons(projectId: string): Promise; listAddons( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - + const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/projects/{projectId}/addons'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/addons'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a Premium Geo DB addon for a project. - * + * * * @param {string} params.projectId - Project ID * @throws {AppwriteException} * @returns {Promise} */ - createPremiumGeoDBAddon(params: { projectId: string }): Promise; + createPremiumGeoDBAddon(params: { + projectId: string; + }): Promise; /** * Create a Premium Geo DB addon for a project. - * + * * * @param {string} projectId - Project ID * @throws {AppwriteException} @@ -87,55 +90,61 @@ export class Projects { */ createPremiumGeoDBAddon(projectId: string): Promise; createPremiumGeoDBAddon( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - + const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/projects/{projectId}/addons/premium-geo-db'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/addons/premium-geo-db'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get the details of a billing addon for a project. - * + * * * @param {string} params.projectId - Project ID * @param {string} params.addonId - Addon ID * @throws {AppwriteException} * @returns {Promise} */ - getAddon(params: { projectId: string, addonId: string }): Promise; + getAddon(params: { + projectId: string; + addonId: string; + }): Promise; /** * Get the details of a billing addon for a project. - * + * * * @param {string} projectId - Project ID * @param {string} addonId - Addon ID @@ -145,60 +154,67 @@ export class Projects { */ getAddon(projectId: string, addonId: string): Promise; getAddon( - paramsOrFirst: { projectId: string, addonId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; addonId: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, addonId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, addonId: string }; + let params: { projectId: string; addonId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + addonId: string; + }; } else { params = { projectId: paramsOrFirst as string, - addonId: rest[0] as string + addonId: rest[0] as string, }; } - + const projectId = params.projectId; const addonId = params.addonId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof addonId === 'undefined') { - throw new AppwriteException('Missing required parameter: "addonId"'); + if (typeof addonId === 'undefined' || addonId === '') { + throw new AppwriteException( + 'Missing required parameter: "addonId"', + ); } - - const apiPath = '/projects/{projectId}/addons/{addonId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{addonId}', encodeURIComponent(String(addonId))); + const apiPath = '/projects/{projectId}/addons/{addonId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{addonId}', encodeURIComponent(String(addonId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Delete a billing addon for a project. - * + * * * @param {string} params.projectId - Project ID * @param {string} params.addonId - Addon ID * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteAddon(params: { projectId: string, addonId: string }): Promise<{}>; + deleteAddon(params: { projectId: string; addonId: string }): Promise<{}>; /** * Delete a billing addon for a project. - * + * * * @param {string} projectId - Project ID * @param {string} addonId - Addon ID @@ -208,61 +224,71 @@ export class Projects { */ deleteAddon(projectId: string, addonId: string): Promise<{}>; deleteAddon( - paramsOrFirst: { projectId: string, addonId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; addonId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { projectId: string, addonId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, addonId: string }; + let params: { projectId: string; addonId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + addonId: string; + }; } else { params = { projectId: paramsOrFirst as string, - addonId: rest[0] as string + addonId: rest[0] as string, }; } - + const projectId = params.projectId; const addonId = params.addonId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof addonId === 'undefined') { - throw new AppwriteException('Missing required parameter: "addonId"'); + if (typeof addonId === 'undefined' || addonId === '') { + throw new AppwriteException( + 'Missing required parameter: "addonId"', + ); } - - const apiPath = '/projects/{projectId}/addons/{addonId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{addonId}', encodeURIComponent(String(addonId))); + const apiPath = '/projects/{projectId}/addons/{addonId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{addonId}', encodeURIComponent(String(addonId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Confirm payment for a billing addon for a project. - * + * * * @param {string} params.projectId - Project ID * @param {string} params.addonId - Addon ID * @throws {AppwriteException} * @returns {Promise} */ - confirmAddonPayment(params: { projectId: string, addonId: string }): Promise; + confirmAddonPayment(params: { + projectId: string; + addonId: string; + }): Promise; /** * Confirm payment for a billing addon for a project. - * + * * * @param {string} projectId - Project ID * @param {string} addonId - Addon ID @@ -270,63 +296,76 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - confirmAddonPayment(projectId: string, addonId: string): Promise; confirmAddonPayment( - paramsOrFirst: { projectId: string, addonId: string } | string, - ...rest: [(string)?] + projectId: string, + addonId: string, + ): Promise; + confirmAddonPayment( + paramsOrFirst: { projectId: string; addonId: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, addonId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, addonId: string }; + let params: { projectId: string; addonId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + addonId: string; + }; } else { params = { projectId: paramsOrFirst as string, - addonId: rest[0] as string + addonId: rest[0] as string, }; } - + const projectId = params.projectId; const addonId = params.addonId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof addonId === 'undefined') { - throw new AppwriteException('Missing required parameter: "addonId"'); + if (typeof addonId === 'undefined' || addonId === '') { + throw new AppwriteException( + 'Missing required parameter: "addonId"', + ); } - - const apiPath = '/projects/{projectId}/addons/{addonId}/confirmations'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{addonId}', encodeURIComponent(String(addonId))); + const apiPath = '/projects/{projectId}/addons/{addonId}/confirmations' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{addonId}', encodeURIComponent(String(addonId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get the price details for a billing addon for a project, including the prorated amount for the remaining days in the current billing cycle. - * + * * * @param {string} params.projectId - Project ID * @param {string} params.addon - Addon key identifier (e.g. premiumGeoDB). * @throws {AppwriteException} * @returns {Promise} */ - getAddonPrice(params: { projectId: string, addon: string }): Promise; + getAddonPrice(params: { + projectId: string; + addon: string; + }): Promise; /** * Get the price details for a billing addon for a project, including the prorated amount for the remaining days in the current billing cycle. - * + * * * @param {string} projectId - Project ID * @param {string} addon - Addon key identifier (e.g. premiumGeoDB). @@ -336,50 +375,55 @@ export class Projects { */ getAddonPrice(projectId: string, addon: string): Promise; getAddonPrice( - paramsOrFirst: { projectId: string, addon: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; addon: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, addon: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, addon: string }; + let params: { projectId: string; addon: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + addon: string; + }; } else { params = { projectId: paramsOrFirst as string, - addon: rest[0] as string + addon: rest[0] as string, }; } - + const projectId = params.projectId; const addon = params.addon; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof addon === 'undefined') { + if (typeof addon === 'undefined' || addon === '') { throw new AppwriteException('Missing required parameter: "addon"'); } - - const apiPath = '/projects/{projectId}/addons/{addon}/price'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{addon}', encodeURIComponent(String(addon))); + const apiPath = '/projects/{projectId}/addons/{addon}/price' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{addon}', encodeURIComponent(String(addon))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Record console access to a project. This endpoint updates the last accessed timestamp for the project to track console activity. - * + * * * @param {string} params.projectId - Project ID * @throws {AppwriteException} @@ -388,7 +432,7 @@ export class Projects { updateConsoleAccess(params: { projectId: string }): Promise<{}>; /** * Record console access to a project. This endpoint updates the last accessed timestamp for the project to track console activity. - * + * * * @param {string} projectId - Project ID * @throws {AppwriteException} @@ -397,40 +441,43 @@ export class Projects { */ updateConsoleAccess(projectId: string): Promise<{}>; updateConsoleAccess( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise<{}> { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - + const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/projects/{projectId}/console-access'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/console-access'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -441,7 +488,10 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - listDevKeys(params: { projectId: string, queries?: string[] }): Promise; + listDevKeys(params: { + projectId: string; + queries?: string[]; + }): Promise; /** * List all the project\'s dev keys. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development.' * @@ -451,30 +501,44 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listDevKeys(projectId: string, queries?: string[]): Promise; listDevKeys( - paramsOrFirst: { projectId: string, queries?: string[] } | string, - ...rest: [(string[])?] + projectId: string, + queries?: string[], + ): Promise; + listDevKeys( + paramsOrFirst: { projectId: string; queries?: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { projectId: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, queries?: string[] }; + let params: { projectId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + queries?: string[]; + }; } else { params = { projectId: paramsOrFirst as string, - queries: rest[0] as string[] + queries: rest[0] as string[], }; } - + const projectId = params.projectId; const queries = params.queries; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/projects/{projectId}/dev-keys'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/dev-keys'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -483,15 +547,10 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -502,7 +561,10 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - getDevKey(params: { projectId: string, keyId: string }): Promise; + getDevKey(params: { + projectId: string; + keyId: string; + }): Promise; /** * Get a project\'s dev key by its unique ID. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development. * @@ -514,45 +576,50 @@ export class Projects { */ getDevKey(projectId: string, keyId: string): Promise; getDevKey( - paramsOrFirst: { projectId: string, keyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; keyId: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, keyId: string }; + let params: { projectId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + }; } else { params = { projectId: paramsOrFirst as string, - keyId: rest[0] as string + keyId: rest[0] as string, }; } - + const projectId = params.projectId; const keyId = params.keyId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/projects/{projectId}/dev-keys/{keyId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/projects/{projectId}/dev-keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -565,7 +632,12 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - updateDevKey(params: { projectId: string, keyId: string, name: string, expire: string }): Promise; + updateDevKey(params: { + projectId: string; + keyId: string; + name: string; + expire: string; + }): Promise; /** * Update a project\'s dev key by its unique ID. Use this endpoint to update a project\'s dev key name or expiration time.' * @@ -577,33 +649,56 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDevKey(projectId: string, keyId: string, name: string, expire: string): Promise; updateDevKey( - paramsOrFirst: { projectId: string, keyId: string, name: string, expire: string } | string, - ...rest: [(string)?, (string)?, (string)?] + projectId: string, + keyId: string, + name: string, + expire: string, + ): Promise; + updateDevKey( + paramsOrFirst: + | { projectId: string; keyId: string; name: string; expire: string } + | string, + ...rest: [string?, string?, string?] ): Promise { - let params: { projectId: string, keyId: string, name: string, expire: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, keyId: string, name: string, expire: string }; + let params: { + projectId: string; + keyId: string; + name: string; + expire: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + name: string; + expire: string; + }; } else { params = { projectId: paramsOrFirst as string, keyId: rest[0] as string, name: rest[1] as string, - expire: rest[2] as string + expire: rest[2] as string, }; } - + const projectId = params.projectId; const keyId = params.keyId; const name = params.name; const expire = params.expire; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } if (typeof name === 'undefined') { @@ -612,8 +707,9 @@ export class Projects { if (typeof expire === 'undefined') { throw new AppwriteException('Missing required parameter: "expire"'); } - - const apiPath = '/projects/{projectId}/dev-keys/{keyId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/projects/{projectId}/dev-keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -626,15 +722,10 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -645,7 +736,7 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDevKey(params: { projectId: string, keyId: string }): Promise<{}>; + deleteDevKey(params: { projectId: string; keyId: string }): Promise<{}>; /** * Delete a project\'s dev key by its unique ID. Once deleted, the key will no longer allow bypassing of rate limits and better logging of errors. * @@ -657,45 +748,51 @@ export class Projects { */ deleteDevKey(projectId: string, keyId: string): Promise<{}>; deleteDevKey( - paramsOrFirst: { projectId: string, keyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; keyId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { projectId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, keyId: string }; + let params: { projectId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + }; } else { params = { projectId: paramsOrFirst as string, - keyId: rest[0] as string + keyId: rest[0] as string, }; } - + const projectId = params.projectId; const keyId = params.keyId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof keyId === 'undefined') { + if (typeof keyId === 'undefined' || keyId === '') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/projects/{projectId}/dev-keys/{keyId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPath = '/projects/{projectId}/dev-keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -707,7 +804,11 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - listSchedules(params: { projectId: string, queries?: string[], total?: boolean }): Promise; + listSchedules(params: { + projectId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the project's schedules. You can use the query params to filter your results. * @@ -718,32 +819,49 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSchedules(projectId: string, queries?: string[], total?: boolean): Promise; listSchedules( - paramsOrFirst: { projectId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + projectId: string, + queries?: string[], + total?: boolean, + ): Promise; + listSchedules( + paramsOrFirst: + { projectId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { projectId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, queries?: string[], total?: boolean }; + let params: { projectId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { projectId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const projectId = params.projectId; const queries = params.queries; const total = params.total; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/projects/{projectId}/schedules'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/schedules'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -755,15 +873,10 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -778,7 +891,14 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - createSchedule(params: { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }): Promise; + createSchedule(params: { + projectId: string; + resourceType: ScheduleResourceType; + resourceId: string; + schedule: string; + active?: boolean; + data?: object; + }): Promise; /** * Create a new schedule for a resource. * @@ -792,15 +912,49 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSchedule(projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object): Promise; createSchedule( - paramsOrFirst: { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object } | string, - ...rest: [(ScheduleResourceType)?, (string)?, (string)?, (boolean)?, (object)?] + projectId: string, + resourceType: ScheduleResourceType, + resourceId: string, + schedule: string, + active?: boolean, + data?: object, + ): Promise; + createSchedule( + paramsOrFirst: + | { + projectId: string; + resourceType: ScheduleResourceType; + resourceId: string; + schedule: string; + active?: boolean; + data?: object; + } + | string, + ...rest: [ScheduleResourceType?, string?, string?, boolean?, object?] ): Promise { - let params: { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }; + let params: { + projectId: string; + resourceType: ScheduleResourceType; + resourceId: string; + schedule: string; + active?: boolean; + data?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + resourceType: ScheduleResourceType; + resourceId: string; + schedule: string; + active?: boolean; + data?: object; + }; } else { params = { projectId: paramsOrFirst as string, @@ -808,10 +962,10 @@ export class Projects { resourceId: rest[1] as string, schedule: rest[2] as string, active: rest[3] as boolean, - data: rest[4] as object + data: rest[4] as object, }; } - + const projectId = params.projectId; const resourceType = params.resourceType; const resourceId = params.resourceId; @@ -819,20 +973,30 @@ export class Projects { const active = params.active; const data = params.data; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } if (typeof resourceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceId"'); + throw new AppwriteException( + 'Missing required parameter: "resourceId"', + ); } if (typeof schedule === 'undefined') { - throw new AppwriteException('Missing required parameter: "schedule"'); + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); } - - const apiPath = '/projects/{projectId}/schedules'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/schedules'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; if (typeof resourceType !== 'undefined') { payload['resourceType'] = resourceType; @@ -854,15 +1018,10 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -873,7 +1032,10 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - getSchedule(params: { projectId: string, scheduleId: string }): Promise; + getSchedule(params: { + projectId: string; + scheduleId: string; + }): Promise; /** * Get a schedule by its unique ID. * @@ -883,52 +1045,62 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getSchedule(projectId: string, scheduleId: string): Promise; getSchedule( - paramsOrFirst: { projectId: string, scheduleId: string } | string, - ...rest: [(string)?] + projectId: string, + scheduleId: string, + ): Promise; + getSchedule( + paramsOrFirst: { projectId: string; scheduleId: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, scheduleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, scheduleId: string }; + let params: { projectId: string; scheduleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + scheduleId: string; + }; } else { params = { projectId: paramsOrFirst as string, - scheduleId: rest[0] as string + scheduleId: rest[0] as string, }; } - + const projectId = params.projectId; const scheduleId = params.scheduleId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof scheduleId === 'undefined') { - throw new AppwriteException('Missing required parameter: "scheduleId"'); + if (typeof scheduleId === 'undefined' || scheduleId === '') { + throw new AppwriteException( + 'Missing required parameter: "scheduleId"', + ); } - - const apiPath = '/projects/{projectId}/schedules/{scheduleId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{scheduleId}', encodeURIComponent(String(scheduleId))); + const apiPath = '/projects/{projectId}/schedules/{scheduleId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{scheduleId}', encodeURIComponent(String(scheduleId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get the onboarding stages for the current project, including each stage’s SDK method key and status (for example pending, completed, or skipped). - * + * * * @param {string} params.projectId - Project unique ID. * @throws {AppwriteException} @@ -937,7 +1109,7 @@ export class Projects { listStages(params: { projectId: string }): Promise; /** * Get the onboarding stages for the current project, including each stage’s SDK method key and status (for example pending, completed, or skipped). - * + * * * @param {string} projectId - Project unique ID. * @throws {AppwriteException} @@ -946,44 +1118,47 @@ export class Projects { */ listStages(projectId: string): Promise; listStages( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - + const projectId = params.projectId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/projects/{projectId}/stages'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/stages'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Update an onboarding stage for the current project. Use this endpoint to skip a stage or leave it unchanged without performing the related API action. - * + * * * @param {string} params.projectId - Project unique ID. * @param {string} params.stageId - SDK method key (namespace.method). @@ -991,10 +1166,14 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - updateStage(params: { projectId: string, stageId: string, skip?: boolean }): Promise; + updateStage(params: { + projectId: string; + stageId: string; + skip?: boolean; + }): Promise; /** * Update an onboarding stage for the current project. Use this endpoint to skip a stage or leave it unchanged without performing the related API action. - * + * * * @param {string} projectId - Project unique ID. * @param {string} stageId - SDK method key (namespace.method). @@ -1003,35 +1182,53 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStage(projectId: string, stageId: string, skip?: boolean): Promise; updateStage( - paramsOrFirst: { projectId: string, stageId: string, skip?: boolean } | string, - ...rest: [(string)?, (boolean)?] + projectId: string, + stageId: string, + skip?: boolean, + ): Promise; + updateStage( + paramsOrFirst: + { projectId: string; stageId: string; skip?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { projectId: string, stageId: string, skip?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, stageId: string, skip?: boolean }; + let params: { projectId: string; stageId: string; skip?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + stageId: string; + skip?: boolean; + }; } else { params = { projectId: paramsOrFirst as string, stageId: rest[0] as string, - skip: rest[1] as boolean + skip: rest[1] as boolean, }; } - + const projectId = params.projectId; const stageId = params.stageId; const skip = params.skip; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - if (typeof stageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "stageId"'); + if (typeof stageId === 'undefined' || stageId === '') { + throw new AppwriteException( + 'Missing required parameter: "stageId"', + ); } - - const apiPath = '/projects/{projectId}/stages/{stageId}'.replace('{projectId}', encodeURIComponent(String(projectId))).replace('{stageId}', encodeURIComponent(String(stageId))); + const apiPath = '/projects/{projectId}/stages/{stageId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{stageId}', encodeURIComponent(String(stageId))); const payload: Payload = {}; if (typeof skip !== 'undefined') { payload['skip'] = skip; @@ -1041,30 +1238,25 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Update the status of a project. Can be used to archive/restore projects, and to restore paused projects. When restoring a paused project, the console fingerprint header must be provided and the project must not be blocked for any reason other than inactivity. - * + * * * @param {string} params.projectId - Project ID * @param {Status} params.status - New status for the project * @throws {AppwriteException} * @returns {Promise<{}>} */ - updateStatus(params: { projectId: string, status: Status }): Promise<{}>; + updateStatus(params: { projectId: string; status: Status }): Promise<{}>; /** * Update the status of a project. Can be used to archive/restore projects, and to restore paused projects. When restoring a paused project, the console fingerprint header must be provided and the project must not be blocked for any reason other than inactivity. - * + * * * @param {string} projectId - Project ID * @param {Status} status - New status for the project @@ -1074,31 +1266,42 @@ export class Projects { */ updateStatus(projectId: string, status: Status): Promise<{}>; updateStatus( - paramsOrFirst: { projectId: string, status: Status } | string, - ...rest: [(Status)?] + paramsOrFirst: { projectId: string; status: Status } | string, + ...rest: [Status?] ): Promise<{}> { - let params: { projectId: string, status: Status }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, status: Status }; + let params: { projectId: string; status: Status }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + status: Status; + }; } else { params = { projectId: paramsOrFirst as string, - status: rest[0] as Status + status: rest[0] as Status, }; } - + const projectId = params.projectId; const status = params.status; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } - - const apiPath = '/projects/{projectId}/status'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/status'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -1108,15 +1311,10 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1127,7 +1325,10 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - updateTeam(params: { projectId: string, teamId: string }): Promise; + updateTeam(params: { + projectId: string; + teamId: string; + }): Promise; /** * Update the team ID of a project allowing for it to be transferred to another team. * @@ -1139,31 +1340,42 @@ export class Projects { */ updateTeam(projectId: string, teamId: string): Promise; updateTeam( - paramsOrFirst: { projectId: string, teamId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; teamId: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, teamId: string }; + let params: { projectId: string; teamId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + teamId: string; + }; } else { params = { projectId: paramsOrFirst as string, - teamId: rest[0] as string + teamId: rest[0] as string, }; } - + const projectId = params.projectId; const teamId = params.teamId; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/projects/{projectId}/team'.replace('{projectId}', encodeURIComponent(String(projectId))); + const apiPath = '/projects/{projectId}/team'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); const payload: Payload = {}; if (typeof teamId !== 'undefined') { payload['teamId'] = teamId; @@ -1173,14 +1385,9 @@ export class Projects { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/proxy.ts b/src/services/proxy.ts index 0ec94aee..714a25b8 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,11 +1,9 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; import { StatusCode } from '../enums/status-code'; import { ProxyResourceType } from '../enums/proxy-resource-type'; - export class Proxy { client: Client; @@ -15,7 +13,7 @@ export class Proxy { /** * Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. - * + * * Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. * * @param {string} params.domain - Domain name. @@ -24,10 +22,14 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createInvalidation(params: { domain: string, type: InvalidationType, reference?: string }): Promise; + createInvalidation(params: { + domain: string; + type: InvalidationType; + reference?: string; + }): Promise; /** * Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. - * + * * Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. * * @param {string} domain - Domain name. @@ -37,23 +39,41 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInvalidation(domain: string, type: InvalidationType, reference?: string): Promise; createInvalidation( - paramsOrFirst: { domain: string, type: InvalidationType, reference?: string } | string, - ...rest: [(InvalidationType)?, (string)?] + domain: string, + type: InvalidationType, + reference?: string, + ): Promise; + createInvalidation( + paramsOrFirst: + | { domain: string; type: InvalidationType; reference?: string } + | string, + ...rest: [InvalidationType?, string?] ): Promise { - let params: { domain: string, type: InvalidationType, reference?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, type: InvalidationType, reference?: string }; + let params: { + domain: string; + type: InvalidationType; + reference?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + type: InvalidationType; + reference?: string; + }; } else { params = { domain: paramsOrFirst as string, type: rest[0] as InvalidationType, - reference: rest[1] as string + reference: rest[1] as string, }; } - + const domain = params.domain; const type = params.type; const reference = params.reference; @@ -64,7 +84,6 @@ export class Proxy { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - const apiPath = '/proxy/invalidations'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -81,15 +100,10 @@ export class Proxy { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -100,7 +114,10 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - listRules(params?: { queries?: string[], total?: boolean }): Promise; + listRules(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the proxy rules. You can use the query params to filter your results. * @@ -110,26 +127,36 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRules(queries?: string[], total?: boolean): Promise; listRules( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listRules( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/proxy/rules'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -142,20 +169,15 @@ export class Proxy { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new proxy rule for serving Appwrite's API on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -165,7 +187,7 @@ export class Proxy { createAPIRule(params: { domain: string }): Promise; /** * Create a new proxy rule for serving Appwrite's API on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -175,24 +197,27 @@ export class Proxy { */ createAPIRule(domain: string): Promise; createAPIRule( - paramsOrFirst: { domain: string } | string + paramsOrFirst: { domain: string } | string, ): Promise { let params: { domain: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domain: string }; } else { params = { - domain: paramsOrFirst as string + domain: paramsOrFirst as string, }; } - + const domain = params.domain; if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } - const apiPath = '/proxy/rules/api'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -203,20 +228,15 @@ export class Proxy { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a new proxy rule for executing Appwrite Function on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -225,10 +245,14 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createFunctionRule(params: { domain: string, functionId: string, branch?: string }): Promise; + createFunctionRule(params: { + domain: string; + functionId: string; + branch?: string; + }): Promise; /** * Create a new proxy rule for executing Appwrite Function on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -238,23 +262,36 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFunctionRule(domain: string, functionId: string, branch?: string): Promise; createFunctionRule( - paramsOrFirst: { domain: string, functionId: string, branch?: string } | string, - ...rest: [(string)?, (string)?] + domain: string, + functionId: string, + branch?: string, + ): Promise; + createFunctionRule( + paramsOrFirst: + { domain: string; functionId: string; branch?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { domain: string, functionId: string, branch?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, functionId: string, branch?: string }; + let params: { domain: string; functionId: string; branch?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + functionId: string; + branch?: string; + }; } else { params = { domain: paramsOrFirst as string, functionId: rest[0] as string, - branch: rest[1] as string + branch: rest[1] as string, }; } - + const domain = params.domain; const functionId = params.functionId; const branch = params.branch; @@ -263,9 +300,10 @@ export class Proxy { throw new AppwriteException('Missing required parameter: "domain"'); } if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - const apiPath = '/proxy/rules/function'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -282,20 +320,15 @@ export class Proxy { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a new proxy rule for to redirect from custom domain to another domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -306,10 +339,16 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createRedirectRule(params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }): Promise; + createRedirectRule(params: { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + }): Promise; /** * Create a new proxy rule for to redirect from custom domain to another domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -321,25 +360,55 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRedirectRule(domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType): Promise; createRedirectRule( - paramsOrFirst: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType } | string, - ...rest: [(string)?, (StatusCode)?, (string)?, (ProxyResourceType)?] + domain: string, + url: string, + statusCode: StatusCode, + resourceId: string, + resourceType: ProxyResourceType, + ): Promise; + createRedirectRule( + paramsOrFirst: + | { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + } + | string, + ...rest: [string?, StatusCode?, string?, ProxyResourceType?] ): Promise { - let params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + let params: { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + }; } else { params = { domain: paramsOrFirst as string, url: rest[0] as string, statusCode: rest[1] as StatusCode, resourceId: rest[2] as string, - resourceType: rest[3] as ProxyResourceType + resourceType: rest[3] as ProxyResourceType, }; } - + const domain = params.domain; const url = params.url; const statusCode = params.statusCode; @@ -353,15 +422,20 @@ export class Proxy { throw new AppwriteException('Missing required parameter: "url"'); } if (typeof statusCode === 'undefined') { - throw new AppwriteException('Missing required parameter: "statusCode"'); + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); } if (typeof resourceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceId"'); + throw new AppwriteException( + 'Missing required parameter: "resourceId"', + ); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } - const apiPath = '/proxy/rules/redirect'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -384,20 +458,15 @@ export class Proxy { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a new proxy rule for serving Appwrite Site on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -406,10 +475,14 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createSiteRule(params: { domain: string, siteId: string, branch?: string }): Promise; + createSiteRule(params: { + domain: string; + siteId: string; + branch?: string; + }): Promise; /** * Create a new proxy rule for serving Appwrite Site on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -419,23 +492,36 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSiteRule(domain: string, siteId: string, branch?: string): Promise; createSiteRule( - paramsOrFirst: { domain: string, siteId: string, branch?: string } | string, - ...rest: [(string)?, (string)?] + domain: string, + siteId: string, + branch?: string, + ): Promise; + createSiteRule( + paramsOrFirst: + { domain: string; siteId: string; branch?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { domain: string, siteId: string, branch?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, siteId: string, branch?: string }; + let params: { domain: string; siteId: string; branch?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + siteId: string; + branch?: string; + }; } else { params = { domain: paramsOrFirst as string, siteId: rest[0] as string, - branch: rest[1] as string + branch: rest[1] as string, }; } - + const domain = params.domain; const siteId = params.siteId; const branch = params.branch; @@ -446,7 +532,6 @@ export class Proxy { if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - const apiPath = '/proxy/rules/site'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -463,15 +548,10 @@ export class Proxy { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -492,39 +572,40 @@ export class Proxy { */ getRule(ruleId: string): Promise; getRule( - paramsOrFirst: { ruleId: string } | string + paramsOrFirst: { ruleId: string } | string, ): Promise { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - + const ruleId = params.ruleId; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/proxy/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -544,40 +625,40 @@ export class Proxy { * @deprecated Use the object parameter style method for a better developer experience. */ deleteRule(ruleId: string): Promise<{}>; - deleteRule( - paramsOrFirst: { ruleId: string } | string - ): Promise<{}> { + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - + const ruleId = params.ruleId; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/proxy/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -598,39 +679,40 @@ export class Proxy { */ updateRuleStatus(ruleId: string): Promise; updateRuleStatus( - paramsOrFirst: { ruleId: string } | string + paramsOrFirst: { ruleId: string } | string, ): Promise { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - + const ruleId = params.ruleId; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/proxy/rules/{ruleId}/status'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/proxy/rules/{ruleId}/status'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/realtime.ts b/src/services/realtime.ts index ebd41313..91aff434 100644 --- a/src/services/realtime.ts +++ b/src/services/realtime.ts @@ -2,11 +2,10 @@ import { AppwriteException, Client, JSONbig } from '../client'; import { Channel, ActionableChannel, ResolvedChannel } from '../channel'; import { Query } from '../query'; import { ID } from '../id'; - export type RealtimeSubscriptionUpdate = { channels?: (string | Channel | ActionableChannel | ResolvedChannel)[]; queries?: (string | Query)[]; -} +}; export type RealtimeSubscription = { /** @@ -25,18 +24,18 @@ export type RealtimeSubscription = { * Prefer `unsubscribe()` for per-subscription teardown and `Realtime.disconnect()` for full shutdown. */ close: () => Promise; -} +}; export type RealtimeCallback = { channels: Set; queries: string[]; // Array of query strings callback: (event: RealtimeResponseEvent) => void; -} +}; export type RealtimeResponse = { type: string; data?: any; -} +}; export type RealtimeResponseEvent = { events: string[]; @@ -44,17 +43,17 @@ export type RealtimeResponseEvent = { timestamp: string; payload: T; subscriptions: string[]; // Backend-provided subscription IDs -} +}; export type RealtimeResponseConnected = { channels: string[]; user?: object; -} +}; export type RealtimeRequest = { type: 'authentication' | 'subscribe' | 'unsubscribe' | 'presence'; data: any; -} +}; export type RealtimePresence = { $id: string; @@ -67,25 +66,25 @@ export type RealtimePresence = { status?: string; source: string; metadata?: Record; -} +}; export type RealtimePresenceCreate = { status: string; presenceId: string; permissions?: string[]; metadata?: Record; -} +}; type RealtimeRequestSubscribeRow = { subscriptionId?: string; channels: string[]; queries: string[]; -} +}; export enum RealtimeCode { NORMAL_CLOSURE = 1000, POLICY_VIOLATION = 1008, - UNKNOWN_ERROR = -1 + UNKNOWN_ERROR = -1, } export class Realtime { @@ -113,7 +112,9 @@ export class Realtime { private connectionId = 0; private reconnect = true; - private onErrorCallbacks: Array<(error?: Error, statusCode?: number) => void> = []; + private onErrorCallbacks: Array< + (error?: Error, statusCode?: number) => void + > = []; private onCloseCallbacks: Array<() => void> = []; private onOpenCallbacks: Array<() => void> = []; @@ -127,7 +128,9 @@ export class Realtime { * @param {Function} callback - Callback function to handle errors * @returns {void} */ - public onError(callback: (error?: Error, statusCode?: number) => void): void { + public onError( + callback: (error?: Error, statusCode?: number) => void, + ): void { this.onErrorCallbacks.push(callback); } @@ -211,7 +214,6 @@ export class Realtime { if (jwt) { queryParams += `&jwt=${encodeURIComponent(jwt)}`; } - const endpoint = this.client.config.endpointRealtime !== '' ? this.client.config.endpointRealtime @@ -243,13 +245,12 @@ export class Realtime { try { const connectionId = ++this.connectionId; const socket = (this.socket = new WebSocket(url)); - socket.addEventListener('open', () => { if (connectionId !== this.connectionId) { return; } this.reconnectAttempts = 0; - this.onOpenCallbacks.forEach(callback => callback()); + this.onOpenCallbacks.forEach((callback) => callback()); this.startHeartbeat(); resolve(); }); @@ -259,7 +260,9 @@ export class Realtime { return; } try { - const message = JSONbig.parse(event.data) as RealtimeResponse; + const message = JSONbig.parse( + event.data, + ) as RealtimeResponse; this.handleMessage(message); } catch (error) { console.error('Failed to parse message:', error); @@ -267,20 +270,28 @@ export class Realtime { }); socket.addEventListener('close', async (event: CloseEvent) => { - if (connectionId !== this.connectionId || socket !== this.socket) { + if ( + connectionId !== this.connectionId || + socket !== this.socket + ) { return; } this.appConnected = false; this.stopHeartbeat(); - this.onCloseCallbacks.forEach(callback => callback()); + this.onCloseCallbacks.forEach((callback) => callback()); - if (!this.reconnect || event.code === RealtimeCode.POLICY_VIOLATION) { + if ( + !this.reconnect || + event.code === RealtimeCode.POLICY_VIOLATION + ) { this.reconnect = true; return; } const timeout = this.getTimeout(); - console.log(`Realtime disconnected. Re-connecting in ${timeout / 1000} seconds.`); + console.log( + `Realtime disconnected. Re-connecting in ${timeout / 1000} seconds.`, + ); await this.sleep(timeout); this.reconnectAttempts++; @@ -292,14 +303,19 @@ export class Realtime { } }); - socket.addEventListener('error', (event: Event) => { - if (connectionId !== this.connectionId || socket !== this.socket) { + socket.addEventListener('error', (_event: Event) => { + if ( + connectionId !== this.connectionId || + socket !== this.socket + ) { return; } this.stopHeartbeat(); const error = new Error('WebSocket error'); console.error('WebSocket error:', error.message); - this.onErrorCallbacks.forEach(callback => callback(error)); + this.onErrorCallbacks.forEach((callback) => + callback(error), + ); reject(error); }); } catch (error) { @@ -318,11 +334,17 @@ export class Realtime { return; } - if (this.socket.readyState === WebSocket.OPEN || - this.socket.readyState === WebSocket.CONNECTING) { - this.socket.addEventListener('close', () => { - resolve(); - }, { once: true }); + if ( + this.socket.readyState === WebSocket.OPEN || + this.socket.readyState === WebSocket.CONNECTING + ) { + this.socket.addEventListener( + 'close', + () => { + resolve(); + }, + { once: true }, + ); this.socket.close(RealtimeCode.NORMAL_CLOSURE); } else { resolve(); @@ -344,21 +366,25 @@ export class Realtime { } private sleep(ms: number): Promise { - return new Promise(resolve => setTimeout(resolve, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); } private sendUnsubscribeMessage(subscriptionIds: string[]): void { - const ids = subscriptionIds.filter(id => typeof id === 'string' && id.length > 0); + const ids = subscriptionIds.filter( + (id) => typeof id === 'string' && id.length > 0, + ); if (ids.length === 0) { return; } if (!this.socket || this.socket.readyState !== WebSocket.OPEN) { return; } - this.socket.send(JSONbig.stringify({ - type: 'unsubscribe', - data: ids.map(subscriptionId => ({ subscriptionId })) - })); + this.socket.send( + JSONbig.stringify({ + type: 'unsubscribe', + data: ids.map((subscriptionId) => ({ subscriptionId })), + }), + ); } private generateUniqueSubscriptionId(): string { @@ -369,7 +395,9 @@ export class Realtime { return id; } } - throw new AppwriteException('Failed to generate unique subscription id'); + throw new AppwriteException( + 'Failed to generate unique subscription id', + ); } private enqueuePendingSubscribe(subscriptionId: string): void { @@ -380,7 +408,7 @@ export class Realtime { this.pendingSubscribes.set(subscriptionId, { subscriptionId, channels: Array.from(subscription.channels), - queries: subscription.queries ?? [] + queries: subscription.queries ?? [], }); } @@ -431,10 +459,12 @@ export class Realtime { const rows = Array.from(this.pendingSubscribes.values()); this.pendingSubscribes.clear(); - this.socket.send(JSONbig.stringify({ - type: 'subscribe', - data: rows - })); + this.socket.send( + JSONbig.stringify({ + type: 'subscribe', + data: rows, + }), + ); } /** @@ -444,12 +474,17 @@ export class Realtime { * @param {string | Channel | ActionableChannel | ResolvedChannel} channel - Channel value (string or Channel builder instance) * @returns {string} Channel string representation */ - private channelToString(channel: string | Channel | ActionableChannel | ResolvedChannel): string { + private channelToString( + channel: string | Channel | ActionableChannel | ResolvedChannel, + ): string { if (typeof channel === 'string') { return channel; } // All Channel instances have toString() method - if (channel && typeof (channel as Channel).toString === 'function') { + if ( + channel && + typeof (channel as Channel).toString === 'function' + ) { return (channel as Channel).toString(); } return String(channel); @@ -465,7 +500,7 @@ export class Realtime { public async subscribe( channel: string | Channel | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent) => void, - queries?: (string | Query)[] + queries?: (string | Query)[], ): Promise; /** @@ -476,9 +511,11 @@ export class Realtime { * @returns {Promise} Subscription object with close method */ public async subscribe( - channels: (string | Channel | ActionableChannel | ResolvedChannel)[], + channels: ( + string | Channel | ActionableChannel | ResolvedChannel + )[], callback: (event: RealtimeResponseEvent) => void, - queries?: (string | Query)[] + queries?: (string | Query)[], ): Promise; /** @@ -491,7 +528,7 @@ export class Realtime { public async subscribe( channel: string | Channel | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent) => void, - queries?: (string | Query)[] + queries?: (string | Query)[], ): Promise; /** @@ -502,32 +539,43 @@ export class Realtime { * @returns {Promise} Subscription object with close method */ public async subscribe( - channels: (string | Channel | ActionableChannel | ResolvedChannel)[], + channels: ( + string | Channel | ActionableChannel | ResolvedChannel + )[], callback: (event: RealtimeResponseEvent) => void, - queries?: (string | Query)[] + queries?: (string | Query)[], ): Promise; public async subscribe( - channelsOrChannel: string | Channel | ActionableChannel | ResolvedChannel | (string | Channel | ActionableChannel | ResolvedChannel)[], + channelsOrChannel: + | string + | Channel + | ActionableChannel + | ResolvedChannel + | (string | Channel | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent) => void, - queries: (string | Query)[] = [] + queries: (string | Query)[] = [], ): Promise { const channelArray = Array.isArray(channelsOrChannel) ? channelsOrChannel : [channelsOrChannel]; - + // Convert all channels to strings - const channelStrings = channelArray.map(ch => this.channelToString(ch)); + const channelStrings = channelArray.map((ch) => + this.channelToString(ch), + ); const channels = new Set(channelStrings); // Convert queries to array of strings // Ensure each query is a separate string in the array const queryStrings: string[] = []; - for (const q of (queries ?? [])) { + for (const q of queries ?? []) { if (Array.isArray(q)) { // Handle nested arrays: [[q1, q2]] -> [q1, q2] for (const inner of q) { - queryStrings.push(typeof inner === 'string' ? inner : inner.toString()); + queryStrings.push( + typeof inner === 'string' ? inner : inner.toString(), + ); } } else { queryStrings.push(typeof q === 'string' ? q : q.toString()); @@ -539,7 +587,7 @@ export class Realtime { this.activeSubscriptions.set(subscriptionId, { channels, queries: queryStrings, - callback + callback, }); this.enqueuePendingSubscribe(subscriptionId); @@ -567,14 +615,18 @@ export class Realtime { this.sendUnsubscribeMessage([subscriptionId]); }; - const update = async (changes: RealtimeSubscriptionUpdate): Promise => { + const update = async ( + changes: RealtimeSubscriptionUpdate, + ): Promise => { const subscription = this.activeSubscriptions.get(subscriptionId); if (!subscription) { return; } if (changes.channels !== undefined) { - const nextChannelStrings = changes.channels.map(ch => this.channelToString(ch)); + const nextChannelStrings = changes.channels.map((ch) => + this.channelToString(ch), + ); subscription.channels = new Set(nextChannelStrings); } @@ -583,10 +635,16 @@ export class Realtime { for (const q of changes.queries) { if (Array.isArray(q)) { for (const inner of q) { - nextQueries.push(typeof inner === 'string' ? inner : (inner as Query).toString()); + nextQueries.push( + typeof inner === 'string' + ? inner + : (inner as Query).toString(), + ); } } else { - nextQueries.push(typeof q === 'string' ? q : q.toString()); + nextQueries.push( + typeof q === 'string' ? q : q.toString(), + ); } } subscription.queries = nextQueries; @@ -599,7 +657,10 @@ export class Realtime { await this.sleep(this.DEBOUNCE_MS); if (this.subCallDepth === 1) { - if (!this.socket || this.socket.readyState > WebSocket.OPEN) { + if ( + !this.socket || + this.socket.readyState > WebSocket.OPEN + ) { await this.createSocket(); } else if (this.socket.readyState === WebSocket.OPEN) { this.sendPendingSubscribes(); @@ -655,7 +716,10 @@ export class Realtime { // payload is stored. if (!this.socket || this.socket.readyState >= WebSocket.CLOSING) { this.createSocket().catch((error) => { - console.error('Failed to open realtime socket for presence:', error); + console.error( + 'Failed to open realtime socket for presence:', + error, + ); }); } @@ -675,10 +739,12 @@ export class Realtime { if (!this.appConnected) { return; } - this.socket.send(JSONbig.stringify({ - type: 'presence', - data: this.pendingPresence - })); + this.socket.send( + JSONbig.stringify({ + type: 'presence', + data: this.pendingPresence, + }), + ); } private handleMessage(message: RealtimeResponse): void { @@ -712,7 +778,9 @@ export class Realtime { let session = this.client.config.session; if (!session) { try { - const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}'); + const cookie = JSONbig.parse( + window.localStorage.getItem('cookieFallback') ?? '{}', + ); session = cookie?.[`a_session_${this.client.config.project}`]; } catch (error) { console.error('Failed to parse cookie fallback:', error); @@ -720,12 +788,14 @@ export class Realtime { } if (session && !messageData.user) { - this.socket?.send(JSONbig.stringify({ - type: 'authentication', - data: { - session - } - })); + this.socket?.send( + JSONbig.stringify({ + type: 'authentication', + data: { + session, + }, + }), + ); } for (const subscriptionId of this.activeSubscriptions.keys()) { @@ -738,10 +808,12 @@ export class Realtime { private handleResponseError(message: RealtimeResponse): void { const error = new AppwriteException( - message.data?.message || 'Unknown error' + message.data?.message || 'Unknown error', ); const statusCode = message.data?.code; - this.onErrorCallbacks.forEach(callback => callback(error, statusCode)); + this.onErrorCallbacks.forEach((callback) => + callback(error, statusCode), + ); } private handleResponseEvent(message: RealtimeResponse): void { @@ -756,7 +828,13 @@ export class Realtime { const timestamp = data.timestamp as string; const subscriptions = data.subscriptions as string[] | undefined; - if (!channels || !events || !payload || !subscriptions || subscriptions.length === 0) { + if ( + !channels || + !events || + !payload || + !subscriptions || + subscriptions.length === 0 + ) { return; } @@ -770,7 +848,7 @@ export class Realtime { channels, timestamp, payload, - subscriptions + subscriptions, }); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 0740ff44..b0ba13f4 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -1,15 +1,20 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; import type { Models } from '../models'; import { Framework } from '../enums/framework'; import { BuildRuntime } from '../enums/build-runtime'; import { Adapter } from '../enums/adapter'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; import { SiteTemplateUseCase } from '../enums/site-template-use-case'; import { TemplateReferenceType } from '../enums/template-reference-type'; import { VCSReferenceType } from '../enums/vcs-reference-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; - export class Sites { client: Client; @@ -26,7 +31,11 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the project's sites. You can use the query params to filter your results. * @@ -37,28 +46,41 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/sites'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -74,15 +96,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -111,10 +128,36 @@ export class Sites { * @param {string} params.buildSpecification - Build specification for the site deployments. * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + create(params: { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }): Promise; /** * Create a new site. * @@ -141,19 +184,150 @@ export class Sites { * @param {string} buildSpecification - Build specification for the site deployments. * @param {string} runtimeSpecification - Runtime specification for the SSR executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + siteId: string, + name: string, + framework: Framework, + buildRuntime: BuildRuntime, + enabled?: boolean, + logging?: boolean, + timeout?: number, + installCommand?: string, + buildCommand?: string, + startCommand?: string, + outputDirectory?: string, + adapter?: Adapter, + installationId?: string, + fallbackFile?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + scopes?: ProjectKeyScopes[], + ): Promise; + create( + paramsOrFirst: + | { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + } + | string, + ...rest: [ + string?, + Framework?, + BuildRuntime?, + boolean?, + boolean?, + number?, + string?, + string?, + string?, + string?, + Adapter?, + string?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ProjectKeyScopes[]?, + ] ): Promise { - let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; } else { params = { siteId: paramsOrFirst as string, @@ -178,10 +352,11 @@ export class Sites { providerPaths: rest[18] as string[], buildSpecification: rest[19] as string, runtimeSpecification: rest[20] as string, - deploymentRetention: rest[21] as number + deploymentRetention: rest[21] as number, + scopes: rest[22] as ProjectKeyScopes[], }; } - + const siteId = params.siteId; const name = params.name; const framework = params.framework; @@ -205,6 +380,7 @@ export class Sites { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const scopes = params.scopes; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); @@ -213,12 +389,15 @@ export class Sites { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof framework === 'undefined') { - throw new AppwriteException('Missing required parameter: "framework"'); + throw new AppwriteException( + 'Missing required parameter: "framework"', + ); } if (typeof buildRuntime === 'undefined') { - throw new AppwriteException('Missing required parameter: "buildRuntime"'); + throw new AppwriteException( + 'Missing required parameter: "buildRuntime"', + ); } - const apiPath = '/sites'; const payload: Payload = {}; if (typeof siteId !== 'undefined') { @@ -290,20 +469,18 @@ export class Sites { if (typeof deploymentRetention !== 'undefined') { payload['deploymentRetention'] = deploymentRetention; } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -313,56 +490,56 @@ export class Sites { * @returns {Promise} */ listFrameworks(): Promise { - const apiPath = '/sites/frameworks'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * List allowed site specifications for this instance. * - * @param {string} params.type - Specification type to list. Can be one of: runtimes, builds. + * @param {string} params.type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. * @throws {AppwriteException} * @returns {Promise} */ - listSpecifications(params?: { type?: string }): Promise; + listSpecifications(params?: { + type?: string; + }): Promise; /** * List allowed site specifications for this instance. * - * @param {string} type - Specification type to list. Can be one of: runtimes, builds. + * @param {string} type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ listSpecifications(type?: string): Promise; listSpecifications( - paramsOrFirst?: { type?: string } | string + paramsOrFirst?: { type?: string } | string, ): Promise { let params: { type?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { type?: string }; } else { params = { - type: paramsOrFirst as string + type: paramsOrFirst as string, }; } - - const type = params.type; + const type = params.type; const apiPath = '/sites/specifications'; const payload: Payload = {}; @@ -373,15 +550,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -394,7 +566,12 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listTemplates(params?: { frameworks?: Framework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number }): Promise; + listTemplates(params?: { + frameworks?: Framework[]; + useCases?: SiteTemplateUseCase[]; + limit?: number; + offset?: number; + }): Promise; /** * List available site templates. You can use template details in [createSite](/docs/references/cloud/server-nodejs/sites#create) method. * @@ -406,30 +583,60 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTemplates(frameworks?: Framework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number): Promise; listTemplates( - paramsOrFirst?: { frameworks?: Framework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number } | Framework[], - ...rest: [(SiteTemplateUseCase[])?, (number)?, (number)?] + frameworks?: Framework[], + useCases?: SiteTemplateUseCase[], + limit?: number, + offset?: number, + ): Promise; + listTemplates( + paramsOrFirst?: + | { + frameworks?: Framework[]; + useCases?: SiteTemplateUseCase[]; + limit?: number; + offset?: number; + } + | Framework[], + ...rest: [SiteTemplateUseCase[]?, number?, number?] ): Promise { - let params: { frameworks?: Framework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('frameworks' in paramsOrFirst || 'useCases' in paramsOrFirst || 'limit' in paramsOrFirst || 'offset' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { frameworks?: Framework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number }; + let params: { + frameworks?: Framework[]; + useCases?: SiteTemplateUseCase[]; + limit?: number; + offset?: number; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('frameworks' in paramsOrFirst || + 'useCases' in paramsOrFirst || + 'limit' in paramsOrFirst || + 'offset' in paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + frameworks?: Framework[]; + useCases?: SiteTemplateUseCase[]; + limit?: number; + offset?: number; + }; } else { params = { frameworks: paramsOrFirst as Framework[], useCases: rest[0] as SiteTemplateUseCase[], limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const frameworks = params.frameworks; const useCases = params.useCases; const limit = params.limit; const offset = params.offset; - const apiPath = '/sites/templates'; const payload: Payload = {}; if (typeof frameworks !== 'undefined') { @@ -448,15 +655,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -477,39 +679,42 @@ export class Sites { */ getTemplate(templateId: string): Promise; getTemplate( - paramsOrFirst: { templateId: string } | string + paramsOrFirst: { templateId: string } | string, ): Promise { let params: { templateId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { templateId: string }; } else { params = { - templateId: paramsOrFirst as string + templateId: paramsOrFirst as string, }; } - + const templateId = params.templateId; - if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + if (typeof templateId === 'undefined' || templateId === '') { + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - - const apiPath = '/sites/templates/{templateId}'.replace('{templateId}', encodeURIComponent(String(templateId))); + const apiPath = '/sites/templates/{templateId}'.replace( + '{templateId}', + encodeURIComponent(String(templateId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -529,40 +734,39 @@ export class Sites { * @deprecated Use the object parameter style method for a better developer experience. */ get(siteId: string): Promise; - get( - paramsOrFirst: { siteId: string } | string - ): Promise { + get(paramsOrFirst: { siteId: string } | string): Promise { let params: { siteId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { siteId: string }; } else { params = { - siteId: paramsOrFirst as string + siteId: paramsOrFirst as string, }; } - + const siteId = params.siteId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -591,10 +795,36 @@ export class Sites { * @param {string} params.buildSpecification - Build specification for the site deployments. * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + update(params: { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }): Promise; /** * Update site by its unique ID. * @@ -621,19 +851,150 @@ export class Sites { * @param {string} buildSpecification - Build specification for the site deployments. * @param {string} runtimeSpecification - Runtime specification for the SSR executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + siteId: string, + name: string, + framework: Framework, + enabled?: boolean, + logging?: boolean, + timeout?: number, + installCommand?: string, + buildCommand?: string, + startCommand?: string, + outputDirectory?: string, + buildRuntime?: BuildRuntime, + adapter?: Adapter, + fallbackFile?: string, + installationId?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + scopes?: ProjectKeyScopes[], + ): Promise; + update( + paramsOrFirst: + | { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + } + | string, + ...rest: [ + string?, + Framework?, + boolean?, + boolean?, + number?, + string?, + string?, + string?, + string?, + BuildRuntime?, + Adapter?, + string?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ProjectKeyScopes[]?, + ] ): Promise { - let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; } else { params = { siteId: paramsOrFirst as string, @@ -658,10 +1019,11 @@ export class Sites { providerPaths: rest[18] as string[], buildSpecification: rest[19] as string, runtimeSpecification: rest[20] as string, - deploymentRetention: rest[21] as number + deploymentRetention: rest[21] as number, + scopes: rest[22] as ProjectKeyScopes[], }; } - + const siteId = params.siteId; const name = params.name; const framework = params.framework; @@ -685,18 +1047,23 @@ export class Sites { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const scopes = params.scopes; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof framework === 'undefined') { - throw new AppwriteException('Missing required parameter: "framework"'); + throw new AppwriteException( + 'Missing required parameter: "framework"', + ); } - - const apiPath = '/sites/{siteId}'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -764,20 +1131,18 @@ export class Sites { if (typeof deploymentRetention !== 'undefined') { payload['deploymentRetention'] = deploymentRetention; } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -797,40 +1162,40 @@ export class Sites { * @deprecated Use the object parameter style method for a better developer experience. */ delete(siteId: string): Promise<{}>; - delete( - paramsOrFirst: { siteId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { siteId: string } | string): Promise<{}> { let params: { siteId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { siteId: string }; } else { params = { - siteId: paramsOrFirst as string + siteId: paramsOrFirst as string, }; } - + const siteId = params.siteId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -841,7 +1206,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - updateSiteDeployment(params: { siteId: string, deploymentId: string }): Promise; + updateSiteDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. * @@ -851,33 +1219,47 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSiteDeployment(siteId: string, deploymentId: string): Promise; updateSiteDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + updateSiteDeployment( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/sites/{siteId}/deployment'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/deployment'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { payload['deploymentId'] = deploymentId; @@ -887,15 +1269,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -908,7 +1285,12 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listDeployments(params: { siteId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listDeployments(params: { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the site's code deployments. You can use the query params to filter your results. * @@ -920,34 +1302,62 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listDeployments(siteId: string, queries?: string[], search?: string, total?: boolean): Promise; listDeployments( - paramsOrFirst: { siteId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + siteId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listDeployments( + paramsOrFirst: + | { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { siteId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const siteId = params.siteId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/deployments'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -962,15 +1372,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -985,7 +1390,15 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createDeployment(params: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void }): Promise; + createDeployment(params: { + siteId: string; + code: File; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + onProgress?: (progress: UploadProgress) => void; + }): Promise; /** * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. * @@ -999,17 +1412,62 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeployment(siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void): Promise; createDeployment( - paramsOrFirst: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(File)?, (string)?, (string)?, (string)?, (boolean)?,((progress: UploadProgress) => void)?] + siteId: string, + code: File, + installCommand?: string, + buildCommand?: string, + outputDirectory?: string, + activate?: boolean, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createDeployment( + paramsOrFirst: + | { + siteId: string; + code: File; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + onProgress?: (progress: UploadProgress) => void; + } + | string, + ...rest: [ + File?, + string?, + string?, + string?, + boolean?, + ((progress: UploadProgress) => void)?, + ] ): Promise { - let params: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; - let onProgress: ((progress: UploadProgress) => void); - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; - onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + let params: { + siteId: string; + code: File; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + code: File; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; } else { params = { siteId: paramsOrFirst as string, @@ -1017,11 +1475,11 @@ export class Sites { installCommand: rest[1] as string, buildCommand: rest[2] as string, outputDirectory: rest[3] as string, - activate: rest[4] as boolean + activate: rest[4] as boolean, }; - onProgress = rest[5] as ((progress: UploadProgress) => void); + onProgress = rest[5] as (progress: UploadProgress) => void; } - + const siteId = params.siteId; const code = params.code; const installCommand = params.installCommand; @@ -1029,14 +1487,16 @@ export class Sites { const outputDirectory = params.outputDirectory; const activate = params.activate; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/deployments'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof installCommand !== 'undefined') { payload['installCommand'] = installCommand; @@ -1058,15 +1518,15 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'multipart/form-data', - 'accept': 'application/json', - } + accept: 'application/json', + }; return this.client.chunkedUpload( 'post', uri, apiHeaders, payload, - onProgress + onProgress, ); } @@ -1078,7 +1538,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createDuplicateDeployment(params: { siteId: string, deploymentId: string }): Promise; + createDuplicateDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * @@ -1088,33 +1551,47 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDuplicateDeployment(siteId: string, deploymentId: string): Promise; createDuplicateDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + createDuplicateDeployment( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/sites/{siteId}/deployments/duplicate'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/deployments/duplicate'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { payload['deploymentId'] = deploymentId; @@ -1124,20 +1601,15 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. * * @param {string} params.siteId - Site ID. @@ -1150,10 +1622,18 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createTemplateDeployment(params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise; + createTemplateDeployment(params: { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. * * @param {string} siteId - Site ID. @@ -1167,15 +1647,60 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise; createTemplateDeployment( - paramsOrFirst: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] + siteId: string, + repository: string, + owner: string, + rootDirectory: string, + type: TemplateReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createTemplateDeployment( + paramsOrFirst: + | { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + TemplateReferenceType?, + string?, + boolean?, + ] ): Promise { - let params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + let params: { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, @@ -1184,10 +1709,10 @@ export class Sites { rootDirectory: rest[2] as string, type: rest[3] as TemplateReferenceType, reference: rest[4] as string, - activate: rest[5] as boolean + activate: rest[5] as boolean, }; } - + const siteId = params.siteId; const repository = params.repository; const owner = params.owner; @@ -1196,26 +1721,34 @@ export class Sites { const reference = params.reference; const activate = params.activate; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof repository === 'undefined') { - throw new AppwriteException('Missing required parameter: "repository"'); + throw new AppwriteException( + 'Missing required parameter: "repository"', + ); } if (typeof owner === 'undefined') { throw new AppwriteException('Missing required parameter: "owner"'); } if (typeof rootDirectory === 'undefined') { - throw new AppwriteException('Missing required parameter: "rootDirectory"'); + throw new AppwriteException( + 'Missing required parameter: "rootDirectory"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/sites/{siteId}/deployments/template'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/deployments/template'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof repository !== 'undefined') { payload['repository'] = repository; @@ -1240,20 +1773,15 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a deployment when a site is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} params.siteId - Site ID. @@ -1263,10 +1791,15 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createVcsDeployment(params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise; + createVcsDeployment(params: { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment when a site is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} siteId - Site ID. @@ -1277,40 +1810,70 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(siteId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise; createVcsDeployment( - paramsOrFirst: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] + siteId: string, + type: VCSReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createVcsDeployment( + paramsOrFirst: + | { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [VCSReferenceType?, string?, boolean?] ): Promise { - let params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + let params: { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, type: rest[0] as VCSReferenceType, reference: rest[1] as string, - activate: rest[2] as boolean + activate: rest[2] as boolean, }; } - + const siteId = params.siteId; const type = params.type; const reference = params.reference; const activate = params.activate; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/sites/{siteId}/deployments/vcs'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/deployments/vcs'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -1326,15 +1889,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1345,7 +1903,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getDeployment(params: { siteId: string, deploymentId: string }): Promise; + getDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Get a site deployment by its unique ID. * @@ -1355,47 +1916,58 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeployment(siteId: string, deploymentId: string): Promise; getDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + getDeployment( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1406,7 +1978,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDeployment(params: { siteId: string, deploymentId: string }): Promise<{}>; + deleteDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise<{}>; /** * Delete a site deployment by its unique ID. * @@ -1418,45 +1993,54 @@ export class Sites { */ deleteDeployment(siteId: string, deploymentId: string): Promise<{}>; deleteDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1469,7 +2053,12 @@ export class Sites { * @throws {AppwriteException} * @returns {string} */ - getDeploymentDownload(params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }): string; + getDeploymentDownload(params: { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }): string; /** * Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -1481,37 +2070,69 @@ export class Sites { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string): string; getDeploymentDownload( - paramsOrFirst: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string } | string, - ...rest: [(string)?, (DeploymentDownloadType)?, (string)?] + siteId: string, + deploymentId: string, + type?: DeploymentDownloadType, + token?: string, + ): string; + getDeploymentDownload( + paramsOrFirst: + | { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + } + | string, + ...rest: [string?, DeploymentDownloadType?, string?] ): string { - let params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; + let params: { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; } else { params = { siteId: paramsOrFirst as string, deploymentId: rest[0] as string, type: rest[1] as DeploymentDownloadType, - token: rest[2] as string + token: rest[2] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; const type = params.type; const token = params.token; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}/download'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/download' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -1521,18 +2142,12 @@ export class Sites { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } @@ -1544,7 +2159,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - updateDeploymentStatus(params: { siteId: string, deploymentId: string }): Promise; + updateDeploymentStatus(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * @@ -1554,48 +2172,59 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDeploymentStatus(siteId: string, deploymentId: string): Promise; updateDeploymentStatus( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + updateDeploymentStatus( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}/status'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); + if (typeof deploymentId === 'undefined' || deploymentId === '') { + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/status' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1607,7 +2236,11 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params: { siteId: string, queries?: string[], total?: boolean }): Promise; + listLogs(params: { + siteId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all site logs. You can use the query params to filter your results. * @@ -1618,32 +2251,47 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listLogs(siteId: string, queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + siteId: string, + queries?: string[], + total?: boolean, + ): Promise; + listLogs( + paramsOrFirst: + { siteId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { siteId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; + let params: { siteId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const siteId = params.siteId; const queries = params.queries; const total = params.total; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}/logs'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/logs'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1655,15 +2303,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1674,7 +2317,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getLog(params: { siteId: string, logId: string }): Promise; + getLog(params: { + siteId: string; + logId: string; + }): Promise; /** * Get a site request log by its unique ID. * @@ -1686,45 +2332,45 @@ export class Sites { */ getLog(siteId: string, logId: string): Promise; getLog( - paramsOrFirst: { siteId: string, logId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; logId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, logId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + let params: { siteId: string; logId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { siteId: string; logId: string }; } else { params = { siteId: paramsOrFirst as string, - logId: rest[0] as string + logId: rest[0] as string, }; } - + const siteId = params.siteId; const logId = params.logId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof logId === 'undefined') { + if (typeof logId === 'undefined' || logId === '') { throw new AppwriteException('Missing required parameter: "logId"'); } - - const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{logId}', encodeURIComponent(String(logId))); + const apiPath = '/sites/{siteId}/logs/{logId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{logId}', encodeURIComponent(String(logId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1735,7 +2381,7 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteLog(params: { siteId: string, logId: string }): Promise<{}>; + deleteLog(params: { siteId: string; logId: string }): Promise<{}>; /** * Delete a site log by its unique ID. * @@ -1747,46 +2393,46 @@ export class Sites { */ deleteLog(siteId: string, logId: string): Promise<{}>; deleteLog( - paramsOrFirst: { siteId: string, logId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; logId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { siteId: string, logId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + let params: { siteId: string; logId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { siteId: string; logId: string }; } else { params = { siteId: paramsOrFirst as string, - logId: rest[0] as string + logId: rest[0] as string, }; } - + const siteId = params.siteId; const logId = params.logId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof logId === 'undefined') { + if (typeof logId === 'undefined' || logId === '') { throw new AppwriteException('Missing required parameter: "logId"'); } - - const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{logId}', encodeURIComponent(String(logId))); + const apiPath = '/sites/{siteId}/logs/{logId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{logId}', encodeURIComponent(String(logId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1798,7 +2444,11 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params: { siteId: string, queries?: string[], total?: boolean }): Promise; + listVariables(params: { + siteId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all variables of a specific site. * @@ -1809,32 +2459,47 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(siteId: string, queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + siteId: string, + queries?: string[], + total?: boolean, + ): Promise; + listVariables( + paramsOrFirst: + { siteId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { siteId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; + let params: { siteId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const siteId = params.siteId; const queries = params.queries; const total = params.total; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/variables'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1846,15 +2511,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1862,55 +2522,93 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }): Promise; /** * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(siteId: string, variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { siteId: string, variableId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + siteId: string, + variableId: string, + key: string, + value: string, + secret?: boolean, + ): Promise; + createVariable( + paramsOrFirst: + | { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; + let params: { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const siteId = params.siteId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -1918,8 +2616,10 @@ export class Sites { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } - - const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', encodeURIComponent(String(siteId))); + const apiPath = '/sites/{siteId}/variables'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); const payload: Payload = {}; if (typeof variableId !== 'undefined') { payload['variableId'] = variableId; @@ -1938,15 +2638,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1957,7 +2652,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getVariable(params: { siteId: string, variableId: string }): Promise; + getVariable(params: { + siteId: string; + variableId: string; + }): Promise; /** * Get a variable by its unique ID. * @@ -1969,45 +2667,50 @@ export class Sites { */ getVariable(siteId: string, variableId: string): Promise; getVariable( - paramsOrFirst: { siteId: string, variableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; variableId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + let params: { siteId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + }; } else { params = { siteId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const siteId = params.siteId; const variableId = params.variableId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/sites/{siteId}/variables/{variableId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2015,58 +2718,97 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }): Promise; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(siteId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + siteId: string, + variableId: string, + key?: string, + value?: string, + secret?: boolean, + ): Promise; + updateVariable( + paramsOrFirst: + | { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + let params: { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const siteId = params.siteId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/sites/{siteId}/variables/{variableId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2082,15 +2824,10 @@ export class Sites { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -2101,7 +2838,7 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteVariable(params: { siteId: string, variableId: string }): Promise<{}>; + deleteVariable(params: { siteId: string; variableId: string }): Promise<{}>; /** * Delete a variable by its unique ID. * @@ -2113,44 +2850,50 @@ export class Sites { */ deleteVariable(siteId: string, variableId: string): Promise<{}>; deleteVariable( - paramsOrFirst: { siteId: string, variableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; variableId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { siteId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + let params: { siteId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + }; } else { params = { siteId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const siteId = params.siteId; const variableId = params.variableId; - if (typeof siteId === 'undefined') { + if (typeof siteId === 'undefined' || siteId === '') { throw new AppwriteException('Missing required parameter: "siteId"'); } - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + if (typeof variableId === 'undefined' || variableId === '') { + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPath = '/sites/{siteId}/variables/{variableId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/storage.ts b/src/services/storage.ts index 76bb1f4c..a897d653 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,11 +1,15 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; import type { Models } from '../models'; import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; import { ImageFormat } from '../enums/image-format'; - export class Storage { client: Client; @@ -22,7 +26,11 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - listBuckets(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listBuckets(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the storage buckets. You can use the query params to filter your results. * @@ -33,28 +41,41 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBuckets(queries?: string[], search?: string, total?: boolean): Promise; listBuckets( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listBuckets( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/storage/buckets'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -70,15 +91,10 @@ export class Storage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -89,7 +105,7 @@ export class Storage { * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -98,7 +114,19 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - createBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise; + createBucket(params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }): Promise; /** * Create a new storage bucket. * @@ -107,7 +135,7 @@ export class Storage { * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -117,15 +145,80 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise; createBucket( - paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] + bucketId: string, + name: string, + permissions?: string[], + fileSecurity?: boolean, + enabled?: boolean, + maximumFileSize?: number, + allowedFileExtensions?: string[], + compression?: Compression, + encryption?: boolean, + antivirus?: boolean, + transformations?: boolean, + ): Promise; + createBucket( + paramsOrFirst: + | { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + } + | string, + ...rest: [ + string?, + string[]?, + boolean?, + boolean?, + number?, + string[]?, + Compression?, + boolean?, + boolean?, + boolean?, + ] ): Promise { - let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + let params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -138,10 +231,10 @@ export class Storage { compression: rest[6] as Compression, encryption: rest[7] as boolean, antivirus: rest[8] as boolean, - transformations: rest[9] as boolean + transformations: rest[9] as boolean, }; } - + const bucketId = params.bucketId; const name = params.name; const permissions = params.permissions; @@ -155,12 +248,13 @@ export class Storage { const transformations = params.transformations; if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/storage/buckets'; const payload: Payload = {}; if (typeof bucketId !== 'undefined') { @@ -201,15 +295,10 @@ export class Storage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -230,39 +319,42 @@ export class Storage { */ getBucket(bucketId: string): Promise; getBucket( - paramsOrFirst: { bucketId: string } | string + paramsOrFirst: { bucketId: string } | string, ): Promise { let params: { bucketId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { bucketId: string }; } else { params = { - bucketId: paramsOrFirst as string + bucketId: paramsOrFirst as string, }; } - + const bucketId = params.bucketId; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - - const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))); + const apiPath = '/storage/buckets/{bucketId}'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -273,7 +365,7 @@ export class Storage { * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -282,7 +374,19 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - updateBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise; + updateBucket(params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }): Promise; /** * Update a storage bucket by its unique ID. * @@ -291,7 +395,7 @@ export class Storage { * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -301,15 +405,80 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise; updateBucket( - paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] + bucketId: string, + name: string, + permissions?: string[], + fileSecurity?: boolean, + enabled?: boolean, + maximumFileSize?: number, + allowedFileExtensions?: string[], + compression?: Compression, + encryption?: boolean, + antivirus?: boolean, + transformations?: boolean, + ): Promise; + updateBucket( + paramsOrFirst: + | { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + } + | string, + ...rest: [ + string?, + string[]?, + boolean?, + boolean?, + number?, + string[]?, + Compression?, + boolean?, + boolean?, + boolean?, + ] ): Promise { - let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + let params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -322,10 +491,10 @@ export class Storage { compression: rest[6] as Compression, encryption: rest[7] as boolean, antivirus: rest[8] as boolean, - transformations: rest[9] as boolean + transformations: rest[9] as boolean, }; } - + const bucketId = params.bucketId; const name = params.name; const permissions = params.permissions; @@ -338,14 +507,18 @@ export class Storage { const antivirus = params.antivirus; const transformations = params.transformations; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))); + const apiPath = '/storage/buckets/{bucketId}'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -382,15 +555,10 @@ export class Storage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -410,40 +578,42 @@ export class Storage { * @deprecated Use the object parameter style method for a better developer experience. */ deleteBucket(bucketId: string): Promise<{}>; - deleteBucket( - paramsOrFirst: { bucketId: string } | string - ): Promise<{}> { + deleteBucket(paramsOrFirst: { bucketId: string } | string): Promise<{}> { let params: { bucketId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { bucketId: string }; } else { params = { - bucketId: paramsOrFirst as string + bucketId: paramsOrFirst as string, }; } - + const bucketId = params.bucketId; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - - const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))); + const apiPath = '/storage/buckets/{bucketId}'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -456,7 +626,12 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - listFiles(params: { bucketId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listFiles(params: { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the user files. You can use the query params to filter your results. * @@ -468,34 +643,64 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listFiles(bucketId: string, queries?: string[], search?: string, total?: boolean): Promise; listFiles( - paramsOrFirst: { bucketId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + bucketId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listFiles( + paramsOrFirst: + | { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { bucketId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const bucketId = params.bucketId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - - const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', encodeURIComponent(String(bucketId))); + const apiPath = '/storage/buckets/{bucketId}/files'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -510,26 +715,21 @@ export class Storage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. - * + * * Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. - * + * * When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. - * + * * If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. - * + * * * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} params.fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -539,16 +739,23 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - createFile(params: { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void }): Promise; + createFile(params: { + bucketId: string; + fileId: string; + file: File; + permissions?: string[]; + folder?: string; + onProgress?: (progress: UploadProgress) => void; + }): Promise; /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. - * + * * Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. - * + * * When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. - * + * * If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. - * + * * * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -559,36 +766,78 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFile(bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void): Promise; createFile( - paramsOrFirst: { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(string)?, (File)?, (string[])?, (string)?,((progress: UploadProgress) => void)?] + bucketId: string, + fileId: string, + file: File, + permissions?: string[], + folder?: string, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createFile( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + file: File; + permissions?: string[]; + folder?: string; + onProgress?: (progress: UploadProgress) => void; + } + | string, + ...rest: [ + string?, + File?, + string[]?, + string?, + ((progress: UploadProgress) => void)?, + ] ): Promise { - let params: { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string }; - let onProgress: ((progress: UploadProgress) => void); - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File, permissions?: string[], folder?: string }; - onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + let params: { + bucketId: string; + fileId: string; + file: File; + permissions?: string[]; + folder?: string; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + file: File; + permissions?: string[]; + folder?: string; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, file: rest[1] as File, permissions: rest[2] as string[], - folder: rest[3] as string + folder: rest[3] as string, }; - onProgress = rest[4] as ((progress: UploadProgress) => void); + onProgress = rest[4] as (progress: UploadProgress) => void; } - + const bucketId = params.bucketId; const fileId = params.fileId; const file = params.file; const permissions = params.permissions; const folder = params.folder; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); @@ -596,8 +845,10 @@ export class Storage { if (typeof file === 'undefined') { throw new AppwriteException('Missing required parameter: "file"'); } - - const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', encodeURIComponent(String(bucketId))); + const apiPath = '/storage/buckets/{bucketId}/files'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); const payload: Payload = {}; if (typeof fileId !== 'undefined') { payload['fileId'] = fileId; @@ -616,15 +867,15 @@ export class Storage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'multipart/form-data', - 'accept': 'application/json', - } + accept: 'application/json', + }; return this.client.chunkedUpload( 'post', uri, apiHeaders, payload, - onProgress + onProgress, ); } @@ -636,7 +887,7 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - getFile(params: { bucketId: string, fileId: string }): Promise; + getFile(params: { bucketId: string; fileId: string }): Promise; /** * Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. * @@ -648,45 +899,50 @@ export class Storage { */ getFile(bucketId: string, fileId: string): Promise; getFile( - paramsOrFirst: { bucketId: string, fileId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { bucketId: string; fileId: string } | string, + ...rest: [string?] ): Promise { - let params: { bucketId: string, fileId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string }; + let params: { bucketId: string; fileId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + }; } else { params = { bucketId: paramsOrFirst as string, - fileId: rest[0] as string + fileId: rest[0] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -699,7 +955,12 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - updateFile(params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }): Promise; + updateFile(params: { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + }): Promise; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. * @@ -711,37 +972,66 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise; updateFile( - paramsOrFirst: { bucketId: string, fileId: string, name?: string, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (string[])?] + bucketId: string, + fileId: string, + name?: string, + permissions?: string[], + ): Promise; + updateFile( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + } + | string, + ...rest: [string?, string?, string[]?] ): Promise { - let params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, name?: string, permissions?: string[] }; + let params: { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[] + permissions: rest[2] as string[], }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const name = params.name; const permissions = params.permissions; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -754,15 +1044,10 @@ export class Storage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -773,7 +1058,7 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteFile(params: { bucketId: string, fileId: string }): Promise<{}>; + deleteFile(params: { bucketId: string; fileId: string }): Promise<{}>; /** * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * @@ -785,45 +1070,51 @@ export class Storage { */ deleteFile(bucketId: string, fileId: string): Promise<{}>; deleteFile( - paramsOrFirst: { bucketId: string, fileId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { bucketId: string; fileId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { bucketId: string, fileId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string }; + let params: { bucketId: string; fileId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + }; } else { params = { bucketId: paramsOrFirst as string, - fileId: rest[0] as string + fileId: rest[0] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -835,7 +1126,11 @@ export class Storage { * @throws {AppwriteException} * @returns {string} */ - getFileDownload(params: { bucketId: string, fileId: string, token?: string }): string; + getFileDownload(params: { + bucketId: string; + fileId: string; + token?: string; + }): string; /** * Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -848,51 +1143,57 @@ export class Storage { */ getFileDownload(bucketId: string, fileId: string, token?: string): string; getFileDownload( - paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: + { bucketId: string; fileId: string; token?: string } | string, + ...rest: [string?, string?] ): string { - let params: { bucketId: string, fileId: string, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; + let params: { bucketId: string; fileId: string; token?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + token?: string; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - token: rest[1] as string + token: rest[1] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const token = params.token; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; if (typeof token !== 'undefined') { payload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } @@ -903,7 +1204,7 @@ export class Storage { * @param {string} params.fileId - File ID * @param {number} params.width - Resize preview image width, Pass an integer between 0 to 4000. * @param {number} params.height - Resize preview image height, Pass an integer between 0 to 4000. - * @param {ImageGravity} params.gravity - Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + * @param {ImageGravity} params.gravity - Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right * @param {number} params.quality - Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @param {number} params.borderWidth - Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. * @param {string} params.borderColor - Preview image border color. Use a valid HEX color, no # is needed for prefix. @@ -916,7 +1217,22 @@ export class Storage { * @throws {AppwriteException} * @returns {string} */ - getFilePreview(params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }): string; + getFilePreview(params: { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + }): string; /** * Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. * @@ -924,7 +1240,7 @@ export class Storage { * @param {string} fileId - File ID * @param {number} width - Resize preview image width, Pass an integer between 0 to 4000. * @param {number} height - Resize preview image height, Pass an integer between 0 to 4000. - * @param {ImageGravity} gravity - Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + * @param {ImageGravity} gravity - Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right * @param {number} quality - Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @param {number} borderWidth - Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. * @param {string} borderColor - Preview image border color. Use a valid HEX color, no # is needed for prefix. @@ -938,15 +1254,95 @@ export class Storage { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): string; getFilePreview( - paramsOrFirst: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string } | string, - ...rest: [(string)?, (number)?, (number)?, (ImageGravity)?, (number)?, (number)?, (string)?, (number)?, (number)?, (number)?, (string)?, (ImageFormat)?, (string)?] + bucketId: string, + fileId: string, + width?: number, + height?: number, + gravity?: ImageGravity, + quality?: number, + borderWidth?: number, + borderColor?: string, + borderRadius?: number, + opacity?: number, + rotation?: number, + background?: string, + output?: ImageFormat, + token?: string, + ): string; + getFilePreview( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + } + | string, + ...rest: [ + string?, + number?, + number?, + ImageGravity?, + number?, + number?, + string?, + number?, + number?, + number?, + string?, + ImageFormat?, + string?, + ] ): string { - let params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; + let params: { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -962,10 +1358,10 @@ export class Storage { rotation: rest[9] as number, background: rest[10] as string, output: rest[11] as ImageFormat, - token: rest[12] as string + token: rest[12] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const width = params.width; @@ -981,14 +1377,17 @@ export class Storage { const output = params.output; const token = params.token; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; @@ -1028,18 +1427,12 @@ export class Storage { } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } @@ -1052,7 +1445,11 @@ export class Storage { * @throws {AppwriteException} * @returns {string} */ - getFileView(params: { bucketId: string, fileId: string, token?: string }): string; + getFileView(params: { + bucketId: string; + fileId: string; + token?: string; + }): string; /** * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. * @@ -1065,51 +1462,57 @@ export class Storage { */ getFileView(bucketId: string, fileId: string, token?: string): string; getFileView( - paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: + { bucketId: string; fileId: string; token?: string } | string, + ...rest: [string?, string?] ): string { - let params: { bucketId: string, fileId: string, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; + let params: { bucketId: string; fileId: string; token?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + token?: string; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - token: rest[1] as string + token: rest[1] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const token = params.token; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; if (typeof token !== 'undefined') { payload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } - payload['project'] = this.client.config.project; - payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - + return uri.toString(); } } diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index db5b41b9..2f2636e1 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,12 +1,10 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { TablesDBIndexType } from '../enums/tables-db-index-type'; import { OrderBy } from '../enums/order-by'; - export class TablesDB { client: Client; @@ -23,7 +21,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * @@ -34,28 +36,41 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/tablesdb'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -71,20 +86,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new Database. - * + * * * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Database name. Max length: 128 chars. @@ -95,10 +105,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Create a new Database. - * + * * * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Database name. Max length: 128 chars. @@ -110,15 +127,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -126,10 +177,10 @@ export class TablesDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; @@ -138,12 +189,13 @@ export class TablesDB { const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/tablesdb'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -169,40 +221,29 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. * * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/tablesdb/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -212,7 +253,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listTransactions(params?: { queries?: string[] }): Promise; + listTransactions(params?: { + queries?: string[]; + }): Promise; /** * List transactions across all databases. * @@ -223,20 +266,24 @@ export class TablesDB { */ listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/tablesdb/transactions'; const payload: Payload = {}; @@ -247,15 +294,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -276,20 +318,24 @@ export class TablesDB { */ createTransaction(ttl?: number): Promise; createTransaction( - paramsOrFirst?: { ttl?: number } | number + paramsOrFirst?: { ttl?: number } | number, ): Promise { let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { ttl?: number }; } else { params = { - ttl: paramsOrFirst as number + ttl: paramsOrFirst as number, }; } - - const ttl = params.ttl; + const ttl = params.ttl; const apiPath = '/tablesdb/transactions'; const payload: Payload = {}; @@ -301,15 +347,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -319,7 +360,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getTransaction(params: { transactionId: string }): Promise; + getTransaction(params: { + transactionId: string; + }): Promise; /** * Get a transaction by its unique ID. * @@ -330,39 +373,42 @@ export class TablesDB { */ getTransaction(transactionId: string): Promise; getTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/tablesdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -374,7 +420,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; /** * Update a transaction, to either commit or roll back its operations. * @@ -385,32 +435,54 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; } else { params = { transactionId: paramsOrFirst as string, commit: rest[0] as boolean, - rollback: rest[1] as boolean + rollback: rest[1] as boolean, }; } - + const transactionId = params.transactionId; const commit = params.commit; const rollback = params.rollback; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/tablesdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof commit !== 'undefined') { payload['commit'] = commit; @@ -423,15 +495,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -452,39 +519,43 @@ export class TablesDB { */ deleteTransaction(transactionId: string): Promise<{}>; deleteTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise<{}> { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/tablesdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -495,7 +566,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; /** * Create multiple operations in a single transaction. * @@ -505,30 +579,46 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createOperations(transactionId: string, operations?: object[]): Promise; createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; } else { params = { transactionId: paramsOrFirst as string, - operations: rest[0] as object[] + operations: rest[0] as object[], }; } - + const transactionId = params.transactionId; const operations = params.operations; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}/operations'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = + '/tablesdb/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof operations !== 'undefined') { payload['operations'] = operations; @@ -538,15 +628,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -567,39 +652,42 @@ export class TablesDB { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -614,7 +702,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + update(params: { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Update a database by its unique ID. * @@ -628,15 +723,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name?: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -644,10 +773,10 @@ export class TablesDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; @@ -655,11 +784,15 @@ export class TablesDB { const replicas = params.replicas; const syncMode = params.syncMode; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -681,15 +814,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -709,53 +837,58 @@ export class TablesDB { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -763,30 +896,45 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { payload['targetReplicaId'] = targetReplicaId; @@ -796,15 +944,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -814,7 +957,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listMigrations(params: { databaseId: string }): Promise; + listMigrations(params: { + databaseId: string; + }): Promise; /** * List the dedicated migrations for a TablesDB database. A database has at most one in-flight migration. * @@ -825,39 +970,42 @@ export class TablesDB { */ listMigrations(databaseId: string): Promise; listMigrations( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -865,64 +1013,98 @@ export class TablesDB { * * @param {string} params.databaseId - Database ID. * @param {string} params.specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. + * @param {boolean} params.autoCutover - Whether to cut over automatically once the copy is verified. When disabled the migration parks at ready_to_cutover and holds there until the cutover is performed manually. * @throws {AppwriteException} * @returns {Promise} */ - createMigration(params: { databaseId: string, specification: string }): Promise; + createMigration(params: { + databaseId: string; + specification: string; + autoCutover?: boolean; + }): Promise; /** * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. * * @param {string} databaseId - Database ID. * @param {string} specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. + * @param {boolean} autoCutover - Whether to cut over automatically once the copy is verified. When disabled the migration parks at ready_to_cutover and holds there until the cutover is performed manually. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMigration(databaseId: string, specification: string): Promise; createMigration( - paramsOrFirst: { databaseId: string, specification: string } | string, - ...rest: [(string)?] + databaseId: string, + specification: string, + autoCutover?: boolean, + ): Promise; + createMigration( + paramsOrFirst: + | { + databaseId: string; + specification: string; + autoCutover?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { databaseId: string, specification: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, specification: string }; + let params: { + databaseId: string; + specification: string; + autoCutover?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + specification: string; + autoCutover?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, - specification: rest[0] as string + specification: rest[0] as string, + autoCutover: rest[1] as boolean, }; } - + const databaseId = params.databaseId; const specification = params.specification; + const autoCutover = params.autoCutover; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof specification === 'undefined') { - throw new AppwriteException('Missing required parameter: "specification"'); + throw new AppwriteException( + 'Missing required parameter: "specification"', + ); } - - const apiPath = '/tablesdb/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof specification !== 'undefined') { payload['specification'] = specification; } + if (typeof autoCutover !== 'undefined') { + payload['autoCutover'] = autoCutover; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -933,7 +1115,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getMigration(params: { databaseId: string, migrationId: string }): Promise; + getMigration(params: { + databaseId: string; + migrationId: string; + }): Promise; /** * Get a single dedicated migration for a TablesDB database by its ID. * @@ -943,47 +1128,57 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getMigration(databaseId: string, migrationId: string): Promise; getMigration( - paramsOrFirst: { databaseId: string, migrationId: string } | string, - ...rest: [(string)?] + databaseId: string, + migrationId: string, + ): Promise; + getMigration( + paramsOrFirst: { databaseId: string; migrationId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, migrationId: string }; + let params: { databaseId: string; migrationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + migrationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - migrationId: rest[0] as string + migrationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const migrationId = params.migrationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); + if (typeof migrationId === 'undefined' || migrationId === '') { + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{migrationId}', encodeURIComponent(String(migrationId))); + const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{migrationId}', encodeURIComponent(String(migrationId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -994,7 +1189,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteMigration(params: { databaseId: string, migrationId: string }): Promise<{}>; + deleteMigration(params: { + databaseId: string; + migrationId: string; + }): Promise<{}>; /** * Abort an in-flight TablesDB dedicated migration. Only allowed before cutover; once the migration has cut over it cannot be aborted. * @@ -1006,46 +1204,132 @@ export class TablesDB { */ deleteMigration(databaseId: string, migrationId: string): Promise<{}>; deleteMigration( - paramsOrFirst: { databaseId: string, migrationId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; migrationId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, migrationId: string }; + let params: { databaseId: string; migrationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + migrationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - migrationId: rest[0] as string + migrationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const migrationId = params.migrationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); + if (typeof migrationId === 'undefined' || migrationId === '') { + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{migrationId}', encodeURIComponent(String(migrationId))); + const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{migrationId}', encodeURIComponent(String(migrationId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, payload); + } + + /** + * Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.migrationId - Migration ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createCutover(params: { + databaseId: string; + migrationId: string; + }): Promise; + /** + * Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. + * + * @param {string} databaseId - Database ID. + * @param {string} migrationId - Migration ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createCutover( + databaseId: string, + migrationId: string, + ): Promise; + createCutover( + paramsOrFirst: { databaseId: string; migrationId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; migrationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + migrationId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + migrationId: rest[0] as string, + }; } - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + const databaseId = params.databaseId; + const migrationId = params.migrationId; + + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof migrationId === 'undefined' || migrationId === '') { + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{migrationId}', + encodeURIComponent(String(migrationId)), + ); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1058,7 +1342,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -1070,34 +1359,64 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -1112,15 +1431,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1130,7 +1444,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -1141,39 +1457,42 @@ export class TablesDB { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1194,39 +1513,42 @@ export class TablesDB { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1239,7 +1561,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listTables(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listTables(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. * @@ -1251,34 +1578,64 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTables(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; listTables( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listTables( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/tables'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1293,15 +1650,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1313,12 +1665,21 @@ export class TablesDB { * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. - * @param {object[]} params.columns - Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.columns - Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise} */ - createTable(params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }): Promise; + createTable(params: { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + }): Promise; /** * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -1328,21 +1689,71 @@ export class TablesDB { * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. - * @param {object[]} columns - Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} columns - Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTable(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[]): Promise; createTable( - paramsOrFirst: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + databaseId: string, + tableId: string, + name: string, + permissions?: string[], + rowSecurity?: boolean, + enabled?: boolean, + columns?: object[], + indexes?: object[], + ): Promise; + createTable( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + object[]?, + object[]?, + ] ): Promise { - let params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }; + let params: { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1352,10 +1763,10 @@ export class TablesDB { rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], - indexes: rest[6] as object[] + indexes: rest[6] as object[], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const name = params.name; @@ -1365,17 +1776,23 @@ export class TablesDB { const columns = params.columns; const indexes = params.indexes; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/tablesdb/{databaseId}/tables'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof tableId !== 'undefined') { payload['tableId'] = tableId; @@ -1403,15 +1820,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1422,7 +1834,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getTable(params: { databaseId: string, tableId: string }): Promise; + getTable(params: { + databaseId: string; + tableId: string; + }): Promise; /** * Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. * @@ -1434,45 +1849,52 @@ export class TablesDB { */ getTable(databaseId: string, tableId: string): Promise; getTable( - paramsOrFirst: { databaseId: string, tableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; tableId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, tableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + let params: { databaseId: string; tableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - tableId: rest[0] as string + tableId: rest[0] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1488,7 +1910,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTable(params: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise; + updateTable(params: { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }): Promise; /** * Update a table by its unique ID. * @@ -1503,15 +1933,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTable(databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise; updateTable( - paramsOrFirst: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + name?: string, + permissions?: string[], + rowSecurity?: boolean, + enabled?: boolean, + purge?: boolean, + ): Promise; + updateTable( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }; + let params: { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1520,10 +1988,10 @@ export class TablesDB { permissions: rest[2] as string[], rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, - purge: rest[5] as boolean + purge: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const name = params.name; @@ -1532,14 +2000,19 @@ export class TablesDB { const enabled = params.enabled; const purge = params.purge; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1561,15 +2034,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1580,7 +2048,7 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteTable(params: { databaseId: string, tableId: string }): Promise<{}>; + deleteTable(params: { databaseId: string; tableId: string }): Promise<{}>; /** * Delete a table by its unique ID. Only users with write permissions have access to delete this resource. * @@ -1592,45 +2060,53 @@ export class TablesDB { */ deleteTable(databaseId: string, tableId: string): Promise<{}>; deleteTable( - paramsOrFirst: { databaseId: string, tableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; tableId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + let params: { databaseId: string; tableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - tableId: rest[0] as string + tableId: rest[0] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1643,7 +2119,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listColumns(params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }): Promise; + listColumns(params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List columns in the table. * @@ -1655,37 +2136,68 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listColumns(databaseId: string, tableId: string, queries?: string[], total?: boolean): Promise; listColumns( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + tableId: string, + queries?: string[], + total?: boolean, + ): Promise; + listColumns( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1697,20 +2209,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a bigint column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -1723,10 +2230,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createBigIntColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createBigIntColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create a bigint column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -1740,15 +2256,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBigIntColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createBigIntColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createBigIntColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1758,10 +2324,10 @@ export class TablesDB { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -1771,20 +2337,27 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -1809,20 +2382,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a bigint column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -1835,10 +2403,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateBigIntColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateBigIntColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update a bigint column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -1852,15 +2429,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBigIntColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateBigIntColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateBigIntColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1870,10 +2497,10 @@ export class TablesDB { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -1883,23 +2510,34 @@ export class TablesDB { const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -1921,20 +2559,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a boolean column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -1945,10 +2578,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createBooleanColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise; + createBooleanColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }): Promise; /** * Create a boolean column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -1960,15 +2600,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise; createBooleanColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: boolean, + array?: boolean, + ): Promise; + createBooleanColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1976,10 +2650,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -1987,20 +2661,28 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2019,15 +2701,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2042,7 +2719,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateBooleanColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise; + updateBooleanColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }): Promise; /** * Update a boolean column. Changing the `default` value will not update already existing rows. * @@ -2056,15 +2740,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise; updateBooleanColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: boolean, + newKey?: string, + ): Promise; + updateBooleanColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2072,10 +2790,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2083,23 +2801,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + if (typeof xdefault === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2115,15 +2844,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2138,7 +2862,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createDatetimeColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createDatetimeColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a date time column according to the ISO 8601 standard. * @@ -2152,15 +2883,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createDatetimeColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createDatetimeColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2168,10 +2933,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2179,20 +2944,28 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2211,15 +2984,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2234,7 +3002,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateDatetimeColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateDatetimeColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a date time column. Changing the `default` value will not update already existing rows. * @@ -2248,15 +3023,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateDatetimeColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateDatetimeColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2264,10 +3073,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2275,23 +3084,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2307,20 +3127,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create an email column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2331,10 +3146,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createEmailColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createEmailColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create an email column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2346,15 +3168,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createEmailColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEmailColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2362,10 +3218,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2373,20 +3229,27 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2405,20 +3268,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an email column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2429,10 +3287,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEmailColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an email column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2444,15 +3309,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateEmailColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEmailColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2460,10 +3359,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2471,23 +3370,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2503,15 +3413,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2527,7 +3432,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createEnumColumn(params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise; + createEnumColumn(params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. * @@ -2542,15 +3455,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise; createEnumColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEnumColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2559,10 +3510,10 @@ export class TablesDB { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - array: rest[5] as boolean + array: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2571,23 +3522,32 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2609,20 +3569,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an enum column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2634,10 +3589,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateEnumColumn(params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEnumColumn(params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an enum column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2650,15 +3613,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise; updateEnumColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEnumColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2667,10 +3668,10 @@ export class TablesDB { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2679,26 +3680,39 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof elements !== 'undefined') { payload['elements'] = elements; @@ -2717,20 +3731,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a float column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2743,10 +3752,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createFloatColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise; + createFloatColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }): Promise; /** * Create a float column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2760,15 +3778,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise; createFloatColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + min?: number, + max?: number, + xdefault?: number, + array?: boolean, + ): Promise; + createFloatColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2778,10 +3846,10 @@ export class TablesDB { min: rest[3] as number, max: rest[4] as number, xdefault: rest[5] as number, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2791,20 +3859,27 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2829,20 +3904,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a float column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2855,10 +3925,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateFloatColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise; + updateFloatColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }): Promise; /** * Update a float column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2872,15 +3951,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise; updateFloatColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number, + min?: number, + max?: number, + newKey?: string, + ): Promise; + updateFloatColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2890,10 +4019,10 @@ export class TablesDB { xdefault: rest[3] as number, min: rest[4] as number, max: rest[5] as number, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2903,23 +4032,34 @@ export class TablesDB { const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -2941,20 +4081,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create an integer column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2967,10 +4102,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createIntegerColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create an integer column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2984,15 +4128,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createIntegerColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createIntegerColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3002,10 +4196,10 @@ export class TablesDB { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3015,20 +4209,28 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3053,20 +4255,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an integer column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3079,10 +4276,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateIntegerColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update an integer column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3096,15 +4302,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateIntegerColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateIntegerColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3114,10 +4370,10 @@ export class TablesDB { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3127,23 +4383,34 @@ export class TablesDB { const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3165,20 +4432,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create IP address column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3189,10 +4451,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createIpColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createIpColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create IP address column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3204,15 +4473,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createIpColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createIpColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3220,10 +4523,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3231,20 +4534,27 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3263,20 +4573,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an ip column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3287,10 +4592,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateIpColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateIpColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an ip column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3302,15 +4614,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateIpColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateIpColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3318,10 +4664,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3329,23 +4675,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3361,15 +4718,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3383,7 +4735,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createLineColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createLineColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric line column. * @@ -3396,45 +4754,82 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLineColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createLineColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createLineColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3450,15 +4845,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3473,7 +4863,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateLineColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updateLineColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a line column. Changing the `default` value will not update already existing rows. * @@ -3487,15 +4884,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLineColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updateLineColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updateLineColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3503,10 +4934,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3514,20 +4945,29 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3543,20 +4983,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a longtext column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3568,10 +5003,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createLongtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createLongtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a longtext column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3584,15 +5027,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLongtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createLongtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createLongtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3601,10 +5082,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3613,20 +5094,28 @@ export class TablesDB { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3648,20 +5137,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a longtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3672,10 +5156,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateLongtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateLongtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a longtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3687,15 +5178,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLongtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateLongtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateLongtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3703,10 +5228,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3714,23 +5239,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3746,20 +5282,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a mediumtext column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3771,10 +5302,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createMediumtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createMediumtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a mediumtext column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3787,15 +5326,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMediumtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createMediumtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createMediumtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3804,10 +5381,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3816,20 +5393,28 @@ export class TablesDB { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -3851,20 +5436,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3875,10 +5455,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateMediumtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateMediumtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3890,15 +5477,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMediumtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateMediumtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateMediumtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3906,10 +5527,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3917,23 +5538,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -3949,15 +5581,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3971,7 +5598,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createPointColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] }): Promise; + createPointColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + }): Promise; /** * Create a geometric point column. * @@ -3984,45 +5617,82 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPointColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[]): Promise; createPointColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number[], + ): Promise; + createPointColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + } + | string, + ...rest: [string?, string?, boolean?, number[]?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[] + xdefault: rest[3] as number[], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4038,15 +5708,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4061,7 +5726,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updatePointColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }): Promise; + updatePointColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }): Promise; /** * Update a point column. Changing the `default` value will not update already existing rows. * @@ -4075,15 +5747,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePointColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string): Promise; updatePointColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number[], + newKey?: string, + ): Promise; + updatePointColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, number[]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4091,10 +5797,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as number[], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4102,20 +5808,29 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4131,15 +5846,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -4153,7 +5863,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createPolygonColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createPolygonColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric polygon column. * @@ -4166,45 +5882,83 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPolygonColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createPolygonColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createPolygonColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4220,15 +5974,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -4243,7 +5992,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updatePolygonColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updatePolygonColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a polygon column. Changing the `default` value will not update already existing rows. * @@ -4257,15 +6013,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePolygonColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updatePolygonColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updatePolygonColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4273,10 +6063,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4284,20 +6074,29 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4313,58 +6112,112 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.relatedTableId - Related Table ID. - * @param {RelationshipType} params.type - Relation type + * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? * @param {string} params.key - Column Key. * @param {string} params.twoWayKey - Two Way Column Key. - * @param {RelationMutate} params.onDelete - Constraints option + * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise} */ - createRelationshipColumn(params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise; + createRelationshipColumn(params: { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }): Promise; /** * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} relatedTableId - Related Table ID. - * @param {RelationshipType} type - Relation type + * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? * @param {string} key - Column Key. * @param {string} twoWayKey - Two Way Column Key. - * @param {RelationMutate} onDelete - Constraints option + * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise; createRelationshipColumn( - paramsOrFirst: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, - ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + databaseId: string, + tableId: string, + relatedTableId: string, + type: RelationshipType, + twoWay?: boolean, + key?: string, + twoWayKey?: string, + onDelete?: RelationMutate, + ): Promise; + createRelationshipColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + } + | string, + ...rest: [ + string?, + string?, + RelationshipType?, + boolean?, + string?, + string?, + RelationMutate?, + ] ): Promise { - let params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + let params: { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4374,10 +6227,10 @@ export class TablesDB { twoWay: rest[3] as boolean, key: rest[4] as string, twoWayKey: rest[5] as string, - onDelete: rest[6] as RelationMutate + onDelete: rest[6] as RelationMutate, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const relatedTableId = params.relatedTableId; @@ -4387,20 +6240,28 @@ export class TablesDB { const twoWayKey = params.twoWayKey; const onDelete = params.onDelete; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof relatedTableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "relatedTableId"'); + throw new AppwriteException( + 'Missing required parameter: "relatedTableId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof relatedTableId !== 'undefined') { payload['relatedTableId'] = relatedTableId; @@ -4425,20 +6286,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create a string column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4452,10 +6308,19 @@ export class TablesDB { * @returns {Promise} * @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. */ - createStringColumn(params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createStringColumn(params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a string column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4469,15 +6334,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createStringColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createStringColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createStringColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4487,10 +6402,10 @@ export class TablesDB { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4500,11 +6415,15 @@ export class TablesDB { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -4513,10 +6432,13 @@ export class TablesDB { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4541,20 +6463,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a string column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4567,10 +6484,18 @@ export class TablesDB { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. */ - updateStringColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateStringColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a string column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4583,15 +6508,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStringColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateStringColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateStringColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4600,10 +6563,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4612,23 +6575,34 @@ export class TablesDB { const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4647,20 +6621,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a text column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4672,10 +6641,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createTextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createTextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a text column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4688,15 +6665,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createTextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createTextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4705,10 +6720,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4717,20 +6732,27 @@ export class TablesDB { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4752,20 +6774,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a text column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4776,10 +6793,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateTextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a text column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4791,15 +6815,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateTextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateTextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4807,10 +6865,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4818,23 +6876,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -4850,20 +6919,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a URL column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -4874,10 +6938,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createUrlColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createUrlColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a URL column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -4889,15 +6960,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createUrlColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createUrlColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4905,10 +7010,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4916,20 +7021,27 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -4948,20 +7060,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update an url column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -4972,10 +7079,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateUrlColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateUrlColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an url column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -4987,15 +7101,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateUrlColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateUrlColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5003,10 +7151,10 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5014,23 +7162,34 @@ export class TablesDB { const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -5046,20 +7205,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Create a varchar column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5072,10 +7226,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createVarcharColumn(params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createVarcharColumn(params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a varchar column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5089,15 +7252,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVarcharColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createVarcharColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createVarcharColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5107,10 +7320,10 @@ export class TablesDB { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5120,11 +7333,15 @@ export class TablesDB { const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -5133,10 +7350,14 @@ export class TablesDB { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -5161,20 +7382,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Update a varchar column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5186,10 +7402,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateVarcharColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateVarcharColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a varchar column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5202,15 +7426,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVarcharColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateVarcharColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateVarcharColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5219,10 +7481,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5231,23 +7493,34 @@ export class TablesDB { const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; @@ -5266,15 +7539,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5286,7 +7554,22 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getColumn(params: { databaseId: string, tableId: string, key: string }): Promise; + getColumn(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise< + | Models.ColumnBoolean + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnString + >; /** * Get column by ID. * @@ -5297,52 +7580,88 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getColumn(databaseId: string, tableId: string, key: string): Promise; getColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + databaseId: string, + tableId: string, + key: string, + ): Promise< + | Models.ColumnBoolean + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnString + >; + getColumn( + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise< + | Models.ColumnBoolean + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnString + > { + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5354,7 +7673,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteColumn(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + deleteColumn(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise<{}>; /** * Deletes a column. * @@ -5367,114 +7690,168 @@ export class TablesDB { */ deleteColumn(databaseId: string, tableId: string, key: string): Promise<{}>; deleteColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Constraints option + * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @param {string} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise} */ - updateRelationshipColumn(params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise; + updateRelationshipColumn(params: { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }): Promise; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Constraints option + * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @param {string} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise; updateRelationshipColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, - ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + databaseId: string, + tableId: string, + key: string, + onDelete?: RelationMutate, + newKey?: string, + ): Promise; + updateRelationshipColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + } + | string, + ...rest: [string?, string?, RelationMutate?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, onDelete: rest[2] as RelationMutate, - newKey: rest[3] as string + newKey: rest[3] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const onDelete = params.onDelete; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; if (typeof onDelete !== 'undefined') { payload['onDelete'] = onDelete; @@ -5487,15 +7864,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -5508,7 +7880,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listIndexes(params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }): Promise; + listIndexes(params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List indexes on the table. * @@ -5520,37 +7897,68 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIndexes(databaseId: string, tableId: string, queries?: string[], total?: boolean): Promise; listIndexes( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + tableId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -5562,15 +7970,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5587,7 +7990,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createIndex(params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; /** * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. * Type can be `key`, `fulltext`, or `unique`. @@ -5603,15 +8014,60 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (TablesDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + databaseId: string, + tableId: string, + key: string, + type: TablesDBIndexType, + columns: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + TablesDBIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5620,10 +8076,10 @@ export class TablesDB { type: rest[2] as TablesDBIndexType, columns: rest[3] as string[], orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] + lengths: rest[5] as number[], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5632,11 +8088,15 @@ export class TablesDB { const orders = params.orders; const lengths = params.lengths; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -5645,10 +8105,13 @@ export class TablesDB { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof columns === 'undefined') { - throw new AppwriteException('Missing required parameter: "columns"'); + throw new AppwriteException( + 'Missing required parameter: "columns"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -5670,15 +8133,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -5690,7 +8148,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getIndex(params: { databaseId: string, tableId: string, key: string }): Promise; + getIndex(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise; /** * Get index by ID. * @@ -5701,52 +8163,66 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getIndex(databaseId: string, tableId: string, key: string): Promise; getIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5758,7 +8234,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteIndex(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + deleteIndex(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise<{}>; /** * Delete an index. * @@ -5771,50 +8251,61 @@ export class TablesDB { */ deleteIndex(databaseId: string, tableId: string, key: string): Promise<{}>; deleteIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -5829,7 +8320,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - listRows(params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + listRows(params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * @@ -5843,15 +8341,49 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listRows(databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; listRows( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + tableId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5859,10 +8391,10 @@ export class TablesDB { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; @@ -5870,14 +8402,19 @@ export class TablesDB { const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -5895,15 +8432,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -5918,7 +8450,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createRow(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }): Promise; + createRow(params: { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -5932,26 +8473,78 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRow(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string): Promise; createRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Omit)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit, + permissions?: string[], + transactionId?: string, + ): Promise; + createRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, + data: rest[2] as Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -5959,11 +8552,15 @@ export class TablesDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); @@ -5971,8 +8568,9 @@ export class TablesDB { if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof rowId !== 'undefined') { payload['rowId'] = rowId; @@ -5991,15 +8589,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -6012,7 +8605,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - createRows(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise>; + createRows(params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }): Promise>; /** * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -6024,40 +8622,71 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createRows(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise>; createRows( - paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + tableId: string, + rows: object[], + transactionId?: string, + ): Promise>; + createRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rows: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rows = params.rows; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rows === 'undefined') { throw new AppwriteException('Missing required parameter: "rows"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof rows !== 'undefined') { payload['rows'] = rows; @@ -6070,20 +8699,15 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -6092,10 +8716,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - upsertRows(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise>; + upsertRows(params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }): Promise>; /** * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -6105,40 +8734,71 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertRows(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise>; upsertRows( - paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + tableId: string, + rows: object[], + transactionId?: string, + ): Promise>; + upsertRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rows: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rows = params.rows; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rows === 'undefined') { throw new AppwriteException('Missing required parameter: "rows"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof rows !== 'undefined') { payload['rows'] = rows; @@ -6151,15 +8811,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -6173,7 +8828,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - updateRows(params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + updateRows(params: { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. * @@ -6186,39 +8847,74 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRows(databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateRows( - paramsOrFirst: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, data: rest[1] as object, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const data = params.data; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -6234,15 +8930,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6255,7 +8946,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - deleteRows(params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }): Promise>; + deleteRows(params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Bulk delete rows using queries, if no queries are passed then all rows are deleted. * @@ -6267,37 +8963,68 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteRows(databaseId: string, tableId: string, queries?: string[], transactionId?: string): Promise>; deleteRows( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, queries: rest[1] as string[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -6310,15 +9037,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -6332,7 +9054,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getRow(params: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }): Promise; + getRow(params: { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + }): Promise; /** * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * @@ -6345,42 +9073,78 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRow(databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string): Promise; getRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof rowId === 'undefined') { + if (typeof rowId === 'undefined' || rowId === '') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -6392,15 +9156,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -6415,7 +9174,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - upsertRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertRow(params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -6429,26 +9197,81 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, + data: rest[2] as Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -6456,17 +9279,23 @@ export class TablesDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof rowId === 'undefined') { + if (typeof rowId === 'undefined' || rowId === '') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -6482,15 +9311,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -6505,7 +9329,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + updateRow(params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -6519,26 +9352,81 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, + data: rest[2] as Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -6546,17 +9434,23 @@ export class TablesDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof rowId === 'undefined') { + if (typeof rowId === 'undefined' || rowId === '') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -6572,15 +9466,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6593,7 +9482,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteRow(params: { databaseId: string, tableId: string, rowId: string, transactionId?: string }): Promise<{}>; + deleteRow(params: { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + }): Promise<{}>; /** * Delete a row by its unique ID. * @@ -6605,40 +9499,72 @@ export class TablesDB { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteRow(databaseId: string, tableId: string, rowId: string, transactionId?: string): Promise<{}>; deleteRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + transactionId?: string, + ): Promise<{}>; + deleteRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, rowId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof rowId === 'undefined') { + if (typeof rowId === 'undefined' || rowId === '') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); const payload: Payload = {}; if (typeof transactionId !== 'undefined') { payload['transactionId'] = transactionId; @@ -6648,14 +9574,10 @@ export class TablesDB { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -6671,7 +9593,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - decrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }): Promise; + decrementRowColumn(params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + }): Promise; /** * Decrement a specific column of a row by a given value. * @@ -6686,15 +9616,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - decrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string): Promise; decrementRowColumn( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + column: string, + value?: number, + min?: number, + transactionId?: string, + ): Promise; + decrementRowColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -6703,10 +9671,10 @@ export class TablesDB { column: rest[2] as string, value: rest[3] as number, min: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -6715,20 +9683,28 @@ export class TablesDB { const min = params.min; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof rowId === 'undefined') { + if (typeof rowId === 'undefined' || rowId === '') { throw new AppwriteException('Missing required parameter: "rowId"'); } - if (typeof column === 'undefined') { + if (typeof column === 'undefined' || column === '') { throw new AppwriteException('Missing required parameter: "column"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))).replace('{column}', encodeURIComponent(String(column))); + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))) + .replace('{column}', encodeURIComponent(String(column))); const payload: Payload = {}; if (typeof value !== 'undefined') { payload['value'] = value; @@ -6744,15 +9720,10 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -6768,7 +9739,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - incrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }): Promise; + incrementRowColumn(params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + }): Promise; /** * Increment a specific column of a row by a given value. * @@ -6783,15 +9762,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - incrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string): Promise; incrementRowColumn( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + column: string, + value?: number, + max?: number, + transactionId?: string, + ): Promise; + incrementRowColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -6800,10 +9817,10 @@ export class TablesDB { column: rest[2] as string, value: rest[3] as number, max: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -6812,20 +9829,28 @@ export class TablesDB { const max = params.max; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } - if (typeof rowId === 'undefined') { + if (typeof rowId === 'undefined' || rowId === '') { throw new AppwriteException('Missing required parameter: "rowId"'); } - if (typeof column === 'undefined') { + if (typeof column === 'undefined' || column === '') { throw new AppwriteException('Missing required parameter: "column"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))).replace('{column}', encodeURIComponent(String(column))); + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))) + .replace('{column}', encodeURIComponent(String(column))); const payload: Payload = {}; if (typeof value !== 'undefined') { payload['value'] = value; @@ -6841,14 +9866,9 @@ export class TablesDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 7d949581..66cdfc57 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Teams { client: Client; @@ -19,7 +17,13 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise>; + list< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise>; /** * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * @@ -30,28 +34,41 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise>; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise>; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise> { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/teams'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -67,15 +84,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -87,7 +99,13 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - create(params: { teamId: string, name: string, roles?: string[] }): Promise>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + teamId: string; + name: string; + roles?: string[]; + }): Promise>; /** * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. * @@ -98,23 +116,36 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(teamId: string, name: string, roles?: string[]): Promise>; create( - paramsOrFirst: { teamId: string, name: string, roles?: string[] } | string, - ...rest: [(string)?, (string[])?] + teamId: string, + name: string, + roles?: string[], + ): Promise>; + create( + paramsOrFirst: + { teamId: string; name: string; roles?: string[] } | string, + ...rest: [string?, string[]?] ): Promise> { - let params: { teamId: string, name: string, roles?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, name: string, roles?: string[] }; + let params: { teamId: string; name: string; roles?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + name: string; + roles?: string[]; + }; } else { params = { teamId: paramsOrFirst as string, name: rest[0] as string, - roles: rest[1] as string[] + roles: rest[1] as string[], }; } - + const teamId = params.teamId; const name = params.name; const roles = params.roles; @@ -125,7 +156,6 @@ export class Teams { if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/teams'; const payload: Payload = {}; if (typeof teamId !== 'undefined') { @@ -142,15 +172,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -160,7 +185,9 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - get(params: { teamId: string }): Promise>; + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { teamId: string }): Promise>; /** * Get a team by its ID. All team members have read access for this resource. * @@ -169,41 +196,44 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - get(teamId: string): Promise>; get( - paramsOrFirst: { teamId: string } | string + teamId: string, + ): Promise>; + get( + paramsOrFirst: { teamId: string } | string, ): Promise> { let params: { teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { teamId: string }; } else { params = { - teamId: paramsOrFirst as string + teamId: paramsOrFirst as string, }; } - + const teamId = params.teamId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -214,7 +244,12 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(params: { teamId: string, name: string }): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + teamId: string; + name: string; + }): Promise>; /** * Update the team's name by its unique ID. * @@ -224,33 +259,43 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateName(teamId: string, name: string): Promise>; - updateName( - paramsOrFirst: { teamId: string, name: string } | string, - ...rest: [(string)?] + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(teamId: string, name: string): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { teamId: string; name: string } | string, + ...rest: [string?] ): Promise> { - let params: { teamId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, name: string }; + let params: { teamId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { teamId: string; name: string }; } else { params = { teamId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const teamId = params.teamId; const name = params.name; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/teams/{teamId}'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -260,15 +305,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -288,40 +328,40 @@ export class Teams { * @deprecated Use the object parameter style method for a better developer experience. */ delete(teamId: string): Promise<{}>; - delete( - paramsOrFirst: { teamId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { teamId: string } | string): Promise<{}> { let params: { teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { teamId: string }; } else { params = { - teamId: paramsOrFirst as string + teamId: paramsOrFirst as string, }; } - + const teamId = params.teamId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -333,7 +373,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params: { teamId: string, queries?: string[], total?: boolean }): Promise; + listInstallations(params: { + teamId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List app installations on a team. Any team member can read installations. * @@ -344,32 +388,47 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(teamId: string, queries?: string[], total?: boolean): Promise; listInstallations( - paramsOrFirst: { teamId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + teamId: string, + queries?: string[], + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst: + { teamId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { teamId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], total?: boolean }; + let params: { teamId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { teamId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const teamId = params.teamId; const queries = params.queries; const total = params.total; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/installations'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/installations'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -381,15 +440,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -401,7 +455,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - createInstallation(params: { teamId: string, appId: string, authorizationDetails?: string }): Promise; + createInstallation(params: { + teamId: string; + appId: string; + authorizationDetails?: string; + }): Promise; /** * Install an app on a team. When authenticated as a user, only team members with the owner role can install apps. Requests using an API key or in admin mode can install apps on any team. The installation is granted the scopes the app currently requests. * @@ -412,35 +470,55 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInstallation(teamId: string, appId: string, authorizationDetails?: string): Promise; createInstallation( - paramsOrFirst: { teamId: string, appId: string, authorizationDetails?: string } | string, - ...rest: [(string)?, (string)?] + teamId: string, + appId: string, + authorizationDetails?: string, + ): Promise; + createInstallation( + paramsOrFirst: + | { teamId: string; appId: string; authorizationDetails?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { teamId: string, appId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, appId: string, authorizationDetails?: string }; + let params: { + teamId: string; + appId: string; + authorizationDetails?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + appId: string; + authorizationDetails?: string; + }; } else { params = { teamId: paramsOrFirst as string, appId: rest[0] as string, - authorizationDetails: rest[1] as string + authorizationDetails: rest[1] as string, }; } - + const teamId = params.teamId; const appId = params.appId; const authorizationDetails = params.authorizationDetails; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/teams/{teamId}/installations'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/installations'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof appId !== 'undefined') { payload['appId'] = appId; @@ -453,15 +531,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -472,7 +545,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { teamId: string, installationId: string }): Promise; + getInstallation(params: { + teamId: string; + installationId: string; + }): Promise; /** * Get an app installation on a team by its unique ID. Any team member can read installations. * @@ -482,47 +558,58 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getInstallation(teamId: string, installationId: string): Promise; getInstallation( - paramsOrFirst: { teamId: string, installationId: string } | string, - ...rest: [(string)?] + teamId: string, + installationId: string, + ): Promise; + getInstallation( + paramsOrFirst: { teamId: string; installationId: string } | string, + ...rest: [string?] ): Promise { - let params: { teamId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, installationId: string }; + let params: { teamId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + installationId: string; + }; } else { params = { teamId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const teamId = params.teamId; const installationId = params.installationId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/teams/{teamId}/installations/{installationId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -534,7 +621,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updateInstallation(params: { teamId: string, installationId: string, authorizationDetails?: string }): Promise; + updateInstallation(params: { + teamId: string; + installationId: string; + authorizationDetails?: string; + }): Promise; /** * Update an app installation on a team. Only team members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. * @@ -545,35 +636,63 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateInstallation(teamId: string, installationId: string, authorizationDetails?: string): Promise; updateInstallation( - paramsOrFirst: { teamId: string, installationId: string, authorizationDetails?: string } | string, - ...rest: [(string)?, (string)?] + teamId: string, + installationId: string, + authorizationDetails?: string, + ): Promise; + updateInstallation( + paramsOrFirst: + | { + teamId: string; + installationId: string; + authorizationDetails?: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { teamId: string, installationId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, installationId: string, authorizationDetails?: string }; + let params: { + teamId: string; + installationId: string; + authorizationDetails?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + installationId: string; + authorizationDetails?: string; + }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string + authorizationDetails: rest[1] as string, }; } - + const teamId = params.teamId; const installationId = params.installationId; const authorizationDetails = params.authorizationDetails; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/teams/{teamId}/installations/{installationId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; if (typeof authorizationDetails !== 'undefined') { payload['authorizationDetails'] = authorizationDetails; @@ -583,15 +702,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -602,7 +716,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteInstallation(params: { teamId: string, installationId: string }): Promise<{}>; + deleteInstallation(params: { + teamId: string; + installationId: string; + }): Promise<{}>; /** * Uninstall an app from a team by its installation ID. Only team members with the owner role can remove installations. Previously issued installation access tokens are revoked. * @@ -614,46 +731,54 @@ export class Teams { */ deleteInstallation(teamId: string, installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { teamId: string, installationId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { teamId: string; installationId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { teamId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, installationId: string }; + let params: { teamId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + installationId: string; + }; } else { params = { teamId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const teamId = params.teamId; const installationId = params.installationId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/teams/{teamId}/installations/{installationId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -665,7 +790,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params: { teamId: string, queries?: string[], total?: boolean }): Promise; + listLogs(params: { + teamId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the team activity logs list by its unique ID. * @@ -676,32 +805,47 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listLogs(teamId: string, queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst: { teamId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + teamId: string, + queries?: string[], + total?: boolean, + ): Promise; + listLogs( + paramsOrFirst: + { teamId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { teamId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], total?: boolean }; + let params: { teamId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { teamId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const teamId = params.teamId; const queries = params.queries; const total = params.total; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/logs'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/logs'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -713,15 +857,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -734,7 +873,12 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - listMemberships(params: { teamId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listMemberships(params: { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * @@ -746,34 +890,62 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMemberships(teamId: string, queries?: string[], search?: string, total?: boolean): Promise; listMemberships( - paramsOrFirst: { teamId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + teamId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMemberships( + paramsOrFirst: + | { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { teamId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { teamId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const teamId = params.teamId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/memberships'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -788,26 +960,21 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. - * + * * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. - * - * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. - * + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. + * * Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. - * + * * * @param {string} params.teamId - Team ID. * @param {string[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. @@ -819,16 +986,24 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - createMembership(params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise; + createMembership(params: { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }): Promise; /** * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. - * + * * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. - * - * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. - * + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. + * * Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. - * + * * * @param {string} teamId - Team ID. * @param {string[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. @@ -841,15 +1016,53 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise; createMembership( - paramsOrFirst: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string, - ...rest: [(string[])?, (string)?, (string)?, (string)?, (string)?, (string)?] + teamId: string, + roles: string[], + email?: string, + userId?: string, + phone?: string, + url?: string, + name?: string, + ): Promise; + createMembership( + paramsOrFirst: + | { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + } + | string, + ...rest: [string[]?, string?, string?, string?, string?, string?] ): Promise { - let params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + let params: { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; } else { params = { teamId: paramsOrFirst as string, @@ -858,10 +1071,10 @@ export class Teams { userId: rest[2] as string, phone: rest[3] as string, url: rest[4] as string, - name: rest[5] as string + name: rest[5] as string, }; } - + const teamId = params.teamId; const roles = params.roles; const email = params.email; @@ -870,14 +1083,16 @@ export class Teams { const url = params.url; const name = params.name; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - - const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/memberships'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; @@ -902,15 +1117,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -921,7 +1131,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - getMembership(params: { teamId: string, membershipId: string }): Promise; + getMembership(params: { + teamId: string; + membershipId: string; + }): Promise; /** * Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. * @@ -931,52 +1144,63 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getMembership(teamId: string, membershipId: string): Promise; getMembership( - paramsOrFirst: { teamId: string, membershipId: string } | string, - ...rest: [(string)?] + teamId: string, + membershipId: string, + ): Promise; + getMembership( + paramsOrFirst: { teamId: string; membershipId: string } | string, + ...rest: [string?] ): Promise { - let params: { teamId: string, membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string }; + let params: { teamId: string; membershipId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + }; } else { params = { teamId: paramsOrFirst as string, - membershipId: rest[0] as string + membershipId: rest[0] as string, }; } - + const teamId = params.teamId; const membershipId = params.membershipId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); - } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); + } + const apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). - * + * * * @param {string} params.teamId - Team ID. * @param {string} params.membershipId - Membership ID. @@ -984,10 +1208,14 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updateMembership(params: { teamId: string, membershipId: string, roles: string[] }): Promise; + updateMembership(params: { + teamId: string; + membershipId: string; + roles: string[]; + }): Promise; /** * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). - * + * * * @param {string} teamId - Team ID. * @param {string} membershipId - Membership ID. @@ -996,38 +1224,57 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembership(teamId: string, membershipId: string, roles: string[]): Promise; updateMembership( - paramsOrFirst: { teamId: string, membershipId: string, roles: string[] } | string, - ...rest: [(string)?, (string[])?] + teamId: string, + membershipId: string, + roles: string[], + ): Promise; + updateMembership( + paramsOrFirst: + { teamId: string; membershipId: string; roles: string[] } | string, + ...rest: [string?, string[]?] ): Promise { - let params: { teamId: string, membershipId: string, roles: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: string[] }; + let params: { teamId: string; membershipId: string; roles: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + roles: string[]; + }; } else { params = { teamId: paramsOrFirst as string, membershipId: rest[0] as string, - roles: rest[1] as string[] + roles: rest[1] as string[], }; } - + const teamId = params.teamId; const membershipId = params.membershipId; const roles = params.roles; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); + const apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: Payload = {}; if (typeof roles !== 'undefined') { payload['roles'] = roles; @@ -1037,15 +1284,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1056,7 +1298,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteMembership(params: { teamId: string, membershipId: string }): Promise<{}>; + deleteMembership(params: { + teamId: string; + membershipId: string; + }): Promise<{}>; /** * This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. * @@ -1068,52 +1313,61 @@ export class Teams { */ deleteMembership(teamId: string, membershipId: string): Promise<{}>; deleteMembership( - paramsOrFirst: { teamId: string, membershipId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { teamId: string; membershipId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { teamId: string, membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string }; + let params: { teamId: string; membershipId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + }; } else { params = { teamId: paramsOrFirst as string, - membershipId: rest[0] as string + membershipId: rest[0] as string, }; } - + const teamId = params.teamId; const membershipId = params.membershipId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); - } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); + } + const apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: Payload = {}; const uri = new URL(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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. - * + * * If the request is successful, a session for the user is automatically created. - * + * * * @param {string} params.teamId - Team ID. * @param {string} params.membershipId - Membership ID. @@ -1122,12 +1376,17 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updateMembershipStatus(params: { teamId: string, membershipId: string, userId: string, secret: string }): Promise; + updateMembershipStatus(params: { + teamId: string; + membershipId: string; + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. - * + * * If the request is successful, a session for the user is automatically created. - * + * * * @param {string} teamId - Team ID. * @param {string} membershipId - Membership ID. @@ -1137,34 +1396,62 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise; updateMembershipStatus( - paramsOrFirst: { teamId: string, membershipId: string, userId: string, secret: string } | string, - ...rest: [(string)?, (string)?, (string)?] + teamId: string, + membershipId: string, + userId: string, + secret: string, + ): Promise; + updateMembershipStatus( + paramsOrFirst: + | { + teamId: string; + membershipId: string; + userId: string; + secret: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise { - let params: { teamId: string, membershipId: string, userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, userId: string, secret: string }; + let params: { + teamId: string; + membershipId: string; + userId: string; + secret: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + userId: string; + secret: string; + }; } else { params = { teamId: paramsOrFirst as string, membershipId: rest[0] as string, userId: rest[1] as string, - secret: rest[2] as string + secret: rest[2] as string, }; } - + const teamId = params.teamId; const membershipId = params.membershipId; const userId = params.userId; const secret = params.secret; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + if (typeof membershipId === 'undefined' || membershipId === '') { + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -1172,8 +1459,12 @@ export class Teams { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); + const apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; @@ -1186,15 +1477,10 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1204,7 +1490,9 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(params: { teamId: string }): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { teamId: string }): Promise; /** * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * @@ -1213,41 +1501,44 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPrefs(teamId: string): Promise; - getPrefs( - paramsOrFirst: { teamId: string } | string - ): Promise { + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(teamId: string): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(paramsOrFirst: { teamId: string } | string): Promise { let params: { teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { teamId: string }; } else { params = { - teamId: paramsOrFirst as string + teamId: paramsOrFirst as string, }; } - + const teamId = params.teamId; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/prefs'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1258,7 +1549,9 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updatePrefs(params: { teamId: string, prefs: object }): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { teamId: string; prefs: object }): Promise; /** * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * @@ -1268,33 +1561,43 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs(teamId: string, prefs: object): Promise; - updatePrefs( - paramsOrFirst: { teamId: string, prefs: object } | string, - ...rest: [(object)?] + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(teamId: string, prefs: object): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { teamId: string; prefs: object } | string, + ...rest: [object?] ): Promise { - let params: { teamId: string, prefs: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, prefs: object }; + let params: { teamId: string; prefs: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { teamId: string; prefs: object }; } else { params = { teamId: paramsOrFirst as string, - prefs: rest[0] as object + prefs: rest[0] as object, }; } - + const teamId = params.teamId; const prefs = params.prefs; - if (typeof teamId === 'undefined') { + if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } - - const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', encodeURIComponent(String(teamId))); + const apiPath = '/teams/{teamId}/prefs'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); const payload: Payload = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; @@ -1304,14 +1607,9 @@ export class Teams { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } } diff --git a/src/services/tokens.ts b/src/services/tokens.ts index c7534241..744ea043 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Tokens { client: Client; @@ -20,7 +18,12 @@ export class Tokens { * @throws {AppwriteException} * @returns {Promise} */ - list(params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }): Promise; + list(params: { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. * @@ -32,37 +35,66 @@ export class Tokens { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(bucketId: string, fileId: string, queries?: string[], total?: boolean): Promise; list( - paramsOrFirst: { bucketId: string, fileId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + bucketId: string, + fileId: string, + queries?: string[], + total?: boolean, + ): Promise; + list( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, queries?: string[], total?: boolean }; + let params: { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const queries = params.queries; const total = params.total; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -74,15 +106,10 @@ export class Tokens { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -94,7 +121,11 @@ export class Tokens { * @throws {AppwriteException} * @returns {Promise} */ - createFileToken(params: { bucketId: string, fileId: string, expire?: string }): Promise; + createFileToken(params: { + bucketId: string; + fileId: string; + expire?: string; + }): Promise; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * @@ -105,35 +136,51 @@ export class Tokens { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFileToken(bucketId: string, fileId: string, expire?: string): Promise; createFileToken( - paramsOrFirst: { bucketId: string, fileId: string, expire?: string } | string, - ...rest: [(string)?, (string)?] + bucketId: string, + fileId: string, + expire?: string, + ): Promise; + createFileToken( + paramsOrFirst: + { bucketId: string; fileId: string; expire?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { bucketId: string, fileId: string, expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, expire?: string }; + let params: { bucketId: string; fileId: string; expire?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + expire?: string; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string + expire: rest[1] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const expire = params.expire; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + if (typeof bucketId === 'undefined' || bucketId === '') { + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - if (typeof fileId === 'undefined') { + if (typeof fileId === 'undefined' || fileId === '') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); const payload: Payload = {}; if (typeof expire !== 'undefined') { payload['expire'] = expire; @@ -143,15 +190,10 @@ export class Tokens { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -172,39 +214,42 @@ export class Tokens { */ get(tokenId: string): Promise; get( - paramsOrFirst: { tokenId: string } | string + paramsOrFirst: { tokenId: string } | string, ): Promise { let params: { tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { tokenId: string }; } else { params = { - tokenId: paramsOrFirst as string + tokenId: paramsOrFirst as string, }; } - + const tokenId = params.tokenId; - if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + if (typeof tokenId === 'undefined' || tokenId === '') { + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', encodeURIComponent(String(tokenId))); + const apiPath = '/tokens/{tokenId}'.replace( + '{tokenId}', + encodeURIComponent(String(tokenId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -215,7 +260,10 @@ export class Tokens { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { tokenId: string, expire?: string }): Promise; + update(params: { + tokenId: string; + expire?: string; + }): Promise; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * @@ -227,28 +275,39 @@ export class Tokens { */ update(tokenId: string, expire?: string): Promise; update( - paramsOrFirst: { tokenId: string, expire?: string } | string, - ...rest: [(string)?] + paramsOrFirst: { tokenId: string; expire?: string } | string, + ...rest: [string?] ): Promise { - let params: { tokenId: string, expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { tokenId: string, expire?: string }; + let params: { tokenId: string; expire?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + tokenId: string; + expire?: string; + }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string + expire: rest[0] as string, }; } - + const tokenId = params.tokenId; const expire = params.expire; - if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + if (typeof tokenId === 'undefined' || tokenId === '') { + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', encodeURIComponent(String(tokenId))); + const apiPath = '/tokens/{tokenId}'.replace( + '{tokenId}', + encodeURIComponent(String(tokenId)), + ); const payload: Payload = {}; if (typeof expire !== 'undefined') { payload['expire'] = expire; @@ -258,15 +317,10 @@ export class Tokens { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -286,39 +340,41 @@ export class Tokens { * @deprecated Use the object parameter style method for a better developer experience. */ delete(tokenId: string): Promise<{}>; - delete( - paramsOrFirst: { tokenId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { tokenId: string } | string): Promise<{}> { let params: { tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { tokenId: string }; } else { params = { - tokenId: paramsOrFirst as string + tokenId: paramsOrFirst as string, }; } - + const tokenId = params.tokenId; - if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + if (typeof tokenId === 'undefined' || tokenId === '') { + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', encodeURIComponent(String(tokenId))); + const apiPath = '/tokens/{tokenId}'.replace( + '{tokenId}', + encodeURIComponent(String(tokenId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/usage.ts b/src/services/usage.ts index 99ca3ae7..53e25a11 100644 --- a/src/services/usage.ts +++ b/src/services/usage.ts @@ -1,13 +1,13 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; +import { UsageEventMetric } from '../enums/usage-event-metric'; import { UsageInterval } from '../enums/usage-interval'; import { UsageEventDimension } from '../enums/usage-event-dimension'; import { UsageOrderBy } from '../enums/usage-order-by'; import { UsageOrderDirection } from '../enums/usage-order-direction'; +import { UsageGaugeMetric } from '../enums/usage-gauge-metric'; import { UsageGaugeDimension } from '../enums/usage-gauge-dimension'; - export class Usage { client: Client; @@ -17,17 +17,17 @@ export class Usage { /** * Aggregate usage event metrics. `metrics[]` (1-10) is required; the response always contains one entry per requested metric, each with its own `points[]` time series. - * + * * **Two response shapes**: * - Omit `interval` for a flat top-N table — one point per dimension combination, no time axis. Useful for "top 10 paths by bandwidth in the last 7 days". * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one point per (time bucket × dimension combination). - * + * * `dimensions[]` breaks each point down by one or more attributes (service, path, status, country, …). `queries[]` filters the underlying events using the standard Utopia query syntax — `equal("path", ["/v1/storage/files"])`, `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `startsWith("path", ["/v1/storage"])`, `equal("status", ["200", "201"])`, `isNotNull("resourceId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `contains`, `startsWith`, `endsWith`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N by aggregated value. When `startAt` is omitted, the default window adapts to `interval` (or 7d when interval is omitted). * - * @param {string[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. On console: `metrics[]=affiliates.clicks`. - * @param {string[]} params.queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: path, method, status, service, resourceType, resourceId, teamId, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion. Allowed methods: equal, notEqual, contains, startsWith, endsWith, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. + * @param {(UsageEventMetric | (string & {}))[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. On console: `metrics[]=affiliates.clicks`. + * @param {string[]} params.queries - Up to 10 filter queries in Utopia syntax. Allowed attributes, also published as the `UsageEventDimension` enum: path, method, status, service, resourceType, resourceId, teamId, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganization. Allowed methods: equal, notEqual, contains, startsWith, endsWith, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. * @param {UsageInterval} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {UsageEventDimension[]} params.dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId. + * @param {UsageEventDimension[]} params.dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganization. * @param {string} params.startAt - Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). * @param {string} params.endAt - Range end in ISO 8601. Defaults to the current time. * @param {UsageOrderBy} params.orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. @@ -37,20 +37,31 @@ export class Usage { * @throws {AppwriteException} * @returns {Promise} */ - listEvents(params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }): Promise; + listEvents(params: { + metrics: (UsageEventMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageEventDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + }): Promise; /** * Aggregate usage event metrics. `metrics[]` (1-10) is required; the response always contains one entry per requested metric, each with its own `points[]` time series. - * + * * **Two response shapes**: * - Omit `interval` for a flat top-N table — one point per dimension combination, no time axis. Useful for "top 10 paths by bandwidth in the last 7 days". * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one point per (time bucket × dimension combination). - * + * * `dimensions[]` breaks each point down by one or more attributes (service, path, status, country, …). `queries[]` filters the underlying events using the standard Utopia query syntax — `equal("path", ["/v1/storage/files"])`, `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `startsWith("path", ["/v1/storage"])`, `equal("status", ["200", "201"])`, `isNotNull("resourceId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `contains`, `startsWith`, `endsWith`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N by aggregated value. When `startAt` is omitted, the default window adapts to `interval` (or 7d when interval is omitted). * - * @param {string[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. On console: `metrics[]=affiliates.clicks`. - * @param {string[]} queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: path, method, status, service, resourceType, resourceId, teamId, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion. Allowed methods: equal, notEqual, contains, startsWith, endsWith, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. + * @param {(UsageEventMetric | (string & {}))[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=executions` or `metrics[]=executions&metrics[]=executions.compute` for stacked charts. On console: `metrics[]=affiliates.clicks`. + * @param {string[]} queries - Up to 10 filter queries in Utopia syntax. Allowed attributes, also published as the `UsageEventDimension` enum: path, method, status, service, resourceType, resourceId, teamId, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganization. Allowed methods: equal, notEqual, contains, startsWith, endsWith, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. * @param {UsageInterval} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {UsageEventDimension[]} dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId. + * @param {UsageEventDimension[]} dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resourceType, country, continentCode, city, region, hostname, ip, osName, clientType, clientName, deviceName, sdk, sdkVersion, teamId, resourceId, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganization. * @param {string} startAt - Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). * @param {string} endAt - Range end in ISO 8601. Defaults to the current time. * @param {UsageOrderBy} orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. @@ -61,18 +72,88 @@ export class Usage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listEvents(metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number): Promise; listEvents( - paramsOrFirst: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number } | string[], - ...rest: [(string[])?, (UsageInterval)?, (UsageEventDimension[])?, (string)?, (string)?, (UsageOrderBy)?, (UsageOrderDirection)?, (number)?, (number)?] + metrics: (UsageEventMetric | (string & {}))[], + queries?: string[], + interval?: UsageInterval, + dimensions?: UsageEventDimension[], + startAt?: string, + endAt?: string, + orderBy?: UsageOrderBy, + orderDir?: UsageOrderDirection, + limit?: number, + offset?: number, + ): Promise; + listEvents( + paramsOrFirst: + | { + metrics: (UsageEventMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageEventDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + } + | (UsageEventMetric | (string & {}))[], + ...rest: [ + string[]?, + UsageInterval?, + UsageEventDimension[]?, + string?, + string?, + UsageOrderBy?, + UsageOrderDirection?, + number?, + number?, + ] ): Promise { - let params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageEventDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; + let params: { + metrics: (UsageEventMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageEventDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('metrics' in paramsOrFirst || + 'queries' in paramsOrFirst || + 'interval' in paramsOrFirst || + 'dimensions' in paramsOrFirst || + 'startAt' in paramsOrFirst || + 'endAt' in paramsOrFirst || + 'orderBy' in paramsOrFirst || + 'orderDir' in paramsOrFirst || + 'limit' in paramsOrFirst || + 'offset' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + metrics: (UsageEventMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageEventDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + }; } else { params = { - metrics: paramsOrFirst as string[], + metrics: paramsOrFirst as (UsageEventMetric | (string & {}))[], queries: rest[0] as string[], interval: rest[1] as UsageInterval, dimensions: rest[2] as UsageEventDimension[], @@ -81,10 +162,10 @@ export class Usage { orderBy: rest[5] as UsageOrderBy, orderDir: rest[6] as UsageOrderDirection, limit: rest[7] as number, - offset: rest[8] as number + offset: rest[8] as number, }; } - + const metrics = params.metrics; const queries = params.queries; const interval = params.interval; @@ -97,9 +178,10 @@ export class Usage { const offset = params.offset; if (typeof metrics === 'undefined') { - throw new AppwriteException('Missing required parameter: "metrics"'); + throw new AppwriteException( + 'Missing required parameter: "metrics"', + ); } - const apiPath = '/usage/events'; const payload: Payload = {}; if (typeof metrics !== 'undefined') { @@ -136,30 +218,27 @@ export class Usage { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Aggregate usage gauge snapshots. Gauges are point-in-time values (storage totals, resource counts, …); each point carries the latest snapshot in its interval via `argMax(value, time)`. `metrics[]` (1-10) is required; the response always contains one entry per requested metric, each with its own `points[]` time series. - * + * * A metric with no stored samples in the window returns an empty `points[]`. A metric that really did read zero returns a point whose `value` is `0`, so "no such series" and "a genuine zero" are different answers. - * + * * **Two response shapes**: * - Omit `interval` for a flat top-N table — `argMax(value, time)` per dimension combination over the whole window, no time axis. Useful for "top 10 resources by current storage". * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one snapshot per (time bucket × dimension combination). - * + * * `dimensions[]` breaks each point down further. Supported on gauges: `resourceId`, `teamId`, `service`, `resourceType`, `ordinal`. `service` and `resourceType` enable per-service / per-resource-type panels (e.g. storage-by-service: group `files.storage`, `deployments.storage`, `builds.storage`, `databases.storage` by `service`). `ordinal` separates per-node series for multi-node resources such as dedicated databases. It is a stable per-node identity, not a role — ordinal 0 is the first member created, and a failover can leave the primary on any ordinal, so read the role from the database's replicas endpoint rather than inferring it here. `queries[]` filters the underlying rows using the standard Utopia query syntax — `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `equal("teamId", ["team_x"])`, `equal("ordinal", ["0"])`, `isNotNull("teamId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). * - * @param {string[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=files.storage` or `metrics[]=files.storage&metrics[]=deployments.storage` for stacked charts. - * @param {string[]} params.queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: service, resourceType, resourceId, teamId, ordinal. Allowed methods: equal, notEqual, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. + * `aggregate` selects how the samples in a bucket are combined: `last` (default) is the latest reading — correct for a snapshot such as storage — while `max` is the highest reading. Use `max` for a sampled level series: peak concurrent realtime connections is `metrics[]=realtime.connections&aggregate=max`, at whatever `interval` the chart needs, since the peak of a set of samples is just the max of their per-bucket maxima. `realtime.connections` is served only here - it is a concurrency level, not a countable event, so `/v1/usage/events` rejects it. + * + * @param {(UsageGaugeMetric | (string & {}))[]} params.metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=files.storage` or `metrics[]=files.storage&metrics[]=deployments.storage` for stacked charts. + * @param {string[]} params.queries - Up to 10 filter queries in Utopia syntax. Allowed attributes, also published as the `UsageGaugeDimension` enum: service, resourceType, resourceId, teamId, ordinal. Allowed methods: equal, notEqual, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. * @param {UsageInterval} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. * @param {UsageGaugeDimension[]} params.dimensions - Break-down dimensions. Allowed: resourceId, teamId, service, resourceType, ordinal. * @param {string} params.startAt - Range start in ISO 8601. Defaults to endAt - 7d. @@ -168,23 +247,38 @@ export class Usage { * @param {UsageOrderDirection} params.orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. * @param {number} params.limit - Maximum rows to return (1-5000). * @param {number} params.offset - Pagination offset (0-100000). + * @param {string} params.aggregate - How to combine the samples in each bucket. `last` (default) returns the latest reading — the right answer for a snapshot such as storage. `max` returns the highest reading, which is what a sampled level series needs: peak concurrent realtime connections is the max of `realtime.connections` over the window. * @throws {AppwriteException} * @returns {Promise} */ - listGauges(params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }): Promise; + listGauges(params: { + metrics: (UsageGaugeMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageGaugeDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + aggregate?: string; + }): Promise; /** * Aggregate usage gauge snapshots. Gauges are point-in-time values (storage totals, resource counts, …); each point carries the latest snapshot in its interval via `argMax(value, time)`. `metrics[]` (1-10) is required; the response always contains one entry per requested metric, each with its own `points[]` time series. - * + * * A metric with no stored samples in the window returns an empty `points[]`. A metric that really did read zero returns a point whose `value` is `0`, so "no such series" and "a genuine zero" are different answers. - * + * * **Two response shapes**: * - Omit `interval` for a flat top-N table — `argMax(value, time)` per dimension combination over the whole window, no time axis. Useful for "top 10 resources by current storage". * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one snapshot per (time bucket × dimension combination). - * + * * `dimensions[]` breaks each point down further. Supported on gauges: `resourceId`, `teamId`, `service`, `resourceType`, `ordinal`. `service` and `resourceType` enable per-service / per-resource-type panels (e.g. storage-by-service: group `files.storage`, `deployments.storage`, `builds.storage`, `databases.storage` by `service`). `ordinal` separates per-node series for multi-node resources such as dedicated databases. It is a stable per-node identity, not a role — ordinal 0 is the first member created, and a failover can leave the primary on any ordinal, so read the role from the database's replicas endpoint rather than inferring it here. `queries[]` filters the underlying rows using the standard Utopia query syntax — `equal("resourceType", ["bucket"])`, `equal("resourceId", ["abc123"])`, `equal("teamId", ["team_x"])`, `equal("ordinal", ["0"])`, `isNotNull("teamId")`. Supported attributes: see `queries[]` param. Supported methods: `equal`, `notEqual`, `isNull`, `isNotNull`. Pass multiple metrics to render stacked charts in one round-trip. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). * - * @param {string[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=files.storage` or `metrics[]=files.storage&metrics[]=deployments.storage` for stacked charts. - * @param {string[]} queries - Up to 10 filter queries in Utopia syntax. Allowed attributes: service, resourceType, resourceId, teamId, ordinal. Allowed methods: equal, notEqual, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. + * `aggregate` selects how the samples in a bucket are combined: `last` (default) is the latest reading — correct for a snapshot such as storage — while `max` is the highest reading. Use `max` for a sampled level series: peak concurrent realtime connections is `metrics[]=realtime.connections&aggregate=max`, at whatever `interval` the chart needs, since the peak of a set of samples is just the max of their per-bucket maxima. `realtime.connections` is served only here - it is a concurrency level, not a countable event, so `/v1/usage/events` rejects it. + * + * @param {(UsageGaugeMetric | (string & {}))[]} metrics - One to ten metric names. Single-metric callers pass a one-element array. Example: `metrics[]=files.storage` or `metrics[]=files.storage&metrics[]=deployments.storage` for stacked charts. + * @param {string[]} queries - Up to 10 filter queries in Utopia syntax. Allowed attributes, also published as the `UsageGaugeDimension` enum: service, resourceType, resourceId, teamId, ordinal. Allowed methods: equal, notEqual, isNull, isNotNull. Example: `queries[]=equal("resourceType", ["bucket"])`. * @param {UsageInterval} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. * @param {UsageGaugeDimension[]} dimensions - Break-down dimensions. Allowed: resourceId, teamId, service, resourceType, ordinal. * @param {string} startAt - Range start in ISO 8601. Defaults to endAt - 7d. @@ -193,22 +287,99 @@ export class Usage { * @param {UsageOrderDirection} orderDir - Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. * @param {number} limit - Maximum rows to return (1-5000). * @param {number} offset - Pagination offset (0-100000). + * @param {string} aggregate - How to combine the samples in each bucket. `last` (default) returns the latest reading — the right answer for a snapshot such as storage. `max` returns the highest reading, which is what a sampled level series needs: peak concurrent realtime connections is the max of `realtime.connections` over the window. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listGauges(metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number): Promise; listGauges( - paramsOrFirst: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number } | string[], - ...rest: [(string[])?, (UsageInterval)?, (UsageGaugeDimension[])?, (string)?, (string)?, (UsageOrderBy)?, (UsageOrderDirection)?, (number)?, (number)?] + metrics: (UsageGaugeMetric | (string & {}))[], + queries?: string[], + interval?: UsageInterval, + dimensions?: UsageGaugeDimension[], + startAt?: string, + endAt?: string, + orderBy?: UsageOrderBy, + orderDir?: UsageOrderDirection, + limit?: number, + offset?: number, + aggregate?: string, + ): Promise; + listGauges( + paramsOrFirst: + | { + metrics: (UsageGaugeMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageGaugeDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + aggregate?: string; + } + | (UsageGaugeMetric | (string & {}))[], + ...rest: [ + string[]?, + UsageInterval?, + UsageGaugeDimension[]?, + string?, + string?, + UsageOrderBy?, + UsageOrderDirection?, + number?, + number?, + string?, + ] ): Promise { - let params: { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { metrics: string[], queries?: string[], interval?: UsageInterval, dimensions?: UsageGaugeDimension[], startAt?: string, endAt?: string, orderBy?: UsageOrderBy, orderDir?: UsageOrderDirection, limit?: number, offset?: number }; + let params: { + metrics: (UsageGaugeMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageGaugeDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + aggregate?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('metrics' in paramsOrFirst || + 'queries' in paramsOrFirst || + 'interval' in paramsOrFirst || + 'dimensions' in paramsOrFirst || + 'startAt' in paramsOrFirst || + 'endAt' in paramsOrFirst || + 'orderBy' in paramsOrFirst || + 'orderDir' in paramsOrFirst || + 'limit' in paramsOrFirst || + 'offset' in paramsOrFirst || + 'aggregate' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + metrics: (UsageGaugeMetric | (string & {}))[]; + queries?: string[]; + interval?: UsageInterval; + dimensions?: UsageGaugeDimension[]; + startAt?: string; + endAt?: string; + orderBy?: UsageOrderBy; + orderDir?: UsageOrderDirection; + limit?: number; + offset?: number; + aggregate?: string; + }; } else { params = { - metrics: paramsOrFirst as string[], + metrics: paramsOrFirst as (UsageGaugeMetric | (string & {}))[], queries: rest[0] as string[], interval: rest[1] as UsageInterval, dimensions: rest[2] as UsageGaugeDimension[], @@ -217,10 +388,11 @@ export class Usage { orderBy: rest[5] as UsageOrderBy, orderDir: rest[6] as UsageOrderDirection, limit: rest[7] as number, - offset: rest[8] as number + offset: rest[8] as number, + aggregate: rest[9] as string, }; } - + const metrics = params.metrics; const queries = params.queries; const interval = params.interval; @@ -231,11 +403,13 @@ export class Usage { const orderDir = params.orderDir; const limit = params.limit; const offset = params.offset; + const aggregate = params.aggregate; if (typeof metrics === 'undefined') { - throw new AppwriteException('Missing required parameter: "metrics"'); + throw new AppwriteException( + 'Missing required parameter: "metrics"', + ); } - const apiPath = '/usage/gauges'; const payload: Payload = {}; if (typeof metrics !== 'undefined') { @@ -268,18 +442,16 @@ export class Usage { if (typeof offset !== 'undefined') { payload['offset'] = offset; } + if (typeof aggregate !== 'undefined') { + payload['aggregate'] = aggregate; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/users.ts b/src/services/users.ts index eff1ce82..8566e7a4 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,12 +1,10 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; import { UsageRange } from '../enums/usage-range'; import { AuthenticatorType } from '../enums/authenticator-type'; import { MessagingProviderType } from '../enums/messaging-provider-type'; - export class Users { client: Client; @@ -23,7 +21,13 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise>; + list< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise>; /** * Get a list of all the project's users. You can use the query params to filter your results. * @@ -34,28 +38,41 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise>; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise>; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise> { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/users'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -71,15 +88,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -93,7 +105,15 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - create(params: { userId: string, email?: string, phone?: string, password?: string, name?: string }): Promise>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + }): Promise>; /** * Create a new user. * @@ -106,25 +126,55 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise>; create( - paramsOrFirst: { userId: string, email?: string, phone?: string, password?: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + userId: string, + email?: string, + phone?: string, + password?: string, + name?: string, + ): Promise>; + create( + paramsOrFirst: + | { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise> { - let params: { userId: string, email?: string, phone?: string, password?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email?: string, phone?: string, password?: string, name?: string }; + let params: { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, phone: rest[1] as string, password: rest[2] as string, - name: rest[3] as string + name: rest[3] as string, }; } - + const userId = params.userId; const email = params.email; const phone = params.phone; @@ -134,7 +184,6 @@ export class Users { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - const apiPath = '/users'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -157,15 +206,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -178,7 +222,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createArgon2User(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createArgon2User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -190,24 +241,49 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createArgon2User(userId: string, email: string, password: string, name?: string): Promise>; - createArgon2User( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createArgon2User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createArgon2User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -220,9 +296,10 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/argon2'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -242,15 +319,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -263,7 +335,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createBcryptUser(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createBcryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -275,24 +354,49 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createBcryptUser(userId: string, email: string, password: string, name?: string): Promise>; - createBcryptUser( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createBcryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createBcryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -305,9 +409,10 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/bcrypt'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -327,15 +432,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -347,7 +447,11 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listIdentities(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listIdentities(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get identities for all users. * @@ -358,28 +462,41 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIdentities(queries?: string[], search?: string, total?: boolean): Promise; listIdentities( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listIdentities( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/users/identities'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -395,15 +512,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -424,39 +536,43 @@ export class Users { */ deleteIdentity(identityId: string): Promise<{}>; deleteIdentity( - paramsOrFirst: { identityId: string } | string + paramsOrFirst: { identityId: string } | string, ): Promise<{}> { let params: { identityId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { identityId: string }; } else { params = { - identityId: paramsOrFirst as string + identityId: paramsOrFirst as string, }; } - + const identityId = params.identityId; - if (typeof identityId === 'undefined') { - throw new AppwriteException('Missing required parameter: "identityId"'); + if (typeof identityId === 'undefined' || identityId === '') { + throw new AppwriteException( + 'Missing required parameter: "identityId"', + ); } - - const apiPath = '/users/identities/{identityId}'.replace('{identityId}', encodeURIComponent(String(identityId))); + const apiPath = '/users/identities/{identityId}'.replace( + '{identityId}', + encodeURIComponent(String(identityId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -469,7 +585,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createMD5User(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createMD5User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -481,24 +604,49 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createMD5User(userId: string, email: string, password: string, name?: string): Promise>; - createMD5User( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createMD5User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createMD5User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -511,9 +659,10 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/md5'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -533,15 +682,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -554,7 +698,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createPHPassUser(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createPHPassUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -566,24 +717,49 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createPHPassUser(userId: string, email: string, password: string, name?: string): Promise>; - createPHPassUser( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createPHPassUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createPHPassUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -596,9 +772,10 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/phpass'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -618,15 +795,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -644,7 +816,19 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createScryptUser(params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }): Promise>; + createScryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -661,15 +845,74 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createScryptUser(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise>; - createScryptUser( - paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (number)?, (number)?, (string)?] + createScryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + passwordSalt: string, + passwordCpu: number, + passwordMemory: number, + passwordParallel: number, + passwordLength: number, + name?: string, + ): Promise>; + createScryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + number?, + number?, + number?, + string?, + ] ): Promise> { - let params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; + let params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, @@ -680,10 +923,10 @@ export class Users { passwordMemory: rest[4] as number, passwordParallel: rest[5] as number, passwordLength: rest[6] as number, - name: rest[7] as string + name: rest[7] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -701,24 +944,35 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } if (typeof passwordSalt === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSalt"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSalt"', + ); } if (typeof passwordCpu === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordCpu"'); + throw new AppwriteException( + 'Missing required parameter: "passwordCpu"', + ); } if (typeof passwordMemory === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordMemory"'); + throw new AppwriteException( + 'Missing required parameter: "passwordMemory"', + ); } if (typeof passwordParallel === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordParallel"'); + throw new AppwriteException( + 'Missing required parameter: "passwordParallel"', + ); } if (typeof passwordLength === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordLength"'); + throw new AppwriteException( + 'Missing required parameter: "passwordLength"', + ); } - const apiPath = '/users/scrypt'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -753,15 +1007,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -777,7 +1026,17 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createScryptModifiedUser(params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }): Promise>; + createScryptModifiedUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -792,15 +1051,57 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createScryptModifiedUser(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise>; - createScryptModifiedUser( - paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + createScryptModifiedUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + passwordSalt: string, + passwordSaltSeparator: string, + passwordSignerKey: string, + name?: string, + ): Promise>; + createScryptModifiedUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, @@ -809,10 +1110,10 @@ export class Users { passwordSalt: rest[2] as string, passwordSaltSeparator: rest[3] as string, passwordSignerKey: rest[4] as string, - name: rest[5] as string + name: rest[5] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -828,18 +1129,25 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } if (typeof passwordSalt === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSalt"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSalt"', + ); } if (typeof passwordSaltSeparator === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSaltSeparator"', + ); } if (typeof passwordSignerKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSignerKey"', + ); } - const apiPath = '/users/scrypt-modified'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -868,15 +1176,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -890,7 +1193,15 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createSHAUser(params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }): Promise>; + createSHAUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -903,25 +1214,59 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createSHAUser(userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string): Promise>; - createSHAUser( - paramsOrFirst: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string } | string, - ...rest: [(string)?, (string)?, (PasswordHash)?, (string)?] + createSHAUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + passwordVersion?: PasswordHash, + name?: string, + ): Promise>; + createSHAUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + } + | string, + ...rest: [string?, string?, PasswordHash?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; + let params: { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, passwordVersion: rest[2] as PasswordHash, - name: rest[3] as string + name: rest[3] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -935,9 +1280,10 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/sha'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -960,20 +1306,15 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Get usage metrics and statistics for all users in the project. You can view the total number of users and sessions. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days. - * + * * * @param {UsageRange} params.range - Date range. * @throws {AppwriteException} @@ -982,7 +1323,7 @@ export class Users { getUsage(params?: { range?: UsageRange }): Promise; /** * Get usage metrics and statistics for all users in the project. You can view the total number of users and sessions. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days. - * + * * * @param {UsageRange} range - Date range. * @throws {AppwriteException} @@ -991,20 +1332,25 @@ export class Users { */ getUsage(range?: UsageRange): Promise; getUsage( - paramsOrFirst?: { range?: UsageRange } | UsageRange + paramsOrFirst?: { range?: UsageRange } | UsageRange, ): Promise { let params: { range?: UsageRange }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('range' in paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'range' in paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { range?: UsageRange }; } else { params = { - range: paramsOrFirst as UsageRange + range: paramsOrFirst as UsageRange, }; } - - const range = params.range; + const range = params.range; const apiPath = '/users/usage'; const payload: Payload = {}; @@ -1015,15 +1361,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1033,7 +1374,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - get(params: { userId: string }): Promise>; + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { userId: string }): Promise>; /** * Get a user by its unique ID. * @@ -1042,41 +1385,44 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - get(userId: string): Promise>; get( - paramsOrFirst: { userId: string } | string + userId: string, + ): Promise>; + get( + paramsOrFirst: { userId: string } | string, ): Promise> { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1096,40 +1442,40 @@ export class Users { * @deprecated Use the object parameter style method for a better developer experience. */ delete(userId: string): Promise<{}>; - delete( - paramsOrFirst: { userId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { userId: string } | string): Promise<{}> { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1140,7 +1486,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateEmail(params: { userId: string, email: string }): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + }): Promise>; /** * Update the user email by its unique ID. * @@ -1150,33 +1501,43 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(userId: string, email: string): Promise>; - updateEmail( - paramsOrFirst: { userId: string, email: string } | string, - ...rest: [(string)?] + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, email: string): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; email: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, email: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string }; + let params: { userId: string; email: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; email: string }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string + email: rest[0] as string, }; } - + const userId = params.userId; const email = params.email; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } - - const apiPath = '/users/{userId}/email'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/email'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; @@ -1186,30 +1547,30 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. - * + * * * @param {string} params.userId - User ID. * @param {boolean} params.impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. * @throws {AppwriteException} * @returns {Promise>} */ - updateImpersonator(params: { userId: string, impersonator: boolean }): Promise>; + updateImpersonator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + impersonator: boolean; + }): Promise>; /** * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. - * + * * * @param {string} userId - User ID. * @param {boolean} impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. @@ -1217,33 +1578,48 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateImpersonator(userId: string, impersonator: boolean): Promise>; - updateImpersonator( - paramsOrFirst: { userId: string, impersonator: boolean } | string, - ...rest: [(boolean)?] + updateImpersonator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, impersonator: boolean): Promise>; + updateImpersonator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; impersonator: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, impersonator: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, impersonator: boolean }; + let params: { userId: string; impersonator: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + impersonator: boolean; + }; } else { params = { userId: paramsOrFirst as string, - impersonator: rest[0] as boolean + impersonator: rest[0] as boolean, }; } - + const userId = params.userId; const impersonator = params.impersonator; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof impersonator === 'undefined') { - throw new AppwriteException('Missing required parameter: "impersonator"'); + throw new AppwriteException( + 'Missing required parameter: "impersonator"', + ); } - - const apiPath = '/users/{userId}/impersonator'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/impersonator'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof impersonator !== 'undefined') { payload['impersonator'] = impersonator; @@ -1253,63 +1629,77 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * * @param {string} params.userId - User ID. - * @param {string} params.sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {string} params.sessionId - Session ID. Use the string 'recent()' to use the most recent session, which is also the default. * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. * @throws {AppwriteException} * @returns {Promise} */ - createJWT(params: { userId: string, sessionId?: string, duration?: number }): Promise; + createJWT(params: { + userId: string; + sessionId?: string; + duration?: number; + }): Promise; /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * * @param {string} userId - User ID. - * @param {string} sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {string} sessionId - Session ID. Use the string 'recent()' to use the most recent session, which is also the default. * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createJWT(userId: string, sessionId?: string, duration?: number): Promise; createJWT( - paramsOrFirst: { userId: string, sessionId?: string, duration?: number } | string, - ...rest: [(string)?, (number)?] + userId: string, + sessionId?: string, + duration?: number, + ): Promise; + createJWT( + paramsOrFirst: + { userId: string; sessionId?: string; duration?: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { userId: string, sessionId?: string, duration?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, sessionId?: string, duration?: number }; + let params: { userId: string; sessionId?: string; duration?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + sessionId?: string; + duration?: number; + }; } else { params = { userId: paramsOrFirst as string, sessionId: rest[0] as string, - duration: rest[1] as number + duration: rest[1] as number, }; } - + const userId = params.userId; const sessionId = params.sessionId; const duration = params.duration; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/jwts'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/jwts'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof sessionId !== 'undefined') { payload['sessionId'] = sessionId; @@ -1322,20 +1712,15 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Update the user labels by its unique ID. - * + * Update the user labels by its unique ID. + * * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. * * @param {string} params.userId - User ID. @@ -1343,10 +1728,15 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateLabels(params: { userId: string, labels: string[] }): Promise>; + updateLabels< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + labels: string[]; + }): Promise>; /** - * Update the user labels by its unique ID. - * + * Update the user labels by its unique ID. + * * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. * * @param {string} userId - User ID. @@ -1355,33 +1745,46 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLabels(userId: string, labels: string[]): Promise>; - updateLabels( - paramsOrFirst: { userId: string, labels: string[] } | string, - ...rest: [(string[])?] + updateLabels< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, labels: string[]): Promise>; + updateLabels< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; labels: string[] } | string, + ...rest: [string[]?] ): Promise> { - let params: { userId: string, labels: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, labels: string[] }; + let params: { userId: string; labels: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + labels: string[]; + }; } else { params = { userId: paramsOrFirst as string, - labels: rest[0] as string[] + labels: rest[0] as string[], }; } - + const userId = params.userId; const labels = params.labels; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } - - const apiPath = '/users/{userId}/labels'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/labels'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof labels !== 'undefined') { payload['labels'] = labels; @@ -1391,15 +1794,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1411,7 +1809,11 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params: { userId: string, queries?: string[], total?: boolean }): Promise; + listLogs(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the user activity logs list by its unique ID. * @@ -1422,32 +1824,47 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listLogs(userId: string, queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst: { userId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + userId: string, + queries?: string[], + total?: boolean, + ): Promise; + listLogs( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { userId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, queries?: string[], total?: boolean }; + let params: { userId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const userId = params.userId; const queries = params.queries; const total = params.total; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/logs'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/logs'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1459,15 +1876,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1480,7 +1892,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listMemberships(params: { userId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listMemberships(params: { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get the user membership list by its unique ID. * @@ -1492,34 +1909,62 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMemberships(userId: string, queries?: string[], search?: string, total?: boolean): Promise; listMemberships( - paramsOrFirst: { userId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + userId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMemberships( + paramsOrFirst: + | { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { userId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const userId = params.userId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/memberships'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/memberships'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1534,15 +1979,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1554,7 +1994,12 @@ export class Users { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead. */ - updateMfa(params: { userId: string, mfa: boolean }): Promise>; + updateMfa< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + mfa: boolean; + }): Promise>; /** * Enable or disable MFA on a user account. * @@ -1564,33 +2009,43 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfa(userId: string, mfa: boolean): Promise>; - updateMfa( - paramsOrFirst: { userId: string, mfa: boolean } | string, - ...rest: [(boolean)?] + updateMfa< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, mfa: boolean): Promise>; + updateMfa< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; mfa: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, mfa: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + let params: { userId: string; mfa: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; mfa: boolean }; } else { params = { userId: paramsOrFirst as string, - mfa: rest[0] as boolean + mfa: rest[0] as boolean, }; } - + const userId = params.userId; const mfa = params.mfa; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } - - const apiPath = '/users/{userId}/mfa'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof mfa !== 'undefined') { payload['mfa'] = mfa; @@ -1600,15 +2055,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1619,7 +2069,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateMFA(params: { userId: string, mfa: boolean }): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + mfa: boolean; + }): Promise>; /** * Enable or disable MFA on a user account. * @@ -1629,33 +2084,43 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFA(userId: string, mfa: boolean): Promise>; - updateMFA( - paramsOrFirst: { userId: string, mfa: boolean } | string, - ...rest: [(boolean)?] + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, mfa: boolean): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; mfa: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, mfa: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + let params: { userId: string; mfa: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; mfa: boolean }; } else { params = { userId: paramsOrFirst as string, - mfa: rest[0] as boolean + mfa: rest[0] as boolean, }; } - + const userId = params.userId; const mfa = params.mfa; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } - - const apiPath = '/users/{userId}/mfa'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof mfa !== 'undefined') { payload['mfa'] = mfa; @@ -1665,15 +2130,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1685,7 +2145,10 @@ export class Users { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead. */ - deleteMfaAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + deleteMfaAuthenticator(params: { + userId: string; + type: AuthenticatorType; + }): Promise<{}>; /** * Delete an authenticator app. * @@ -1695,47 +2158,54 @@ export class Users { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; deleteMfaAuthenticator( - paramsOrFirst: { userId: string, type: AuthenticatorType } | string, - ...rest: [(AuthenticatorType)?] + userId: string, + type: AuthenticatorType, + ): Promise<{}>; + deleteMfaAuthenticator( + paramsOrFirst: { userId: string; type: AuthenticatorType } | string, + ...rest: [AuthenticatorType?] ): Promise<{}> { - let params: { userId: string, type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + let params: { userId: string; type: AuthenticatorType }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + type: AuthenticatorType; + }; } else { params = { userId: paramsOrFirst as string, - type: rest[0] as AuthenticatorType + type: rest[0] as AuthenticatorType, }; } - + const userId = params.userId; const type = params.type; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/users/{userId}/mfa/authenticators/{type}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{type}', encodeURIComponent(String(type))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1746,7 +2216,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteMFAAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + deleteMFAAuthenticator(params: { + userId: string; + type: AuthenticatorType; + }): Promise<{}>; /** * Delete an authenticator app. * @@ -1756,47 +2229,126 @@ export class Users { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteMFAAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; deleteMFAAuthenticator( - paramsOrFirst: { userId: string, type: AuthenticatorType } | string, - ...rest: [(AuthenticatorType)?] + userId: string, + type: AuthenticatorType, + ): Promise<{}>; + deleteMFAAuthenticator( + paramsOrFirst: { userId: string; type: AuthenticatorType } | string, + ...rest: [AuthenticatorType?] ): Promise<{}> { - let params: { userId: string, type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + let params: { userId: string; type: AuthenticatorType }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + type: AuthenticatorType; + }; } else { params = { userId: paramsOrFirst as string, - type: rest[0] as AuthenticatorType + type: rest[0] as AuthenticatorType, }; } - + const userId = params.userId; const type = params.type; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{type}', encodeURIComponent(String(type))); + const apiPath = '/users/{userId}/mfa/authenticators/{type}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{type}', encodeURIComponent(String(type))); const payload: 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, payload); + } + + /** + * Get a custom MFA challenge for a user, including the code to be delivered through your own channel. + * + * @param {string} params.userId - User ID. + * @param {string} params.challengeId - ID of the challenge. + * @throws {AppwriteException} + * @returns {Promise} + */ + getMFAChallenge(params: { + userId: string; + challengeId: string; + }): Promise; + /** + * Get a custom MFA challenge for a user, including the code to be delivered through your own channel. + * + * @param {string} userId - User ID. + * @param {string} challengeId - ID of the challenge. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMFAChallenge( + userId: string, + challengeId: string, + ): Promise; + getMFAChallenge( + paramsOrFirst: { userId: string; challengeId: string } | string, + ...rest: [string?] + ): Promise { + let params: { userId: string; challengeId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + challengeId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + challengeId: rest[0] as string, + }; } - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + const userId = params.userId; + const challengeId = params.challengeId; + + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof challengeId === 'undefined' || challengeId === '') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + const apiPath = '/users/{userId}/mfa/challenges/{challengeId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{challengeId}', encodeURIComponent(String(challengeId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1818,39 +2370,40 @@ export class Users { */ listMfaFactors(userId: string): Promise; listMfaFactors( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/factors'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1871,39 +2424,40 @@ export class Users { */ listMFAFactors(userId: string): Promise; listMFAFactors( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/factors'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1914,7 +2468,9 @@ export class Users { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead. */ - getMfaRecoveryCodes(params: { userId: string }): Promise; + getMfaRecoveryCodes(params: { + userId: string; + }): Promise; /** * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -1925,39 +2481,40 @@ export class Users { */ getMfaRecoveryCodes(userId: string): Promise; getMfaRecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1967,7 +2524,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getMFARecoveryCodes(params: { userId: string }): Promise; + getMFARecoveryCodes(params: { + userId: string; + }): Promise; /** * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -1978,39 +2537,40 @@ export class Users { */ getMFARecoveryCodes(userId: string): Promise; getMFARecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2021,7 +2581,9 @@ export class Users { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead. */ - updateMfaRecoveryCodes(params: { userId: string }): Promise; + updateMfaRecoveryCodes(params: { + userId: string; + }): Promise; /** * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -2032,40 +2594,41 @@ export class Users { */ updateMfaRecoveryCodes(userId: string): Promise; updateMfaRecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -2075,7 +2638,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - updateMFARecoveryCodes(params: { userId: string }): Promise; + updateMFARecoveryCodes(params: { + userId: string; + }): Promise; /** * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -2086,40 +2651,41 @@ export class Users { */ updateMFARecoveryCodes(userId: string): Promise; updateMFARecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -2130,7 +2696,9 @@ export class Users { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead. */ - createMfaRecoveryCodes(params: { userId: string }): Promise; + createMfaRecoveryCodes(params: { + userId: string; + }): Promise; /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. * @@ -2141,40 +2709,41 @@ export class Users { */ createMfaRecoveryCodes(userId: string): Promise; createMfaRecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2184,7 +2753,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - createMFARecoveryCodes(params: { userId: string }): Promise; + createMFARecoveryCodes(params: { + userId: string; + }): Promise; /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. * @@ -2195,40 +2766,41 @@ export class Users { */ createMFARecoveryCodes(userId: string): Promise; createMFARecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2239,7 +2811,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(params: { userId: string, name: string }): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + name: string; + }): Promise>; /** * Update the user name by its unique ID. * @@ -2249,33 +2826,43 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateName(userId: string, name: string): Promise>; - updateName( - paramsOrFirst: { userId: string, name: string } | string, - ...rest: [(string)?] + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, name: string): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; name: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, name: string }; + let params: { userId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; name: string }; } else { params = { userId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const userId = params.userId; const name = params.name; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/users/{userId}/name'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/name'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -2285,15 +2872,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2304,7 +2886,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updatePassword(params: { userId: string, password: string }): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + password: string; + }): Promise>; /** * Update the user password by its unique ID. * @@ -2314,33 +2901,48 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePassword(userId: string, password: string): Promise>; - updatePassword( - paramsOrFirst: { userId: string, password: string } | string, - ...rest: [(string)?] + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, password: string): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; password: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, password: string }; + let params: { userId: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + password: string; + }; } else { params = { userId: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const userId = params.userId; const password = params.password; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - - const apiPath = '/users/{userId}/password'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/password'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof password !== 'undefined') { payload['password'] = password; @@ -2350,15 +2952,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2369,7 +2966,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updatePhone(params: { userId: string, number: string }): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + number: string; + }): Promise>; /** * Update the user phone by its unique ID. * @@ -2379,33 +2981,46 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhone(userId: string, number: string): Promise>; - updatePhone( - paramsOrFirst: { userId: string, number: string } | string, - ...rest: [(string)?] + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, number: string): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; number: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, number: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, number: string }; + let params: { userId: string; number: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + number: string; + }; } else { params = { userId: paramsOrFirst as string, - number: rest[0] as string + number: rest[0] as string, }; } - + const userId = params.userId; const number = params.number; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } - - const apiPath = '/users/{userId}/phone'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/phone'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof number !== 'undefined') { payload['number'] = number; @@ -2415,15 +3030,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2433,7 +3043,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(params: { userId: string }): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { userId: string }): Promise; /** * Get the user preferences by its unique ID. * @@ -2442,41 +3054,44 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPrefs(userId: string): Promise; - getPrefs( - paramsOrFirst: { userId: string } | string - ): Promise { + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(paramsOrFirst: { userId: string } | string): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/prefs'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/prefs'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2487,7 +3102,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - updatePrefs(params: { userId: string, prefs: object }): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { userId: string; prefs: object }): Promise; /** * Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * @@ -2497,33 +3114,43 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs(userId: string, prefs: object): Promise; - updatePrefs( - paramsOrFirst: { userId: string, prefs: object } | string, - ...rest: [(object)?] + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, prefs: object): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; prefs: object } | string, + ...rest: [object?] ): Promise { - let params: { userId: string, prefs: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, prefs: object }; + let params: { userId: string; prefs: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; prefs: object }; } else { params = { userId: paramsOrFirst as string, - prefs: rest[0] as object + prefs: rest[0] as object, }; } - + const userId = params.userId; const prefs = params.prefs; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } - - const apiPath = '/users/{userId}/prefs'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/prefs'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; @@ -2533,15 +3160,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2552,7 +3174,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listSessions(params: { userId: string, total?: boolean }): Promise; + listSessions(params: { + userId: string; + total?: boolean; + }): Promise; /** * Get the user sessions list by its unique ID. * @@ -2564,28 +3189,37 @@ export class Users { */ listSessions(userId: string, total?: boolean): Promise; listSessions( - paramsOrFirst: { userId: string, total?: boolean } | string, - ...rest: [(boolean)?] + paramsOrFirst: { userId: string; total?: boolean } | string, + ...rest: [boolean?] ): Promise { - let params: { userId: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, total?: boolean }; + let params: { userId: string; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, - total: rest[0] as boolean + total: rest[0] as boolean, }; } - + const userId = params.userId; const total = params.total; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/sessions'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/sessions'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof total !== 'undefined') { payload['total'] = total; @@ -2594,20 +3228,15 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Creates a session for a user. Returns an immediately usable session object. - * + * * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. * * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -2617,7 +3246,7 @@ export class Users { createSession(params: { userId: string }): Promise; /** * Creates a session for a user. Returns an immediately usable session object. - * + * * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. * * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -2627,40 +3256,41 @@ export class Users { */ createSession(userId: string): Promise; createSession( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/sessions'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/sessions'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2680,40 +3310,40 @@ export class Users { * @deprecated Use the object parameter style method for a better developer experience. */ deleteSessions(userId: string): Promise<{}>; - deleteSessions( - paramsOrFirst: { userId: string } | string - ): Promise<{}> { + deleteSessions(paramsOrFirst: { userId: string } | string): Promise<{}> { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - + const userId = params.userId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/sessions'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/sessions'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -2724,7 +3354,7 @@ export class Users { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSession(params: { userId: string, sessionId: string }): Promise<{}>; + deleteSession(params: { userId: string; sessionId: string }): Promise<{}>; /** * Delete a user sessions by its unique ID. * @@ -2736,45 +3366,51 @@ export class Users { */ deleteSession(userId: string, sessionId: string): Promise<{}>; deleteSession( - paramsOrFirst: { userId: string, sessionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; sessionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { userId: string, sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, sessionId: string }; + let params: { userId: string; sessionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + sessionId: string; + }; } else { params = { userId: paramsOrFirst as string, - sessionId: rest[0] as string + sessionId: rest[0] as string, }; } - + const userId = params.userId; const sessionId = params.sessionId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + if (typeof sessionId === 'undefined' || sessionId === '') { + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{sessionId}', encodeURIComponent(String(sessionId))); + const apiPath = '/users/{userId}/sessions/{sessionId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{sessionId}', encodeURIComponent(String(sessionId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -2785,7 +3421,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateStatus(params: { userId: string, status: boolean }): Promise>; + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + status: boolean; + }): Promise>; /** * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. * @@ -2795,33 +3436,46 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStatus(userId: string, status: boolean): Promise>; - updateStatus( - paramsOrFirst: { userId: string, status: boolean } | string, - ...rest: [(boolean)?] + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, status: boolean): Promise>; + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; status: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, status: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, status: boolean }; + let params: { userId: string; status: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + status: boolean; + }; } else { params = { userId: paramsOrFirst as string, - status: rest[0] as boolean + status: rest[0] as boolean, }; } - + const userId = params.userId; const status = params.status; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } - - const apiPath = '/users/{userId}/status'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/status'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2831,15 +3485,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -2851,7 +3500,11 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listTargets(params: { userId: string, queries?: string[], total?: boolean }): Promise; + listTargets(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List the messaging targets that are associated with a user. * @@ -2862,32 +3515,47 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTargets(userId: string, queries?: string[], total?: boolean): Promise; listTargets( - paramsOrFirst: { userId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + userId: string, + queries?: string[], + total?: boolean, + ): Promise; + listTargets( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { userId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, queries?: string[], total?: boolean }; + let params: { userId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const userId = params.userId; const queries = params.queries; const total = params.total; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/targets'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/targets'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -2899,15 +3567,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2922,7 +3585,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - createTarget(params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }): Promise; + createTarget(params: { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + }): Promise; /** * Create a messaging target. * @@ -2936,15 +3606,49 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTarget(userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string): Promise; createTarget( - paramsOrFirst: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string } | string, - ...rest: [(string)?, (MessagingProviderType)?, (string)?, (string)?, (string)?] + userId: string, + targetId: string, + providerType: MessagingProviderType, + identifier: string, + providerId?: string, + name?: string, + ): Promise; + createTarget( + paramsOrFirst: + | { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + } + | string, + ...rest: [string?, MessagingProviderType?, string?, string?, string?] ): Promise { - let params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; + let params: { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, @@ -2952,10 +3656,10 @@ export class Users { providerType: rest[1] as MessagingProviderType, identifier: rest[2] as string, providerId: rest[3] as string, - name: rest[4] as string + name: rest[4] as string, }; } - + const userId = params.userId; const targetId = params.targetId; const providerType = params.providerType; @@ -2963,20 +3667,28 @@ export class Users { const providerId = params.providerId; const name = params.name; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } if (typeof providerType === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerType"'); + throw new AppwriteException( + 'Missing required parameter: "providerType"', + ); } if (typeof identifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "identifier"'); + throw new AppwriteException( + 'Missing required parameter: "identifier"', + ); } - - const apiPath = '/users/{userId}/targets'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/targets'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof targetId !== 'undefined') { payload['targetId'] = targetId; @@ -2998,15 +3710,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3017,7 +3724,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getTarget(params: { userId: string, targetId: string }): Promise; + getTarget(params: { + userId: string; + targetId: string; + }): Promise; /** * Get a user's push notification target by ID. * @@ -3029,45 +3739,50 @@ export class Users { */ getTarget(userId: string, targetId: string): Promise; getTarget( - paramsOrFirst: { userId: string, targetId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; targetId: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + let params: { userId: string; targetId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + }; } else { params = { userId: paramsOrFirst as string, - targetId: rest[0] as string + targetId: rest[0] as string, }; } - + const userId = params.userId; const targetId = params.targetId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + if (typeof targetId === 'undefined' || targetId === '') { + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } - - const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{targetId}', encodeURIComponent(String(targetId))); + const apiPath = '/users/{userId}/targets/{targetId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{targetId}', encodeURIComponent(String(targetId))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -3081,7 +3796,13 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - updateTarget(params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }): Promise; + updateTarget(params: { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + }): Promise; /** * Update a messaging target. * @@ -3094,39 +3815,72 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTarget(userId: string, targetId: string, identifier?: string, providerId?: string, name?: string): Promise; updateTarget( - paramsOrFirst: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + userId: string, + targetId: string, + identifier?: string, + providerId?: string, + name?: string, + ): Promise; + updateTarget( + paramsOrFirst: + | { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; + let params: { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, targetId: rest[0] as string, identifier: rest[1] as string, providerId: rest[2] as string, - name: rest[3] as string + name: rest[3] as string, }; } - + const userId = params.userId; const targetId = params.targetId; const identifier = params.identifier; const providerId = params.providerId; const name = params.name; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + if (typeof targetId === 'undefined' || targetId === '') { + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } - - const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{targetId}', encodeURIComponent(String(targetId))); + const apiPath = '/users/{userId}/targets/{targetId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{targetId}', encodeURIComponent(String(targetId))); const payload: Payload = {}; if (typeof identifier !== 'undefined') { payload['identifier'] = identifier; @@ -3142,15 +3896,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3161,7 +3910,7 @@ export class Users { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteTarget(params: { userId: string, targetId: string }): Promise<{}>; + deleteTarget(params: { userId: string; targetId: string }): Promise<{}>; /** * Delete a messaging target. * @@ -3173,50 +3922,56 @@ export class Users { */ deleteTarget(userId: string, targetId: string): Promise<{}>; deleteTarget( - paramsOrFirst: { userId: string, targetId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; targetId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { userId: string, targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + let params: { userId: string; targetId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + }; } else { params = { userId: paramsOrFirst as string, - targetId: rest[0] as string + targetId: rest[0] as string, }; } - + const userId = params.userId; const targetId = params.targetId; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + if (typeof targetId === 'undefined' || targetId === '') { + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } - - const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{targetId}', encodeURIComponent(String(targetId))); + const apiPath = '/users/{userId}/targets/{targetId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{targetId}', encodeURIComponent(String(targetId))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. - * + * * * @param {string} params.userId - User ID. * @param {number} params.length - Token length in characters. The default length is 6 characters @@ -3224,10 +3979,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - createToken(params: { userId: string, length?: number, expire?: number }): Promise; + createToken(params: { + userId: string; + length?: number; + expire?: number; + }): Promise; /** * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. - * + * * * @param {string} userId - User ID. * @param {number} length - Token length in characters. The default length is 6 characters @@ -3236,32 +3995,47 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createToken(userId: string, length?: number, expire?: number): Promise; createToken( - paramsOrFirst: { userId: string, length?: number, expire?: number } | string, - ...rest: [(number)?, (number)?] + userId: string, + length?: number, + expire?: number, + ): Promise; + createToken( + paramsOrFirst: + { userId: string; length?: number; expire?: number } | string, + ...rest: [number?, number?] ): Promise { - let params: { userId: string, length?: number, expire?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, length?: number, expire?: number }; + let params: { userId: string; length?: number; expire?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + length?: number; + expire?: number; + }; } else { params = { userId: paramsOrFirst as string, length: rest[0] as number, - expire: rest[1] as number + expire: rest[1] as number, }; } - + const userId = params.userId; const length = params.length; const expire = params.expire; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/tokens'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/tokens'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof length !== 'undefined') { payload['length'] = length; @@ -3274,15 +4048,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -3293,7 +4062,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateEmailVerification(params: { userId: string, emailVerification: boolean }): Promise>; + updateEmailVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + emailVerification: boolean; + }): Promise>; /** * Update the user email verification status by its unique ID. * @@ -3303,33 +4077,51 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailVerification(userId: string, emailVerification: boolean): Promise>; - updateEmailVerification( - paramsOrFirst: { userId: string, emailVerification: boolean } | string, - ...rest: [(boolean)?] + updateEmailVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + emailVerification: boolean, + ): Promise>; + updateEmailVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; emailVerification: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, emailVerification: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, emailVerification: boolean }; + let params: { userId: string; emailVerification: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + emailVerification: boolean; + }; } else { params = { userId: paramsOrFirst as string, - emailVerification: rest[0] as boolean + emailVerification: rest[0] as boolean, }; } - + const userId = params.userId; const emailVerification = params.emailVerification; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof emailVerification === 'undefined') { - throw new AppwriteException('Missing required parameter: "emailVerification"'); + throw new AppwriteException( + 'Missing required parameter: "emailVerification"', + ); } - - const apiPath = '/users/{userId}/verification'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/verification'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof emailVerification !== 'undefined') { payload['emailVerification'] = emailVerification; @@ -3339,15 +4131,10 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -3358,7 +4145,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updatePhoneVerification(params: { userId: string, phoneVerification: boolean }): Promise>; + updatePhoneVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + phoneVerification: boolean; + }): Promise>; /** * Update the user phone verification status by its unique ID. * @@ -3368,33 +4160,51 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneVerification(userId: string, phoneVerification: boolean): Promise>; - updatePhoneVerification( - paramsOrFirst: { userId: string, phoneVerification: boolean } | string, - ...rest: [(boolean)?] + updatePhoneVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + phoneVerification: boolean, + ): Promise>; + updatePhoneVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; phoneVerification: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, phoneVerification: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, phoneVerification: boolean }; + let params: { userId: string; phoneVerification: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + phoneVerification: boolean; + }; } else { params = { userId: paramsOrFirst as string, - phoneVerification: rest[0] as boolean + phoneVerification: rest[0] as boolean, }; } - + const userId = params.userId; const phoneVerification = params.phoneVerification; - if (typeof userId === 'undefined') { + if (typeof userId === 'undefined' || userId === '') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof phoneVerification === 'undefined') { - throw new AppwriteException('Missing required parameter: "phoneVerification"'); + throw new AppwriteException( + 'Missing required parameter: "phoneVerification"', + ); } - - const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', encodeURIComponent(String(userId))); + const apiPath = '/users/{userId}/verification/phone'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); const payload: Payload = {}; if (typeof phoneVerification !== 'undefined') { payload['phoneVerification'] = phoneVerification; @@ -3404,14 +4214,9 @@ export class Users { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/src/services/vcs.ts b/src/services/vcs.ts index de7e4368..a890f560 100644 --- a/src/services/vcs.ts +++ b/src/services/vcs.ts @@ -1,9 +1,7 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { VCSDetectionType } from '../enums/vcs-detection-type'; - export class Vcs { client: Client; @@ -21,7 +19,12 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - createRepositoryDetection(params: { installationId: string, providerRepositoryId: string, type: VCSDetectionType, providerRootDirectory?: string }): Promise; + createRepositoryDetection(params: { + installationId: string; + providerRepositoryId: string; + type: VCSDetectionType; + providerRootDirectory?: string; + }): Promise; /** * Analyze a GitHub repository to automatically detect the programming language and runtime environment. This endpoint scans the repository's files and language statistics to determine the appropriate runtime settings for your function. The GitHub installation must be properly configured and the repository must be accessible through your installation for this endpoint to work. * @@ -33,40 +36,73 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRepositoryDetection(installationId: string, providerRepositoryId: string, type: VCSDetectionType, providerRootDirectory?: string): Promise; createRepositoryDetection( - paramsOrFirst: { installationId: string, providerRepositoryId: string, type: VCSDetectionType, providerRootDirectory?: string } | string, - ...rest: [(string)?, (VCSDetectionType)?, (string)?] + installationId: string, + providerRepositoryId: string, + type: VCSDetectionType, + providerRootDirectory?: string, + ): Promise; + createRepositoryDetection( + paramsOrFirst: + | { + installationId: string; + providerRepositoryId: string; + type: VCSDetectionType; + providerRootDirectory?: string; + } + | string, + ...rest: [string?, VCSDetectionType?, string?] ): Promise { - let params: { installationId: string, providerRepositoryId: string, type: VCSDetectionType, providerRootDirectory?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, providerRepositoryId: string, type: VCSDetectionType, providerRootDirectory?: string }; + let params: { + installationId: string; + providerRepositoryId: string; + type: VCSDetectionType; + providerRootDirectory?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + providerRepositoryId: string; + type: VCSDetectionType; + providerRootDirectory?: string; + }; } else { params = { installationId: paramsOrFirst as string, providerRepositoryId: rest[0] as string, type: rest[1] as VCSDetectionType, - providerRootDirectory: rest[2] as string + providerRootDirectory: rest[2] as string, }; } - + const installationId = params.installationId; const providerRepositoryId = params.providerRepositoryId; const type = params.type; const providerRootDirectory = params.providerRootDirectory; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } if (typeof providerRepositoryId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerRepositoryId"'); + throw new AppwriteException( + 'Missing required parameter: "providerRepositoryId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/vcs/github/installations/{installationId}/detections'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = + '/vcs/github/installations/{installationId}/detections'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; if (typeof providerRepositoryId !== 'undefined') { payload['providerRepositoryId'] = providerRepositoryId; @@ -82,15 +118,10 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -103,7 +134,15 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - listRepositories(params: { installationId: string, type: VCSDetectionType, search?: string, queries?: string[] }): Promise; + listRepositories(params: { + installationId: string; + type: VCSDetectionType; + search?: string; + queries?: string[]; + }): Promise< + | Models.ProviderRepositoryRuntimeList + | Models.ProviderRepositoryFrameworkList + >; /** * Get a list of GitHub repositories available through your installation. This endpoint returns repositories with their basic information, detected runtime environments, and latest push dates. You can optionally filter repositories using a search term. Each repository's runtime is automatically detected based on its contents and language statistics. The GitHub installation must be properly configured for this endpoint to work. * @@ -115,37 +154,74 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRepositories(installationId: string, type: VCSDetectionType, search?: string, queries?: string[]): Promise; listRepositories( - paramsOrFirst: { installationId: string, type: VCSDetectionType, search?: string, queries?: string[] } | string, - ...rest: [(VCSDetectionType)?, (string)?, (string[])?] - ): Promise { - let params: { installationId: string, type: VCSDetectionType, search?: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, type: VCSDetectionType, search?: string, queries?: string[] }; + installationId: string, + type: VCSDetectionType, + search?: string, + queries?: string[], + ): Promise< + | Models.ProviderRepositoryRuntimeList + | Models.ProviderRepositoryFrameworkList + >; + listRepositories( + paramsOrFirst: + | { + installationId: string; + type: VCSDetectionType; + search?: string; + queries?: string[]; + } + | string, + ...rest: [VCSDetectionType?, string?, string[]?] + ): Promise< + | Models.ProviderRepositoryRuntimeList + | Models.ProviderRepositoryFrameworkList + > { + let params: { + installationId: string; + type: VCSDetectionType; + search?: string; + queries?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + type: VCSDetectionType; + search?: string; + queries?: string[]; + }; } else { params = { installationId: paramsOrFirst as string, type: rest[0] as VCSDetectionType, search: rest[1] as string, - queries: rest[2] as string[] + queries: rest[2] as string[], }; } - + const installationId = params.installationId; const type = params.type; const search = params.search; const queries = params.queries; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = + '/vcs/github/installations/{installationId}/providerRepositories'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; if (typeof type !== 'undefined') { payload['type'] = type; @@ -160,15 +236,10 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -181,7 +252,12 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - createRepository(params: { installationId: string, name: string, xprivate: boolean, providerNamespace?: string }): Promise; + createRepository(params: { + installationId: string; + name: string; + xprivate: boolean; + providerNamespace?: string; + }): Promise; /** * Create a new GitHub repository through your installation. This endpoint allows you to create either a public or private repository by specifying a name and visibility setting. The repository will be created under your GitHub user account or organization, depending on your installation type. The GitHub installation must be properly configured and have the necessary permissions for repository creation. * @@ -193,40 +269,73 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRepository(installationId: string, name: string, xprivate: boolean, providerNamespace?: string): Promise; createRepository( - paramsOrFirst: { installationId: string, name: string, xprivate: boolean, providerNamespace?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?] + installationId: string, + name: string, + xprivate: boolean, + providerNamespace?: string, + ): Promise; + createRepository( + paramsOrFirst: + | { + installationId: string; + name: string; + xprivate: boolean; + providerNamespace?: string; + } + | string, + ...rest: [string?, boolean?, string?] ): Promise { - let params: { installationId: string, name: string, xprivate: boolean, providerNamespace?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, name: string, xprivate: boolean, providerNamespace?: string }; + let params: { + installationId: string; + name: string; + xprivate: boolean; + providerNamespace?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + name: string; + xprivate: boolean; + providerNamespace?: string; + }; } else { params = { installationId: paramsOrFirst as string, name: rest[0] as string, xprivate: rest[1] as boolean, - providerNamespace: rest[2] as string + providerNamespace: rest[2] as string, }; } - + const installationId = params.installationId; const name = params.name; const xprivate = params.xprivate; const providerNamespace = params.providerNamespace; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof xprivate === 'undefined') { - throw new AppwriteException('Missing required parameter: "xprivate"'); + throw new AppwriteException( + 'Missing required parameter: "xprivate"', + ); } - - const apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = + '/vcs/github/installations/{installationId}/providerRepositories'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -242,15 +351,10 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -261,7 +365,10 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - getRepository(params: { installationId: string, providerRepositoryId: string }): Promise; + getRepository(params: { + installationId: string; + providerRepositoryId: string; + }): Promise; /** * Get detailed information about a specific GitHub repository from your installation. This endpoint returns repository details including its ID, name, visibility status, organization, and latest push date. The GitHub installation must be properly configured and have access to the requested repository for this endpoint to work. * @@ -271,52 +378,73 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRepository(installationId: string, providerRepositoryId: string): Promise; getRepository( - paramsOrFirst: { installationId: string, providerRepositoryId: string } | string, - ...rest: [(string)?] + installationId: string, + providerRepositoryId: string, + ): Promise; + getRepository( + paramsOrFirst: + { installationId: string; providerRepositoryId: string } | string, + ...rest: [string?] ): Promise { - let params: { installationId: string, providerRepositoryId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, providerRepositoryId: string }; + let params: { installationId: string; providerRepositoryId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + providerRepositoryId: string; + }; } else { params = { installationId: paramsOrFirst as string, - providerRepositoryId: rest[0] as string + providerRepositoryId: rest[0] as string, }; } - + const installationId = params.installationId; const providerRepositoryId = params.providerRepositoryId; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - if (typeof providerRepositoryId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerRepositoryId"'); + if ( + typeof providerRepositoryId === 'undefined' || + providerRepositoryId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "providerRepositoryId"', + ); } - - const apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}'.replace('{installationId}', encodeURIComponent(String(installationId))).replace('{providerRepositoryId}', encodeURIComponent(String(providerRepositoryId))); + const apiPath = + '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}' + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ) + .replace( + '{providerRepositoryId}', + encodeURIComponent(String(providerRepositoryId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Get a list of branches from a GitHub repository in your installation. This endpoint supports filtering by a search term and pagination using query strings such as `Query.limit()`, `Query.offset()`, `Query.cursorAfter()`, and `Query.cursorBefore()`. It returns branch names along with the total number of matches. The GitHub installation must be properly configured and have access to the requested repository for this endpoint to work. - * + * * * @param {string} params.installationId - Installation Id * @param {string} params.providerRepositoryId - Repository Id @@ -325,10 +453,15 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - listRepositoryBranches(params: { installationId: string, providerRepositoryId: string, search?: string, queries?: string[] }): Promise; + listRepositoryBranches(params: { + installationId: string; + providerRepositoryId: string; + search?: string; + queries?: string[]; + }): Promise; /** * Get a list of branches from a GitHub repository in your installation. This endpoint supports filtering by a search term and pagination using query strings such as `Query.limit()`, `Query.offset()`, `Query.cursorAfter()`, and `Query.cursorBefore()`. It returns branch names along with the total number of matches. The GitHub installation must be properly configured and have access to the requested repository for this endpoint to work. - * + * * * @param {string} installationId - Installation Id * @param {string} providerRepositoryId - Repository Id @@ -338,37 +471,78 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRepositoryBranches(installationId: string, providerRepositoryId: string, search?: string, queries?: string[]): Promise; listRepositoryBranches( - paramsOrFirst: { installationId: string, providerRepositoryId: string, search?: string, queries?: string[] } | string, - ...rest: [(string)?, (string)?, (string[])?] + installationId: string, + providerRepositoryId: string, + search?: string, + queries?: string[], + ): Promise; + listRepositoryBranches( + paramsOrFirst: + | { + installationId: string; + providerRepositoryId: string; + search?: string; + queries?: string[]; + } + | string, + ...rest: [string?, string?, string[]?] ): Promise { - let params: { installationId: string, providerRepositoryId: string, search?: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, providerRepositoryId: string, search?: string, queries?: string[] }; + let params: { + installationId: string; + providerRepositoryId: string; + search?: string; + queries?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + providerRepositoryId: string; + search?: string; + queries?: string[]; + }; } else { params = { installationId: paramsOrFirst as string, providerRepositoryId: rest[0] as string, search: rest[1] as string, - queries: rest[2] as string[] + queries: rest[2] as string[], }; } - + const installationId = params.installationId; const providerRepositoryId = params.providerRepositoryId; const search = params.search; const queries = params.queries; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - if (typeof providerRepositoryId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerRepositoryId"'); + if ( + typeof providerRepositoryId === 'undefined' || + providerRepositoryId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "providerRepositoryId"', + ); } - - const apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches'.replace('{installationId}', encodeURIComponent(String(installationId))).replace('{providerRepositoryId}', encodeURIComponent(String(providerRepositoryId))); + const apiPath = + '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches' + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ) + .replace( + '{providerRepositoryId}', + encodeURIComponent(String(providerRepositoryId)), + ); const payload: Payload = {}; if (typeof search !== 'undefined') { payload['search'] = search; @@ -380,15 +554,10 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -401,7 +570,12 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - getRepositoryContents(params: { installationId: string, providerRepositoryId: string, providerRootDirectory?: string, providerReference?: string }): Promise; + getRepositoryContents(params: { + installationId: string; + providerRepositoryId: string; + providerRootDirectory?: string; + providerReference?: string; + }): Promise; /** * Get a list of files and directories from a GitHub repository connected to your project. This endpoint returns the contents of a specified repository path, including file names, sizes, and whether each item is a file or directory. The GitHub installation must be properly configured and the repository must be accessible through your installation for this endpoint to work. * @@ -413,37 +587,78 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRepositoryContents(installationId: string, providerRepositoryId: string, providerRootDirectory?: string, providerReference?: string): Promise; getRepositoryContents( - paramsOrFirst: { installationId: string, providerRepositoryId: string, providerRootDirectory?: string, providerReference?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + installationId: string, + providerRepositoryId: string, + providerRootDirectory?: string, + providerReference?: string, + ): Promise; + getRepositoryContents( + paramsOrFirst: + | { + installationId: string; + providerRepositoryId: string; + providerRootDirectory?: string; + providerReference?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise { - let params: { installationId: string, providerRepositoryId: string, providerRootDirectory?: string, providerReference?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, providerRepositoryId: string, providerRootDirectory?: string, providerReference?: string }; + let params: { + installationId: string; + providerRepositoryId: string; + providerRootDirectory?: string; + providerReference?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + providerRepositoryId: string; + providerRootDirectory?: string; + providerReference?: string; + }; } else { params = { installationId: paramsOrFirst as string, providerRepositoryId: rest[0] as string, providerRootDirectory: rest[1] as string, - providerReference: rest[2] as string + providerReference: rest[2] as string, }; } - + const installationId = params.installationId; const providerRepositoryId = params.providerRepositoryId; const providerRootDirectory = params.providerRootDirectory; const providerReference = params.providerReference; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - if (typeof providerRepositoryId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerRepositoryId"'); + if ( + typeof providerRepositoryId === 'undefined' || + providerRepositoryId === '' + ) { + throw new AppwriteException( + 'Missing required parameter: "providerRepositoryId"', + ); } - - const apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/contents'.replace('{installationId}', encodeURIComponent(String(installationId))).replace('{providerRepositoryId}', encodeURIComponent(String(providerRepositoryId))); + const apiPath = + '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/contents' + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ) + .replace( + '{providerRepositoryId}', + encodeURIComponent(String(providerRepositoryId)), + ); const payload: Payload = {}; if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; @@ -455,15 +670,10 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -475,7 +685,11 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise<{}>} */ - updateExternalDeployments(params: { installationId: string, repositoryId: string, providerPullRequestId: string }): Promise<{}>; + updateExternalDeployments(params: { + installationId: string; + repositoryId: string; + providerPullRequestId: string; + }): Promise<{}>; /** * Authorize and create deployments for a GitHub pull request in your project. This endpoint allows external contributions by creating deployments from pull requests, enabling preview environments for code review. The pull request must be open and not previously authorized. The GitHub installation must be properly configured and have access to both the repository and pull request for this endpoint to work. * @@ -486,38 +700,74 @@ export class Vcs { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateExternalDeployments(installationId: string, repositoryId: string, providerPullRequestId: string): Promise<{}>; updateExternalDeployments( - paramsOrFirst: { installationId: string, repositoryId: string, providerPullRequestId: string } | string, - ...rest: [(string)?, (string)?] + installationId: string, + repositoryId: string, + providerPullRequestId: string, + ): Promise<{}>; + updateExternalDeployments( + paramsOrFirst: + | { + installationId: string; + repositoryId: string; + providerPullRequestId: string; + } + | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { installationId: string, repositoryId: string, providerPullRequestId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, repositoryId: string, providerPullRequestId: string }; + let params: { + installationId: string; + repositoryId: string; + providerPullRequestId: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + repositoryId: string; + providerPullRequestId: string; + }; } else { params = { installationId: paramsOrFirst as string, repositoryId: rest[0] as string, - providerPullRequestId: rest[1] as string + providerPullRequestId: rest[1] as string, }; } - + const installationId = params.installationId; const repositoryId = params.repositoryId; const providerPullRequestId = params.providerPullRequestId; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - if (typeof repositoryId === 'undefined') { - throw new AppwriteException('Missing required parameter: "repositoryId"'); + if (typeof repositoryId === 'undefined' || repositoryId === '') { + throw new AppwriteException( + 'Missing required parameter: "repositoryId"', + ); } if (typeof providerPullRequestId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerPullRequestId"'); + throw new AppwriteException( + 'Missing required parameter: "providerPullRequestId"', + ); } - - const apiPath = '/vcs/github/installations/{installationId}/repositories/{repositoryId}'.replace('{installationId}', encodeURIComponent(String(installationId))).replace('{repositoryId}', encodeURIComponent(String(repositoryId))); + const apiPath = + '/vcs/github/installations/{installationId}/repositories/{repositoryId}' + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ) + .replace( + '{repositoryId}', + encodeURIComponent(String(repositoryId)), + ); const payload: Payload = {}; if (typeof providerPullRequestId !== 'undefined') { payload['providerPullRequestId'] = providerPullRequestId; @@ -527,20 +777,15 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * List all VCS installations configured for the current project. This endpoint returns a list of installations including their provider, organization, and other configuration details. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: provider, organization * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. @@ -548,10 +793,14 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listInstallations(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * List all VCS installations configured for the current project. This endpoint returns a list of installations including their provider, organization, and other configuration details. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: provider, organization * @param {string} search - Search term to filter your list results. Max length: 256 chars. @@ -560,28 +809,41 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(queries?: string[], search?: string, total?: boolean): Promise; listInstallations( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/vcs/installations'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -597,27 +859,24 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** - * Get a VCS installation by its unique ID. This endpoint returns the installation's details including its provider, organization, and configuration. + * Get a VCS installation by its unique ID. This endpoint returns the installation's details including its provider, organization, and configuration. * * @param {string} params.installationId - Installation Id * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { installationId: string }): Promise; + getInstallation(params: { + installationId: string; + }): Promise; /** - * Get a VCS installation by its unique ID. This endpoint returns the installation's details including its provider, organization, and configuration. + * Get a VCS installation by its unique ID. This endpoint returns the installation's details including its provider, organization, and configuration. * * @param {string} installationId - Installation Id * @throws {AppwriteException} @@ -626,39 +885,42 @@ export class Vcs { */ getInstallation(installationId: string): Promise; getInstallation( - paramsOrFirst: { installationId: string } | string + paramsOrFirst: { installationId: string } | string, ): Promise { let params: { installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { installationId: string }; } else { params = { - installationId: paramsOrFirst as string + installationId: paramsOrFirst as string, }; } - + const installationId = params.installationId; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/vcs/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = '/vcs/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -679,39 +941,43 @@ export class Vcs { */ deleteInstallation(installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { installationId: string } | string + paramsOrFirst: { installationId: string } | string, ): Promise<{}> { let params: { installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { installationId: string }; } else { params = { - installationId: paramsOrFirst as string + installationId: paramsOrFirst as string, }; } - + const installationId = params.installationId; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/vcs/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = '/vcs/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -723,7 +989,11 @@ export class Vcs { * @throws {AppwriteException} * @returns {Promise} */ - listNamespaces(params: { installationId: string, search?: string, queries?: string[] }): Promise; + listNamespaces(params: { + installationId: string; + search?: string; + queries?: string[]; + }): Promise; /** * List provider namespaces available to a VCS installation. This can include the user personal namespace and any groups or organizations the installation can browse. * @@ -734,32 +1004,55 @@ export class Vcs { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listNamespaces(installationId: string, search?: string, queries?: string[]): Promise; listNamespaces( - paramsOrFirst: { installationId: string, search?: string, queries?: string[] } | string, - ...rest: [(string)?, (string[])?] + installationId: string, + search?: string, + queries?: string[], + ): Promise; + listNamespaces( + paramsOrFirst: + | { installationId: string; search?: string; queries?: string[] } + | string, + ...rest: [string?, string[]?] ): Promise { - let params: { installationId: string, search?: string, queries?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, search?: string, queries?: string[] }; + let params: { + installationId: string; + search?: string; + queries?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + search?: string; + queries?: string[]; + }; } else { params = { installationId: paramsOrFirst as string, search: rest[0] as string, - queries: rest[1] as string[] + queries: rest[1] as string[], }; } - + const installationId = params.installationId; const search = params.search; const queries = params.queries; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + if (typeof installationId === 'undefined' || installationId === '') { + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/vcs/installations/{installationId}/namespaces'.replace('{installationId}', encodeURIComponent(String(installationId))); + const apiPath = + '/vcs/installations/{installationId}/namespaces'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); const payload: Payload = {}; if (typeof search !== 'undefined') { payload['search'] = search; @@ -771,14 +1064,9 @@ export class Vcs { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 99c337d6..82735635 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,10 +1,8 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; import { OrderBy } from '../enums/order-by'; - export class VectorsDB { client: Client; @@ -20,7 +18,10 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * @@ -32,24 +33,31 @@ export class VectorsDB { */ list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/vectorsdb'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -62,20 +70,15 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Create a new Database. - * + * * * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Database name. Max length: 128 chars. @@ -86,10 +89,17 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Create a new Database. - * + * * * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Database name. Max length: 128 chars. @@ -101,15 +111,49 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -117,10 +161,10 @@ export class VectorsDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; @@ -129,12 +173,13 @@ export class VectorsDB { const syncMode = params.syncMode; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/vectorsdb'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -160,40 +205,29 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. * * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/vectorsdb/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -203,7 +237,9 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - listTransactions(params?: { queries?: string[] }): Promise; + listTransactions(params?: { + queries?: string[]; + }): Promise; /** * List transactions across all databases. * @@ -214,20 +250,24 @@ export class VectorsDB { */ listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; + const queries = params.queries; const apiPath = '/vectorsdb/transactions'; const payload: Payload = {}; @@ -238,15 +278,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -267,20 +302,24 @@ export class VectorsDB { */ createTransaction(ttl?: number): Promise; createTransaction( - paramsOrFirst?: { ttl?: number } | number + paramsOrFirst?: { ttl?: number } | number, ): Promise { let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { ttl?: number }; } else { params = { - ttl: paramsOrFirst as number + ttl: paramsOrFirst as number, }; } - - const ttl = params.ttl; + const ttl = params.ttl; const apiPath = '/vectorsdb/transactions'; const payload: Payload = {}; @@ -292,15 +331,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -310,7 +344,9 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - getTransaction(params: { transactionId: string }): Promise; + getTransaction(params: { + transactionId: string; + }): Promise; /** * Get a transaction by its unique ID. * @@ -321,39 +357,42 @@ export class VectorsDB { */ getTransaction(transactionId: string): Promise; getTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -365,7 +404,11 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; /** * Update a transaction, to either commit or roll back its operations. * @@ -376,32 +419,54 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; } else { params = { transactionId: paramsOrFirst as string, commit: rest[0] as boolean, - rollback: rest[1] as boolean + rollback: rest[1] as boolean, }; } - + const transactionId = params.transactionId; const commit = params.commit; const rollback = params.rollback; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof commit !== 'undefined') { payload['commit'] = commit; @@ -414,15 +479,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -443,39 +503,43 @@ export class VectorsDB { */ deleteTransaction(transactionId: string): Promise<{}>; deleteTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise<{}> { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - + const transactionId = params.transactionId; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -486,7 +550,10 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; /** * Create multiple operations in a single transaction. * @@ -496,30 +563,46 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createOperations(transactionId: string, operations?: object[]): Promise; createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; } else { params = { transactionId: paramsOrFirst as string, - operations: rest[0] as object[] + operations: rest[0] as object[], }; } - + const transactionId = params.transactionId; const operations = params.operations; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof transactionId === 'undefined' || transactionId === '') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/vectorsdb/transactions/{transactionId}/operations'.replace('{transactionId}', encodeURIComponent(String(transactionId))); + const apiPath = + '/vectorsdb/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); const payload: Payload = {}; if (typeof operations !== 'undefined') { payload['operations'] = operations; @@ -529,15 +612,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -558,39 +636,42 @@ export class VectorsDB { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -605,7 +686,14 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + update(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Update a database by its unique ID. * @@ -619,15 +707,49 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -635,10 +757,10 @@ export class VectorsDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; @@ -646,14 +768,18 @@ export class VectorsDB { const replicas = params.replicas; const syncMode = params.syncMode; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -675,15 +801,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -703,40 +824,42 @@ export class VectorsDB { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -749,7 +872,12 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listCollections(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * @@ -761,34 +889,64 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; listCollections( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listCollections( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -803,15 +961,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -827,7 +980,15 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - createCollection(params: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; + createCollection(params: { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }): Promise; /** * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * @@ -842,15 +1003,53 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCollection(databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; createCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string[])?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + name: string, + dimension: number, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + ): Promise; + createCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + let params: { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -859,10 +1058,10 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -871,20 +1070,28 @@ export class VectorsDB { const documentSecurity = params.documentSecurity; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof dimension === 'undefined') { - throw new AppwriteException('Missing required parameter: "dimension"'); + throw new AppwriteException( + 'Missing required parameter: "dimension"', + ); } - - const apiPath = '/vectorsdb/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof collectionId !== 'undefined') { payload['collectionId'] = collectionId; @@ -909,15 +1116,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -928,7 +1130,10 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - getCollection(params: { databaseId: string, collectionId: string }): Promise; + getCollection(params: { + databaseId: string; + collectionId: string; + }): Promise; /** * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. * @@ -938,47 +1143,60 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getCollection(databaseId: string, collectionId: string): Promise; getCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + databaseId: string, + collectionId: string, + ): Promise; + getCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -994,7 +1212,15 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - updateCollection(params: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; + updateCollection(params: { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }): Promise; /** * Update a collection by its unique ID. * @@ -1009,15 +1235,53 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCollection(databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; updateCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string[])?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + name: string, + dimension?: number, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + ): Promise; + updateCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + let params: { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1026,10 +1290,10 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -1038,17 +1302,25 @@ export class VectorsDB { const documentSecurity = params.documentSecurity; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -1070,15 +1342,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1089,7 +1356,10 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + deleteCollection(params: { + databaseId: string; + collectionId: string; + }): Promise<{}>; /** * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. * @@ -1101,45 +1371,56 @@ export class VectorsDB { */ deleteCollection(databaseId: string, collectionId: string): Promise<{}>; deleteCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -1147,20 +1428,29 @@ export class VectorsDB { * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 524288 characters long. * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). * @throws {AppwriteException} * @returns {Promise>} */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + listDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 524288 characters long. * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). @@ -1168,15 +1458,49 @@ export class VectorsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1184,10 +1508,10 @@ export class VectorsDB { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; @@ -1195,14 +1519,23 @@ export class VectorsDB { const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1220,15 +1553,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1239,10 +1567,22 @@ export class VectorsDB { * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise} */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; + createDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * @@ -1251,49 +1591,120 @@ export class VectorsDB { * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; createDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?] + databaseId: string, + collectionId: string, + documentId: string, + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit, + permissions?: string[], + transactionId?: string, + ): Promise; + createDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, - permissions: rest[3] as string[] + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit, + permissions: rest[3] as string[], + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const data = params.data; const permissions = params.permissions; + const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); } if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documentId !== 'undefined') { payload['documentId'] = documentId; @@ -1304,20 +1715,18 @@ export class VectorsDB { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1326,75 +1735,121 @@ export class VectorsDB { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param {object[]} params.documents - Array of documents data as JSON objects. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; + createDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param {object[]} documents - Array of documents data as JSON objects. + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, - ...rest: [(string)?, (object[])?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + createDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - documents: rest[1] as object[] + documents: rest[1] as object[], + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; + const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1403,10 +1858,17 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise>} */ - upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + upsertDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1416,40 +1878,77 @@ export class VectorsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + upsertDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; @@ -1462,15 +1961,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1484,7 +1978,15 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise>} */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + updateDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. * @@ -1497,39 +1999,78 @@ export class VectorsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, data: rest[1] as object, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const data = params.data; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -1545,15 +2086,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1566,7 +2102,14 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise>} */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; + deleteDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * @@ -1578,37 +2121,72 @@ export class VectorsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1621,38 +2199,42 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 524288 characters long. * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). * @throws {AppwriteException} * @returns {Promise>} */ - createQuery(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + createQuery< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 524288 characters long. * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). @@ -1660,15 +2242,49 @@ export class VectorsDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createQuery(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; createQuery( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + createQuery( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1676,10 +2292,10 @@ export class VectorsDB { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; @@ -1687,14 +2303,23 @@ export class VectorsDB { const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1713,15 +2338,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -1735,7 +2355,15 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; + getDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }): Promise; /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -1748,42 +2376,87 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -1795,15 +2468,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -1818,7 +2486,19 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * @@ -1832,26 +2512,84 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -1859,17 +2597,32 @@ export class VectorsDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -1885,15 +2638,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** @@ -1908,7 +2656,19 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + updateDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -1922,26 +2682,84 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -1949,17 +2767,32 @@ export class VectorsDB { const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; @@ -1975,15 +2808,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** @@ -1996,7 +2824,12 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; + deleteDocument(params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }): Promise<{}>; /** * Delete a document by its unique ID. * @@ -2008,40 +2841,81 @@ export class VectorsDB { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + transactionId?: string, + ): Promise<{}>; + deleteDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined' || documentId === '') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); const payload: Payload = {}; if (typeof transactionId !== 'undefined') { payload['transactionId'] = transactionId; @@ -2051,14 +2925,10 @@ export class VectorsDB { 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -2071,7 +2941,12 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + listIndexes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List indexes in the collection. * @@ -2083,37 +2958,72 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; listIndexes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -2125,15 +3035,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2150,7 +3055,15 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; /** * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. * Attributes can be `key`, `fulltext`, and `unique`. @@ -2166,15 +3079,60 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (VectorsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + databaseId: string, + collectionId: string, + key: string, + type: VectorsDBIndexType, + attributes: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + VectorsDBIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2183,10 +3141,10 @@ export class VectorsDB { type: rest[2] as VectorsDBIndexType, attributes: rest[3] as string[], orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] + lengths: rest[5] as number[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2195,11 +3153,15 @@ export class VectorsDB { const orders = params.orders; const lengths = params.lengths; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -2208,10 +3170,17 @@ export class VectorsDB { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); + throw new AppwriteException( + 'Missing required parameter: "attributes"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; @@ -2233,15 +3202,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2253,7 +3217,11 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; + getIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise; /** * Get index by ID. * @@ -2264,52 +3232,70 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getIndex(databaseId: string, collectionId: string, key: string): Promise; getIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2321,7 +3307,11 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + deleteIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; /** * Delete an index. * @@ -2332,65 +3322,87 @@ export class VectorsDB { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; deleteIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + if (typeof collectionId === 'undefined' || collectionId === '') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } - if (typeof key === 'undefined') { + if (typeof key === 'undefined' || key === '') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -2398,30 +3410,45 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { payload['targetReplicaId'] = targetReplicaId; @@ -2431,15 +3458,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** @@ -2452,7 +3474,12 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -2464,34 +3491,64 @@ export class VectorsDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; @@ -2506,15 +3563,10 @@ export class VectorsDB { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2524,7 +3576,9 @@ export class VectorsDB { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -2535,39 +3589,42 @@ export class VectorsDB { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -2588,38 +3645,41 @@ export class VectorsDB { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - + const databaseId = params.databaseId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/vectorsdb/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const apiPath = '/vectorsdb/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } } diff --git a/src/services/waf.ts b/src/services/waf.ts index 3027344a..d111aff8 100644 --- a/src/services/waf.ts +++ b/src/services/waf.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Waf { client: Client; @@ -12,7 +10,7 @@ export class Waf { /** * 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. @@ -20,10 +18,14 @@ export class Waf { * @throws {AppwriteException} * @returns {Promise} */ - listRules(params?: { queries?: string[], search?: string, total?: boolean }): 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. @@ -32,28 +34,41 @@ export class Waf { * @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)?] + 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 (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - const apiPath = '/waf/rules'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -69,20 +84,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * 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. @@ -95,10 +105,19 @@ export class Waf { * @throws {AppwriteException} * @returns {Promise} */ - createBypassRule(params: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): 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. @@ -112,15 +131,65 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -130,10 +199,10 @@ export class Waf { description: rest[3] as string, priority: rest[4] as number, enabled: rest[5] as boolean, - conditions: rest[6] as string + conditions: rest[6] as string, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const name = params.name; @@ -147,12 +216,13 @@ export class Waf { throw new AppwriteException('Missing required parameter: "ruleId"'); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/waf/rules/bypass'; const payload: Payload = {}; if (typeof ruleId !== 'undefined') { @@ -184,20 +254,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * 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. @@ -210,10 +275,19 @@ export class Waf { * @throws {AppwriteException} * @returns {Promise} */ - updateBypassRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): 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. @@ -227,15 +301,65 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -245,10 +369,10 @@ export class Waf { description: rest[3] as string, priority: rest[4] as number, enabled: rest[5] as boolean, - conditions: rest[6] as string + conditions: rest[6] as string, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const resourceId = params.resourceId; @@ -258,11 +382,13 @@ export class Waf { const enabled = params.enabled; const conditions = params.conditions; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/waf/rules/bypass/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; if (typeof resourceType !== 'undefined') { payload['resourceType'] = resourceType; @@ -290,20 +416,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * 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. @@ -319,10 +440,22 @@ export class Waf { * @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; + 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. @@ -339,15 +472,80 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -360,10 +558,10 @@ export class Waf { enabled: rest[6] as boolean, conditions: rest[7] as string, difficulty: rest[8] as number, - ttl: rest[9] as number + ttl: rest[9] as number, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const name = params.name; @@ -380,12 +578,13 @@ export class Waf { throw new AppwriteException('Missing required parameter: "ruleId"'); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/waf/rules/challenge'; const payload: Payload = {}; if (typeof ruleId !== 'undefined') { @@ -426,20 +625,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * 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. @@ -455,10 +649,22 @@ export class Waf { * @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; + 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. @@ -475,15 +681,80 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -496,10 +767,10 @@ export class Waf { enabled: rest[6] as boolean, conditions: rest[7] as string, difficulty: rest[8] as number, - ttl: rest[9] as number + ttl: rest[9] as number, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const resourceId = params.resourceId; @@ -512,11 +783,13 @@ export class Waf { const difficulty = params.difficulty; const ttl = params.ttl; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/waf/rules/challenge/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; if (typeof resourceType !== 'undefined') { payload['resourceType'] = resourceType; @@ -553,20 +826,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * 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. @@ -579,10 +847,19 @@ export class Waf { * @throws {AppwriteException} * @returns {Promise} */ - createDenyRule(params: { ruleId: string, resourceType: string, name: string, resourceId?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): 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. @@ -596,15 +873,65 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -614,10 +941,10 @@ export class Waf { description: rest[3] as string, priority: rest[4] as number, enabled: rest[5] as boolean, - conditions: rest[6] as string + conditions: rest[6] as string, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const name = params.name; @@ -631,12 +958,13 @@ export class Waf { throw new AppwriteException('Missing required parameter: "ruleId"'); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/waf/rules/deny'; const payload: Payload = {}; if (typeof ruleId !== 'undefined') { @@ -668,20 +996,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * 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. @@ -694,10 +1017,19 @@ export class Waf { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyRule(params: { ruleId: string, resourceType?: string, resourceId?: string, name?: string, description?: string, priority?: number, enabled?: boolean, conditions?: string }): 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. @@ -711,15 +1043,65 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -729,10 +1111,10 @@ export class Waf { description: rest[3] as string, priority: rest[4] as number, enabled: rest[5] as boolean, - conditions: rest[6] as string + conditions: rest[6] as string, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const resourceId = params.resourceId; @@ -742,11 +1124,13 @@ export class Waf { const enabled = params.enabled; const conditions = params.conditions; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/waf/rules/deny/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; if (typeof resourceType !== 'undefined') { payload['resourceType'] = resourceType; @@ -774,20 +1158,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * 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. @@ -797,16 +1176,32 @@ export class Waf { * @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, priority?: number, enabled?: boolean, conditions?: string }): 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. @@ -816,6 +1211,8 @@ export class Waf { * @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. @@ -823,15 +1220,90 @@ export class Waf { * @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, 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, priority?: number, enabled?: boolean, conditions?: string } | string, - ...rest: [(string)?, (string)?, (number)?, (number)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?] + 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, 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, priority?: number, enabled?: boolean, conditions?: string }; + 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, @@ -842,12 +1314,14 @@ export class Waf { resourceId: rest[4] as string, description: rest[5] as string, key: rest[6] as string, - priority: rest[7] as number, - enabled: rest[8] as boolean, - conditions: rest[9] 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; @@ -856,6 +1330,8 @@ export class Waf { 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; @@ -864,7 +1340,9 @@ export class Waf { throw new AppwriteException('Missing required parameter: "ruleId"'); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -873,9 +1351,10 @@ export class Waf { throw new AppwriteException('Missing required parameter: "limit"'); } if (typeof interval === 'undefined') { - throw new AppwriteException('Missing required parameter: "interval"'); + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); } - const apiPath = '/waf/rules/rate-limit'; const payload: Payload = {}; if (typeof ruleId !== 'undefined') { @@ -902,6 +1381,12 @@ export class Waf { if (typeof key !== 'undefined') { payload['key'] = key; } + if (typeof strategy !== 'undefined') { + payload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + payload['maxBucketSize'] = maxBucketSize; + } if (typeof priority !== 'undefined') { payload['priority'] = priority; } @@ -916,20 +1401,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * 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. @@ -939,16 +1419,30 @@ export class Waf { * @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, priority?: number, enabled?: boolean, conditions?: string }): 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. @@ -958,6 +1452,7 @@ export class Waf { * @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. @@ -965,15 +1460,85 @@ export class Waf { * @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, 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, priority?: number, enabled?: boolean, conditions?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (number)?, (number)?, (string)?, (number)?, (boolean)?, (string)?] + 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, 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, priority?: number, enabled?: boolean, conditions?: string }; + 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, @@ -984,12 +1549,13 @@ export class Waf { limit: rest[4] as number, interval: rest[5] as number, key: rest[6] as string, - priority: rest[7] as number, - enabled: rest[8] as boolean, - conditions: rest[9] 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; @@ -998,15 +1564,18 @@ export class Waf { 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') { + 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 apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; if (typeof resourceType !== 'undefined') { payload['resourceType'] = resourceType; @@ -1029,6 +1598,9 @@ export class Waf { if (typeof key !== 'undefined') { payload['key'] = key; } + if (typeof maxBucketSize !== 'undefined') { + payload['maxBucketSize'] = maxBucketSize; + } if (typeof priority !== 'undefined') { payload['priority'] = priority; } @@ -1043,20 +1615,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * 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. @@ -1071,10 +1638,21 @@ export class Waf { * @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; + 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. @@ -1090,15 +1668,75 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -1110,10 +1748,10 @@ export class Waf { description: rest[5] as string, priority: rest[6] as number, enabled: rest[7] as boolean, - conditions: rest[8] as string + conditions: rest[8] as string, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const name = params.name; @@ -1129,18 +1767,23 @@ export class Waf { throw new AppwriteException('Missing required parameter: "ruleId"'); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + 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"'); + throw new AppwriteException( + 'Missing required parameter: "location"', + ); } if (typeof statusCode === 'undefined') { - throw new AppwriteException('Missing required parameter: "statusCode"'); + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); } - const apiPath = '/waf/rules/redirect'; const payload: Payload = {}; if (typeof ruleId !== 'undefined') { @@ -1178,20 +1821,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** * 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. @@ -1206,10 +1844,21 @@ export class Waf { * @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; + 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. @@ -1225,15 +1874,75 @@ export class Waf { * @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)?] + 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 }; + 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, @@ -1245,10 +1954,10 @@ export class Waf { statusCode: rest[5] as number, priority: rest[6] as number, enabled: rest[7] as boolean, - conditions: rest[8] as string + conditions: rest[8] as string, }; } - + const ruleId = params.ruleId; const resourceType = params.resourceType; const resourceId = params.resourceId; @@ -1260,11 +1969,13 @@ export class Waf { const enabled = params.enabled; const conditions = params.conditions; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/waf/rules/redirect/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; if (typeof resourceType !== 'undefined') { payload['resourceType'] = resourceType; @@ -1298,20 +2009,15 @@ export class Waf { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } /** * Get a WAF rule by its ID. - * + * * * @param {string} params.ruleId - Rule ID. * @throws {AppwriteException} @@ -1320,7 +2026,7 @@ export class Waf { getRule(params: { ruleId: string }): Promise; /** * Get a WAF rule by its ID. - * + * * * @param {string} ruleId - Rule ID. * @throws {AppwriteException} @@ -1329,44 +2035,45 @@ export class Waf { */ getRule(ruleId: string): Promise; getRule( - paramsOrFirst: { ruleId: string } | string + paramsOrFirst: { ruleId: string } | string, ): Promise { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - + const ruleId = params.ruleId; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/waf/rules/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** * Delete a WAF rule. - * + * * * @param {string} params.ruleId - Rule ID. * @throws {AppwriteException} @@ -1375,7 +2082,7 @@ export class Waf { deleteRule(params: { ruleId: string }): Promise<{}>; /** * Delete a WAF rule. - * + * * * @param {string} ruleId - Rule ID. * @throws {AppwriteException} @@ -1383,40 +2090,39 @@ export class Waf { * @deprecated Use the object parameter style method for a better developer experience. */ deleteRule(ruleId: string): Promise<{}>; - deleteRule( - paramsOrFirst: { ruleId: string } | string - ): Promise<{}> { + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - + const ruleId = params.ruleId; - if (typeof ruleId === 'undefined') { + if (typeof ruleId === 'undefined' || ruleId === '') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/waf/rules/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } } diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 8a8c1f46..f24e3f40 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,8 +1,6 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - export class Webhooks { client: Client; @@ -18,7 +16,10 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all webhooks belonging to the project. You can use the query params to filter your results. * @@ -30,24 +31,31 @@ export class Webhooks { */ list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - const apiPath = '/webhooks'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -60,15 +68,10 @@ export class Webhooks { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -86,7 +89,17 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }): Promise; + create(params: { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + }): Promise; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. * @@ -103,15 +116,70 @@ export class Webhooks { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string): Promise; create( - paramsOrFirst: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?] + webhookId: string, + url: string, + name: string, + events: string[], + enabled?: boolean, + tls?: boolean, + authUsername?: string, + authPassword?: string, + secret?: string, + ): Promise; + create( + paramsOrFirst: + | { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + string?, + string?, + string?, + ] ): Promise { - let params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }; + let params: { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + }; } else { params = { webhookId: paramsOrFirst as string, @@ -122,10 +190,10 @@ export class Webhooks { tls: rest[4] as boolean, authUsername: rest[5] as string, authPassword: rest[6] as string, - secret: rest[7] as string + secret: rest[7] as string, }; } - + const webhookId = params.webhookId; const url = params.url; const name = params.name; @@ -137,7 +205,9 @@ export class Webhooks { const secret = params.secret; if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); @@ -148,7 +218,6 @@ export class Webhooks { if (typeof events === 'undefined') { throw new AppwriteException('Missing required parameter: "events"'); } - const apiPath = '/webhooks'; const payload: Payload = {}; if (typeof webhookId !== 'undefined') { @@ -183,19 +252,14 @@ export class Webhooks { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); + return this.client.call('post', uri, apiHeaders, payload); } /** - * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. * * @param {string} params.webhookId - Webhook ID. * @throws {AppwriteException} @@ -203,7 +267,7 @@ export class Webhooks { */ get(params: { webhookId: string }): Promise; /** - * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. * * @param {string} webhookId - Webhook ID. * @throws {AppwriteException} @@ -212,39 +276,42 @@ export class Webhooks { */ get(webhookId: string): Promise; get( - paramsOrFirst: { webhookId: string } | string + paramsOrFirst: { webhookId: string } | string, ): Promise { let params: { webhookId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { webhookId: string }; } else { params = { - webhookId: paramsOrFirst as string + webhookId: paramsOrFirst as string, }; } - + const webhookId = params.webhookId; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + if (typeof webhookId === 'undefined' || webhookId === '') { + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } - - const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', encodeURIComponent(String(webhookId))); + const apiPath = '/webhooks/{webhookId}'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.call('get', uri, apiHeaders, payload); } /** @@ -261,7 +328,16 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }): Promise; + update(params: { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + }): Promise; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. * @@ -277,15 +353,65 @@ export class Webhooks { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string): Promise; update( - paramsOrFirst: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?] + webhookId: string, + name: string, + url: string, + events: string[], + enabled?: boolean, + tls?: boolean, + authUsername?: string, + authPassword?: string, + ): Promise; + update( + paramsOrFirst: + | { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + string?, + string?, + ] ): Promise { - let params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }; + let params: { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + }; } else { params = { webhookId: paramsOrFirst as string, @@ -295,10 +421,10 @@ export class Webhooks { enabled: rest[3] as boolean, tls: rest[4] as boolean, authUsername: rest[5] as string, - authPassword: rest[6] as string + authPassword: rest[6] as string, }; } - + const webhookId = params.webhookId; const name = params.name; const url = params.url; @@ -308,8 +434,10 @@ export class Webhooks { const authUsername = params.authUsername; const authPassword = params.authPassword; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + if (typeof webhookId === 'undefined' || webhookId === '') { + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -320,8 +448,10 @@ export class Webhooks { if (typeof events === 'undefined') { throw new AppwriteException('Missing required parameter: "events"'); } - - const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', encodeURIComponent(String(webhookId))); + const apiPath = '/webhooks/{webhookId}'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; @@ -349,19 +479,14 @@ export class Webhooks { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); + return this.client.call('put', uri, apiHeaders, payload); } /** - * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. * * @param {string} params.webhookId - Webhook ID. * @throws {AppwriteException} @@ -369,7 +494,7 @@ export class Webhooks { */ delete(params: { webhookId: string }): Promise<{}>; /** - * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. * * @param {string} webhookId - Webhook ID. * @throws {AppwriteException} @@ -377,40 +502,42 @@ export class Webhooks { * @deprecated Use the object parameter style method for a better developer experience. */ delete(webhookId: string): Promise<{}>; - delete( - paramsOrFirst: { webhookId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { webhookId: string } | string): Promise<{}> { let params: { webhookId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { webhookId: string }; } else { params = { - webhookId: paramsOrFirst as string + webhookId: paramsOrFirst as string, }; } - + const webhookId = params.webhookId; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + if (typeof webhookId === 'undefined' || webhookId === '') { + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } - - const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', encodeURIComponent(String(webhookId))); + const apiPath = '/webhooks/{webhookId}'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); const payload: 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, - payload - ); + return this.client.call('delete', uri, apiHeaders, payload); } /** @@ -421,7 +548,10 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - updateSecret(params: { webhookId: string, secret?: string }): Promise; + updateSecret(params: { + webhookId: string; + secret?: string; + }): Promise; /** * Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook. * @@ -433,28 +563,39 @@ export class Webhooks { */ updateSecret(webhookId: string, secret?: string): Promise; updateSecret( - paramsOrFirst: { webhookId: string, secret?: string } | string, - ...rest: [(string)?] + paramsOrFirst: { webhookId: string; secret?: string } | string, + ...rest: [string?] ): Promise { - let params: { webhookId: string, secret?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { webhookId: string, secret?: string }; + let params: { webhookId: string; secret?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + webhookId: string; + secret?: string; + }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const webhookId = params.webhookId; const secret = params.secret; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + if (typeof webhookId === 'undefined' || webhookId === '') { + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } - - const apiPath = '/webhooks/{webhookId}/secret'.replace('{webhookId}', encodeURIComponent(String(webhookId))); + const apiPath = '/webhooks/{webhookId}/secret'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); const payload: Payload = {}; if (typeof secret !== 'undefined') { payload['secret'] = secret; @@ -464,14 +605,9 @@ export class Webhooks { const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); + return this.client.call('patch', uri, apiHeaders, payload); } } diff --git a/tsconfig.json b/tsconfig.json index 8a27d1f0..c7292aa8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,9 +16,9 @@ "skipLibCheck": true, "strict": true, "target": "ES6", - "traceResolution": false, + "traceResolution": false }, "compileOnSave": false, "exclude": ["node_modules", "dist"], "include": ["src"] -} \ No newline at end of file +} From 9da8f18ca1e497631362d515a9cabbcff385ca26 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 17 Sep 2026 16:24:14 +0100 Subject: [PATCH 07/10] chore: update Console SDK to 16.1.0 --- CHANGELOG.md | 1 + package-lock.json | 338 +++++++++++++++++----------------- package.json | 4 +- src/services/avatars.ts | 9 + src/services/functions.ts | 1 + src/services/organizations.ts | 2 + src/services/sites.ts | 1 + src/services/storage.ts | 3 + 8 files changed, 188 insertions(+), 171 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 554ab776..78c20c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 16.1.0 +* Fixed: `impersonateuserid` is carried again by every client URL builder — the avatar helpers, `functions`/`sites` `getDeploymentDownload()`, `organizations` `getInvoiceDownload()`/`getInvoiceView()`, and `storage` `getFileDownload()`/`getFilePreview()`/`getFileView()`. The browser loads these URLs directly and cannot send the impersonation header, so an impersonating console operator was served their own resources or a 401 * Breaking: the `Addon` enum is now `AddonKey` * Breaking: removed `EmbeddingModel.Bgesmall` and `EmbeddingModel.Embeddinggemma` * Breaking: removed `ProjectKeyScopes.DedicatedDatabasesExecute`; dedicated database execution follows `databases.write` diff --git a/package-lock.json b/package-lock.json index cd6d2e33..b60ff304 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,11 +20,11 @@ "eslint": "10.10.0", "playwright": "1.56.1", "prettier": "3.9.6", - "rollup": "4.63.1", + "rollup": "4.63.2", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3", - "typescript-eslint": "8.69.0" + "typescript-eslint": "8.70.0" }, "engines": { "node": ">=18.0.0" @@ -405,9 +405,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.1.tgz", - "integrity": "sha512-UZ8sUxPTiHWYX9QNdJedb1kDZSpS1t/VPWBWGSgqHNi9w3Cu6IXvu2mzbhiTiPvtrqgTQJ+zqiAq2iPIPilpaQ==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.2.tgz", + "integrity": "sha512-Xa6RDoWa+hNiX6PgsljlH6W75RaONx3y6PVlbLhkEWW+GaPQ3dP5gwbL/erAzQHWwkvW5UxdD5l87Qx2FAQ/4A==", "cpu": [ "arm" ], @@ -419,9 +419,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.1.tgz", - "integrity": "sha512-cQ4nFQABN5cDvDpbvJ7bMStCpnaVxynZrRMfUJYgxcIk9Sh54FIO1vtfkg0B69REjER77ioZ/ov+eAApx/KmLQ==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.2.tgz", + "integrity": "sha512-vNASxsghMfQ5s+v3PrpnJd+ryL/26lxCCaGI+sDJ7VzmHiYXIrrVltsDhaawxLM1WcoMU2oYlbPHLaYQtBzhcg==", "cpu": [ "arm64" ], @@ -433,9 +433,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.1.tgz", - "integrity": "sha512-FQNqd1lRy/0QhDk3xeRIkSBiCpXCiDnZO3YLVdcDKN1UBiKToNftCzcXYNLshmPDUMlu2TdeS8tGcsU6f3YF1Q==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.2.tgz", + "integrity": "sha512-0dWDjmlrpZAgjPD/aPzUDhBW8APLRjAni5bOrM76wiiZm+E+KTMVKNhAzaTBohz8UyO2fKNAl0+fygbe2HZXOA==", "cpu": [ "arm64" ], @@ -447,9 +447,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.1.tgz", - "integrity": "sha512-pvD16V939D3CloK0+qikpGaxiPrDUXTe7Y5cWOMkMSy7m1cawa8EGy/kXYi/G/cKAC4HDAbSnzCIk1WmsoOKXg==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.2.tgz", + "integrity": "sha512-N58uktcwzk3+qT4KHEuNdIxX1N01RWrkfVoml69EAbSaNDL+sbNVLx2RMl4Qd23lpA0fgPvyh5hHb4weD5WKmg==", "cpu": [ "x64" ], @@ -461,9 +461,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.1.tgz", - "integrity": "sha512-pcFGeL2345VwdTnJhA6zLbew+YgWB0qBG2+dMtXjCicf6+rm6kO6cOoh5VnTe0ZMrMRgRyuHmCJxZWrIdzYuOw==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.2.tgz", + "integrity": "sha512-HWF2zH8EAp2scWRpt2PGe6iUGz7zi04waXsdRr3zb4DWCk2ImIo5FZu0jjmD53nP/DGSvnW0e7/1ToCNZs2lZw==", "cpu": [ "arm64" ], @@ -475,9 +475,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.1.tgz", - "integrity": "sha512-mRJlqSRulVzcKq/LKA6ICSIc3K/l4fzlVn/gePn2nXIHy8seRi5z/eeRE0d/XMBxcMldiXtQTSpRj0tkkC3g8Q==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.2.tgz", + "integrity": "sha512-MkvcwHMnzPSMOQEwB6wHnLzmc+hT8BGc5bW/Mhmjjgx3wbj6VBnlc47XsK74kD0K9MikFfXpQqyz4NUXaUW62A==", "cpu": [ "x64" ], @@ -489,9 +489,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.1.tgz", - "integrity": "sha512-YDUNvVM85TI3g/1OpnqKP1h4NeW/j64DfWMf+G3M809xNk1bJSnpFp4sh83NpmVE5DXnkh8ULor4LTVZKoYLHw==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.2.tgz", + "integrity": "sha512-xe1bCKPJaKsD0tfd7Rb6bGfUogJTpKbTEEthsfdb7hTfTRNJVQTdirabQx0o6ERVba/smkM720soMY+0QnrlSQ==", "cpu": [ "arm" ], @@ -506,9 +506,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.1.tgz", - "integrity": "sha512-7Mcn71p9ZuQFAj+h+dhQXy/yeLePRS2yKRnmW1DijA9thKO5qap0GNOIQK4yQ6iP3SU0Mrb/yWo8h8vgRba8lw==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.2.tgz", + "integrity": "sha512-yOM7LdK0p6gk6+Q773OEwtlsikT1TL3yMmYsTtRlDRPha5vV2DC5x7LqRWDr6f3cSYNMKVqxzffXv8ivxNBIFQ==", "cpu": [ "arm" ], @@ -523,9 +523,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.1.tgz", - "integrity": "sha512-4YiLQTX6U4CSl0L9cluep9A9W6UmTfqBDc2/CH6wlu54pl4E7Jn3cOD8oxzvBDEGk/JMKgJ47C8g+radF7mwvg==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.2.tgz", + "integrity": "sha512-qiWuJJV3DybA2IfzvRimeKXGrGuVPv1zobSY/26KnP3HbV0VcNb3ECzgvtbvF3xjSMkcooou6HASXZuLdjnhpQ==", "cpu": [ "arm64" ], @@ -540,9 +540,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.1.tgz", - "integrity": "sha512-2ra8F7w8OquwZN9z2/fKFnli69wa8PLwaVzRMIPGb13ByMJwC28Fbp8YcVGoUhlYMTt7j5j9bNgpysrN2UM+vw==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.2.tgz", + "integrity": "sha512-akcZquRzCY/KpUoZAMBhGf7oi4LmXq1BzRA5CPAC3rkUf28Y/sAYV3jSL+JKd7cwEyFvR5G0XVZ0gaMedP+60A==", "cpu": [ "arm64" ], @@ -557,9 +557,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.1.tgz", - "integrity": "sha512-Sy20ncyhjmBP0Ml+UvQbimjlk6VFgjW5uNP+qqwHB00mTE8Bl2C1TuHTlRwK2YoXeZbee5lP2XevBWVkAQAtSQ==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.2.tgz", + "integrity": "sha512-fNwYHrPyYyxauPzX/cpYw8Z7LQpp+DGA0KCoswA0aVFBpmdMil9XgjB8V3Ny64Ihu797+GKcuJqnsOKEmor7fA==", "cpu": [ "loong64" ], @@ -574,9 +574,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.1.tgz", - "integrity": "sha512-noITLp8oNjYliPnGWmLyelIHwULGqbHloQHGw1rtxbWhTuWooRpnZarZQJ1y9EUC4szuCusCc+HEpUtxpIwYvA==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.2.tgz", + "integrity": "sha512-XfvsgzR7DZqREdst7K1Mj3ilSUM5xLAHJcIMDFPKdxTs9q5VHOT8aMA+a683fqBu7DQl8+Sd9HCsQYL8EMY9qA==", "cpu": [ "loong64" ], @@ -591,9 +591,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.1.tgz", - "integrity": "sha512-hlxxXd+F1mWiAcaFR7Sv9ZQT6m6UfI8+Vy/kFJzztq2pDMU/0wZ9sish0iszNZvsQDo8Gc0i5yuFEOz5dDf6fA==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.2.tgz", + "integrity": "sha512-Pp7gVZggEFlbcuztay+/U0gVG9S1XAh8i7I1Re/htbAzo43P5wHZHw6pTyzotISqlKohoh9RpIfnOz3RbemK1w==", "cpu": [ "ppc64" ], @@ -608,9 +608,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.1.tgz", - "integrity": "sha512-EF7OpqQTQ/BvGqLzUi4rEHuagCV9MugAUXSHemwPW5vxZ75RR+jxO/2j95Ph2dalMpFHSVECjRoioHZgA9zOYA==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.2.tgz", + "integrity": "sha512-zkgL2xff6i7u5hau/m6FGeS8gRkLEdgLw522WGmdWWlLd9btmNl3S80mcEjtGq+kvgUekQ3+BOYLLLcPlS2LIA==", "cpu": [ "ppc64" ], @@ -625,9 +625,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.1.tgz", - "integrity": "sha512-wQO3JesW9PRkwlabQ27y7sPfVOOTLRG73I4F2UYHG5PXun3J9U3y+b7ezVKSYbsvSKGQ1k1cq8Qlun4C9kLt3w==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.2.tgz", + "integrity": "sha512-qOheJomrkVCbbHFJ7L3J97cnhfogKqguAQphv26+3ZsAQIF1L19b+dArl//s8rjJHJLz9byykyM8NBP4nmSa1g==", "cpu": [ "riscv64" ], @@ -642,9 +642,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.1.tgz", - "integrity": "sha512-ouAGwhO6wHRXdnOVCOsB0tRFkA7nhNB2Nwax6oECXN0YiN8EYUTBAOudADOB1PI+yDL61TeNx/u7MVCzksNbkQ==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.2.tgz", + "integrity": "sha512-XlxLD54wQhH3FciCgMofxBw27NzUe818gJH410qWvc41UT0ZFcgxVjyX5/EK8MPTupjeVWqN5oy+9pCA9mqfCA==", "cpu": [ "riscv64" ], @@ -659,9 +659,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.1.tgz", - "integrity": "sha512-q2R38Sn+1J8RxhfJ+T54wSWmyKXWec+9jgDfqO2AtArEqHO5R2aeayp5H5OYLr5UYDVGsVaZPEFUooMhYCdz5A==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.2.tgz", + "integrity": "sha512-vdryWeRb2bLJZf0Fv/W8se6nvsHe2PkTCxV0meheK3nQE+G90VCJcke51Miy1yQRsfm2uqIyjXOu4wmUzbTtkQ==", "cpu": [ "s390x" ], @@ -676,9 +676,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.1.tgz", - "integrity": "sha512-gfI5T24WLLuFfSKw7Go/zDXjAAV0fny0swTaDv+WjK7vqcw4cRhFfdsyKL1n+ukI+ooBxn3bVQnyrn06WpI50w==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.2.tgz", + "integrity": "sha512-bcq2h2pkKmH2po4cZV8VWzO4lL40STyu/nLoFpYMQp9C2tCVNTdcVv86MwSsn3D5s1FBe2Ty1atqvVAUTMimNg==", "cpu": [ "x64" ], @@ -693,9 +693,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.1.tgz", - "integrity": "sha512-4h6XqthmB4Hspji84wvgk+ElodTsGj+dbZqHJHHtKxj4mYq0ANSEEPX9ys3moJueqsRjwpaJYH7874Itwnj2ow==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.2.tgz", + "integrity": "sha512-EGoo5DMVMRkTId8fuTDaoxVlR5ZTsKULUezRjd9gCw5eeY+DjCvDpZAOlNUvKPGX+7rS1RWx6j+yOpNPx0cUgQ==", "cpu": [ "x64" ], @@ -710,9 +710,9 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.1.tgz", - "integrity": "sha512-dlfCOa87o1VAYegLQ9EKilx2JCeRofiyPGhTCmqnuXZ6bMPiycO1rq1+sKoulAp7pGLIsTIw+1x5R+zgh5LhhA==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.2.tgz", + "integrity": "sha512-MErl12k7BFHZG1TI9QF/3lSSZARzq9KgNy/FjnqFMCkv+N4RSSzoUCA5h2mqHX4Mox3WaTVKblyzhQ1zRb2ZuQ==", "cpu": [ "x64" ], @@ -724,9 +724,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.1.tgz", - "integrity": "sha512-cjkLbOlfcm3QGhMM1J5zaZjsw1GggbN6rw9UTSSRrPrR1KkcXnN7Uq9rPw34xImQ9VOY9GN+6u2Zj80B9ptkcw==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.2.tgz", + "integrity": "sha512-ILs8k07Wh4p0PsNY4wYLEaXZKMOpVhrG5QDB0yHhGhuzOfDlnyHN6sflL4El/MpUP1y8uY2lUZrv4oBS6pTT3g==", "cpu": [ "arm64" ], @@ -738,9 +738,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.1.tgz", - "integrity": "sha512-Li1KdUnWGE4N3e1F/B4RTB1ms+nG4WBgjByO46pkeBVX/2UBsY53xf5vK9WygVmnH3RwncIST7lkSdLSY6P9lg==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.2.tgz", + "integrity": "sha512-hKgB3nz/TKD3Wv78XEsyXzQsNjvhOHmwKQTvXADGOyU/cIClZDO7DsoggbdmJDPGp5V80tA3Vfv61PaKTLH3LA==", "cpu": [ "arm64" ], @@ -752,9 +752,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.1.tgz", - "integrity": "sha512-t4ZYOSoLTgwhuFMrmTMLx/+i1DQVK7HYqMc6kY46EApwi8X0nIVphzdNoThU3xt6n+N5urG1/gxBdCaKDLavfg==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.2.tgz", + "integrity": "sha512-T4wf1mudIDxN8Q/CWIBJC1u5gQUc+r5mPvlwoSbIvNkyVTP2TAFeobEmst5AQ4gMyAz4sSByVdoTDfvTmGK/8g==", "cpu": [ "ia32" ], @@ -766,9 +766,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.1.tgz", - "integrity": "sha512-RgroPfMmKlD1RzSDxvwgcPiy2HNQKoYV7OmwIXDsk73uKW5t6B/V8KIy27SMv/FNXFo/oSBtWc9J0X7t91ezZg==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.2.tgz", + "integrity": "sha512-tC3IY7qoaD9Ll3/8WJQn49j5V2f/NuI9S41NOE2iM5MPs3sPIvOkVToLcz/7Bz4pyF7PSvrtwu8I/pUrGOSecQ==", "cpu": [ "x64" ], @@ -780,9 +780,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.1.tgz", - "integrity": "sha512-at8QVep6S3h5Y6gSbdGU06bRY5WJkf6WUduM9YtvYMbYhB1MOFfUgc6kehitQXzOtMSaT70q7f9ydPhpqu821w==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.2.tgz", + "integrity": "sha512-6NHnk/K3eq2ZFYcU1X8g67s9qIJRCOTT92gwLMVBp08dB2uuuwI1/Q/empzL2Bfr2f2WRLJVwpp90RmacQyFkw==", "cpu": [ "x64" ], @@ -829,17 +829,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.69.0.tgz", - "integrity": "sha512-t5jQTKPIgVW1PE6dR6H6Qz5gm8zjMlX5/2gRaOGd9eO6V7J+tQc6iWKukEe7dY8u9HyYasQ0yfF0/FSSTEO2gA==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.70.0.tgz", + "integrity": "sha512-/v8HZt6RlyIZxB3ntehELOcUcfxKPVGWXnQdJuHRmzrqgF8nQypcC/oxGW+Ot4VGKDq81XugPKxx0n5PBtf9PA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.69.0", - "@typescript-eslint/type-utils": "8.69.0", - "@typescript-eslint/utils": "8.69.0", - "@typescript-eslint/visitor-keys": "8.69.0", + "@typescript-eslint/scope-manager": "8.70.0", + "@typescript-eslint/type-utils": "8.70.0", + "@typescript-eslint/utils": "8.70.0", + "@typescript-eslint/visitor-keys": "8.70.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -852,15 +852,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.69.0", + "@typescript-eslint/parser": "^8.70.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.8.tgz", - "integrity": "sha512-YYNsSlXBjMk92SKnkwvB5LOVSa6OznlFUGcsvrFgNJbJCd0M1XKeFVRc8ZByeCqz32FivYNHJVooLmdqrmvp/Q==", + "version": "7.0.9", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.9.tgz", + "integrity": "sha512-brTTsvFRt5C1gGHtPst/281UjPD5t9fBqbgoMPlVWy11ZLTPfu7HxK4ZYqO9H7o/yC9rSTCI85EaQ4OoY12qYw==", "dev": true, "license": "MIT", "engines": { @@ -868,16 +868,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.69.0.tgz", - "integrity": "sha512-l4b0DhWioGg6Gt2ebGlvfkFMOjRsauxtsnDRwUSRX1qHq3HdTfQHV8wW9zEXeciai6HfeaKOedQn2Zoofx3WBw==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.70.0.tgz", + "integrity": "sha512-zYvrmj9Yxd63UGaXw+kdt6A0F0s0qveJyuatIM77bYC2DE4pgmg7a50u8LR7PRtXd0x+h+Tl3eXabGm06SWd3Q==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.69.0", - "@typescript-eslint/types": "8.69.0", - "@typescript-eslint/typescript-estree": "8.69.0", - "@typescript-eslint/visitor-keys": "8.69.0", + "@typescript-eslint/scope-manager": "8.70.0", + "@typescript-eslint/types": "8.70.0", + "@typescript-eslint/typescript-estree": "8.70.0", + "@typescript-eslint/visitor-keys": "8.70.0", "debug": "^4.4.3" }, "engines": { @@ -893,14 +893,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.69.0.tgz", - "integrity": "sha512-yi4obFrHMmnsesWehHbkg9zMA7Jt8cXT+mKM08G999pH1yT6nqgsHx7MYm0uY1wAj8CqiBXYRJ7WAT0QdQHQXg==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.70.0.tgz", + "integrity": "sha512-hFHbTNqhU9G+2eKFXCBVb1tjFT/LceiJ4+HfLO4pTpDI0KHi6iajpcFFkaSQ9gXmCh7n82A0PthaayEdN6mspQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.69.0", - "@typescript-eslint/types": "^8.69.0", + "@typescript-eslint/tsconfig-utils": "^8.70.0", + "@typescript-eslint/types": "^8.70.0", "debug": "^4.4.3" }, "engines": { @@ -915,14 +915,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.69.0.tgz", - "integrity": "sha512-ewfspqWvSxKSOaplqAUNbaSFO0eB6w1EtQ+esfYFRm3614Ty4uNtExkcbgd6nWsXphbqKyf9ZYdbZdv2xEoWEQ==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.70.0.tgz", + "integrity": "sha512-8nP3Kwh5hlgZ4FicGvmznAmJe8UL4sdU8tLukrPaMuQmDuk4Y8xYfzu/aYZW4xT2JCgc7H/TpDI5cGlxcWJSqQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.69.0", - "@typescript-eslint/visitor-keys": "8.69.0" + "@typescript-eslint/types": "8.70.0", + "@typescript-eslint/visitor-keys": "8.70.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -933,9 +933,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.69.0.tgz", - "integrity": "sha512-xNqK7YTDZsLniQMV/4rpFR8Z5JlqeRvVjuG1YgF/mdPVH84HSD19L8CczMA0qg2RfwEV231GHH3VnToJDo4MfQ==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.70.0.tgz", + "integrity": "sha512-adnkeeNq9Sq1sUf4+FRVc0KdgYghzsgFpZSQVZVvY0LCuUuN0FnQgyGzCJeC4fW1cdXseBAjU2EOqUIjbNcZUw==", "dev": true, "license": "MIT", "engines": { @@ -950,15 +950,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.69.0.tgz", - "integrity": "sha512-ZfoJAVg3JZndQEpEl9petVlxau3lRuElc4HRMuAlLCf8to04/iHz692RUSNmXKDjEuJmIL+KZ2/BsOcBc16dsA==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.70.0.tgz", + "integrity": "sha512-NUMKIhYVaVIVLnRL9CRt+VVcuLgSHUCpXn4/+K8wql+vdInUzvx8BjUO1oJ7cG9shjFJKtF8F8Hh2kCh3/KBVw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.69.0", - "@typescript-eslint/typescript-estree": "8.69.0", - "@typescript-eslint/utils": "8.69.0", + "@typescript-eslint/types": "8.70.0", + "@typescript-eslint/typescript-estree": "8.70.0", + "@typescript-eslint/utils": "8.70.0", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -975,9 +975,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.69.0.tgz", - "integrity": "sha512-K3VrubUPhlo9VDBS6QdI8YB5j7ClpqLRdefcz6PFrhnwicehBweqQ9Evhl4l+FYz0HdDmMqIiSX0aldGRYtDCA==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.70.0.tgz", + "integrity": "sha512-asTOIYhDg4zdzOScCyaytrsV3cR6B4ecPQlXw/dJIm7J/MZTtCtfVII9JD8Geh4jTCrK/Xe6cg5UevoleMcoJQ==", "dev": true, "license": "MIT", "engines": { @@ -989,16 +989,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.69.0.tgz", - "integrity": "sha512-AdFkgqck3Vudb/kWnxlyafU/4aBhHrbQ9locP2N4psXTy5mOBg0SHJumnLvx7r6g1gV4DKvUFwV2nJZBoqOD8w==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.70.0.tgz", + "integrity": "sha512-d9NmHMPEKQ7QCLLm1jI3zmoQBwT5KwFYjXBJ9ymZfKCUU+5rmTRykKAFvH5Qn/ZCds3CEAFS9OC9M/jkl0X2bA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.69.0", - "@typescript-eslint/tsconfig-utils": "8.69.0", - "@typescript-eslint/types": "8.69.0", - "@typescript-eslint/visitor-keys": "8.69.0", + "@typescript-eslint/project-service": "8.70.0", + "@typescript-eslint/tsconfig-utils": "8.70.0", + "@typescript-eslint/types": "8.70.0", + "@typescript-eslint/visitor-keys": "8.70.0", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -1017,16 +1017,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.69.0.tgz", - "integrity": "sha512-tUbx60BBqQa31kXF5MCsOOLL5E/WzUuxIn7YpAvq+eaUlqvk8/NXnXMBNAdLCr0icjkzem7iUA5QqWHe/hJ1aw==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.70.0.tgz", + "integrity": "sha512-oZmtKJz/4fufZ2p3+Cn3ijEojcdfR+1zYDH2xKYrEly0dR/Q/1xUPRCOlKGxod78nWlU2UnDe09GZ3TaknBFGA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.69.0", - "@typescript-eslint/types": "8.69.0", - "@typescript-eslint/typescript-estree": "8.69.0" + "@typescript-eslint/scope-manager": "8.70.0", + "@typescript-eslint/types": "8.70.0", + "@typescript-eslint/typescript-estree": "8.70.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1041,13 +1041,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.69.0.tgz", - "integrity": "sha512-+rmdgPA+EXkNgKYvHvFfhrs35utXbwaC5PGpDquSXcoXQDKUA5UjV0LmTucG/4JXkM31BTu4TilHtrN8IVBe8w==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.70.0.tgz", + "integrity": "sha512-BoC8PiO4Hkdo0TVJh9Ntxr5MxPDI7/oFsrygN5ADelFSeXG/qgNuucIGA+L5Z6JpPTE/uRfcTWtscjbUaufepQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.69.0", + "@typescript-eslint/types": "8.70.0", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -1996,9 +1996,9 @@ } }, "node_modules/rollup": { - "version": "4.63.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.1.tgz", - "integrity": "sha512-3Df9jsstwhccuEfmAMi9l8XUh/GOkVObmFTU7CCVBysEbcOZLl84jCtaAZMcPiMz2EGKsATzQcU+Xr3n/wU6cg==", + "version": "4.63.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.2.tgz", + "integrity": "sha512-l5eyksV4tPBj6lJyEa37YzIOCSOV7lkZzEHUdpjWZbtD7wTcFYmEYXSgm5bT4vV+dZLb9rBG1W9GROOG4NS4Ew==", "dev": true, "license": "MIT", "dependencies": { @@ -2013,31 +2013,31 @@ }, "optionalDependencies": { "@napi-rs/lzma-linux-x64-gnu": "1.5.1", - "@rollup/rollup-android-arm-eabi": "4.63.1", - "@rollup/rollup-android-arm64": "4.63.1", - "@rollup/rollup-darwin-arm64": "4.63.1", - "@rollup/rollup-darwin-x64": "4.63.1", - "@rollup/rollup-freebsd-arm64": "4.63.1", - "@rollup/rollup-freebsd-x64": "4.63.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.63.1", - "@rollup/rollup-linux-arm-musleabihf": "4.63.1", - "@rollup/rollup-linux-arm64-gnu": "4.63.1", - "@rollup/rollup-linux-arm64-musl": "4.63.1", - "@rollup/rollup-linux-loong64-gnu": "4.63.1", - "@rollup/rollup-linux-loong64-musl": "4.63.1", - "@rollup/rollup-linux-ppc64-gnu": "4.63.1", - "@rollup/rollup-linux-ppc64-musl": "4.63.1", - "@rollup/rollup-linux-riscv64-gnu": "4.63.1", - "@rollup/rollup-linux-riscv64-musl": "4.63.1", - "@rollup/rollup-linux-s390x-gnu": "4.63.1", - "@rollup/rollup-linux-x64-gnu": "4.63.1", - "@rollup/rollup-linux-x64-musl": "4.63.1", - "@rollup/rollup-openbsd-x64": "4.63.1", - "@rollup/rollup-openharmony-arm64": "4.63.1", - "@rollup/rollup-win32-arm64-msvc": "4.63.1", - "@rollup/rollup-win32-ia32-msvc": "4.63.1", - "@rollup/rollup-win32-x64-gnu": "4.63.1", - "@rollup/rollup-win32-x64-msvc": "4.63.1", + "@rollup/rollup-android-arm-eabi": "4.63.2", + "@rollup/rollup-android-arm64": "4.63.2", + "@rollup/rollup-darwin-arm64": "4.63.2", + "@rollup/rollup-darwin-x64": "4.63.2", + "@rollup/rollup-freebsd-arm64": "4.63.2", + "@rollup/rollup-freebsd-x64": "4.63.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.2", + "@rollup/rollup-linux-arm-musleabihf": "4.63.2", + "@rollup/rollup-linux-arm64-gnu": "4.63.2", + "@rollup/rollup-linux-arm64-musl": "4.63.2", + "@rollup/rollup-linux-loong64-gnu": "4.63.2", + "@rollup/rollup-linux-loong64-musl": "4.63.2", + "@rollup/rollup-linux-ppc64-gnu": "4.63.2", + "@rollup/rollup-linux-ppc64-musl": "4.63.2", + "@rollup/rollup-linux-riscv64-gnu": "4.63.2", + "@rollup/rollup-linux-riscv64-musl": "4.63.2", + "@rollup/rollup-linux-s390x-gnu": "4.63.2", + "@rollup/rollup-linux-x64-gnu": "4.63.2", + "@rollup/rollup-linux-x64-musl": "4.63.2", + "@rollup/rollup-openbsd-x64": "4.63.2", + "@rollup/rollup-openharmony-arm64": "4.63.2", + "@rollup/rollup-win32-arm64-msvc": "4.63.2", + "@rollup/rollup-win32-ia32-msvc": "4.63.2", + "@rollup/rollup-win32-x64-gnu": "4.63.2", + "@rollup/rollup-win32-x64-msvc": "4.63.2", "fsevents": "~2.3.2" } }, @@ -2184,16 +2184,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.69.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.69.0.tgz", - "integrity": "sha512-B3MltX0VqjUBNEe3b3sSuiRbfa6XrfHFtBiPamjT5AsW/dfq+y+bc0wyuS9DxAS1LyzCxRp2+rxzpLUvqM2BvA==", + "version": "8.70.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.70.0.tgz", + "integrity": "sha512-P/W5cz70/cQAuKfY3xwQMWWTV7BvJ0mAQmi+9mBcsVPaBUpd6Ohpa+fECv9rBFrQcig86jAiNBFNWUqnTjr4pw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.69.0", - "@typescript-eslint/parser": "8.69.0", - "@typescript-eslint/typescript-estree": "8.69.0", - "@typescript-eslint/utils": "8.69.0" + "@typescript-eslint/eslint-plugin": "8.70.0", + "@typescript-eslint/parser": "8.70.0", + "@typescript-eslint/typescript-estree": "8.70.0", + "@typescript-eslint/utils": "8.70.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index c8c59602..9f049e64 100644 --- a/package.json +++ b/package.json @@ -48,11 +48,11 @@ "eslint": "10.10.0", "playwright": "1.56.1", "prettier": "3.9.6", - "rollup": "4.63.1", + "rollup": "4.63.2", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3", - "typescript-eslint": "8.69.0" + "typescript-eslint": "8.70.0" }, "overrides": { "brace-expansion": "5.0.9" diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 2ad22d6c..84c42d3c 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -119,6 +119,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -233,6 +234,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -290,6 +292,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -399,6 +402,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -482,6 +486,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -594,6 +599,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -748,6 +754,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -854,6 +861,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -1178,6 +1186,7 @@ export class Avatars { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); diff --git a/src/services/functions.ts b/src/services/functions.ts index c91f7e93..f4f108a7 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -2140,6 +2140,7 @@ export class Functions { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); diff --git a/src/services/organizations.ts b/src/services/organizations.ts index 81bfa975..16231cd4 100644 --- a/src/services/organizations.ts +++ b/src/services/organizations.ts @@ -2367,6 +2367,7 @@ export class Organizations { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -2626,6 +2627,7 @@ export class Organizations { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); diff --git a/src/services/sites.ts b/src/services/sites.ts index b0ba13f4..bd459dc5 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -2143,6 +2143,7 @@ export class Sites { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); diff --git a/src/services/storage.ts b/src/services/storage.ts index a897d653..b2c0fc60 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1189,6 +1189,7 @@ export class Storage { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -1428,6 +1429,7 @@ export class Storage { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -1508,6 +1510,7 @@ export class Storage { const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; + payload['impersonateuserid'] = this.client.config.impersonateuserid; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); From 0f4d849d28166d966a7a8c04033743e21bddfcf5 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sun, 20 Sep 2026 20:48:31 +0100 Subject: [PATCH 08/10] chore: update Console SDK to 17.0.0 --- CHANGELOG.md | 25 + README.md | 6 +- ...gs.md => create-email-verification-otp.md} | 5 +- .../account/create-id-token-session.md | 20 + .../update-email-verification-otp.md} | 9 +- .../messaging/create-appwrite-provider.md | 19 + docs/examples/messaging/create-topic.md | 2 + .../messaging/create-twilio-provider.md | 2 +- .../messaging/update-appwrite-provider.md | 19 + docs/examples/messaging/update-topic.md | 2 + .../create-ephemeral-project-key.md | 17 + .../create-project-key.md} | 9 +- .../delete-project-key.md} | 6 +- .../get-project-key.md} | 6 +- .../list-project-keys.md} | 7 +- .../organization/update-project-key.md | 19 + ...{cancel-downgrade.md => get-estimation.md} | 2 +- docs/examples/project/get-usage.md | 17 - .../examples/project/update-o-auth-2-apple.md | 2 + .../project/update-o-auth-2-google.md | 2 + .../project/update-password-pwned-policy.md | 17 + docs/examples/teams/list-logs.md | 17 - package-lock.json | 4 +- package.json | 2 +- src/client.ts | 20 +- src/enums/billing-plan-group.ts | 3 +- src/enums/cache-database.ts | 1 - src/enums/framework.ts | 1 + src/enums/id-token-provider.ts | 4 + src/enums/organization-key-scopes.ts | 6 +- src/enums/project-email-template-id.ts | 1 + src/enums/project-key-scopes.ts | 1 + src/enums/project-policy-id.ts | 1 + src/enums/project-usage-range.ts | 4 - src/enums/query-suggestion-resource.ts | 4 +- src/index.ts | 4 +- src/models.ts | 785 +++++------------- src/services/account.ts | 372 +++++++-- src/services/console.ts | 4 +- src/services/manager.ts | 34 +- src/services/messaging.ts | 325 +++++++- src/services/organization.ts | 582 +++++++++++++ src/services/organizations.ts | 123 ++- src/services/project.ts | 266 +++--- src/services/projects.ts | 315 ------- src/services/storage.ts | 8 +- src/services/teams.ts | 82 -- src/services/users.ts | 86 +- 48 files changed, 1846 insertions(+), 1422 deletions(-) rename docs/examples/account/{list-logs.md => create-email-verification-otp.md} (75%) create mode 100644 docs/examples/account/create-id-token-session.md rename docs/examples/{users/list-logs.md => account/update-email-verification-otp.md} (56%) create mode 100644 docs/examples/messaging/create-appwrite-provider.md create mode 100644 docs/examples/messaging/update-appwrite-provider.md create mode 100644 docs/examples/organization/create-ephemeral-project-key.md rename docs/examples/{projects/update-dev-key.md => organization/create-project-key.md} (50%) rename docs/examples/{projects/delete-dev-key.md => organization/delete-project-key.md} (62%) rename docs/examples/{projects/get-dev-key.md => organization/get-project-key.md} (62%) rename docs/examples/{projects/list-dev-keys.md => organization/list-project-keys.md} (58%) create mode 100644 docs/examples/organization/update-project-key.md rename docs/examples/organizations/{cancel-downgrade.md => get-estimation.md} (87%) delete mode 100644 docs/examples/project/get-usage.md create mode 100644 docs/examples/project/update-password-pwned-policy.md delete mode 100644 docs/examples/teams/list-logs.md create mode 100644 src/enums/id-token-provider.ts delete mode 100644 src/enums/project-usage-range.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 78c20c47..222b5edf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Change Log +## 17.0.0 + +* Breaking: SDK now targets Appwrite 2.2 (`X-Appwrite-Response-Format: 2.2.0`) +* Breaking: removed `Account.listLogs`, `Teams.listLogs`, `Users.listLogs` and the `Log`, `LogList` models +* Breaking: removed `Client.setDevKey`, the `Projects` dev key methods, and the `DevKey`, `DevKeyList` models +* Breaking: removed `Project.getUsage`, the `ProjectUsageRange` enum and `UsageProject`, `MetricBreakdown` models +* Breaking: removed `Organizations.cancelDowngrade` +* Breaking: `Manager.listBlocks` returns `ManagerBlockList`; `BlockList`, `BlockDelete` renamed to `ManagerBlockList`, `ManagerBlockDelete` with a new `ManagerBlock` model +* Breaking: `Block` model dropped `billingPlan`, `organizationId`, `organizationName`, `projectName`, `region`, `reason` +* Breaking: `Project.devKeys` field removed +* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` +* Breaking: `OrganizationKeyScopes` dev key and `organization.keys.*` scopes replaced by `organization.projects.keys.*` +* Breaking: `CacheDatabase.Logs` and `QuerySuggestionResource` `DevKeys`, `Executions`, `Stats` values removed +* Added: `Organization` project key methods `listProjectKeys`, `createProjectKey`, `createEphemeralProjectKey`, `getProjectKey`, `updateProjectKey`, `deleteProjectKey` +* Added: `Account.createIdTokenSession` for native Apple and Google sign-in with `IdTokenProvider` enum +* Added: `Account.createEmailVerificationOTP` and `Account.updateEmailVerificationOTP` +* Added: `Messaging.createAppwriteProvider` and `Messaging.updateAppwriteProvider` for Appwrite push, with `qos` and `expiry` on `Topic` +* Added: `Organizations.getEstimation` for the current billing cycle charge estimate +* Added: `Project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `ProjectPolicyId.Passwordpwned` +* Added: `nativeEnabled`, `nativeClientIds` parameters on `Project.updateOAuth2Apple` and `Project.updateOAuth2Google` and matching fields on `OAuth2Apple`, `OAuth2Google` +* Added: `Framework.Jaspr`, `ProjectEmailTemplateId.OtpVerification`, `ProjectKeyScopes.DedicatedDatabasesExecute`, `QuerySuggestionResource.AppwritePushLedger` +* Added: `passwordPwned` on `User`, `providerIdToken` on `Identity`, `firstAccessedAt` and `mcpAccessedAt` on `Project`, `eligibleCountries` on `BillingPlan` +* Added: `protocol`, `accept`, `acceptLanguage`, `queryKeys` fields on `UsageDataPoint` +* Fixed: empty-string required parameters are rejected instead of sent to the API + ## 16.1.0 * Fixed: `impersonateuserid` is carried again by every client URL builder — the avatar helpers, `functions`/`sites` `getDeploymentDownload()`, `organizations` `getInvoiceDownload()`/`getInvoiceView()`, and `storage` `getFileDownload()`/`getFilePreview()`/`getFileView()`. The browser loads these URLs directly and cannot send the impersonation header, so an impersonating console operator was served their own resources or a 401 diff --git a/README.md b/README.md index a9175d8a..1c917b26 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Console SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.2.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 latest 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-console/releases) when APIs differ. +**This SDK targets Appwrite server version 2.0.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-console/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -33,7 +33,7 @@ import { Client, Account } from '@appwrite.io/console'; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` ## Getting Started diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/create-email-verification-otp.md similarity index 75% rename from docs/examples/account/list-logs.md rename to docs/examples/account/create-email-verification-otp.md index 9b2d4e5c..7424c5bd 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/create-email-verification-otp.md @@ -7,9 +7,8 @@ const client = new Client() const account = new Account(client); -const result = await account.listLogs({ - queries: [], // optional - total: false, // optional +const result = await account.createEmailVerificationOTP({ + phrase: false, // optional }); console.log(result); diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md new file mode 100644 index 00000000..f54355ac --- /dev/null +++ b/docs/examples/account/create-id-token-session.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Account, IdTokenProvider } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createIdTokenSession({ + provider: IdTokenProvider.Apple, + idToken: '', + nonce: '', // optional + accessToken: '', // optional + accessTokenExpiry: 0, // optional + name: '', // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/account/update-email-verification-otp.md similarity index 56% rename from docs/examples/users/list-logs.md rename to docs/examples/account/update-email-verification-otp.md index 6affdede..204ec33e 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/account/update-email-verification-otp.md @@ -1,16 +1,15 @@ ```javascript -import { Client, Users } from '@appwrite.io/console'; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const users = new Users(client); +const account = new Account(client); -const result = await users.listLogs({ +const result = await account.updateEmailVerificationOTP({ userId: '', - queries: [], // optional - total: false, // optional + secret: '', }); console.log(result); diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md new file mode 100644 index 00000000..131e915b --- /dev/null +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Messaging } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createAppwriteProvider({ + providerId: '', + name: '', + enabled: false, // optional + qos: 0, // optional + expiry: 0, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 1757fa6f..1e1247f7 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -11,6 +11,8 @@ const result = await messaging.createTopic({ topicId: '', name: '', subscribe: ['any'], // optional + qos: 0, // optional + expiry: 0, // optional }); console.log(result); diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 75a41f89..f1010c9b 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -10,7 +10,7 @@ const messaging = new Messaging(client); const result = await messaging.createTwilioProvider({ providerId: '', name: '', - from: '+12065550100', // optional + from: '', // optional accountSid: '', // optional authToken: '', // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md new file mode 100644 index 00000000..c87972d0 --- /dev/null +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Messaging } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateAppwriteProvider({ + providerId: '', + name: '', // optional + enabled: false, // optional + qos: 0, // optional + expiry: 0, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 633728c6..ef9c7645 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -11,6 +11,8 @@ const result = await messaging.updateTopic({ topicId: '', name: '', // optional subscribe: ['any'], // optional + qos: 0, // optional + expiry: 0, // optional }); console.log(result); diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md new file mode 100644 index 00000000..d1cb1295 --- /dev/null +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Organization, ProjectKeyScopes } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organization = new Organization(client); + +const result = await organization.createEphemeralProjectKey({ + projectId: '', + scopes: [ProjectKeyScopes.ProjectRead], + duration: 600, +}); + +console.log(result); +``` diff --git a/docs/examples/projects/update-dev-key.md b/docs/examples/organization/create-project-key.md similarity index 50% rename from docs/examples/projects/update-dev-key.md rename to docs/examples/organization/create-project-key.md index 424f7be1..2361bb94 100644 --- a/docs/examples/projects/update-dev-key.md +++ b/docs/examples/organization/create-project-key.md @@ -1,17 +1,18 @@ ```javascript -import { Client, Projects } from '@appwrite.io/console'; +import { Client, Organization, ProjectKeyScopes } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const organization = new Organization(client); -const result = await projects.updateDevKey({ +const result = await organization.createProjectKey({ projectId: '', keyId: '', name: '', - expire: '2020-10-15T06:38:00.000+00:00', + scopes: [ProjectKeyScopes.ProjectRead], + expire: '2020-10-15T06:38:00.000+00:00', // optional }); console.log(result); diff --git a/docs/examples/projects/delete-dev-key.md b/docs/examples/organization/delete-project-key.md similarity index 62% rename from docs/examples/projects/delete-dev-key.md rename to docs/examples/organization/delete-project-key.md index c0940dec..4c97d8f5 100644 --- a/docs/examples/projects/delete-dev-key.md +++ b/docs/examples/organization/delete-project-key.md @@ -1,13 +1,13 @@ ```javascript -import { Client, Projects } from '@appwrite.io/console'; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const organization = new Organization(client); -const result = await projects.deleteDevKey({ +const result = await organization.deleteProjectKey({ projectId: '', keyId: '', }); diff --git a/docs/examples/projects/get-dev-key.md b/docs/examples/organization/get-project-key.md similarity index 62% rename from docs/examples/projects/get-dev-key.md rename to docs/examples/organization/get-project-key.md index 265b6401..8032e97c 100644 --- a/docs/examples/projects/get-dev-key.md +++ b/docs/examples/organization/get-project-key.md @@ -1,13 +1,13 @@ ```javascript -import { Client, Projects } from '@appwrite.io/console'; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const organization = new Organization(client); -const result = await projects.getDevKey({ +const result = await organization.getProjectKey({ projectId: '', keyId: '', }); diff --git a/docs/examples/projects/list-dev-keys.md b/docs/examples/organization/list-project-keys.md similarity index 58% rename from docs/examples/projects/list-dev-keys.md rename to docs/examples/organization/list-project-keys.md index 46a0307e..eeedbf4c 100644 --- a/docs/examples/projects/list-dev-keys.md +++ b/docs/examples/organization/list-project-keys.md @@ -1,15 +1,16 @@ ```javascript -import { Client, Projects } from '@appwrite.io/console'; +import { Client, Organization } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const organization = new Organization(client); -const result = await projects.listDevKeys({ +const result = await organization.listProjectKeys({ projectId: '', queries: [], // optional + total: false, // optional }); console.log(result); diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md new file mode 100644 index 00000000..550ecebd --- /dev/null +++ b/docs/examples/organization/update-project-key.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Organization, ProjectKeyScopes } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organization = new Organization(client); + +const result = await organization.updateProjectKey({ + projectId: '', + keyId: '', + name: '', + scopes: [ProjectKeyScopes.ProjectRead], + expire: '2020-10-15T06:38:00.000+00:00', // optional +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/cancel-downgrade.md b/docs/examples/organizations/get-estimation.md similarity index 87% rename from docs/examples/organizations/cancel-downgrade.md rename to docs/examples/organizations/get-estimation.md index fd3a61de..7830f8fb 100644 --- a/docs/examples/organizations/cancel-downgrade.md +++ b/docs/examples/organizations/get-estimation.md @@ -7,7 +7,7 @@ const client = new Client() const organizations = new Organizations(client); -const result = await organizations.cancelDowngrade({ +const result = await organizations.getEstimation({ organizationId: '', }); diff --git a/docs/examples/project/get-usage.md b/docs/examples/project/get-usage.md deleted file mode 100644 index 195c46b4..00000000 --- a/docs/examples/project/get-usage.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, Project, ProjectUsageRange } from '@appwrite.io/console'; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const project = new Project(client); - -const result = await project.getUsage({ - startDate: '2020-10-15T06:38:00.000+00:00', - endDate: '2020-10-15T06:38:00.000+00:00', - period: ProjectUsageRange.OneHour, // optional -}); - -console.log(result); -``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index ea8fef83..0c4a52b0 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -12,7 +12,9 @@ const result = await project.updateOAuth2Apple({ keyId: '', // optional teamId: '', // optional p8File: '', // optional + nativeClientIds: [], // optional enabled: false, // optional + nativeEnabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 2780c0ca..c0bbe651 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -15,7 +15,9 @@ const result = await project.updateOAuth2Google({ clientId: '', // optional clientSecret: '', // optional prompt: [ProjectOAuth2GooglePrompt.None], // optional + nativeClientIds: [], // optional enabled: false, // optional + nativeEnabled: false, // optional }); console.log(result); diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md new file mode 100644 index 00000000..ee4b7ef5 --- /dev/null +++ b/docs/examples/project/update-password-pwned-policy.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.updatePasswordPwnedPolicy({ + enabled: false, // optional + sessions: false, // optional + users: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/teams/list-logs.md b/docs/examples/teams/list-logs.md deleted file mode 100644 index 889413dd..00000000 --- a/docs/examples/teams/list-logs.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, Teams } from '@appwrite.io/console'; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const teams = new Teams(client); - -const result = await teams.listLogs({ - teamId: '', - queries: [], // optional - total: false, // optional -}); - -console.log(result); -``` diff --git a/package-lock.json b/package-lock.json index b60ff304..f63c20c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "16.1.0", + "version": "17.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "16.1.0", + "version": "17.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index 9f049e64..1683a871 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "16.1.0", + "version": "17.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 7f973722..86594e53 100644 --- a/src/client.ts +++ b/src/client.ts @@ -377,7 +377,6 @@ class Client { mode: string; cookie: string; session: string; - devkey: string; impersonateuserid: string; impersonateuseremail: string; impersonateuserphone: string; @@ -396,7 +395,6 @@ class Client { mode: '', cookie: '', session: '', - devkey: '', impersonateuserid: '', impersonateuseremail: '', impersonateuserphone: '', @@ -411,8 +409,8 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '16.1.0', - 'X-Appwrite-Response-Format': '2.0.0', + 'x-sdk-version': '17.0.0', + 'X-Appwrite-Response-Format': '2.2.0', }; /** @@ -660,20 +658,6 @@ class Client { this.config.session = value; return this; } - /** - * Set DevKey - * - * Your secret dev API key - * - * @param value string - * - * @return {this} - */ - setDevKey(value: string): this { - this.headers['X-Appwrite-Dev-Key'] = value; - this.config.devkey = value; - return this; - } /** * Set ImpersonateUserId * diff --git a/src/enums/billing-plan-group.ts b/src/enums/billing-plan-group.ts index e8cd15d8..fd8da3ae 100644 --- a/src/enums/billing-plan-group.ts +++ b/src/enums/billing-plan-group.ts @@ -1,5 +1,6 @@ export enum BillingPlanGroup { - Starter = 'starter', + Free = 'free', + Start = 'start', Pro = 'pro', Scale = 'scale', } diff --git a/src/enums/cache-database.ts b/src/enums/cache-database.ts index 936ed1e5..f048cbfc 100644 --- a/src/enums/cache-database.ts +++ b/src/enums/cache-database.ts @@ -1,5 +1,4 @@ export enum CacheDatabase { Console = 'console', Project = 'project', - Logs = 'logs', } diff --git a/src/enums/framework.ts b/src/enums/framework.ts index 6173a0ef..65f4a87e 100644 --- a/src/enums/framework.ts +++ b/src/enums/framework.ts @@ -11,6 +11,7 @@ export enum Framework { Remix = 'remix', Lynx = 'lynx', Flutter = 'flutter', + Jaspr = 'jaspr', Reactnative = 'react-native', Vite = 'vite', Other = 'other', diff --git a/src/enums/id-token-provider.ts b/src/enums/id-token-provider.ts new file mode 100644 index 00000000..4f99708a --- /dev/null +++ b/src/enums/id-token-provider.ts @@ -0,0 +1,4 @@ +export enum IdTokenProvider { + Apple = 'apple', + Google = 'google', +} diff --git a/src/enums/organization-key-scopes.ts b/src/enums/organization-key-scopes.ts index 2e878b48..abae3738 100644 --- a/src/enums/organization-key-scopes.ts +++ b/src/enums/organization-key-scopes.ts @@ -1,10 +1,8 @@ export enum OrganizationKeyScopes { ProjectsRead = 'projects.read', ProjectsWrite = 'projects.write', - DevKeysRead = 'devKeys.read', - DevKeysWrite = 'devKeys.write', - OrganizationKeysRead = 'organization.keys.read', - OrganizationKeysWrite = 'organization.keys.write', + OrganizationProjectsKeysRead = 'organization.projects.keys.read', + OrganizationProjectsKeysWrite = 'organization.projects.keys.write', OrganizationInstallationsRead = 'organization.installations.read', OrganizationInstallationsWrite = 'organization.installations.write', OrganizationMembershipsRead = 'organization.memberships.read', diff --git a/src/enums/project-email-template-id.ts b/src/enums/project-email-template-id.ts index c8ecbec4..b2f5a808 100644 --- a/src/enums/project-email-template-id.ts +++ b/src/enums/project-email-template-id.ts @@ -6,4 +6,5 @@ export enum ProjectEmailTemplateId { MfaChallenge = 'mfaChallenge', SessionAlert = 'sessionAlert', OtpSession = 'otpSession', + OtpVerification = 'otpVerification', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index e17dffdb..d7cb41cf 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -103,6 +103,7 @@ export enum ProjectKeyScopes { ReportsWrite = 'reports.write', PresencesRead = 'presences.read', PresencesWrite = 'presences.write', + DedicatedDatabasesExecute = 'dedicatedDatabases.execute', BackupsPoliciesRead = 'backups.policies.read', BackupsPoliciesWrite = 'backups.policies.write', ArchivesRead = 'archives.read', diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index c05f7f60..d323094f 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -3,6 +3,7 @@ export enum ProjectPolicyId { Passwordhistory = 'password-history', Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', + Passwordpwned = 'password-pwned', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', diff --git a/src/enums/project-usage-range.ts b/src/enums/project-usage-range.ts deleted file mode 100644 index 8a6cfa0e..00000000 --- a/src/enums/project-usage-range.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ProjectUsageRange { - OneHour = '1h', - OneDay = '1d', -} diff --git a/src/enums/query-suggestion-resource.ts b/src/enums/query-suggestion-resource.ts index 6482f6a1..8e6c0019 100644 --- a/src/enums/query-suggestion-resource.ts +++ b/src/enums/query-suggestion-resource.ts @@ -18,7 +18,6 @@ export enum QuerySuggestionResource { Schedules = 'schedules', Platforms = 'platforms', Keys = 'keys', - DevKeys = 'devkeys', Webhooks = 'webhooks', Notifications = 'notifications', Certificates = 'certificates', @@ -41,6 +40,7 @@ export enum QuerySuggestionResource { Buckets = 'buckets', Providers = 'providers', Messages = 'messages', + AppwritePushLedger = 'appwritepushledger', Topics = 'topics', Subscribers = 'subscribers', Targets = 'targets', @@ -83,13 +83,11 @@ export enum QuerySuggestionResource { Functions = 'functions', Sites = 'sites', Deployments = 'deployments', - Executions = 'executions', Variables = 'variables', Migrations = 'migrations', ResourceTokens = 'resourcetokens', Transactions = 'transactions', TransactionLogs = 'transactionlogs', - Stats = 'stats', DedicatedDatabases = 'dedicateddatabases', DedicatedDatabaseConfigs = 'dedicateddatabaseconfigs', DedicatedDatabaseRuntimes = 'dedicateddatabaseruntimes', diff --git a/src/index.ts b/src/index.ts index 6b7112f9..fc8cf549 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ /** * Appwrite Console SDK * - * This SDK targets Appwrite server version 2.0.x as shipped on Appwrite Cloud. + * This SDK targets Appwrite server version 2.2.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-console/releases) @@ -66,6 +66,7 @@ export { Operator, Condition } from './operator'; export { AccountKeyScopes } from './enums/account-key-scopes'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; +export { IdTokenProvider } from './enums/id-token-provider'; export { OAuthProvider } from './enums/o-auth-provider'; export { Browser } from './enums/browser'; export { CreditCard } from './enums/credit-card'; @@ -118,7 +119,6 @@ export { ProjectPolicyId } from './enums/project-policy-id'; export { ProjectProtocolId } from './enums/project-protocol-id'; export { ProjectServiceId } from './enums/project-service-id'; export { ProjectSMTPSecure } from './enums/project-smtp-secure'; -export { ProjectUsageRange } from './enums/project-usage-range'; export { ScheduleResourceType } from './enums/schedule-resource-type'; export { Status } from './enums/status'; export { InvalidationType } from './enums/invalidation-type'; diff --git a/src/models.ts b/src/models.ts index 3e2de11d..59230f45 100644 --- a/src/models.ts +++ b/src/models.ts @@ -200,20 +200,6 @@ export namespace Models { notifications: Notification[]; }; - /** - * Logs List - */ - export type LogList = { - /** - * Total number of logs that matched your query. - */ - total: number; - /** - * List of logs. - */ - logs: Log[]; - }; - /** * Files List */ @@ -544,20 +530,6 @@ export namespace Models { keys: Key[]; }; - /** - * Dev Keys List - */ - export type DevKeyList = { - /** - * Total number of devKeys that matched your query. - */ - total: number; - /** - * List of devKeys. - */ - devKeys: DevKey[]; - }; - /** * Countries List */ @@ -672,6 +644,7 @@ export namespace Models { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -3288,100 +3261,6 @@ export namespace Models { metadata?: object; }; - /** - * Log - */ - export type Log = { - /** - * Event name. - */ - event: string; - /** - * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - */ - userId: string; - /** - * User email of the actor recorded for this log. During impersonation, this is the original impersonator. - */ - userEmail: string; - /** - * User name of the actor recorded for this log. During impersonation, this is the original impersonator. - */ - userName: string; - /** - * API mode when event triggered. - */ - mode: string; - /** - * User type who triggered the audit log. Possible values: user, admin, guest, hidden, keyProject, keyAccount, keyOrganization. - */ - userType: string; - /** - * IP session in use when the session was created. - */ - ip: string; - /** - * Log creation date in ISO 8601 format. - */ - time: string; - /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - */ - osCode: string; - /** - * Operating system name. - */ - osName: string; - /** - * Operating system version. - */ - osVersion: string; - /** - * Client type. - */ - clientType: string; - /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - */ - clientCode: string; - /** - * Client name. - */ - clientName: string; - /** - * Client version. - */ - clientVersion: string; - /** - * Client engine name. - */ - clientEngine: string; - /** - * Client engine name. - */ - clientEngineVersion: string; - /** - * Device name. - */ - deviceName: string; - /** - * Device brand name. - */ - deviceBrand: string; - /** - * Device model name. - */ - deviceModel: string; - /** - * Country two-character ISO 3166-1 alpha code. - */ - countryCode: string; - /** - * Country name. - */ - countryName: string; - }; - /** * User */ @@ -3464,6 +3343,10 @@ export namespace Models { * Whether the user email is in its canonical form. */ emailIsCanonical?: boolean; + /** + * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. + */ + passwordPwned?: boolean; /** * Phone verification status. */ @@ -3780,6 +3663,10 @@ export namespace Models { * Identity Provider Refresh Token. */ providerRefreshToken: string; + /** + * Identity Provider ID token (JWT) from the most recent native sign-in. Empty for identities created through the browser OAuth2 flow. + */ + providerIdToken: string; }; /** @@ -5309,7 +5196,7 @@ export namespace Models { */ errors: string; /** - * Resource(function/site) execution duration in seconds. + * Total time the resource(function/site) took to respond, in seconds. */ duration: number; /** @@ -5346,10 +5233,6 @@ export namespace Models { * Project region */ region: string; - /** - * Deprecated since 1.9.5: List of dev keys. - */ - devKeys: DevKey[]; /** * Status for custom SMTP */ @@ -5438,6 +5321,14 @@ export namespace Models { * Billing limits reached */ billingLimits?: BillingLimits; + /** + * First time the project received a non-console API request. Empty until the project is used. + */ + firstAccessedAt?: string; + /** + * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. + */ + mcpAccessedAt?: string; /** * OAuth2 server status */ @@ -5692,44 +5583,6 @@ export namespace Models { sdks: string[]; }; - /** - * DevKey - */ - export type DevKey = { - /** - * Key ID. - */ - $id: string; - /** - * Key creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Key update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Key name. - */ - name: string; - /** - * Key expiration date in ISO 8601 format. - */ - expire: string; - /** - * Secret key. - */ - secret: string; - /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - */ - accessedAt: string; - /** - * List of SDK user agents that used this key. - */ - sdks: string[]; - }; - /** * Mock Number */ @@ -5974,6 +5827,14 @@ export namespace Models { * Google OAuth2 prompt values. */ prompt: OAuth2GooglePrompt[]; + /** + * Native Google sign-in is active and can be used to create sessions from an ID token. Independent of enabled, which only controls the browser-based flow. + */ + nativeEnabled: boolean; + /** + * Additional OAuth2 client IDs accepted as ID token audiences for native sign-in, next to the client ID. + */ + nativeClientIds: string[]; }; /** @@ -6742,6 +6603,14 @@ export namespace Models { * Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. */ p8File: string; + /** + * Native Sign in with Apple is active and can be used to create sessions from an ID token. Independent of enabled, which only controls the browser-based flow. + */ + nativeEnabled: boolean; + /** + * App bundle IDs accepted as ID token audiences for native Sign in with Apple, next to the Services ID. + */ + nativeClientIds: string[]; }; /** @@ -6969,6 +6838,28 @@ export namespace Models { enabled: boolean; }; + /** + * Policy Password Pwned + */ + export type PolicyPasswordPwned = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether password pwned policy is enabled. + */ + enabled: boolean; + /** + * Whether passwords are checked when a session is created. + */ + sessions: boolean; + /** + * Whether users signing in with a breached password are blocked until they reset it. Only applies when sessions are checked. + */ + users: boolean; + }; + /** * Policy Session Alert */ @@ -7099,6 +6990,62 @@ export namespace Models { custom: boolean; }; + /** + * Policy Deny Aliased Email + */ + export type PolicyDenyAliasedEmail = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether the deny aliased email policy is enabled. + */ + enabled: boolean; + }; + + /** + * Policy Deny Disposable Email + */ + export type PolicyDenyDisposableEmail = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether the deny disposable email policy is enabled. + */ + enabled: boolean; + }; + + /** + * Policy Deny Free Email + */ + export type PolicyDenyFreeEmail = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether the deny free email policy is enabled. + */ + enabled: boolean; + }; + + /** + * Policy Deny Corporate Email + */ + export type PolicyDenyCorporateEmail = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether the deny non-corporate email policy is enabled. + */ + enabled: boolean; + }; + /** * Platform Web */ @@ -7419,28 +7366,6 @@ export namespace Models { date: string; }; - /** - * Metric Breakdown - */ - export type MetricBreakdown = { - /** - * Resource ID. - */ - resourceId?: string; - /** - * Resource name. - */ - name: string; - /** - * The value of this metric at the timestamp. - */ - value: number; - /** - * The estimated value of this metric at the end of the period. - */ - estimate?: number; - }; - /** * UsageUsers */ @@ -7486,299 +7411,21 @@ export namespace Models { }; /** - * Project + * usageDataPoint */ - export type UsageProject = { + export type UsageDataPoint = { /** - * Total aggregated number of function executions. + * Bucket start timestamp in ISO 8601. Omitted for flat dimension aggregates. */ - executionsTotal: number; + time?: string; /** - * Total aggregated number of documents in legacy/tablesdb. + * Aggregated value for the point. */ - documentsTotal: number; + value: number; /** - * Total aggregated number of documents in documentsdb. + * Value when broken down by `path`. */ - documentsdbDocumentsTotal: number; - /** - * Total aggregated number of rows. - */ - rowsTotal: number; - /** - * Total aggregated number of databases. - */ - databasesTotal: number; - /** - * Total aggregated number of documentsdb. - */ - documentsdbTotal: number; - /** - * Total aggregated sum of databases storage size (in bytes). - */ - databasesStorageTotal: number; - /** - * Total aggregated sum of documentsdb databases storage size (in bytes). - */ - documentsdbDatabasesStorageTotal: number; - /** - * Total aggregated number of users. - */ - usersTotal: number; - /** - * Total aggregated sum of files storage size (in bytes). - */ - filesStorageTotal: number; - /** - * Total aggregated sum of functions storage size (in bytes). - */ - functionsStorageTotal: number; - /** - * Total aggregated sum of builds storage size (in bytes). - */ - buildsStorageTotal: number; - /** - * Total aggregated sum of deployments storage size (in bytes). - */ - deploymentsStorageTotal: number; - /** - * Total aggregated number of buckets. - */ - bucketsTotal: number; - /** - * Total aggregated number of function executions mbSeconds. - */ - executionsMbSecondsTotal: number; - /** - * Total aggregated number of function builds mbSeconds. - */ - buildsMbSecondsTotal: number; - /** - * Aggregated stats for total databases reads. - */ - databasesReadsTotal: number; - /** - * Aggregated stats for total databases writes. - */ - databasesWritesTotal: number; - /** - * Total number of documentsdb databases reads. - */ - documentsdbDatabasesReadsTotal: number; - /** - * Total number of documentsdb databases writes. - */ - documentsdbDatabasesWritesTotal: number; - /** - * Aggregated number of requests per period. - */ - requests: Metric[]; - /** - * Aggregated number of consumed bandwidth per period. - */ - network: Metric[]; - /** - * Aggregated number of users per period. - */ - users: Metric[]; - /** - * Aggregated number of executions per period. - */ - executions: Metric[]; - /** - * Aggregated stats for total auth phone. - */ - authPhoneTotal: number; - /** - * Aggregated stats for total auth phone estimation. - */ - authPhoneEstimate: number; - /** - * Aggregated breakdown in totals of phone auth by country. - */ - authPhoneCountryBreakdown: MetricBreakdown[]; - /** - * Aggregated stats for database reads. - */ - databasesReads: Metric[]; - /** - * Aggregated stats for database writes. - */ - databasesWrites: Metric[]; - /** - * An array of aggregated number of documentsdb database reads. - */ - documentsdbDatabasesReads: Metric[]; - /** - * An array of aggregated number of documentsdb database writes. - */ - documentsdbDatabasesWrites: Metric[]; - /** - * An array of aggregated sum of documentsdb databases storage size (in bytes) per period. - */ - documentsdbDatabasesStorage: Metric[]; - /** - * An array of aggregated number of image transformations. - */ - imageTransformations: Metric[]; - /** - * Total aggregated number of image transformations. - */ - imageTransformationsTotal: number; - /** - * Total aggregated number of VectorsDB databases. - */ - vectorsdbDatabasesTotal: number; - /** - * Total aggregated number of VectorsDB collections. - */ - vectorsdbCollectionsTotal: number; - /** - * Total aggregated number of VectorsDB documents. - */ - vectorsdbDocumentsTotal: number; - /** - * Total aggregated VectorsDB storage (bytes). - */ - vectorsdbDatabasesStorageTotal: number; - /** - * Total aggregated number of VectorsDB reads. - */ - vectorsdbDatabasesReadsTotal: number; - /** - * Total aggregated number of VectorsDB writes. - */ - vectorsdbDatabasesWritesTotal: number; - /** - * Aggregated VectorsDB databases per period. - */ - vectorsdbDatabases: Metric[]; - /** - * Aggregated VectorsDB collections per period. - */ - vectorsdbCollections: Metric[]; - /** - * Aggregated VectorsDB documents per period. - */ - vectorsdbDocuments: Metric[]; - /** - * Aggregated VectorsDB storage per period. - */ - vectorsdbDatabasesStorage: Metric[]; - /** - * Aggregated VectorsDB reads per period. - */ - vectorsdbDatabasesReads: Metric[]; - /** - * Aggregated VectorsDB writes per period. - */ - vectorsdbDatabasesWrites: Metric[]; - /** - * Aggregated number of text embedding calls per period. - */ - embeddingsText: Metric[]; - /** - * Aggregated number of tokens processed by text embeddings per period. - */ - embeddingsTextTokens: Metric[]; - /** - * Aggregated duration spent generating text embeddings per period. - */ - embeddingsTextDuration: Metric[]; - /** - * Aggregated number of errors while generating text embeddings per period. - */ - embeddingsTextErrors: Metric[]; - /** - * Total aggregated number of text embedding calls. - */ - embeddingsTextTotal: number; - /** - * Total aggregated number of tokens processed by text. - */ - embeddingsTextTokensTotal: number; - /** - * Total aggregated duration spent generating text embeddings. - */ - embeddingsTextDurationTotal: number; - /** - * Total aggregated number of errors while generating text embeddings. - */ - embeddingsTextErrorsTotal: number; - /** - * Aggregated number of function executions per period. - */ - functionsExecutions: Metric[]; - /** - * Total aggregated number of function executions. - */ - functionsExecutionsTotal: number; - /** - * Aggregated number of site executions per period. - */ - sitesExecutions: Metric[]; - /** - * Total aggregated number of site executions. - */ - sitesExecutionsTotal: number; - /** - * Aggregated stats for total network bandwidth. - */ - networkTotal: number; - /** - * Aggregated stats for total backups storage. - */ - backupsStorageTotal: number; - /** - * An array of aggregated number of screenshots generated. - */ - screenshotsGenerated: Metric[]; - /** - * Total aggregated number of screenshots generated. - */ - screenshotsGeneratedTotal: number; - /** - * Current aggregated number of open Realtime connections. - */ - realtimeConnectionsTotal: number; - /** - * Total number of Realtime messages sent to clients. - */ - realtimeMessagesTotal: number; - /** - * Total consumed Realtime bandwidth (in bytes). - */ - realtimeBandwidthTotal: number; - /** - * Aggregated number of open Realtime connections per period. - */ - realtimeConnections: Metric[]; - /** - * Aggregated number of Realtime messages sent to clients per period. - */ - realtimeMessages: Metric[]; - /** - * Aggregated consumed Realtime bandwidth (in bytes) per period. - */ - realtimeBandwidth: Metric[]; - }; - - /** - * usageDataPoint - */ - export type UsageDataPoint = { - /** - * Bucket start timestamp in ISO 8601. Omitted for flat dimension aggregates. - */ - time?: string; - /** - * Aggregated value for the point. - */ - value: number; - /** - * Value when broken down by `path`. - */ - path?: string; + path?: string; /** * Value when broken down by `method`. */ @@ -7807,6 +7454,22 @@ export namespace Models { * Value when broken down by `ip`. */ ip?: string; + /** + * Value when broken down by `protocol`. + */ + protocol?: string; + /** + * Value when broken down by `accept`. + */ + accept?: string; + /** + * Value when broken down by `acceptLanguage`. + */ + acceptLanguage?: string; + /** + * Value when broken down by `queryKeys`. + */ + queryKeys?: string; /** * Value when broken down by `osName`. */ @@ -8589,6 +8252,14 @@ export namespace Models { * Subscribe permissions. */ subscribe: string[]; + /** + * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. + */ + qos?: number; + /** + * Message retention in seconds for offline delivery. + */ + expiry?: number; }; /** @@ -10055,6 +9726,10 @@ export namespace Models { * Does plan require billing address */ requiresBillingAddress: boolean; + /** + * ISO country codes eligible for this regional plan. Empty means no restriction. + */ + eligibleCountries?: string[]; /** * Is the billing plan available */ @@ -10343,48 +10018,10 @@ export namespace Models { * Block mode. full blocks reads and writes; readOnly blocks writes only. */ mode: string; - /** - * Reason for the block. Can be null if no reason was provided. - */ - reason?: string; /** * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ expiredAt?: string; - /** - * Name of the project this block applies to. - */ - projectName: string; - /** - * Region of the project this block applies to. - */ - region: string; - /** - * Name of the organization that owns the project. - */ - organizationName: string; - /** - * ID of the organization that owns the project. - */ - organizationId: string; - /** - * Billing plan of the organization that owns the project. - */ - billingPlan: string; - }; - - /** - * BlockDelete - */ - export type BlockDelete = { - /** - * Number of blocks deleted - */ - deleted: number; - /** - * List of deleted blocks - */ - blocks: Block[]; }; /** @@ -11761,6 +11398,70 @@ export namespace Models { to: string; }; + /** + * ManagerBlock + */ + export type ManagerBlock = { + /** + * Block creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Resource type that is blocked + */ + resourceType: string; + /** + * Resource identifier that is blocked + */ + resourceId: string; + /** + * Block mode. full blocks reads and writes; readOnly blocks writes only. + */ + mode: string; + /** + * Block expiration date in ISO 8601 format. Can be null if the block does not expire. + */ + expiredAt?: string; + /** + * Reason for the block. Can be null if no reason was provided. + */ + reason?: string; + /** + * Name of the project this block applies to. + */ + projectName: string; + /** + * Region of the project this block applies to. + */ + region: string; + /** + * Name of the organization that owns the project. + */ + organizationName: string; + /** + * ID of the organization that owns the project. + */ + organizationId: string; + /** + * Billing plan of the organization that owns the project. + */ + billingPlan: string; + }; + + /** + * ManagerBlockDelete + */ + export type ManagerBlockDelete = { + /** + * Number of blocks deleted + */ + deleted: number; + /** + * List of deleted blocks + */ + blocks: ManagerBlock[]; + }; + /** * Organization */ @@ -12225,62 +11926,6 @@ export namespace Models { enabled: boolean; }; - /** - * Policy Deny Aliased Email - */ - export type PolicyDenyAliasedEmail = { - /** - * Policy ID. - */ - $id: string; - /** - * Whether the deny aliased email policy is enabled. - */ - enabled: boolean; - }; - - /** - * Policy Deny Disposable Email - */ - export type PolicyDenyDisposableEmail = { - /** - * Policy ID. - */ - $id: string; - /** - * Whether the deny disposable email policy is enabled. - */ - enabled: boolean; - }; - - /** - * Policy Deny Free Email - */ - export type PolicyDenyFreeEmail = { - /** - * Policy ID. - */ - $id: string; - /** - * Whether the deny free email policy is enabled. - */ - enabled: boolean; - }; - - /** - * Policy Deny Corporate Email - */ - export type PolicyDenyCorporateEmail = { - /** - * Policy ID. - */ - $id: string; - /** - * Whether the deny non-corporate email policy is enabled. - */ - enabled: boolean; - }; - /** * PoolerConfig */ @@ -14162,9 +13807,9 @@ export namespace Models { }; /** - * Blocks list + * Manager blocks list */ - export type BlockList = { + export type ManagerBlockList = { /** * Total number of blocks that matched your query. */ @@ -14172,7 +13817,7 @@ export namespace Models { /** * List of blocks. */ - blocks: Block[]; + blocks: ManagerBlock[]; }; /** diff --git a/src/services/account.ts b/src/services/account.ts index 7dfbeb0d..8c878fa3 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -5,6 +5,7 @@ import type { Models } from '../models'; import { AccountKeyScopes } from '../enums/account-key-scopes'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; +import { IdTokenProvider } from '../enums/id-token-provider'; import { OAuthProvider } from '../enums/o-auth-provider'; export class Account { client: Client; @@ -1775,72 +1776,6 @@ export class Account { return this.client.call('delete', uri, apiHeaders, payload); } - /** - * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. - * - * @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). Only supported methods are limit and offset - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listLogs(params?: { - queries?: string[]; - total?: boolean; - }): Promise; - /** - * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. - * - * @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). Only supported methods are limit and offset - * @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. - */ - listLogs(queries?: string[], total?: boolean): Promise; - listLogs( - 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/logs'; - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - /** * Enable or disable MFA on an account. * @@ -3821,6 +3756,169 @@ export class Account { return this.client.call('post', uri, apiHeaders, payload); } + /** + * Allow the user to login to their account using an OpenID Connect ID token obtained natively from the OAuth2 provider, for example via Google Credential Manager on Android or Sign in with Apple on iOS. No browser or redirect is involved: the ID token is verified against the provider's published signing keys and a session is created in a single request. + * + * Native sign-in is switched on per provider with its nativeEnabled setting. It is independent of the browser-based flow's enabled setting, which has no effect on this endpoint. The token's audience must match the provider's configured client ID or one of its native client IDs; tokens issued for any other client ID are rejected. For Sign in with Apple, register your app's bundle ID as a native client ID. For Google, the web client ID used by Credential Manager is usually the configured client ID; add your Android and iOS client IDs as native client IDs if your app requests tokens for them. + * + * Pass the raw nonce used when requesting the ID token so it can be validated against the token's nonce claim. When signing in with Apple, the nonce is required: hash it with SHA-256 before passing it to the Apple SDK, and send the raw value here - Apple tokens requested without a nonce are rejected. For Google the nonce is optional: it is validated whenever the token carries one, and ignored when the provider issued the token without one. Apple only returns the user's name on the first authorization, and never inside the ID token - capture it on the client and pass it via the name parameter. + * + * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the verified email received from the provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. + * + * This flow does not return provider refresh tokens. You may pass an access token the provider handed your client, along with its lifetime, to store it on the session - but Appwrite cannot renew it once it expires. If your app needs long-lived access to provider APIs, use the browser-based OAuth2 flow instead. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * + * @param {IdTokenProvider} params.provider - OAuth2 provider that issued the ID token. Currently, supported providers are: apple, google. + * @param {string} params.idToken - OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple. + * @param {string} params.nonce - Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce. + * @param {string} params.accessToken - Provider access token to store alongside the session for calling provider APIs. Never used for authentication. + * @param {number} params.accessTokenExpiry - Seconds until the provider access token expires, as reported by the provider. Stored so clients can tell when the stored token goes stale. + * @param {string} params.name - User name. Only used when creating a new user and the ID token has no name claim, such as on the first Sign in with Apple authorization. + * @throws {AppwriteException} + * @returns {Promise} + */ + createIdTokenSession(params: { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + }): Promise; + /** + * Allow the user to login to their account using an OpenID Connect ID token obtained natively from the OAuth2 provider, for example via Google Credential Manager on Android or Sign in with Apple on iOS. No browser or redirect is involved: the ID token is verified against the provider's published signing keys and a session is created in a single request. + * + * Native sign-in is switched on per provider with its nativeEnabled setting. It is independent of the browser-based flow's enabled setting, which has no effect on this endpoint. The token's audience must match the provider's configured client ID or one of its native client IDs; tokens issued for any other client ID are rejected. For Sign in with Apple, register your app's bundle ID as a native client ID. For Google, the web client ID used by Credential Manager is usually the configured client ID; add your Android and iOS client IDs as native client IDs if your app requests tokens for them. + * + * Pass the raw nonce used when requesting the ID token so it can be validated against the token's nonce claim. When signing in with Apple, the nonce is required: hash it with SHA-256 before passing it to the Apple SDK, and send the raw value here - Apple tokens requested without a nonce are rejected. For Google the nonce is optional: it is validated whenever the token carries one, and ignored when the provider issued the token without one. Apple only returns the user's name on the first authorization, and never inside the ID token - capture it on the client and pass it via the name parameter. + * + * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the verified email received from the provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. + * + * This flow does not return provider refresh tokens. You may pass an access token the provider handed your client, along with its lifetime, to store it on the session - but Appwrite cannot renew it once it expires. If your app needs long-lived access to provider APIs, use the browser-based OAuth2 flow instead. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * + * @param {IdTokenProvider} provider - OAuth2 provider that issued the ID token. Currently, supported providers are: apple, google. + * @param {string} idToken - OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple. + * @param {string} nonce - Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce. + * @param {string} accessToken - Provider access token to store alongside the session for calling provider APIs. Never used for authentication. + * @param {number} accessTokenExpiry - Seconds until the provider access token expires, as reported by the provider. Stored so clients can tell when the stored token goes stale. + * @param {string} name - User name. Only used when creating a new user and the ID token has no name claim, such as on the first Sign in with Apple authorization. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIdTokenSession( + provider: IdTokenProvider, + idToken: string, + nonce?: string, + accessToken?: string, + accessTokenExpiry?: number, + name?: string, + ): Promise; + createIdTokenSession( + paramsOrFirst: + | { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + } + | IdTokenProvider, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('provider' in paramsOrFirst || + 'idToken' in paramsOrFirst || + 'nonce' in paramsOrFirst || + 'accessToken' in paramsOrFirst || + 'accessTokenExpiry' in paramsOrFirst || + 'name' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + }; + } else { + params = { + provider: paramsOrFirst as IdTokenProvider, + idToken: rest[0] as string, + nonce: rest[1] as string, + accessToken: rest[2] as string, + accessTokenExpiry: rest[3] as number, + name: rest[4] as string, + }; + } + + const provider = params.provider; + const idToken = params.idToken; + const nonce = params.nonce; + const accessToken = params.accessToken; + const accessTokenExpiry = params.accessTokenExpiry; + const name = params.name; + + if (typeof provider === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); + } + if (typeof idToken === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "idToken"', + ); + } + const apiPath = '/account/sessions/id-token'; + const payload: Payload = {}; + if (typeof provider !== 'undefined') { + payload['provider'] = provider; + } + if (typeof idToken !== 'undefined') { + payload['idToken'] = idToken; + } + if (typeof nonce !== 'undefined') { + payload['nonce'] = nonce; + } + if (typeof accessToken !== 'undefined') { + payload['accessToken'] = accessToken; + } + if (typeof accessTokenExpiry !== 'undefined') { + payload['accessTokenExpiry'] = accessTokenExpiry; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } + /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -4793,6 +4891,8 @@ export class Account { * * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. * + * If there is already an active session, the OAuth2 identity is attached to the logged-in account and that session stays active until the token is exchanged for a new one. + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. @@ -4813,6 +4913,8 @@ export class Account { * * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. * + * If there is already an active session, the OAuth2 identity is attached to the logged-in account and that session stays active until the token is exchanged for a new one. + * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. @@ -5255,6 +5357,144 @@ export class Account { return this.client.call('put', uri, apiHeaders, payload); } + /** + * Use this endpoint to send a 6-digit verification code to the currently logged in user's email address. Unlike [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a verification page. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {boolean} params.phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + */ + createEmailVerificationOTP(params?: { + phrase?: boolean; + }): Promise; + /** + * Use this endpoint to send a 6-digit verification code to the currently logged in user's email address. Unlike [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a verification page. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {boolean} phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailVerificationOTP(phrase?: boolean): Promise; + createEmailVerificationOTP( + paramsOrFirst?: { phrase?: boolean } | boolean, + ): Promise { + let params: { phrase?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { phrase?: boolean }; + } else { + params = { + phrase: paramsOrFirst as boolean, + }; + } + + const phrase = params.phrase; + + const apiPath = '/account/verifications/email/otp'; + const payload: Payload = {}; + if (typeof phrase !== 'undefined') { + payload['phrase'] = phrase; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } + + /** + * Use this endpoint to complete the user email verification process using the 6-digit code that was emailed by [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). Pass the **userId** of the user being verified along with the **secret** code from the email. If confirmed, this route will return a 200 status code and the code is consumed. + * + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification OTP code. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateEmailVerificationOTP(params: { + userId: string; + secret: string; + }): Promise; + /** + * Use this endpoint to complete the user email verification process using the 6-digit code that was emailed by [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). Pass the **userId** of the user being verified along with the **secret** code from the email. If confirmed, this route will return a 200 status code and the code is consumed. + * + * + * @param {string} userId - User ID. + * @param {string} secret - Valid verification OTP code. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailVerificationOTP( + userId: string, + secret: string, + ): Promise; + updateEmailVerificationOTP( + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] + ): Promise { + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string, + }; + } + + const userId = params.userId; + const secret = params.secret; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + const apiPath = '/account/verifications/email/otp'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, payload); + } + /** * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * diff --git a/src/services/console.ts b/src/services/console.ts index d2f7f943..fb2d29db 100644 --- a/src/services/console.ts +++ b/src/services/console.ts @@ -1063,7 +1063,7 @@ export class Console { /** * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. * - * @param {ProjectEmailTemplateId} params.templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateId} params.templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification * @param {ProjectEmailTemplateLocale} params.locale - Template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} @@ -1075,7 +1075,7 @@ export class Console { /** * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. * - * @param {ProjectEmailTemplateId} templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateId} templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification * @param {ProjectEmailTemplateLocale} locale - Template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} diff --git a/src/services/manager.ts b/src/services/manager.ts index b8efaa18..bb85bed7 100644 --- a/src/services/manager.ts +++ b/src/services/manager.ts @@ -23,7 +23,7 @@ export class Manager { * @param {string} params.reason - Optional reason why the resource is blocked * @param {string} params.expiredAt - Optional expiration date for the block * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ createBlock(params: { projectId: string; @@ -32,7 +32,7 @@ export class Manager { mode?: BlockMode; reason?: string; expiredAt?: string; - }): Promise; + }): Promise; /** * Creates a new resource block. * @@ -43,7 +43,7 @@ export class Manager { * @param {string} reason - Optional reason why the resource is blocked * @param {string} expiredAt - Optional expiration date for the block * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ createBlock( @@ -53,7 +53,7 @@ export class Manager { mode?: BlockMode, reason?: string, expiredAt?: string, - ): Promise; + ): Promise; createBlock( paramsOrFirst: | { @@ -66,7 +66,7 @@ export class Manager { } | string, ...rest: [BlockResourceType?, string?, BlockMode?, string?, string?] - ): Promise { + ): Promise { let params: { projectId: string; resourceType: BlockResourceType; @@ -154,13 +154,13 @@ export class Manager { * @param {BlockResourceType} params.resourceType - Resource type to unblock * @param {string} params.resourceId - Optional resource ID (if omitted, all blocks of this type will be removed) * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ deleteBlock(params: { projectId: string; resourceType: BlockResourceType; resourceId?: string; - }): Promise; + }): Promise; /** * Deletes resource blocks for a project. * @@ -168,14 +168,14 @@ export class Manager { * @param {BlockResourceType} resourceType - Resource type to unblock * @param {string} resourceId - Optional resource ID (if omitted, all blocks of this type will be removed) * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ deleteBlock( projectId: string, resourceType: BlockResourceType, resourceId?: string, - ): Promise; + ): Promise; deleteBlock( paramsOrFirst: | { @@ -185,7 +185,7 @@ export class Manager { } | string, ...rest: [BlockResourceType?, string?] - ): Promise { + ): Promise { let params: { projectId: string; resourceType: BlockResourceType; @@ -250,21 +250,21 @@ export class Manager { * * @param {string} params.projectId - Project ID * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - listBlocks(params: { projectId: string }): Promise; + listBlocks(params: { projectId: string }): Promise; /** * Lists all resource blocks for a project. * * @param {string} projectId - Project ID * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBlocks(projectId: string): Promise; + listBlocks(projectId: string): Promise; listBlocks( paramsOrFirst: { projectId: string } | string, - ): Promise { + ): Promise { let params: { projectId: string }; if ( @@ -307,7 +307,7 @@ export class Manager { * @param {CacheTarget} params.cache - Cache target. * @param {boolean} params.all - Clear the entire selected cache target. * @param {CacheDatabase} params.database - Database cache scope. - * @param {string} params.projectId - Project ID for project or logs database cache. + * @param {string} params.projectId - Project ID for project database cache. * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @throws {AppwriteException} @@ -329,7 +329,7 @@ export class Manager { * @param {CacheTarget} cache - Cache target. * @param {boolean} all - Clear the entire selected cache target. * @param {CacheDatabase} database - Database cache scope. - * @param {string} projectId - Project ID for project or logs database cache. + * @param {string} projectId - Project ID for project database cache. * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @throws {AppwriteException} diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 7787c49c..73aefb81 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -2659,6 +2659,245 @@ export class Messaging { return this.client.call('patch', uri, apiHeaders, payload); } + /** + * Create a new Appwrite push provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + */ + createAppwriteProvider(params: { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }): Promise; + /** + * Create a new Appwrite push provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createAppwriteProvider( + providerId: string, + name: string, + enabled?: boolean, + qos?: number, + expiry?: number, + ): Promise; + createAppwriteProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, boolean?, number?, number?] + ): Promise { + let params: { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + qos: rest[2] as number, + expiry: rest[3] as number, + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const qos = params.qos; + const expiry = params.expiry; + + if (typeof providerId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/messaging/providers/appwrite'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof qos !== 'undefined') { + payload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + payload['expiry'] = expiry; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } + + /** + * Update an Appwrite push provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAppwriteProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }): Promise; + /** + * Update an Appwrite push provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAppwriteProvider( + providerId: string, + name?: string, + enabled?: boolean, + qos?: number, + expiry?: number, + ): Promise; + updateAppwriteProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, boolean?, number?, number?] + ): Promise { + let params: { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + qos: rest[2] as number, + expiry: rest[3] as number, + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const qos = params.qos; + const expiry = params.expiry; + + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); + } + const apiPath = '/messaging/providers/appwrite/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof qos !== 'undefined') { + payload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + payload['expiry'] = expiry; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + /** * Create a new Firebase Cloud Messaging provider. * @@ -6271,7 +6510,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. * @param {boolean} params.enabled - Set as enabled. @@ -6291,7 +6530,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. * @param {boolean} enabled - Set as enabled. @@ -6407,7 +6646,7 @@ export class Messaging { * @param {boolean} params.enabled - Set as enabled. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. - * @param {string} params.from - Sender number. + * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @throws {AppwriteException} * @returns {Promise} */ @@ -6427,7 +6666,7 @@ export class Messaging { * @param {boolean} enabled - Set as enabled. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. - * @param {string} from - Sender number. + * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -6993,6 +7232,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} */ @@ -7000,6 +7241,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; + qos?: number; + expiry?: number; }): Promise; /** * Create a new topic. @@ -7007,6 +7250,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -7015,13 +7260,28 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], + qos?: number, + expiry?: number, ): Promise; createTopic( paramsOrFirst: - { topicId: string; name: string; subscribe?: string[] } | string, - ...rest: [string?, string[]?] + | { + topicId: string; + name: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, string[]?, number?, number?] ): Promise { - let params: { topicId: string; name: string; subscribe?: string[] }; + let params: { + topicId: string; + name: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + }; if ( paramsOrFirst && @@ -7032,18 +7292,24 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; + qos?: number; + expiry?: number; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], + qos: rest[2] as number, + expiry: rest[3] as number, }; } const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; + const qos = params.qos; + const expiry = params.expiry; if (typeof topicId === 'undefined') { throw new AppwriteException( @@ -7064,6 +7330,12 @@ export class Messaging { if (typeof subscribe !== 'undefined') { payload['subscribe'] = subscribe; } + if (typeof qos !== 'undefined') { + payload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + payload['expiry'] = expiry; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -7140,6 +7412,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} */ @@ -7147,6 +7421,8 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; + qos?: number; + expiry?: number; }): Promise; /** * Update a topic by its unique ID. @@ -7155,6 +7431,8 @@ export class Messaging { * @param {string} topicId - Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -7163,13 +7441,28 @@ export class Messaging { topicId: string, name?: string, subscribe?: string[], + qos?: number, + expiry?: number, ): Promise; updateTopic( paramsOrFirst: - { topicId: string; name?: string; subscribe?: string[] } | string, - ...rest: [string?, string[]?] + | { + topicId: string; + name?: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, string[]?, number?, number?] ): Promise { - let params: { topicId: string; name?: string; subscribe?: string[] }; + let params: { + topicId: string; + name?: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + }; if ( paramsOrFirst && @@ -7180,18 +7473,24 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; + qos?: number; + expiry?: number; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], + qos: rest[2] as number, + expiry: rest[3] as number, }; } const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; + const qos = params.qos; + const expiry = params.expiry; if (typeof topicId === 'undefined' || topicId === '') { throw new AppwriteException( @@ -7209,6 +7508,12 @@ export class Messaging { if (typeof subscribe !== 'undefined') { payload['subscribe'] = subscribe; } + if (typeof qos !== 'undefined') { + payload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + payload['expiry'] = expiry; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/organization.ts b/src/services/organization.ts index 8e96a636..88f6b127 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -3,6 +3,7 @@ import type { Models } from '../models'; import { OrganizationKeyScopes } from '../enums/organization-key-scopes'; import { Region } from '../enums/region'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; export class Organization { client: Client; @@ -1583,4 +1584,585 @@ export class Organization { return this.client.call('delete', uri, apiHeaders, payload); } + + /** + * Get a list of all API keys of a project in your organization. + * + * @param {string} params.projectId - Project unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listProjectKeys(params: { + projectId: string; + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get a list of all API keys of a project in your organization. + * + * @param {string} projectId - Project unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listProjectKeys( + projectId: string, + queries?: string[], + total?: boolean, + ): Promise; + listProjectKeys( + paramsOrFirst: + { projectId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise { + let params: { projectId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + queries?: string[]; + total?: boolean; + }; + } else { + params = { + projectId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean, + }; + } + + const projectId = params.projectId; + const queries = params.queries; + const total = params.total; + + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + const apiPath = '/organization/projects/{projectId}/keys'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); + } + + /** + * Create a new API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create an ephemeral API key if you need a short-lived key instead. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key 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 - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + createProjectKey(params: { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }): Promise; + /** + * Create a new API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create an ephemeral API key if you need a short-lived key instead. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key 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 - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createProjectKey( + projectId: string, + keyId: string, + name: string, + scopes: ProjectKeyScopes[], + expire?: string, + ): Promise; + createProjectKey( + paramsOrFirst: + | { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ): Promise { + let params: { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + name: rest[1] as string, + scopes: rest[2] as ProjectKeyScopes[], + expire: rest[3] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + const apiPath = '/organization/projects/{projectId}/keys'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const payload: Payload = {}; + if (typeof keyId !== 'undefined') { + payload['keyId'] = keyId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } + + /** + * Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {string} params.projectId - Project unique ID. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {number} params.duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + createEphemeralProjectKey(params: { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + }): Promise; + /** + * Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {string} projectId - Project unique ID. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {number} duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEphemeralProjectKey( + projectId: string, + scopes: ProjectKeyScopes[], + duration: number, + ): Promise; + createEphemeralProjectKey( + paramsOrFirst: + | { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + } + | string, + ...rest: [ProjectKeyScopes[]?, number?] + ): Promise { + let params: { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + }; + } else { + params = { + projectId: paramsOrFirst as string, + scopes: rest[0] as ProjectKeyScopes[], + duration: rest[1] as number, + }; + } + + const projectId = params.projectId; + const scopes = params.scopes; + const duration = params.duration; + + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + if (typeof duration === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "duration"', + ); + } + const apiPath = + '/organization/projects/{projectId}/keys/ephemeral'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const payload: Payload = {}; + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } + + /** + * Get a project key by its unique ID. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getProjectKey(params: { + projectId: string; + keyId: string; + }): Promise; + /** + * Get a project key by its unique ID. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getProjectKey(projectId: string, keyId: string): Promise; + getProjectKey( + paramsOrFirst: { projectId: string; keyId: string } | string, + ...rest: [string?] + ): Promise { + let params: { projectId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined' || keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + const apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); + } + + /** + * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key ID. + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateProjectKey(params: { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }): Promise; + /** + * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key ID. + * @param {string} name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateProjectKey( + projectId: string, + keyId: string, + name: string, + scopes: ProjectKeyScopes[], + expire?: string, + ): Promise; + updateProjectKey( + paramsOrFirst: + | { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ): Promise { + let params: { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + name: rest[1] as string, + scopes: rest[2] as ProjectKeyScopes[], + expire: rest[3] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined' || keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + const apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, payload); + } + + /** + * Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteProjectKey(params: { projectId: string; keyId: string }): Promise<{}>; + /** + * Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteProjectKey(projectId: string, keyId: string): Promise<{}>; + deleteProjectKey( + paramsOrFirst: { projectId: string; keyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { projectId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined' || keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + const apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); + const payload: 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, payload); + } } diff --git a/src/services/organizations.ts b/src/services/organizations.ts index 16231cd4..d79e4d9b 100644 --- a/src/services/organizations.ts +++ b/src/services/organizations.ts @@ -1836,6 +1836,64 @@ export class Organizations { return this.client.call('get', uri, apiHeaders, payload); } + /** + * Get an estimate of the charge for the organization current billing cycle. + * + * @param {string} params.organizationId - Organization ID + * @throws {AppwriteException} + * @returns {Promise} + */ + getEstimation(params: { + organizationId: string; + }): Promise; + /** + * Get an estimate of the charge for the organization current billing cycle. + * + * @param {string} organizationId - Organization ID + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEstimation(organizationId: string): Promise; + getEstimation( + paramsOrFirst: { organizationId: string } | string, + ): Promise { + let params: { organizationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { organizationId: string }; + } else { + params = { + organizationId: paramsOrFirst as string, + }; + } + + const organizationId = params.organizationId; + + if (typeof organizationId === 'undefined' || organizationId === '') { + throw new AppwriteException( + 'Missing required parameter: "organizationId"', + ); + } + const apiPath = '/organizations/{organizationId}/estimations'.replace( + '{organizationId}', + encodeURIComponent(String(organizationId)), + ); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, payload); + } + /** * Get estimation for deleting an organization. * @@ -3255,71 +3313,6 @@ export class Organizations { return this.client.call('patch', uri, apiHeaders, payload); } - /** - * Cancel the downgrade initiated for an organization. - * - * @param {string} params.organizationId - Organization Unique ID - * @throws {AppwriteException} - * @returns {Promise>} - */ - cancelDowngrade< - Preferences extends Models.Preferences = Models.DefaultPreferences, - >(params: { - organizationId: string; - }): Promise>; - /** - * Cancel the downgrade initiated for an organization. - * - * @param {string} organizationId - Organization Unique ID - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - cancelDowngrade< - Preferences extends Models.Preferences = Models.DefaultPreferences, - >(organizationId: string): Promise>; - cancelDowngrade< - Preferences extends Models.Preferences = Models.DefaultPreferences, - >( - paramsOrFirst: { organizationId: string } | string, - ): Promise> { - let params: { organizationId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { organizationId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - }; - } - - const organizationId = params.organizationId; - - if (typeof organizationId === 'undefined' || organizationId === '') { - throw new AppwriteException( - 'Missing required parameter: "organizationId"', - ); - } - const apiPath = '/organizations/{organizationId}/plan/cancel'.replace( - '{organizationId}', - encodeURIComponent(String(organizationId)), - ); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - return this.client.call('patch', uri, apiHeaders, payload); - } - /** * Create a billing plan estimation for upgrading or downgrading an organization plan. * diff --git a/src/services/project.ts b/src/services/project.ts index 938b96e7..b41100a8 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -12,7 +12,6 @@ import { ProjectServiceId } from '../enums/project-service-id'; import { ProjectSMTPSecure } from '../enums/project-smtp-secure'; import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; -import { ProjectUsageRange } from '../enums/project-usage-range'; export class Project { client: Client; @@ -1424,7 +1423,9 @@ export class Project { * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} */ @@ -1433,7 +1434,9 @@ export class Project { keyId?: string; teamId?: string; p8File?: string; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; }): Promise; /** * Update the project OAuth2 Apple configuration. @@ -1442,7 +1445,9 @@ export class Project { * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -1452,7 +1457,9 @@ export class Project { keyId?: string, teamId?: string, p8File?: string, + nativeClientIds?: string[], enabled?: boolean, + nativeEnabled?: boolean, ): Promise; updateOAuth2Apple( paramsOrFirst?: @@ -1461,17 +1468,21 @@ export class Project { keyId?: string; teamId?: string; p8File?: string; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string[]?, boolean?, boolean?] ): Promise { let params: { serviceId?: string; keyId?: string; teamId?: string; p8File?: string; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; }; if ( @@ -1485,7 +1496,9 @@ export class Project { keyId?: string; teamId?: string; p8File?: string; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; }; } else { params = { @@ -1493,7 +1506,9 @@ export class Project { keyId: rest[0] as string, teamId: rest[1] as string, p8File: rest[2] as string, - enabled: rest[3] as boolean, + nativeClientIds: rest[3] as string[], + enabled: rest[4] as boolean, + nativeEnabled: rest[5] as boolean, }; } @@ -1501,7 +1516,9 @@ export class Project { const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; + const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const payload: Payload = {}; @@ -1517,9 +1534,15 @@ export class Project { if (typeof p8File !== 'undefined') { payload['p8File'] = p8File; } + if (typeof nativeClientIds !== 'undefined') { + payload['nativeClientIds'] = nativeClientIds; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof nativeEnabled !== 'undefined') { + payload['nativeEnabled'] = nativeEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3129,7 +3152,9 @@ export class Project { * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} */ @@ -3137,7 +3162,9 @@ export class Project { clientId?: string; clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; }): Promise; /** * Update the project OAuth2 Google configuration. @@ -3145,7 +3172,9 @@ export class Project { * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3154,7 +3183,9 @@ export class Project { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], + nativeClientIds?: string[], enabled?: boolean, + nativeEnabled?: boolean, ): Promise; updateOAuth2Google( paramsOrFirst?: @@ -3162,16 +3193,26 @@ export class Project { clientId?: string; clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; } | string, - ...rest: [string?, ProjectOAuth2GooglePrompt[]?, boolean?] + ...rest: [ + string?, + ProjectOAuth2GooglePrompt[]?, + string[]?, + boolean?, + boolean?, + ] ): Promise { let params: { clientId?: string; clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; }; if ( @@ -3184,21 +3225,27 @@ export class Project { clientId?: string; clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; + nativeClientIds?: string[]; enabled?: boolean; + nativeEnabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, prompt: rest[1] as ProjectOAuth2GooglePrompt[], - enabled: rest[2] as boolean, + nativeClientIds: rest[2] as string[], + enabled: rest[3] as boolean, + nativeEnabled: rest[4] as boolean, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; + const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const payload: Payload = {}; @@ -3211,9 +3258,15 @@ export class Project { if (typeof prompt !== 'undefined') { payload['prompt'] = prompt; } + if (typeof nativeClientIds !== 'undefined') { + payload['nativeClientIds'] = nativeClientIds; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof nativeEnabled !== 'undefined') { + payload['nativeEnabled'] = nativeEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -7802,6 +7855,88 @@ export class Project { return this.client.call('patch', uri, apiHeaders, payload); } + /** + * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, a password that appears in any known breach cannot be set or changed. Enable `sessions` to check passwords on sign-in too. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. + * + * @param {boolean} params.enabled - Toggle password pwned policy. Set to true to block passwords exposed in known data breaches, or false to allow them. Default is true. When changing this policy, existing passwords remain valid. + * @param {boolean} params.sessions - Whether passwords are checked when a session is created. When enabled, signing in records whether the password appears in a known data breach. Default is false. + * @param {boolean} params.users - Whether users signing in with a breached password are blocked until they reset it. Only applies when sessions are checked. Default is false, which allows the sign-in. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordPwnedPolicy(params?: { + enabled?: boolean; + sessions?: boolean; + users?: boolean; + }): Promise; + /** + * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, a password that appears in any known breach cannot be set or changed. Enable `sessions` to check passwords on sign-in too. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. + * + * @param {boolean} enabled - Toggle password pwned policy. Set to true to block passwords exposed in known data breaches, or false to allow them. Default is true. When changing this policy, existing passwords remain valid. + * @param {boolean} sessions - Whether passwords are checked when a session is created. When enabled, signing in records whether the password appears in a known data breach. Default is false. + * @param {boolean} users - Whether users signing in with a breached password are blocked until they reset it. Only applies when sessions are checked. Default is false, which allows the sign-in. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordPwnedPolicy( + enabled?: boolean, + sessions?: boolean, + users?: boolean, + ): Promise; + updatePasswordPwnedPolicy( + paramsOrFirst?: + | { enabled?: boolean; sessions?: boolean; users?: boolean } + | boolean, + ...rest: [boolean?, boolean?] + ): Promise { + let params: { enabled?: boolean; sessions?: boolean; users?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + sessions?: boolean; + users?: boolean; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + sessions: rest[0] as boolean, + users: rest[1] as boolean, + }; + } + + const enabled = params.enabled; + const sessions = params.sessions; + const users = params.users; + + const apiPath = '/project/policies/password-pwned'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof sessions !== 'undefined') { + payload['sessions'] = sessions; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + /** * Update the password strength requirements for users in the project. * @@ -8208,9 +8343,9 @@ export class Project { /** * 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, 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, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8219,6 +8354,7 @@ export class Project { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8234,9 +8370,9 @@ export class Project { /** * 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, 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, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8246,6 +8382,7 @@ export class Project { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8265,6 +8402,7 @@ export class Project { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8789,7 +8927,7 @@ export class Project { /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -8813,7 +8951,7 @@ export class Project { /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @param {string} subject - Subject of the email template. Can be up to 255 characters. * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -8959,7 +9097,7 @@ export class Project { /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} @@ -8971,7 +9109,7 @@ export class Project { /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} @@ -9038,100 +9176,6 @@ export class Project { return this.client.call('get', uri, apiHeaders, payload); } - /** - * Get comprehensive usage statistics for your project. View metrics including network requests, bandwidth, storage, function executions, database usage, and user activity. Specify a time range with startDate and endDate, and optionally set the data granularity with period (1h or 1d). The response includes both total counts and detailed breakdowns by resource, along with historical data over the specified period. - * - * @param {string} params.startDate - Starting date for the usage - * @param {string} params.endDate - End date for the usage - * @param {ProjectUsageRange} params.period - Period used - * @throws {AppwriteException} - * @returns {Promise} - */ - getUsage(params: { - startDate: string; - endDate: string; - period?: ProjectUsageRange; - }): Promise; - /** - * Get comprehensive usage statistics for your project. View metrics including network requests, bandwidth, storage, function executions, database usage, and user activity. Specify a time range with startDate and endDate, and optionally set the data granularity with period (1h or 1d). The response includes both total counts and detailed breakdowns by resource, along with historical data over the specified period. - * - * @param {string} startDate - Starting date for the usage - * @param {string} endDate - End date for the usage - * @param {ProjectUsageRange} period - Period used - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getUsage( - startDate: string, - endDate: string, - period?: ProjectUsageRange, - ): Promise; - getUsage( - paramsOrFirst: - | { startDate: string; endDate: string; period?: ProjectUsageRange } - | string, - ...rest: [string?, ProjectUsageRange?] - ): Promise { - let params: { - startDate: string; - endDate: string; - period?: ProjectUsageRange; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - startDate: string; - endDate: string; - period?: ProjectUsageRange; - }; - } else { - params = { - startDate: paramsOrFirst as string, - endDate: rest[0] as string, - period: rest[1] as ProjectUsageRange, - }; - } - - const startDate = params.startDate; - const endDate = params.endDate; - const period = params.period; - - if (typeof startDate === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "startDate"', - ); - } - if (typeof endDate === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "endDate"', - ); - } - const apiPath = '/project/usage'; - const payload: Payload = {}; - if (typeof startDate !== 'undefined') { - payload['startDate'] = startDate; - } - if (typeof endDate !== 'undefined') { - payload['endDate'] = endDate; - } - if (typeof period !== 'undefined') { - payload['period'] = period; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - /** * Get a list of all project environment variables. * diff --git a/src/services/projects.ts b/src/services/projects.ts index 08737e7f..f12af384 100644 --- a/src/services/projects.ts +++ b/src/services/projects.ts @@ -480,321 +480,6 @@ export class Projects { return this.client.call('patch', uri, apiHeaders, payload); } - /** - * List all the project\'s dev keys. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development.' - * - * @param {string} params.projectId - Project unique ID. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: accessedAt, expire - * @throws {AppwriteException} - * @returns {Promise} - */ - listDevKeys(params: { - projectId: string; - queries?: string[]; - }): Promise; - /** - * List all the project\'s dev keys. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development.' - * - * @param {string} projectId - Project unique ID. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: accessedAt, expire - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listDevKeys( - projectId: string, - queries?: string[], - ): Promise; - listDevKeys( - paramsOrFirst: { projectId: string; queries?: string[] } | string, - ...rest: [string[]?] - ): Promise { - let params: { projectId: string; queries?: string[] }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - projectId: string; - queries?: string[]; - }; - } else { - params = { - projectId: paramsOrFirst as string, - queries: rest[0] as string[], - }; - } - - const projectId = params.projectId; - const queries = params.queries; - - if (typeof projectId === 'undefined' || projectId === '') { - throw new AppwriteException( - 'Missing required parameter: "projectId"', - ); - } - const apiPath = '/projects/{projectId}/dev-keys'.replace( - '{projectId}', - encodeURIComponent(String(projectId)), - ); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - - /** - * Get a project\'s dev key by its unique ID. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development. - * - * @param {string} params.projectId - Project unique ID. - * @param {string} params.keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getDevKey(params: { - projectId: string; - keyId: string; - }): Promise; - /** - * Get a project\'s dev key by its unique ID. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development. - * - * @param {string} projectId - Project unique ID. - * @param {string} keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getDevKey(projectId: string, keyId: string): Promise; - getDevKey( - paramsOrFirst: { projectId: string; keyId: string } | string, - ...rest: [string?] - ): Promise { - let params: { projectId: string; keyId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - projectId: string; - keyId: string; - }; - } else { - params = { - projectId: paramsOrFirst as string, - keyId: rest[0] as string, - }; - } - - const projectId = params.projectId; - const keyId = params.keyId; - - if (typeof projectId === 'undefined' || projectId === '') { - throw new AppwriteException( - 'Missing required parameter: "projectId"', - ); - } - if (typeof keyId === 'undefined' || keyId === '') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - const apiPath = '/projects/{projectId}/dev-keys/{keyId}' - .replace('{projectId}', encodeURIComponent(String(projectId))) - .replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - - /** - * Update a project\'s dev key by its unique ID. Use this endpoint to update a project\'s dev key name or expiration time.' - * - * @param {string} params.projectId - Project unique ID. - * @param {string} params.keyId - Key unique ID. - * @param {string} params.name - Key name. Max length: 128 chars. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateDevKey(params: { - projectId: string; - keyId: string; - name: string; - expire: string; - }): Promise; - /** - * Update a project\'s dev key by its unique ID. Use this endpoint to update a project\'s dev key name or expiration time.' - * - * @param {string} projectId - Project unique ID. - * @param {string} keyId - Key unique ID. - * @param {string} name - Key name. Max length: 128 chars. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateDevKey( - projectId: string, - keyId: string, - name: string, - expire: string, - ): Promise; - updateDevKey( - paramsOrFirst: - | { projectId: string; keyId: string; name: string; expire: string } - | string, - ...rest: [string?, string?, string?] - ): Promise { - let params: { - projectId: string; - keyId: string; - name: string; - expire: string; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - projectId: string; - keyId: string; - name: string; - expire: string; - }; - } else { - params = { - projectId: paramsOrFirst as string, - keyId: rest[0] as string, - name: rest[1] as string, - expire: rest[2] as string, - }; - } - - const projectId = params.projectId; - const keyId = params.keyId; - const name = params.name; - const expire = params.expire; - - if (typeof projectId === 'undefined' || projectId === '') { - throw new AppwriteException( - 'Missing required parameter: "projectId"', - ); - } - if (typeof keyId === 'undefined' || keyId === '') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof expire === 'undefined') { - throw new AppwriteException('Missing required parameter: "expire"'); - } - const apiPath = '/projects/{projectId}/dev-keys/{keyId}' - .replace('{projectId}', encodeURIComponent(String(projectId))) - .replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - return this.client.call('put', uri, apiHeaders, payload); - } - - /** - * Delete a project\'s dev key by its unique ID. Once deleted, the key will no longer allow bypassing of rate limits and better logging of errors. - * - * @param {string} params.projectId - Project unique ID. - * @param {string} params.keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteDevKey(params: { projectId: string; keyId: string }): Promise<{}>; - /** - * Delete a project\'s dev key by its unique ID. Once deleted, the key will no longer allow bypassing of rate limits and better logging of errors. - * - * @param {string} projectId - Project unique ID. - * @param {string} keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteDevKey(projectId: string, keyId: string): Promise<{}>; - deleteDevKey( - paramsOrFirst: { projectId: string; keyId: string } | string, - ...rest: [string?] - ): Promise<{}> { - let params: { projectId: string; keyId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - projectId: string; - keyId: string; - }; - } else { - params = { - projectId: paramsOrFirst as string, - keyId: rest[0] as string, - }; - } - - const projectId = params.projectId; - const keyId = params.keyId; - - if (typeof projectId === 'undefined' || projectId === '') { - throw new AppwriteException( - 'Missing required parameter: "projectId"', - ); - } - if (typeof keyId === 'undefined' || keyId === '') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - const apiPath = '/projects/{projectId}/dev-keys/{keyId}' - .replace('{projectId}', encodeURIComponent(String(projectId))) - .replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: 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, payload); - } - /** * Get a list of all the project's schedules. You can use the query params to filter your results. * diff --git a/src/services/storage.ts b/src/services/storage.ts index b2c0fc60..55efaa67 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -105,7 +105,7 @@ export class Storage { * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -135,7 +135,7 @@ export class Storage { * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -365,7 +365,7 @@ export class Storage { * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled @@ -395,7 +395,7 @@ export class Storage { * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 0B. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled diff --git a/src/services/teams.ts b/src/services/teams.ts index 66cdfc57..54aacf19 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -781,88 +781,6 @@ export class Teams { return this.client.call('delete', uri, apiHeaders, payload); } - /** - * Get the team activity logs list by its unique ID. - * - * @param {string} params.teamId - Team 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). Only supported methods are limit and offset - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listLogs(params: { - teamId: string; - queries?: string[]; - total?: boolean; - }): Promise; - /** - * Get the team activity logs list by its unique ID. - * - * @param {string} teamId - Team 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). Only supported methods are limit and offset - * @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. - */ - listLogs( - teamId: string, - queries?: string[], - total?: boolean, - ): Promise; - listLogs( - paramsOrFirst: - { teamId: string; queries?: string[]; total?: boolean } | string, - ...rest: [string[]?, boolean?] - ): Promise { - let params: { teamId: string; queries?: string[]; total?: boolean }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - teamId: string; - queries?: string[]; - total?: boolean; - }; - } else { - params = { - teamId: paramsOrFirst as string, - queries: rest[0] as string[], - total: rest[1] as boolean, - }; - } - - const teamId = params.teamId; - const queries = params.queries; - const total = params.total; - - if (typeof teamId === 'undefined' || teamId === '') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - const apiPath = '/teams/{teamId}/logs'.replace( - '{teamId}', - encodeURIComponent(String(teamId)), - ); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - /** * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * diff --git a/src/services/users.ts b/src/services/users.ts index 8566e7a4..78f9795f 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -15,7 +15,7 @@ export class Users { /** * Get a list of all the project's users. You can use the query params to filter your results. * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, passwordPwned, labels, impersonator, accessedAt * @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} @@ -31,7 +31,7 @@ export class Users { /** * Get a list of all the project's users. You can use the query params to filter your results. * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, passwordPwned, labels, impersonator, accessedAt * @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} @@ -1800,88 +1800,6 @@ export class Users { return this.client.call('put', uri, apiHeaders, payload); } - /** - * Get the user activity logs list by its unique ID. - * - * @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). Only supported methods are limit and offset - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listLogs(params: { - userId: string; - queries?: string[]; - total?: boolean; - }): Promise; - /** - * Get the user activity logs list by its unique ID. - * - * @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). Only supported methods are limit and offset - * @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. - */ - listLogs( - userId: string, - queries?: string[], - total?: boolean, - ): Promise; - listLogs( - paramsOrFirst: - { userId: string; queries?: string[]; total?: boolean } | string, - ...rest: [string[]?, boolean?] - ): Promise { - let params: { userId: string; queries?: string[]; total?: boolean }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - userId: string; - queries?: string[]; - total?: boolean; - }; - } 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}/logs'.replace( - '{userId}', - encodeURIComponent(String(userId)), - ); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - /** * Get the user membership list by its unique ID. * From a487154b58cacfa680e26c5b15c7c687eb124afb Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sun, 20 Sep 2026 21:02:20 +0100 Subject: [PATCH 09/10] docs: scope the empty-string check to path parameters --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 222b5edf..9fe3ecdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ * Added: `Framework.Jaspr`, `ProjectEmailTemplateId.OtpVerification`, `ProjectKeyScopes.DedicatedDatabasesExecute`, `QuerySuggestionResource.AppwritePushLedger` * Added: `passwordPwned` on `User`, `providerIdToken` on `Identity`, `firstAccessedAt` and `mcpAccessedAt` on `Project`, `eligibleCountries` on `BillingPlan` * Added: `protocol`, `accept`, `acceptLanguage`, `queryKeys` fields on `UsageDataPoint` -* Fixed: empty-string required parameters are rejected instead of sent to the API +* Fixed: empty-string required path parameters are rejected instead of sent to the API ## 16.1.0 From 416fa6d799a940673416fc269b98ff696cb1b0ad Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 27 Sep 2026 13:03:54 +0545 Subject: [PATCH 10/10] chore: update Console SDK to 18.0.0 --- CHANGELOG.md | 19 +- README.md | 6 +- .../create-recovery-otp.md} | 9 +- docs/examples/account/update-recovery-otp.md | 17 + docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 4 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 4 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 5 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- docs/examples/growth/create-conversation.md | 23 + docs/examples/growth/create-installation.md | 25 + .../manager/update-organization-status.md | 17 + docs/examples/messaging/create-email.md | 2 + docs/examples/messaging/update-email.md | 2 + .../create-ephemeral-project-key.md | 2 +- .../organization/create-project-key.md | 2 +- .../organization/update-project-key.md | 2 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../project/update-o-auth-2-auth-0.md | 7 +- .../project/update-o-auth-2-discord.md | 7 +- .../project/update-o-auth-2-git-hub.md | 7 +- .../examples/project/update-o-auth-2-kakao.md | 7 +- .../project/update-o-auth-2-microsoft.md | 7 +- docs/examples/project/update-o-auth-2-okta.md | 3 +- .../project/update-o-auth-2-salesforce.md | 7 +- docs/examples/project/update-o-auth-2-zoho.md | 3 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 10 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 5 +- docs/examples/vectorsdb/delete-documents.md | 4 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 10 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- package-lock.json | 590 ++++++++++++-- package.json | 7 +- rollup.config.mjs | 6 +- src/client.ts | 62 +- src/enums/build-runtime.ts | 3 + src/enums/conversation-type.ts | 9 + src/enums/o-auth-2-auth-0-prompt.ts | 5 + src/enums/o-auth-2-discord-prompt.ts | 4 + src/enums/o-auth-2-github-prompt.ts | 3 + src/enums/o-auth-2-kakao-prompt.ts | 6 + src/enums/o-auth-2-microsoft-prompt.ts | 6 + src/enums/o-auth-2-okta-prompt.ts | 5 + src/enums/o-auth-2-salesforce-prompt.ts | 4 + src/enums/o-auth-2-zoho-prompt.ts | 3 + src/enums/project-email-template-id.ts | 1 + src/enums/project-o-auth-2-auth-0-prompt.ts | 5 + src/enums/project-o-auth-2-discord-prompt.ts | 4 + src/enums/project-o-auth-2-git-hub-prompt.ts | 3 + src/enums/project-o-auth-2-kakao-prompt.ts | 6 + .../project-o-auth-2-microsoft-prompt.ts | 6 + src/enums/project-o-auth-2-okta-prompt.ts | 5 + .../project-o-auth-2-salesforce-prompt.ts | 4 + src/enums/project-o-auth-2-zoho-prompt.ts | 3 + src/enums/query-suggestion-resource.ts | 2 +- src/enums/runtime.ts | 3 + src/index.ts | 28 +- src/models.ts | 76 +- src/services/account.ts | 172 +++- src/services/console.ts | 4 +- src/services/databases.ts | 28 +- src/services/growth.ts | 411 ++++++++++ src/services/manager.ts | 91 +++ src/services/messaging.ts | 62 +- src/services/organizations.ts | 58 -- src/services/project.ts | 190 ++++- src/services/push.ts | 754 ++++++++++++++++++ src/services/tables-db.ts | 274 ++++--- src/services/users.ts | 4 +- src/topic.ts | 103 +++ 91 files changed, 2984 insertions(+), 350 deletions(-) rename docs/examples/{organizations/get-estimation.md => account/create-recovery-otp.md} (50%) create mode 100644 docs/examples/account/update-recovery-otp.md create mode 100644 docs/examples/growth/create-conversation.md create mode 100644 docs/examples/growth/create-installation.md create mode 100644 docs/examples/manager/update-organization-status.md create mode 100644 src/enums/conversation-type.ts create mode 100644 src/enums/o-auth-2-auth-0-prompt.ts create mode 100644 src/enums/o-auth-2-discord-prompt.ts create mode 100644 src/enums/o-auth-2-github-prompt.ts create mode 100644 src/enums/o-auth-2-kakao-prompt.ts create mode 100644 src/enums/o-auth-2-microsoft-prompt.ts create mode 100644 src/enums/o-auth-2-okta-prompt.ts create mode 100644 src/enums/o-auth-2-salesforce-prompt.ts create mode 100644 src/enums/o-auth-2-zoho-prompt.ts create mode 100644 src/enums/project-o-auth-2-auth-0-prompt.ts create mode 100644 src/enums/project-o-auth-2-discord-prompt.ts create mode 100644 src/enums/project-o-auth-2-git-hub-prompt.ts create mode 100644 src/enums/project-o-auth-2-kakao-prompt.ts create mode 100644 src/enums/project-o-auth-2-microsoft-prompt.ts create mode 100644 src/enums/project-o-auth-2-okta-prompt.ts create mode 100644 src/enums/project-o-auth-2-salesforce-prompt.ts create mode 100644 src/enums/project-o-auth-2-zoho-prompt.ts create mode 100644 src/services/growth.ts create mode 100644 src/services/push.ts create mode 100644 src/topic.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fe3ecdc..d09cdeaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## 18.0.0 + +* Breaking: SDK now targets Appwrite 2.3 (`X-Appwrite-Response-Format: 2.3.0`) +* Breaking: removed `Organizations.getEstimation` +* Breaking: `QuerySuggestionResource.AppwritePushLedger` renamed to `PushLedger` +* Added: `Manager.updateOrganizationStatus` to block and unblock an organization +* Added: `Push` service over MQTT with `Topic`, plus `Client.setPushEndpoint` and `Client.setPushClientId` +* Added: `Growth` service with `createConversation`, `createInstallation`, `ConversationType` enum and `GrowthConversation` model +* Added: `Account.createRecoveryOTP` and `Account.updateRecoveryOTP` for code-based password recovery +* Added: `prompt` parameter on `Project.updateOAuth2*` for Auth0, Discord, GitHub, Kakao, Microsoft, Okta, Salesforce, Zoho +* Added: matching `prompt` fields and enums on the `OAuth2*` provider models +* Added: `replyToName` and `replyToEmail` on `Messaging.createEmail` and `Messaging.updateEmail` +* Added: `organizationUrl` on the `Installation` model +* Added: `ProjectEmailTemplateId.OtpRecovery` and Deno 1.21, 1.24, 1.35 in `Runtime` and `BuildRuntime` +* Updated: `Databases.getAttribute` return type now includes bigint, spatial, varchar and text attributes +* Updated: added `mqtt` and `buffer` dependencies and browser Node polyfills for `Push` +* Fixed: chunked uploads without a file in the payload now send a regular request + ## 17.0.0 * Breaking: SDK now targets Appwrite 2.2 (`X-Appwrite-Response-Format: 2.2.0`) @@ -17,7 +35,6 @@ * Added: `Account.createIdTokenSession` for native Apple and Google sign-in with `IdTokenProvider` enum * Added: `Account.createEmailVerificationOTP` and `Account.updateEmailVerificationOTP` * Added: `Messaging.createAppwriteProvider` and `Messaging.updateAppwriteProvider` for Appwrite push, with `qos` and `expiry` on `Topic` -* Added: `Organizations.getEstimation` for the current billing cycle charge estimate * Added: `Project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `ProjectPolicyId.Passwordpwned` * Added: `nativeEnabled`, `nativeClientIds` parameters on `Project.updateOAuth2Apple` and `Project.updateOAuth2Google` and matching fields on `OAuth2Apple`, `OAuth2Google` * Added: `Framework.Jaspr`, `ProjectEmailTemplateId.OtpVerification`, `ProjectKeyScopes.DedicatedDatabasesExecute`, `QuerySuggestionResource.AppwritePushLedger` diff --git a/README.md b/README.md index 1c917b26..c1c963be 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Console SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.2.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.0.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-console/releases) when APIs differ. +**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-console/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -33,7 +33,7 @@ import { Client, Account } from '@appwrite.io/console'; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` ## Getting Started diff --git a/docs/examples/organizations/get-estimation.md b/docs/examples/account/create-recovery-otp.md similarity index 50% rename from docs/examples/organizations/get-estimation.md rename to docs/examples/account/create-recovery-otp.md index 7830f8fb..baf48cb9 100644 --- a/docs/examples/organizations/get-estimation.md +++ b/docs/examples/account/create-recovery-otp.md @@ -1,14 +1,15 @@ ```javascript -import { Client, Organizations } from '@appwrite.io/console'; +import { Client, Account } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const organizations = new Organizations(client); +const account = new Account(client); -const result = await organizations.getEstimation({ - organizationId: '', +const result = await account.createRecoveryOTP({ + email: 'email@example.com', + phrase: false, // optional }); console.log(result); diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md new file mode 100644 index 00000000..4d23d7c6 --- /dev/null +++ b/docs/examples/account/update-recovery-otp.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Account } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updateRecoveryOTP({ + userId: '', + secret: '', + password: 'password', +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index e264c929..3ba08ea3 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -10,7 +10,16 @@ const databases = new Databases(client); const result = await databases.createDocuments({ databaseId: '', collectionId: '', - documents: [], + documents: [ + { + $id: 'example1', + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 01a86729..788f5d2e 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -17,7 +17,7 @@ const result = await databases.createIndex({ collectionId: '', key: '', type: DatabasesIndexType.Key, - attributes: [], + attributes: ['username'], orders: [OrderBy.Asc], // optional lengths: [], // optional }); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index fd68feeb..08fca8a1 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -10,7 +10,9 @@ const databases = new Databases(client); const result = await databases.deleteDocuments({ databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}', + ], // optional transactionId: '', // optional }); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 5ee9d710..5a62dd5c 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -10,7 +10,16 @@ const databases = new Databases(client); const result = await databases.upsertDocuments({ databaseId: '', collectionId: '', - documents: [], + documents: [ + { + $id: 'example1', + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1c961336..fc5fce8c 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -10,7 +10,16 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.createDocuments({ databaseId: '', collectionId: '', - documents: [], + documents: [ + { + $id: 'example1', + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index ec398d9d..ce61944a 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -17,7 +17,7 @@ const result = await documentsDB.createIndex({ collectionId: '', key: '', type: DocumentsDBIndexType.Key, - attributes: [], + attributes: ['username'], orders: [OrderBy.Asc], // optional lengths: [], // optional }); diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index f9e603c0..125cd561 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -10,7 +10,9 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.deleteDocuments({ databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}', + ], // optional transactionId: '', // optional }); diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index fb5a380a..ec7d8251 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -10,7 +10,16 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.upsertDocuments({ databaseId: '', collectionId: '', - documents: [], + documents: [ + { + $id: 'example1', + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 0b93299b..36639a80 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -8,7 +8,10 @@ const client = new Client() const embeddings = new Embeddings(client); const result = await embeddings.createTextEmbeddings({ - texts: [], + texts: [ + 'Appwrite helps developers build applications.', + 'Find documents with semantic search.', + ], model: EmbeddingModel.NomicEmbedText, // optional }); diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 25c0ffbd..de226404 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -8,7 +8,9 @@ const client = new Client() const graphql = new Graphql(client); const result = await graphql.mutation({ - query: {}, + query: { + query: 'mutation { accountUpdateName(name: "Walter") { name } }', + }, }); console.log(result); diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 73b3da23..5773b877 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -8,7 +8,9 @@ const client = new Client() const graphql = new Graphql(client); const result = await graphql.query({ - query: {}, + query: { + query: 'query { localeGet { ip } }', + }, }); console.log(result); diff --git a/docs/examples/growth/create-conversation.md b/docs/examples/growth/create-conversation.md new file mode 100644 index 00000000..ad321dcc --- /dev/null +++ b/docs/examples/growth/create-conversation.md @@ -0,0 +1,23 @@ +```javascript +import { Client, Growth, ConversationType } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const growth = new Growth(client); + +const result = await growth.createConversation({ + type: ConversationType.Support, + email: 'email@example.com', // optional + name: '', // optional + subject: '', // optional + message: '', // optional + organizationId: '', // optional + projectId: '', // optional + attributes: {}, // optional + attachment: document.getElementById('uploader').files[0], // optional +}); + +console.log(result); +``` diff --git a/docs/examples/growth/create-installation.md b/docs/examples/growth/create-installation.md new file mode 100644 index 00000000..a4fb466c --- /dev/null +++ b/docs/examples/growth/create-installation.md @@ -0,0 +1,25 @@ +```javascript +import { Client, Growth } from '@appwrite.io/console'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const growth = new Growth(client); + +const result = await growth.createInstallation({ + email: 'email@example.com', // optional + name: '', // optional + version: '', // optional + domain: '', // optional + database: '', // optional + hostIp: '', // optional + userAgent: '', // optional + os: '', // optional + arch: '', // optional + cpus: null, // optional + ram: null, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/manager/update-organization-status.md b/docs/examples/manager/update-organization-status.md new file mode 100644 index 00000000..b1b1e19a --- /dev/null +++ b/docs/examples/manager/update-organization-status.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Manager } from '@appwrite.io/console'; + +const client = new Client().setEndpoint( + 'https://.cloud.appwrite.io/v1', +); // Your API Endpoint + +const manager = new Manager(client); + +const result = await manager.updateOrganizationStatus({ + teamId: '', + status: false, + reason: '', // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index a6da1435..bed1afc9 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -17,6 +17,8 @@ const result = await messaging.createEmail({ cc: [], // optional bcc: [], // optional attachments: [], // optional + replyToEmail: 'email@example.com', // optional + replyToName: '', // optional draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 77f765a4..a043d35e 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -18,6 +18,8 @@ const result = await messaging.updateEmail({ html: false, // optional cc: [], // optional bcc: [], // optional + replyToEmail: 'email@example.com', // optional + replyToName: '', // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional }); diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md index d1cb1295..4cc1194a 100644 --- a/docs/examples/organization/create-ephemeral-project-key.md +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -9,7 +9,7 @@ const organization = new Organization(client); const result = await organization.createEphemeralProjectKey({ projectId: '', - scopes: [ProjectKeyScopes.ProjectRead], + scopes: [ProjectKeyScopes.UsersRead], duration: 600, }); diff --git a/docs/examples/organization/create-project-key.md b/docs/examples/organization/create-project-key.md index 2361bb94..7e9786a8 100644 --- a/docs/examples/organization/create-project-key.md +++ b/docs/examples/organization/create-project-key.md @@ -11,7 +11,7 @@ const result = await organization.createProjectKey({ projectId: '', keyId: '', name: '', - scopes: [ProjectKeyScopes.ProjectRead], + scopes: [ProjectKeyScopes.UsersRead], expire: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md index 550ecebd..dbb0c7ed 100644 --- a/docs/examples/organization/update-project-key.md +++ b/docs/examples/organization/update-project-key.md @@ -11,7 +11,7 @@ const result = await organization.updateProjectKey({ projectId: '', keyId: '', name: '', - scopes: [ProjectKeyScopes.ProjectRead], + scopes: [ProjectKeyScopes.UsersRead], expire: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index f5f76a42..f86455cf 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.createEphemeralKey({ - scopes: [ProjectKeyScopes.ProjectRead], + scopes: [ProjectKeyScopes.UsersRead], duration: 600, }); diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md index 5354d732..d6341200 100644 --- a/docs/examples/project/create-key.md +++ b/docs/examples/project/create-key.md @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createKey({ keyId: '', name: '', - scopes: [ProjectKeyScopes.ProjectRead], + scopes: [ProjectKeyScopes.UsersRead], expire: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 300e972c..96653785 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.createSMTPTest({ - emails: [], + emails: ['recipient@example.com'], }); console.log(result); diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 3bba96a0..0be53efe 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateKey({ keyId: '', name: '', - scopes: [ProjectKeyScopes.ProjectRead], + scopes: [ProjectKeyScopes.UsersRead], expire: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index 8df4ffb4..12f8fceb 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateLabels({ - labels: [], + labels: ['production'], }); console.log(result); diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 7c2898e4..01abc6ba 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { + Client, + Project, + ProjectOAuth2Auth0Prompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,6 +15,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional + prompt: [ProjectOAuth2Auth0Prompt.None], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 1116db06..fc7aaa09 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { + Client, + Project, + ProjectOAuth2DiscordPrompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,6 +14,7 @@ const project = new Project(client); const result = await project.updateOAuth2Discord({ clientId: '', // optional clientSecret: '', // optional + prompt: [ProjectOAuth2DiscordPrompt.None], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index f3cc3b13..0c4e2045 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { + Client, + Project, + ProjectOAuth2GitHubPrompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,6 +14,7 @@ const project = new Project(client); const result = await project.updateOAuth2GitHub({ clientId: '', // optional clientSecret: '', // optional + prompt: [ProjectOAuth2GitHubPrompt.SelectAccount], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index b92e049d..cf304988 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { + Client, + Project, + ProjectOAuth2KakaoPrompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,6 +14,7 @@ const project = new Project(client); const result = await project.updateOAuth2Kakao({ clientId: '', // optional clientSecret: '', // optional + prompt: [ProjectOAuth2KakaoPrompt.None], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 18f21fe9..9bbbfa13 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { + Client, + Project, + ProjectOAuth2MicrosoftPrompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,6 +15,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '', // optional applicationSecret: '', // optional tenant: '', // optional + prompt: [ProjectOAuth2MicrosoftPrompt.None], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index a94ad691..da983aca 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { Client, Project, ProjectOAuth2OktaPrompt } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,6 +12,7 @@ const result = await project.updateOAuth2Okta({ clientSecret: '', // optional domain: 'example.com', // optional authorizationServerId: '', // optional + prompt: [ProjectOAuth2OktaPrompt.None], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 04c3da12..8b19d764 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -1,5 +1,9 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { + Client, + Project, + ProjectOAuth2SalesforcePrompt, +} from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,6 +14,7 @@ const project = new Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '', // optional customerSecret: '', // optional + prompt: [ProjectOAuth2SalesforcePrompt.Login], // optional enabled: false, // optional }); diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 0a1ff861..524d1185 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project } from '@appwrite.io/console'; +import { Client, Project, ProjectOAuth2ZohoPrompt } from '@appwrite.io/console'; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,6 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Zoho({ clientId: '', // optional clientSecret: '', // optional + prompt: [ProjectOAuth2ZohoPrompt.Consent], // optional enabled: false, // optional }); diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 1b4f0aba..629a8ef1 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -17,7 +17,7 @@ const result = await tablesDB.createIndex({ tableId: '', key: '', type: TablesDBIndexType.Key, - columns: [], + columns: ['username'], orders: [OrderBy.Asc], // optional lengths: [], // optional }); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 2c046135..cd3ca02a 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -10,7 +10,16 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createRows({ databaseId: '', tableId: '', - rows: [], + rows: [ + { + $id: 'example1', + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 58df6f19..b528d434 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -10,7 +10,7 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.deleteRows({ databaseId: '', tableId: '', - queries: [], // optional + queries: ['{"method":"equal", "attribute":"$id", "values":[""]}'], // optional transactionId: '', // optional }); diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 005f7b4e..e42d2d44 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -10,7 +10,16 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.upsertRows({ databaseId: '', tableId: '', - rows: [], + rows: [ + { + $id: 'example1', + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 35581d30..d06d4894 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -9,7 +9,7 @@ const teams = new Teams(client); const result = await teams.createMembership({ teamId: '', - roles: [], + roles: ['editor'], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 6ed36583..efa11810 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -10,7 +10,7 @@ const teams = new Teams(client); const result = await teams.updateMembership({ teamId: '', membershipId: '', - roles: [], + roles: ['editor'], }); console.log(result); diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index bf287f36..62e2a7e7 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -9,7 +9,7 @@ const users = new Users(client); const result = await users.updateLabels({ userId: '', - labels: [], + labels: ['subscriber'], }); console.log(result); diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index b69be570..12996a2c 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -11,7 +11,7 @@ const result = await vectorsDB.createCollection({ databaseId: '', collectionId: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional enabled: false, // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 6bda5bf1..e49698e8 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -10,7 +10,15 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createDocuments({ databaseId: '', collectionId: '', - documents: [], + documents: [ + { + $id: 'example1', + embeddings: [0.12, -0.55, 0.88, 1.02], + metadata: { + name: 'First document', + }, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index 1f8b422d..d02efaeb 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -17,7 +17,7 @@ const result = await vectorsDB.createIndex({ collectionId: '', key: '', type: VectorsDBIndexType.HnswEuclidean, - attributes: [], + attributes: ['embeddings'], orders: [OrderBy.Asc], // optional lengths: [], // optional }); diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index fc90ed8b..ce27bd39 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -16,7 +16,10 @@ const result = await vectorsDB.createOperations({ collectionId: '', documentId: '', data: { - name: "Walter O'Brien", + embeddings: [0.12, -0.55, 0.88, 1.02], + metadata: { + name: 'First document', + }, }, }, ], // optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index e699485b..98e2d1bf 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -10,7 +10,9 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.deleteDocuments({ databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}', + ], // optional transactionId: '', // optional }); diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 49102441..afa2d357 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -11,7 +11,7 @@ const result = await vectorsDB.updateCollection({ databaseId: '', collectionId: '', name: '', - dimension: 1, // optional + dimension: 4, // optional permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional enabled: false, // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index af58d1d4..6f13ae74 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -10,7 +10,15 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.upsertDocuments({ databaseId: '', collectionId: '', - documents: [], + documents: [ + { + $id: 'example1', + embeddings: [0.12, -0.55, 0.88, 1.02], + metadata: { + name: 'First document', + }, + }, + ], transactionId: '', // optional }); diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index f5817fbe..39301365 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -11,7 +11,7 @@ const result = await webhooks.create({ webhookId: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ['users.*.create'], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 78071ef4..058f73e1 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -11,7 +11,7 @@ const result = await webhooks.update({ webhookId: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ['users.*.create'], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/package-lock.json b/package-lock.json index f63c20c8..3bd09a25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,17 @@ { "name": "@appwrite.io/console", - "version": "17.0.0", + "version": "18.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "17.0.0", + "version": "18.0.0", "license": "BSD-3-Clause", "dependencies": { - "json-bigint": "1.0.0" + "buffer": "6.0.3", + "json-bigint": "1.0.0", + "mqtt": "5.15.2" }, "devDependencies": { "@eslint/js": "10.0.1", @@ -21,6 +23,7 @@ "playwright": "1.56.1", "prettier": "3.9.6", "rollup": "4.63.2", + "rollup-plugin-polyfill-node": "0.13.0", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3", @@ -33,6 +36,15 @@ "brace-expansion": "5.0.9" } }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -290,9 +302,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -329,6 +338,29 @@ } } }, + "node_modules/@rollup/plugin-inject": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-inject/-/plugin-inject-5.0.5.tgz", + "integrity": "sha512-2+DEJbNBoPROPkgTDNe8/1YXWcqxbN5DTjASVIOx8HS+pITXushyNiBV56RB08zuptzz8gT3YfkqriTBVycepg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", @@ -496,9 +528,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -513,9 +542,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -530,9 +556,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -547,9 +570,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -564,9 +584,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -581,9 +598,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -598,9 +612,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -615,9 +626,6 @@ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -632,9 +640,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -649,9 +654,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -666,9 +668,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -683,9 +682,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -700,9 +696,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -821,6 +814,24 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/node": { + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.2.tgz", + "integrity": "sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g==", + "license": "MIT", + "dependencies": { + "undici-types": "~8.9.0" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.24", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.24.tgz", + "integrity": "sha512-NRvUNC/JFGPJvqdAfEve8oginbM6V08u5NzLWpG8MwA2kTPOLnqk+wpwuPT+mp3aUsxyuT6m2gnrPuHYCruzEg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/resolve": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", @@ -828,6 +839,15 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.70.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.70.0.tgz", @@ -1058,6 +1078,18 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/acorn": { "version": "8.18.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz", @@ -1108,6 +1140,26 @@ "node": "18 || 20 || >=22" } }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/bignumber.js": { "version": "9.3.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", @@ -1117,6 +1169,18 @@ "node": "*" } }, + "node_modules/bl": { + "version": "6.1.6", + "resolved": "https://registry.npmjs.org/bl/-/bl-6.1.6.tgz", + "integrity": "sha512-jLsPgN/YSvPUg9UX0Kd73CXpm2Psg9FxMeCSXnk3WBO3CMT10JMwijubhGfHCnFu6TPn1ei3b975dxv7K2pWVg==", + "license": "MIT", + "dependencies": { + "@types/readable-stream": "^4.0.0", + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^4.2.0" + } + }, "node_modules/brace-expansion": { "version": "5.0.9", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", @@ -1130,6 +1194,48 @@ "node": "20 || >=22" } }, + "node_modules/broker-factory": { + "version": "3.1.15", + "resolved": "https://registry.npmjs.org/broker-factory/-/broker-factory-3.1.15.tgz", + "integrity": "sha512-ko+aWvgNuP49meGrdjUu7rC+Y+Wai3cCPxP3xWwHsHfehFjOh5ZQM2yC4gEB2UddeZ/YXhm0K1eG/L6fxym2Og==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7", + "fast-unique-numbers": "^9.0.27", + "tslib": "^2.8.1", + "worker-factory": "^7.0.50" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, "node_modules/bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -1154,6 +1260,12 @@ "qified": "^0.10.1" } }, + "node_modules/commist": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/commist/-/commist-3.2.0.tgz", + "integrity": "sha512-4PIMoPniho+LqXmpS5d3NuGYncG6XWlkBSVGiWycL22dd42OYdUGil2CWuzklaJoNxyxUSpO4MKIBU94viWNAw==", + "license": "MIT" + }, "node_modules/commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -1161,6 +1273,35 @@ "dev": true, "license": "MIT" }, + "node_modules/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "engines": [ + "node >= 6.0" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/concat-stream/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/content-disposition": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", @@ -1190,7 +1331,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -1406,6 +1546,24 @@ "node": ">=0.10.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1427,6 +1585,19 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-unique-numbers": { + "version": "9.0.27", + "resolved": "https://registry.npmjs.org/fast-unique-numbers/-/fast-unique-numbers-9.0.27.tgz", + "integrity": "sha512-nDA9ADeINN8SA2u2wCtU+siWFTTDqQR37XvgPIDDmboWQeExz7X0mImxuaN+kJddliIqy2FpVRmnvRZ+j8i1/A==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.2", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=18.2.0" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -1555,6 +1726,12 @@ "node": ">= 0.4" } }, + "node_modules/help-me": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", + "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", + "license": "MIT" + }, "node_modules/hookified": { "version": "1.15.1", "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", @@ -1562,6 +1739,26 @@ "dev": true, "license": "MIT" }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -1582,14 +1779,29 @@ "node": ">=0.8.19" } }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ip-address": { + "version": "10.7.2", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.2.tgz", + "integrity": "sha512-7H/2gFSIitxc0hG3nOI1glS8QLo/EHBFFLk8vEUjXY/xu0AdL8jZ9U1IzO2PUm0d2D/ofQcAifb0g6OBkt8U7w==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, "node_modules/is-core-module": { - "version": "2.16.2", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", - "integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==", + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.17.0.tgz", + "integrity": "sha512-J/vG0zBCbIKOQFfufSwyXdMrsohyJIUNkrnmo6WZGzoM7tr/lsbfW5b2BvisL6zsyMzK9UxV9L6c7AoFbyXHOA==", "dev": true, "license": "MIT", "dependencies": { - "hasown": "^2.0.3" + "hasown": "^2.0.4" }, "engines": { "node": ">= 0.4" @@ -1645,6 +1857,16 @@ "dev": true, "license": "ISC" }, + "node_modules/js-sdsl": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", + "integrity": "sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } + }, "node_modules/json-bigint": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", @@ -1708,6 +1930,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "license": "ISC" + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -1757,11 +1985,62 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mqtt": { + "version": "5.15.2", + "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-5.15.2.tgz", + "integrity": "sha512-VWZU2CSUY3U3oN0PSBRDE5SNsFi4zqqNeQ/uv3pZWqY3CrBXD/dhd0ZLjlsk5YnebGlrapi4lRVNJPUNQ5aZ3w==", + "license": "MIT", + "dependencies": { + "@types/readable-stream": "^4.0.21", + "@types/ws": "^8.18.1", + "commist": "^3.2.0", + "concat-stream": "^2.0.0", + "debug": "^4.4.1", + "help-me": "^5.0.0", + "lru-cache": "^10.4.3", + "minimist": "^1.2.8", + "mqtt-packet": "^9.0.2", + "number-allocator": "^1.0.14", + "readable-stream": "^4.7.0", + "rfdc": "^1.4.1", + "socks": "^2.8.6", + "split2": "^4.2.0", + "worker-timers": "^8.0.23", + "ws": "^8.18.3" + }, + "bin": { + "mqtt": "build/bin/mqtt.js", + "mqtt_pub": "build/bin/pub.js", + "mqtt_sub": "build/bin/sub.js" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/mqtt-packet": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/mqtt-packet/-/mqtt-packet-9.0.2.tgz", + "integrity": "sha512-MvIY0B8/qjq7bKxdN1eD+nrljoeaai+qjLJgfRn3TiMuz0pamsIWY2bFODPZMSNmabsLANXsLl4EMoWvlaTZWA==", + "license": "MIT", + "dependencies": { + "bl": "^6.0.8", + "debug": "^4.3.4", + "process-nextick-args": "^2.0.1" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/natural-compare": { @@ -1771,6 +2050,16 @@ "dev": true, "license": "MIT" }, + "node_modules/number-allocator": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/number-allocator/-/number-allocator-1.0.14.tgz", + "integrity": "sha512-OrL44UTVAvkKdOdRQZIJpLkAdjXGTRda052sN4sO77bKEzYYqWKMBjQvrJFzqygI99gL6Z4u2xctPW1tB8ErvA==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.1", + "js-sdsl": "4.3.0" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -1933,6 +2222,21 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -1973,6 +2277,22 @@ "node": ">= 0.6" } }, + "node_modules/readable-stream": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/resolve": { "version": "1.22.12", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz", @@ -1995,6 +2315,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/rfdc": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", + "license": "MIT" + }, "node_modules/rollup": { "version": "4.63.2", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.2.tgz", @@ -2041,6 +2367,39 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-polyfill-node": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-polyfill-node/-/rollup-plugin-polyfill-node-0.13.0.tgz", + "integrity": "sha512-FYEvpCaD5jGtyBuBFcQImEGmTxDTPbiHjJdrYIp+mFIwgXiXabxvKUK7ZT9P31ozu2Tqm9llYQMRWsfvTMTAOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/plugin-inject": "^5.0.4" + }, + "peerDependencies": { + "rollup": "^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/semver": { "version": "7.8.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", @@ -2106,6 +2465,48 @@ "node": ">=8" } }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.10", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.10.tgz", + "integrity": "sha512-e0VyvkVTwVYViNovRkZ9aodhxVlyoMn7eJhVUPxZ+eK9P/7CBkxvvsBOHqFPEH416726W8tLXXXjKwqgTErrCQ==", + "license": "MIT", + "dependencies": { + "ip-address": "^10.1.1", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -2153,7 +2554,6 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, "license": "0BSD" }, "node_modules/type-check": { @@ -2169,6 +2569,12 @@ "node": ">= 0.8.0" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "license": "MIT" + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -2207,6 +2613,12 @@ "typescript": ">=4.8.4 <6.1.0" } }, + "node_modules/undici-types": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -2217,6 +2629,12 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2243,6 +2661,74 @@ "node": ">=0.10.0" } }, + "node_modules/worker-factory": { + "version": "7.0.50", + "resolved": "https://registry.npmjs.org/worker-factory/-/worker-factory-7.0.50.tgz", + "integrity": "sha512-hhwc0G+sFwM4qBuhJIUBn2p1Jf8v/FwmLUANBf/Q+Lt2uI8mfIZQhXaZQACodQD4R7Zp6cn/6702bIvNn2puJQ==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7", + "fast-unique-numbers": "^9.0.27", + "tslib": "^2.8.1" + } + }, + "node_modules/worker-timers": { + "version": "8.0.34", + "resolved": "https://registry.npmjs.org/worker-timers/-/worker-timers-8.0.34.tgz", + "integrity": "sha512-WXL+Dqsm0G6dnC66rQsvM3tPT2adhbqSirWUCZGglkALOr8ocS0KlpU0iuKbjflJOlu3ydZikMEVrYnHOM9suw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7", + "tslib": "^2.8.1", + "worker-timers-broker": "^8.0.18", + "worker-timers-worker": "^9.0.15" + } + }, + "node_modules/worker-timers-broker": { + "version": "8.0.18", + "resolved": "https://registry.npmjs.org/worker-timers-broker/-/worker-timers-broker-8.0.18.tgz", + "integrity": "sha512-FrjzDVX1wKfZN0gRbCFqv8VHuTncG4sbI/WGEg4tSSQeIsnwqg4YBYWMAHYLJtUDEYYmiK65UKFrVMVk2irDSg==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7", + "broker-factory": "^3.1.15", + "fast-unique-numbers": "^9.0.27", + "tslib": "^2.8.1", + "worker-timers-worker": "^9.0.15" + } + }, + "node_modules/worker-timers-worker": { + "version": "9.0.15", + "resolved": "https://registry.npmjs.org/worker-timers-worker/-/worker-timers-worker-9.0.15.tgz", + "integrity": "sha512-KKUe7lZ/Aignr51H6hOUik8LwTnIgojH/1lwhli8A8qIEIyewogZTpNpMW5B6BF7nmwBOkUoTYgf1H3QShcjSA==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7", + "tslib": "^2.8.1", + "worker-factory": "^7.0.50" + } + }, + "node_modules/ws": { + "version": "8.21.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz", + "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 1683a871..72f45446 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "17.0.0", + "version": "18.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { @@ -37,7 +37,9 @@ "node": ">=18.0.0" }, "dependencies": { - "json-bigint": "1.0.0" + "buffer": "6.0.3", + "json-bigint": "1.0.0", + "mqtt": "5.15.2" }, "devDependencies": { "@eslint/js": "10.0.1", @@ -49,6 +51,7 @@ "playwright": "1.56.1", "prettier": "3.9.6", "rollup": "4.63.2", + "rollup-plugin-polyfill-node": "0.13.0", "serve-handler": "6.1.7", "tslib": "2.8.1", "typescript": "5.9.3", diff --git a/rollup.config.mjs b/rollup.config.mjs index 0d5864b6..99cecd12 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -3,6 +3,7 @@ const pkg = JSON.parse(readFileSync('./package.json', 'utf8')); import typescript from '@rollup/plugin-typescript'; import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; +import nodePolyfills from 'rollup-plugin-polyfill-node'; const external = Object.keys(pkg.dependencies ?? {}); @@ -28,7 +29,10 @@ export default [ { input: 'src/index.ts', plugins: [ - resolve({ browser: true }), + // The Push service uses mqtt.js, which references Node built-ins + // (buffer/process/stream/…); polyfill them for the browser bundle. + nodePolyfills(), + resolve({ browser: true, preferBuiltins: false }), commonjs(), typescript({ outDir: 'dist' }), ], diff --git a/src/client.ts b/src/client.ts index 86594e53..f2eabf6f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -368,6 +368,8 @@ class Client { config: { endpoint: string; endpointRealtime: string; + endpointPush: string; + pushClientId: string; project: string; key: string; organization: string; @@ -386,6 +388,8 @@ class Client { } = { endpoint: 'https://cloud.appwrite.io/v1', endpointRealtime: '', + endpointPush: '', + pushClientId: '', project: '', key: '', organization: '', @@ -409,8 +413,8 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '17.0.0', - 'X-Appwrite-Response-Format': '2.2.0', + 'x-sdk-version': '18.0.0', + 'X-Appwrite-Response-Format': '2.3.0', }; /** @@ -479,6 +483,53 @@ class Client { return this; } + /** + * Set Push Endpoint + * + * The MQTT-over-WebSocket URL the AppwritePush service connects to. + * + * @param {string} endpointPush + * + * @returns {this} + */ + setPushEndpoint(endpointPush: string): this { + if (!endpointPush || typeof endpointPush !== 'string') { + throw new AppwriteException('Endpoint must be a valid string'); + } + + if ( + !endpointPush.startsWith('ws://') && + !endpointPush.startsWith('wss://') + ) { + throw new AppwriteException( + 'Invalid push endpoint URL: ' + endpointPush, + ); + } + + this.config.endpointPush = endpointPush; + return this; + } + + /** + * Set Push Client Id + * + * A stable client id for the AppwritePush service. The broker keys its + * offline-replay cursor on this id, so pass a stable value to resume replay across + * reloads/restarts. Defaults to a per-connection id when unset. + * + * @param {string} pushClientId + * + * @returns {this} + */ + setPushClientId(pushClientId: string): this { + if (!pushClientId || typeof pushClientId !== 'string') { + throw new AppwriteException('Client id must be a valid string'); + } + + this.config.pushClientId = pushClientId; + return this; + } + /** * Set self-signed * @@ -1097,12 +1148,9 @@ class Client { const options: RequestInit = { method, headers, + credentials: this.config.credentials, }; - if (headers['X-Appwrite-Dev-Key'] === undefined) { - options.credentials = this.config.credentials; - } - if (method === 'GET') { for (const [key, value] of Object.entries(Client.flatten(params))) { url.searchParams.append(key, value); @@ -1151,7 +1199,7 @@ class Client { ) ?? []; if (!file || !fileParam) { - throw new Error('File not found in payload'); + return await this.call(method, url, headers, originalPayload); } if (file.size <= Client.CHUNK_SIZE) { diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 2dfd9c61..01558318 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -31,6 +31,9 @@ export enum BuildRuntime { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', + Deno121 = 'deno-1.21', + Deno124 = 'deno-1.24', + Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/enums/conversation-type.ts b/src/enums/conversation-type.ts new file mode 100644 index 00000000..924d33b2 --- /dev/null +++ b/src/enums/conversation-type.ts @@ -0,0 +1,9 @@ +export enum ConversationType { + Support = 'support', + Feedback = 'feedback', + Docs = 'docs', + Enterprise = 'enterprise', + Startup = 'startup', + Partner = 'partner', + Sponsorship = 'sponsorship', +} diff --git a/src/enums/o-auth-2-auth-0-prompt.ts b/src/enums/o-auth-2-auth-0-prompt.ts new file mode 100644 index 00000000..e015cae0 --- /dev/null +++ b/src/enums/o-auth-2-auth-0-prompt.ts @@ -0,0 +1,5 @@ +export enum OAuth2Auth0Prompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-discord-prompt.ts b/src/enums/o-auth-2-discord-prompt.ts new file mode 100644 index 00000000..ece22e48 --- /dev/null +++ b/src/enums/o-auth-2-discord-prompt.ts @@ -0,0 +1,4 @@ +export enum OAuth2DiscordPrompt { + None = 'none', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-github-prompt.ts b/src/enums/o-auth-2-github-prompt.ts new file mode 100644 index 00000000..0519185f --- /dev/null +++ b/src/enums/o-auth-2-github-prompt.ts @@ -0,0 +1,3 @@ +export enum OAuth2GithubPrompt { + SelectAccount = 'select_account', +} diff --git a/src/enums/o-auth-2-kakao-prompt.ts b/src/enums/o-auth-2-kakao-prompt.ts new file mode 100644 index 00000000..2b5713a5 --- /dev/null +++ b/src/enums/o-auth-2-kakao-prompt.ts @@ -0,0 +1,6 @@ +export enum OAuth2KakaoPrompt { + None = 'none', + Login = 'login', + Create = 'create', + SelectAccount = 'select_account', +} diff --git a/src/enums/o-auth-2-microsoft-prompt.ts b/src/enums/o-auth-2-microsoft-prompt.ts new file mode 100644 index 00000000..53689659 --- /dev/null +++ b/src/enums/o-auth-2-microsoft-prompt.ts @@ -0,0 +1,6 @@ +export enum OAuth2MicrosoftPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', + SelectAccount = 'select_account', +} diff --git a/src/enums/o-auth-2-okta-prompt.ts b/src/enums/o-auth-2-okta-prompt.ts new file mode 100644 index 00000000..8e279048 --- /dev/null +++ b/src/enums/o-auth-2-okta-prompt.ts @@ -0,0 +1,5 @@ +export enum OAuth2OktaPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-salesforce-prompt.ts b/src/enums/o-auth-2-salesforce-prompt.ts new file mode 100644 index 00000000..131dd107 --- /dev/null +++ b/src/enums/o-auth-2-salesforce-prompt.ts @@ -0,0 +1,4 @@ +export enum OAuth2SalesforcePrompt { + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-zoho-prompt.ts b/src/enums/o-auth-2-zoho-prompt.ts new file mode 100644 index 00000000..22ac9540 --- /dev/null +++ b/src/enums/o-auth-2-zoho-prompt.ts @@ -0,0 +1,3 @@ +export enum OAuth2ZohoPrompt { + Consent = 'consent', +} diff --git a/src/enums/project-email-template-id.ts b/src/enums/project-email-template-id.ts index b2f5a808..be742ea3 100644 --- a/src/enums/project-email-template-id.ts +++ b/src/enums/project-email-template-id.ts @@ -7,4 +7,5 @@ export enum ProjectEmailTemplateId { SessionAlert = 'sessionAlert', OtpSession = 'otpSession', OtpVerification = 'otpVerification', + OtpRecovery = 'otpRecovery', } diff --git a/src/enums/project-o-auth-2-auth-0-prompt.ts b/src/enums/project-o-auth-2-auth-0-prompt.ts new file mode 100644 index 00000000..a09f94f7 --- /dev/null +++ b/src/enums/project-o-auth-2-auth-0-prompt.ts @@ -0,0 +1,5 @@ +export enum ProjectOAuth2Auth0Prompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-discord-prompt.ts b/src/enums/project-o-auth-2-discord-prompt.ts new file mode 100644 index 00000000..ec81b72b --- /dev/null +++ b/src/enums/project-o-auth-2-discord-prompt.ts @@ -0,0 +1,4 @@ +export enum ProjectOAuth2DiscordPrompt { + None = 'none', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-git-hub-prompt.ts b/src/enums/project-o-auth-2-git-hub-prompt.ts new file mode 100644 index 00000000..9abd5121 --- /dev/null +++ b/src/enums/project-o-auth-2-git-hub-prompt.ts @@ -0,0 +1,3 @@ +export enum ProjectOAuth2GitHubPrompt { + SelectAccount = 'select_account', +} diff --git a/src/enums/project-o-auth-2-kakao-prompt.ts b/src/enums/project-o-auth-2-kakao-prompt.ts new file mode 100644 index 00000000..6eae8b29 --- /dev/null +++ b/src/enums/project-o-auth-2-kakao-prompt.ts @@ -0,0 +1,6 @@ +export enum ProjectOAuth2KakaoPrompt { + None = 'none', + Login = 'login', + Create = 'create', + SelectAccount = 'select_account', +} diff --git a/src/enums/project-o-auth-2-microsoft-prompt.ts b/src/enums/project-o-auth-2-microsoft-prompt.ts new file mode 100644 index 00000000..27ff7b26 --- /dev/null +++ b/src/enums/project-o-auth-2-microsoft-prompt.ts @@ -0,0 +1,6 @@ +export enum ProjectOAuth2MicrosoftPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', + SelectAccount = 'select_account', +} diff --git a/src/enums/project-o-auth-2-okta-prompt.ts b/src/enums/project-o-auth-2-okta-prompt.ts new file mode 100644 index 00000000..eedf1a01 --- /dev/null +++ b/src/enums/project-o-auth-2-okta-prompt.ts @@ -0,0 +1,5 @@ +export enum ProjectOAuth2OktaPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-salesforce-prompt.ts b/src/enums/project-o-auth-2-salesforce-prompt.ts new file mode 100644 index 00000000..777d4a91 --- /dev/null +++ b/src/enums/project-o-auth-2-salesforce-prompt.ts @@ -0,0 +1,4 @@ +export enum ProjectOAuth2SalesforcePrompt { + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-zoho-prompt.ts b/src/enums/project-o-auth-2-zoho-prompt.ts new file mode 100644 index 00000000..6f67a617 --- /dev/null +++ b/src/enums/project-o-auth-2-zoho-prompt.ts @@ -0,0 +1,3 @@ +export enum ProjectOAuth2ZohoPrompt { + Consent = 'consent', +} diff --git a/src/enums/query-suggestion-resource.ts b/src/enums/query-suggestion-resource.ts index 8e6c0019..272418af 100644 --- a/src/enums/query-suggestion-resource.ts +++ b/src/enums/query-suggestion-resource.ts @@ -40,7 +40,7 @@ export enum QuerySuggestionResource { Buckets = 'buckets', Providers = 'providers', Messages = 'messages', - AppwritePushLedger = 'appwritepushledger', + PushLedger = 'pushledger', Topics = 'topics', Subscribers = 'subscribers', Targets = 'targets', diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 7bbcbb6f..1f3d4823 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -31,6 +31,9 @@ export enum Runtime { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', + Deno121 = 'deno-1.21', + Deno124 = 'deno-1.24', + Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/index.ts b/src/index.ts index fc8cf549..4d501ac5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ /** * Appwrite Console SDK * - * This SDK targets Appwrite server version 2.2.x as shipped on Appwrite Cloud. + * 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-console/releases) @@ -22,6 +22,7 @@ export { Domains } from './services/domains'; export { Embeddings } from './services/embeddings'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; +export { Growth } from './services/growth'; export { Locale } from './services/locale'; export { Manager } from './services/manager'; export { Messaging } from './services/messaging'; @@ -50,6 +51,7 @@ export { VectorsDB } from './services/vectors-db'; export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export { Realtime } from './services/realtime'; +export { Push } from './services/push'; export type { Models, Payload, @@ -57,10 +59,17 @@ export type { UploadProgress, } from './client'; export type { RealtimeSubscription } from './services/realtime'; +export type { + PushMessage, + PushSubscription, + SubscribeOptions, + MessageCallback, +} from './services/push'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; +export { Topic, ResolvedTopic } from './topic'; export { Channel } from './channel'; export { Operator, Condition } from './operator'; export { AccountKeyScopes } from './enums/account-key-scopes'; @@ -96,6 +105,7 @@ export { TemplateReferenceType } from './enums/template-reference-type'; export { VCSReferenceType } from './enums/vcs-reference-type'; export { DeploymentDownloadType } from './enums/deployment-download-type'; export { ExecutionMethod } from './enums/execution-method'; +export { ConversationType } from './enums/conversation-type'; export { BlockResourceType } from './enums/block-resource-type'; export { BlockMode } from './enums/block-mode'; export { Region } from './enums/region'; @@ -112,8 +122,16 @@ export { OrganizationKeyScopes } from './enums/organization-key-scopes'; export { AddonKey } from './enums/addon-key'; export { UsageRange } from './enums/usage-range'; export { ProjectAuthMethodId } from './enums/project-auth-method-id'; +export { ProjectOAuth2Auth0Prompt } from './enums/project-o-auth-2-auth-0-prompt'; +export { ProjectOAuth2DiscordPrompt } from './enums/project-o-auth-2-discord-prompt'; +export { ProjectOAuth2GitHubPrompt } from './enums/project-o-auth-2-git-hub-prompt'; export { ProjectOAuth2GooglePrompt } from './enums/project-o-auth-2-google-prompt'; +export { ProjectOAuth2KakaoPrompt } from './enums/project-o-auth-2-kakao-prompt'; +export { ProjectOAuth2MicrosoftPrompt } from './enums/project-o-auth-2-microsoft-prompt'; export { ProjectOAuth2OidcPrompt } from './enums/project-o-auth-2-oidc-prompt'; +export { ProjectOAuth2OktaPrompt } from './enums/project-o-auth-2-okta-prompt'; +export { ProjectOAuth2SalesforcePrompt } from './enums/project-o-auth-2-salesforce-prompt'; +export { ProjectOAuth2ZohoPrompt } from './enums/project-o-auth-2-zoho-prompt'; export { ProjectOAuthProviderId } from './enums/project-o-auth-provider-id'; export { ProjectPolicyId } from './enums/project-policy-id'; export { ProjectProtocolId } from './enums/project-protocol-id'; @@ -153,8 +171,16 @@ export { DeploymentStatus } from './enums/deployment-status'; export { ExecutionResourceType } from './enums/execution-resource-type'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; +export { OAuth2GithubPrompt } from './enums/o-auth-2-github-prompt'; +export { OAuth2DiscordPrompt } from './enums/o-auth-2-discord-prompt'; export { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +export { OAuth2ZohoPrompt } from './enums/o-auth-2-zoho-prompt'; +export { OAuth2SalesforcePrompt } from './enums/o-auth-2-salesforce-prompt'; +export { OAuth2Auth0Prompt } from './enums/o-auth-2-auth-0-prompt'; export { OAuth2OidcPrompt } from './enums/o-auth-2-oidc-prompt'; +export { OAuth2OktaPrompt } from './enums/o-auth-2-okta-prompt'; +export { OAuth2MicrosoftPrompt } from './enums/o-auth-2-microsoft-prompt'; +export { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; export { PlatformType } from './enums/platform-type'; export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; export { ProxyRuleStatus } from './enums/proxy-rule-status'; diff --git a/src/models.ts b/src/models.ts index 59230f45..a6c959af 100644 --- a/src/models.ts +++ b/src/models.ts @@ -11,8 +11,16 @@ import { ExecutionStatus } from './enums/execution-status'; import { ProjectAuthMethodId } from './enums/project-auth-method-id'; import { ProjectServiceId } from './enums/project-service-id'; import { ProjectProtocolId } from './enums/project-protocol-id'; +import { OAuth2GithubPrompt } from './enums/o-auth-2-github-prompt'; +import { OAuth2DiscordPrompt } from './enums/o-auth-2-discord-prompt'; import { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +import { OAuth2ZohoPrompt } from './enums/o-auth-2-zoho-prompt'; +import { OAuth2SalesforcePrompt } from './enums/o-auth-2-salesforce-prompt'; +import { OAuth2Auth0Prompt } from './enums/o-auth-2-auth-0-prompt'; import { OAuth2OidcPrompt } from './enums/o-auth-2-oidc-prompt'; +import { OAuth2OktaPrompt } from './enums/o-auth-2-okta-prompt'; +import { OAuth2MicrosoftPrompt } from './enums/o-auth-2-microsoft-prompt'; +import { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; import { PlatformType } from './enums/platform-type'; import { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; import { ProxyRuleStatus } from './enums/proxy-rule-status'; @@ -4673,6 +4681,10 @@ export namespace Models { * VCS (Version Control System) installation ID. */ providerInstallationId: string; + /** + * VCS (Version Control System) organization URL. Points at the configured instance, which is not the provider's own host for a self-hosted install. + */ + organizationUrl: string; }; /** @@ -5625,6 +5637,10 @@ export namespace Models { * GitHub OAuth2 client secret. */ clientSecret: string; + /** + * GitHub OAuth2 prompt values. + */ + prompt: OAuth2GithubPrompt[]; }; /** @@ -5647,6 +5663,10 @@ export namespace Models { * Discord OAuth2 client secret. */ clientSecret: string; + /** + * Discord OAuth2 prompt values. + */ + prompt: OAuth2DiscordPrompt[]; }; /** @@ -5879,6 +5899,10 @@ export namespace Models { * Zoho OAuth2 client secret. */ clientSecret: string; + /** + * Zoho OAuth2 prompt values. + */ + prompt: OAuth2ZohoPrompt[]; }; /** @@ -6099,6 +6123,10 @@ export namespace Models { * Salesforce OAuth2 consumer secret. */ customerSecret: string; + /** + * Salesforce OAuth2 prompt values. + */ + prompt: OAuth2SalesforcePrompt[]; }; /** @@ -6415,6 +6443,10 @@ export namespace Models { * Auth0 OAuth2 client secret. */ clientSecret: string; + /** + * Auth0 OAuth2 prompt values. + */ + prompt: OAuth2Auth0Prompt[]; /** * Auth0 OAuth2 endpoint domain. */ @@ -6497,6 +6529,10 @@ export namespace Models { * OpenID Connect OAuth2 client secret. */ clientSecret: string; + /** + * OpenID Connect prompt values controlling the authentication and consent screens. + */ + prompt: OAuth2OidcPrompt[]; /** * OpenID Connect well-known configuration URL. When set, authorization, token, and user info endpoints can be discovered automatically. */ @@ -6513,10 +6549,6 @@ export namespace Models { * OpenID Connect user info endpoint URL. */ userInfoURL: string; - /** - * OpenID Connect prompt values controlling the authentication and consent screens. - */ - prompt: OAuth2OidcPrompt[]; /** * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ @@ -6543,6 +6575,10 @@ export namespace Models { * Okta OAuth2 client secret. */ clientSecret: string; + /** + * Okta OAuth2 prompt values. + */ + prompt: OAuth2OktaPrompt[]; /** * Okta OAuth2 domain. */ @@ -6633,6 +6669,10 @@ export namespace Models { * Microsoft OAuth2 application secret. */ applicationSecret: string; + /** + * Microsoft OAuth2 prompt values. + */ + prompt: OAuth2MicrosoftPrompt[]; /** * Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. */ @@ -6703,6 +6743,10 @@ export namespace Models { * Kakao OAuth2 client secret. */ clientSecret: string; + /** + * Kakao OAuth2 prompt values. + */ + prompt: OAuth2KakaoPrompt[]; }; /** @@ -6847,15 +6891,15 @@ export namespace Models { */ $id: string; /** - * Whether password pwned policy is enabled. + * Whether passwords are checked against known data breaches and the result recorded on the user. */ enabled: boolean; /** - * Whether passwords are checked when a session is created. + * Whether a sign-in with a breached password is refused until the password is reset. */ sessions: boolean; /** - * Whether users signing in with a breached password are blocked until they reset it. Only applies when sessions are checked. + * Whether a breached password is rejected when a user signs up or sets a new password. */ users: boolean; }; @@ -11132,6 +11176,24 @@ export namespace Models { organizationCredits: number; }; + /** + * Growth Conversation + */ + export type GrowthConversation = { + /** + * Conversation type. + */ + type: string; + /** + * Email address the conversation was filed under. For a signed in console user this is the account email. + */ + email: string; + /** + * Organization ID the conversation was filed against. Empty when none was given or the user is not a member. + */ + organizationId: string; + }; + /** * Extensions */ diff --git a/src/services/account.ts b/src/services/account.ts index 8c878fa3..6e00bad5 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -3616,6 +3616,174 @@ export class Account { return this.client.call('put', uri, apiHeaders, payload); } + /** + * Use this endpoint to send a 6-digit password recovery code to the user's email address. Unlike [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a recovery page. Learn more about how to [complete the recovery process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {string} params.email - User email. + * @param {boolean} params.phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecoveryOTP(params: { + email: string; + phrase?: boolean; + }): Promise; + /** + * Use this endpoint to send a 6-digit password recovery code to the user's email address. Unlike [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a recovery page. Learn more about how to [complete the recovery process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {string} email - User email. + * @param {boolean} phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecoveryOTP(email: string, phrase?: boolean): Promise; + createRecoveryOTP( + paramsOrFirst: { email: string; phrase?: boolean } | string, + ...rest: [boolean?] + ): Promise { + let params: { email: string; phrase?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + email: string; + phrase?: boolean; + }; + } else { + params = { + email: paramsOrFirst as string, + phrase: rest[0] as boolean, + }; + } + + const email = params.email; + const phrase = params.phrase; + + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + const apiPath = '/account/recovery/otp'; + const payload: Payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof phrase !== 'undefined') { + payload['phrase'] = phrase; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } + + /** + * Use this endpoint to complete the user password recovery process using the 6-digit code that was emailed by [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). Pass the **userId** of the user along with the **secret** code from the email and the new **password** to set. If confirmed, this route will return a 200 status code, the code is consumed and the user's password is updated. + * + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid recovery OTP code. + * @param {string} params.password - New user password. Must be between 8 and 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecoveryOTP(params: { + userId: string; + secret: string; + password: string; + }): Promise; + /** + * Use this endpoint to complete the user password recovery process using the 6-digit code that was emailed by [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). Pass the **userId** of the user along with the **secret** code from the email and the new **password** to set. If confirmed, this route will return a 200 status code, the code is consumed and the user's password is updated. + * + * + * @param {string} userId - User ID. + * @param {string} secret - Valid recovery OTP code. + * @param {string} password - New user password. Must be between 8 and 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecoveryOTP( + userId: string, + secret: string, + password: string, + ): Promise; + updateRecoveryOTP( + paramsOrFirst: + { userId: string; secret: string; password: string } | string, + ...rest: [string?, string?] + ): Promise { + let params: { userId: string; secret: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + password: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string, + password: rest[1] as string, + }; + } + + const userId = params.userId; + const secret = params.secret; + const password = params.password; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "password"', + ); + } + const apiPath = '/account/recovery/otp'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, payload); + } + /** * Get the list of active sessions across different devices for the currently logged in user. * @@ -4456,7 +4624,7 @@ export class Account { } /** - * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. + * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. A session holds one push target per provider, so if one already exists this endpoint updates and returns that target instead of creating a second one, and a device that rotates its token is never notified twice. * * @param {string} params.targetId - Target 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.identifier - The target identifier (token, email, phone etc.) @@ -4470,7 +4638,7 @@ export class Account { providerId?: string; }): Promise; /** - * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. + * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. A session holds one push target per provider, so if one already exists this endpoint updates and returns that target instead of creating a second one, and a device that rotates its token is never notified twice. * * @param {string} targetId - Target 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} identifier - The target identifier (token, email, phone etc.) diff --git a/src/services/console.ts b/src/services/console.ts index fb2d29db..29b5cc66 100644 --- a/src/services/console.ts +++ b/src/services/console.ts @@ -1063,7 +1063,7 @@ export class Console { /** * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. * - * @param {ProjectEmailTemplateId} params.templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification + * @param {ProjectEmailTemplateId} params.templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} @@ -1075,7 +1075,7 @@ export class Console { /** * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. * - * @param {ProjectEmailTemplateId} templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification + * @param {ProjectEmailTemplateId} templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} diff --git a/src/services/databases.ts b/src/services/databases.ts index c35bd0bb..0d998723 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -7080,7 +7080,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. */ getAttribute(params: { @@ -7089,6 +7089,7 @@ export class Databases { key: string; }): Promise< | Models.AttributeBoolean + | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail @@ -7097,6 +7098,13 @@ export class Databases { | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext | Models.AttributeString >; /** @@ -7106,7 +7114,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getAttribute( @@ -7115,6 +7123,7 @@ export class Databases { key: string, ): Promise< | Models.AttributeBoolean + | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail @@ -7123,6 +7132,13 @@ export class Databases { | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext | Models.AttributeString >; getAttribute( @@ -7131,6 +7147,7 @@ export class Databases { ...rest: [string?, string?] ): Promise< | Models.AttributeBoolean + | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail @@ -7139,6 +7156,13 @@ export class Databases { | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext | Models.AttributeString > { let params: { databaseId: string; collectionId: string; key: string }; diff --git a/src/services/growth.ts b/src/services/growth.ts new file mode 100644 index 00000000..51eaaf3a --- /dev/null +++ b/src/services/growth.ts @@ -0,0 +1,411 @@ +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; +import type { Models } from '../models'; + +import { ConversationType } from '../enums/conversation-type'; +export class Growth { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Create a conversation with the Appwrite team: support requests, product and docs feedback, enterprise, startup and partner applications, and event sponsorship requests. Signed in console users are identified by their session or JWT; everyone else must pass an email. Attach a file of up to 5MB to support and feedback conversations. + * + * @param {ConversationType} params.type - Conversation type. + * @param {string} params.email - Email address to reply to. Required without a console session, ignored with one. + * @param {string} params.name - Name of the person filing the conversation. Required for enterprise, startup, partner and sponsorship. + * @param {string} params.subject - Conversation subject. + * @param {string} params.message - Conversation message. Required for support, feedback, enterprise and partner. + * @param {string} params.organizationId - Organization ID the conversation is about. Kept only when the session user is a member. + * @param {string} params.projectId - Project ID the conversation is about. Kept only when it belongs to the kept organization. + * @param {object} params.attributes - Additional attributes for the conversation type, as an object or a JSON string. + * @param {File} params.attachment - File attachment, support and feedback only, max 5MB. + * @throws {AppwriteException} + * @returns {Promise} + */ + createConversation(params: { + type: ConversationType; + email?: string; + name?: string; + subject?: string; + message?: string; + organizationId?: string; + projectId?: string; + attributes?: object; + attachment?: File; + onProgress?: (progress: UploadProgress) => void; + }): Promise; + /** + * Create a conversation with the Appwrite team: support requests, product and docs feedback, enterprise, startup and partner applications, and event sponsorship requests. Signed in console users are identified by their session or JWT; everyone else must pass an email. Attach a file of up to 5MB to support and feedback conversations. + * + * @param {ConversationType} type - Conversation type. + * @param {string} email - Email address to reply to. Required without a console session, ignored with one. + * @param {string} name - Name of the person filing the conversation. Required for enterprise, startup, partner and sponsorship. + * @param {string} subject - Conversation subject. + * @param {string} message - Conversation message. Required for support, feedback, enterprise and partner. + * @param {string} organizationId - Organization ID the conversation is about. Kept only when the session user is a member. + * @param {string} projectId - Project ID the conversation is about. Kept only when it belongs to the kept organization. + * @param {object} attributes - Additional attributes for the conversation type, as an object or a JSON string. + * @param {File} attachment - File attachment, support and feedback only, max 5MB. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createConversation( + type: ConversationType, + email?: string, + name?: string, + subject?: string, + message?: string, + organizationId?: string, + projectId?: string, + attributes?: object, + attachment?: File, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createConversation( + paramsOrFirst: + | { + type: ConversationType; + email?: string; + name?: string; + subject?: string; + message?: string; + organizationId?: string; + projectId?: string; + attributes?: object; + attachment?: File; + onProgress?: (progress: UploadProgress) => void; + } + | ConversationType, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + object?, + File?, + ((progress: UploadProgress) => void)?, + ] + ): Promise { + let params: { + type: ConversationType; + email?: string; + name?: string; + subject?: string; + message?: string; + organizationId?: string; + projectId?: string; + attributes?: object; + attachment?: File; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('type' in paramsOrFirst || + 'email' in paramsOrFirst || + 'name' in paramsOrFirst || + 'subject' in paramsOrFirst || + 'message' in paramsOrFirst || + 'organizationId' in paramsOrFirst || + 'projectId' in paramsOrFirst || + 'attributes' in paramsOrFirst || + 'attachment' in paramsOrFirst || + 'onProgress' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + type: ConversationType; + email?: string; + name?: string; + subject?: string; + message?: string; + organizationId?: string; + projectId?: string; + attributes?: object; + attachment?: File; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; + } else { + params = { + type: paramsOrFirst as ConversationType, + email: rest[0] as string, + name: rest[1] as string, + subject: rest[2] as string, + message: rest[3] as string, + organizationId: rest[4] as string, + projectId: rest[5] as string, + attributes: rest[6] as object, + attachment: rest[7] as File, + }; + onProgress = rest[8] as (progress: UploadProgress) => void; + } + + const type = params.type; + const email = params.email; + const name = params.name; + const subject = params.subject; + const message = params.message; + const organizationId = params.organizationId; + const projectId = params.projectId; + const attributes = params.attributes; + const attachment = params.attachment; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + const apiPath = '/growth/conversations'; + const payload: Payload = {}; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof subject !== 'undefined') { + payload['subject'] = subject; + } + if (typeof message !== 'undefined') { + payload['message'] = message; + } + if (typeof organizationId !== 'undefined') { + payload['organizationId'] = organizationId; + } + if (typeof projectId !== 'undefined') { + payload['projectId'] = projectId; + } + if (typeof attributes !== 'undefined') { + payload['attributes'] = attributes; + } + if (typeof attachment !== 'undefined') { + payload['attachment'] = attachment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'multipart/form-data', + accept: 'application/json', + }; + + return this.client.chunkedUpload( + 'post', + uri, + apiHeaders, + payload, + onProgress, + ); + } + + /** + * Record a self-hosted installation. Every report is stored as its own row; the admin email is optional because headless CLI installs create no account. + * + * @param {string} params.email - Admin email from the installation, when an account was created. + * @param {string} params.name - Admin name. + * @param {string} params.version - Appwrite version. + * @param {string} params.domain - Installation domain. + * @param {string} params.database - Database adapter. + * @param {string} params.hostIp - Resolved installation host IP address. + * @param {string} params.userAgent - Installation user agent. + * @param {string} params.os - Installation operating system. + * @param {string} params.arch - Installation CPU architecture. + * @param {number} params.cpus - Installation CPU count. + * @param {number} params.ram - Installation RAM in MB. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + createInstallation(params?: { + email?: string; + name?: string; + version?: string; + domain?: string; + database?: string; + hostIp?: string; + userAgent?: string; + os?: string; + arch?: string; + cpus?: number; + ram?: number; + }): Promise<{}>; + /** + * Record a self-hosted installation. Every report is stored as its own row; the admin email is optional because headless CLI installs create no account. + * + * @param {string} email - Admin email from the installation, when an account was created. + * @param {string} name - Admin name. + * @param {string} version - Appwrite version. + * @param {string} domain - Installation domain. + * @param {string} database - Database adapter. + * @param {string} hostIp - Resolved installation host IP address. + * @param {string} userAgent - Installation user agent. + * @param {string} os - Installation operating system. + * @param {string} arch - Installation CPU architecture. + * @param {number} cpus - Installation CPU count. + * @param {number} ram - Installation RAM in MB. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createInstallation( + email?: string, + name?: string, + version?: string, + domain?: string, + database?: string, + hostIp?: string, + userAgent?: string, + os?: string, + arch?: string, + cpus?: number, + ram?: number, + ): Promise<{}>; + createInstallation( + paramsOrFirst?: + | { + email?: string; + name?: string; + version?: string; + domain?: string; + database?: string; + hostIp?: string; + userAgent?: string; + os?: string; + arch?: string; + cpus?: number; + ram?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + number?, + ] + ): Promise<{}> { + let params: { + email?: string; + name?: string; + version?: string; + domain?: string; + database?: string; + hostIp?: string; + userAgent?: string; + os?: string; + arch?: string; + cpus?: number; + ram?: number; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + email?: string; + name?: string; + version?: string; + domain?: string; + database?: string; + hostIp?: string; + userAgent?: string; + os?: string; + arch?: string; + cpus?: number; + ram?: number; + }; + } else { + params = { + email: paramsOrFirst as string, + name: rest[0] as string, + version: rest[1] as string, + domain: rest[2] as string, + database: rest[3] as string, + hostIp: rest[4] as string, + userAgent: rest[5] as string, + os: rest[6] as string, + arch: rest[7] as string, + cpus: rest[8] as number, + ram: rest[9] as number, + }; + } + + const email = params.email; + const name = params.name; + const version = params.version; + const domain = params.domain; + const database = params.database; + const hostIp = params.hostIp; + const userAgent = params.userAgent; + const os = params.os; + const arch = params.arch; + const cpus = params.cpus; + const ram = params.ram; + + const apiPath = '/growth/installations'; + const payload: Payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof version !== 'undefined') { + payload['version'] = version; + } + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof database !== 'undefined') { + payload['database'] = database; + } + if (typeof hostIp !== 'undefined') { + payload['hostIp'] = hostIp; + } + if (typeof userAgent !== 'undefined') { + payload['userAgent'] = userAgent; + } + if (typeof os !== 'undefined') { + payload['os'] = os; + } + if (typeof arch !== 'undefined') { + payload['arch'] = arch; + } + if (typeof cpus !== 'undefined') { + payload['cpus'] = cpus; + } + if (typeof ram !== 'undefined') { + payload['ram'] = ram; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, payload); + } +} diff --git a/src/services/manager.ts b/src/services/manager.ts index bb85bed7..ed58a586 100644 --- a/src/services/manager.ts +++ b/src/services/manager.ts @@ -451,6 +451,97 @@ export class Manager { return this.client.call('delete', uri, apiHeaders, payload); } + /** + * Blocks or unblocks an organization, the same way a billing-limit block does. Blocking makes the organization read-only, disables its backup policies and spins down its dedicated databases. + * + * @param {string} params.teamId - Organization ID. + * @param {boolean} params.status - Organization status. Set to `false` to block and `true` to unblock. + * @param {string} params.reason - Optional reason when blocking, kept in the audit trail. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updateOrganizationStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + teamId: string; + status: boolean; + reason?: string; + }): Promise>; + /** + * Blocks or unblocks an organization, the same way a billing-limit block does. Blocking makes the organization read-only, disables its backup policies and spins down its dedicated databases. + * + * @param {string} teamId - Organization ID. + * @param {boolean} status - Organization status. Set to `false` to block and `true` to unblock. + * @param {string} reason - Optional reason when blocking, kept in the audit trail. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOrganizationStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + teamId: string, + status: boolean, + reason?: string, + ): Promise>; + updateOrganizationStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { teamId: string; status: boolean; reason?: string } | string, + ...rest: [boolean?, string?] + ): Promise> { + let params: { teamId: string; status: boolean; reason?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + status: boolean; + reason?: string; + }; + } else { + params = { + teamId: paramsOrFirst as string, + status: rest[0] as boolean, + reason: rest[1] as string, + }; + } + + const teamId = params.teamId; + const status = params.status; + const reason = params.reason; + + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (typeof status === 'undefined') { + throw new AppwriteException('Missing required parameter: "status"'); + } + const apiPath = '/manager/organizations/status'; + const payload: Payload = {}; + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof reason !== 'undefined') { + payload['reason'] = reason; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + /** * Updates a console user status using a user ID or email address. * diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 73aefb81..664f7220 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -102,6 +102,8 @@ export class Messaging { * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. @@ -118,6 +120,8 @@ export class Messaging { cc?: string[]; bcc?: string[]; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; draft?: boolean; html?: boolean; scheduledAt?: string; @@ -134,6 +138,8 @@ export class Messaging { * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. @@ -151,6 +157,8 @@ export class Messaging { cc?: string[], bcc?: string[], attachments?: string[], + replyToEmail?: string, + replyToName?: string, draft?: boolean, html?: boolean, scheduledAt?: string, @@ -167,6 +175,8 @@ export class Messaging { cc?: string[]; bcc?: string[]; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; draft?: boolean; html?: boolean; scheduledAt?: string; @@ -181,6 +191,8 @@ export class Messaging { string[]?, string[]?, string[]?, + string?, + string?, boolean?, boolean?, string?, @@ -196,6 +208,8 @@ export class Messaging { cc?: string[]; bcc?: string[]; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; draft?: boolean; html?: boolean; scheduledAt?: string; @@ -216,6 +230,8 @@ export class Messaging { cc?: string[]; bcc?: string[]; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; draft?: boolean; html?: boolean; scheduledAt?: string; @@ -231,9 +247,11 @@ export class Messaging { cc: rest[5] as string[], bcc: rest[6] as string[], attachments: rest[7] as string[], - draft: rest[8] as boolean, - html: rest[9] as boolean, - scheduledAt: rest[10] as string, + replyToEmail: rest[8] as string, + replyToName: rest[9] as string, + draft: rest[10] as boolean, + html: rest[11] as boolean, + scheduledAt: rest[12] as string, }; } @@ -246,6 +264,8 @@ export class Messaging { const cc = params.cc; const bcc = params.bcc; const attachments = params.attachments; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; @@ -294,6 +314,12 @@ export class Messaging { if (typeof attachments !== 'undefined') { payload['attachments'] = attachments; } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } if (typeof draft !== 'undefined') { payload['draft'] = draft; } @@ -328,6 +354,8 @@ export class Messaging { * @param {boolean} params.html - Is content of type HTML * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. + * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. * @throws {AppwriteException} @@ -344,6 +372,8 @@ export class Messaging { html?: boolean; cc?: string[]; bcc?: string[]; + replyToEmail?: string; + replyToName?: string; scheduledAt?: string; attachments?: string[]; }): Promise; @@ -361,6 +391,8 @@ export class Messaging { * @param {boolean} html - Is content of type HTML * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. + * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. * @throws {AppwriteException} @@ -378,6 +410,8 @@ export class Messaging { html?: boolean, cc?: string[], bcc?: string[], + replyToEmail?: string, + replyToName?: string, scheduledAt?: string, attachments?: string[], ): Promise; @@ -394,6 +428,8 @@ export class Messaging { html?: boolean; cc?: string[]; bcc?: string[]; + replyToEmail?: string; + replyToName?: string; scheduledAt?: string; attachments?: string[]; } @@ -409,6 +445,8 @@ export class Messaging { string[]?, string[]?, string?, + string?, + string?, string[]?, ] ): Promise { @@ -423,6 +461,8 @@ export class Messaging { html?: boolean; cc?: string[]; bcc?: string[]; + replyToEmail?: string; + replyToName?: string; scheduledAt?: string; attachments?: string[]; }; @@ -443,6 +483,8 @@ export class Messaging { html?: boolean; cc?: string[]; bcc?: string[]; + replyToEmail?: string; + replyToName?: string; scheduledAt?: string; attachments?: string[]; }; @@ -458,8 +500,10 @@ export class Messaging { html: rest[6] as boolean, cc: rest[7] as string[], bcc: rest[8] as string[], - scheduledAt: rest[9] as string, - attachments: rest[10] as string[], + replyToEmail: rest[9] as string, + replyToName: rest[10] as string, + scheduledAt: rest[11] as string, + attachments: rest[12] as string[], }; } @@ -473,6 +517,8 @@ export class Messaging { const html = params.html; const cc = params.cc; const bcc = params.bcc; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; const scheduledAt = params.scheduledAt; const attachments = params.attachments; @@ -513,6 +559,12 @@ export class Messaging { if (typeof bcc !== 'undefined') { payload['bcc'] = bcc; } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } if (typeof scheduledAt !== 'undefined') { payload['scheduledAt'] = scheduledAt; } diff --git a/src/services/organizations.ts b/src/services/organizations.ts index d79e4d9b..17ac4dd7 100644 --- a/src/services/organizations.ts +++ b/src/services/organizations.ts @@ -1836,64 +1836,6 @@ export class Organizations { return this.client.call('get', uri, apiHeaders, payload); } - /** - * Get an estimate of the charge for the organization current billing cycle. - * - * @param {string} params.organizationId - Organization ID - * @throws {AppwriteException} - * @returns {Promise} - */ - getEstimation(params: { - organizationId: string; - }): Promise; - /** - * Get an estimate of the charge for the organization current billing cycle. - * - * @param {string} organizationId - Organization ID - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getEstimation(organizationId: string): Promise; - getEstimation( - paramsOrFirst: { organizationId: string } | string, - ): Promise { - let params: { organizationId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { organizationId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - }; - } - - const organizationId = params.organizationId; - - if (typeof organizationId === 'undefined' || organizationId === '') { - throw new AppwriteException( - 'Missing required parameter: "organizationId"', - ); - } - const apiPath = '/organizations/{organizationId}/estimations'.replace( - '{organizationId}', - encodeURIComponent(String(organizationId)), - ); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, payload); - } - /** * Get estimation for deleting an organization. * diff --git a/src/services/project.ts b/src/services/project.ts index b41100a8..c843de32 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -3,8 +3,16 @@ import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; import { ProjectKeyScopes } from '../enums/project-key-scopes'; +import { ProjectOAuth2Auth0Prompt } from '../enums/project-o-auth-2-auth-0-prompt'; +import { ProjectOAuth2DiscordPrompt } from '../enums/project-o-auth-2-discord-prompt'; +import { ProjectOAuth2GitHubPrompt } from '../enums/project-o-auth-2-git-hub-prompt'; import { ProjectOAuth2GooglePrompt } from '../enums/project-o-auth-2-google-prompt'; +import { ProjectOAuth2KakaoPrompt } from '../enums/project-o-auth-2-kakao-prompt'; +import { ProjectOAuth2MicrosoftPrompt } from '../enums/project-o-auth-2-microsoft-prompt'; import { ProjectOAuth2OidcPrompt } from '../enums/project-o-auth-2-oidc-prompt'; +import { ProjectOAuth2OktaPrompt } from '../enums/project-o-auth-2-okta-prompt'; +import { ProjectOAuth2SalesforcePrompt } from '../enums/project-o-auth-2-salesforce-prompt'; +import { ProjectOAuth2ZohoPrompt } from '../enums/project-o-auth-2-zoho-prompt'; import { ProjectOAuthProviderId } from '../enums/project-o-auth-provider-id'; import { ProjectPolicyId } from '../enums/project-policy-id'; import { ProjectProtocolId } from '../enums/project-protocol-id'; @@ -1646,6 +1654,7 @@ export class Project { * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -1654,6 +1663,7 @@ export class Project { clientId?: string; clientSecret?: string; endpoint?: string; + prompt?: ProjectOAuth2Auth0Prompt[]; enabled?: boolean; }): Promise; /** @@ -1662,6 +1672,7 @@ export class Project { * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -1671,6 +1682,7 @@ export class Project { clientId?: string, clientSecret?: string, endpoint?: string, + prompt?: ProjectOAuth2Auth0Prompt[], enabled?: boolean, ): Promise; updateOAuth2Auth0( @@ -1679,15 +1691,17 @@ export class Project { clientId?: string; clientSecret?: string; endpoint?: string; + prompt?: ProjectOAuth2Auth0Prompt[]; enabled?: boolean; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [string?, string?, ProjectOAuth2Auth0Prompt[]?, boolean?] ): Promise { let params: { clientId?: string; clientSecret?: string; endpoint?: string; + prompt?: ProjectOAuth2Auth0Prompt[]; enabled?: boolean; }; @@ -1701,6 +1715,7 @@ export class Project { clientId?: string; clientSecret?: string; endpoint?: string; + prompt?: ProjectOAuth2Auth0Prompt[]; enabled?: boolean; }; } else { @@ -1708,13 +1723,15 @@ export class Project { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean, + prompt: rest[2] as ProjectOAuth2Auth0Prompt[], + enabled: rest[3] as boolean, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/auth0'; @@ -1728,6 +1745,9 @@ export class Project { if (typeof endpoint !== 'undefined') { payload['endpoint'] = endpoint; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -2355,6 +2375,7 @@ export class Project { * * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -2362,6 +2383,7 @@ export class Project { updateOAuth2Discord(params?: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2DiscordPrompt[]; enabled?: boolean; }): Promise; /** @@ -2369,6 +2391,7 @@ export class Project { * * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -2377,17 +2400,24 @@ export class Project { updateOAuth2Discord( clientId?: string, clientSecret?: string, + prompt?: ProjectOAuth2DiscordPrompt[], enabled?: boolean, ): Promise; updateOAuth2Discord( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2DiscordPrompt[]; + enabled?: boolean; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, ProjectOAuth2DiscordPrompt[]?, boolean?] ): Promise { let params: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2DiscordPrompt[]; enabled?: boolean; }; @@ -2400,18 +2430,21 @@ export class Project { params = (paramsOrFirst || {}) as { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2DiscordPrompt[]; enabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + prompt: rest[1] as ProjectOAuth2DiscordPrompt[], + enabled: rest[2] as boolean, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/discord'; @@ -2422,6 +2455,9 @@ export class Project { if (typeof clientSecret !== 'undefined') { payload['clientSecret'] = clientSecret; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -2963,6 +2999,7 @@ export class Project { * * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -2970,6 +3007,7 @@ export class Project { updateOAuth2GitHub(params?: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2GitHubPrompt[]; enabled?: boolean; }): Promise; /** @@ -2977,6 +3015,7 @@ export class Project { * * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -2985,17 +3024,24 @@ export class Project { updateOAuth2GitHub( clientId?: string, clientSecret?: string, + prompt?: ProjectOAuth2GitHubPrompt[], enabled?: boolean, ): Promise; updateOAuth2GitHub( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GitHubPrompt[]; + enabled?: boolean; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, ProjectOAuth2GitHubPrompt[]?, boolean?] ): Promise { let params: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2GitHubPrompt[]; enabled?: boolean; }; @@ -3008,18 +3054,21 @@ export class Project { params = (paramsOrFirst || {}) as { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2GitHubPrompt[]; enabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + prompt: rest[1] as ProjectOAuth2GitHubPrompt[], + enabled: rest[2] as boolean, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/github'; @@ -3030,6 +3079,9 @@ export class Project { if (typeof clientSecret !== 'undefined') { payload['clientSecret'] = clientSecret; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -3369,6 +3421,7 @@ export class Project { * * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -3376,6 +3429,7 @@ export class Project { updateOAuth2Kakao(params?: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; enabled?: boolean; }): Promise; /** @@ -3383,6 +3437,7 @@ export class Project { * * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -3391,17 +3446,24 @@ export class Project { updateOAuth2Kakao( clientId?: string, clientSecret?: string, + prompt?: ProjectOAuth2KakaoPrompt[], enabled?: boolean, ): Promise; updateOAuth2Kakao( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; + enabled?: boolean; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] ): Promise { let params: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; enabled?: boolean; }; @@ -3414,18 +3476,21 @@ export class Project { params = (paramsOrFirst || {}) as { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; enabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + prompt: rest[1] as ProjectOAuth2KakaoPrompt[], + enabled: rest[2] as boolean, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/kakao'; @@ -3436,6 +3501,9 @@ export class Project { if (typeof clientSecret !== 'undefined') { payload['clientSecret'] = clientSecret; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -3746,6 +3814,7 @@ export class Project { * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -3754,6 +3823,7 @@ export class Project { applicationId?: string; applicationSecret?: string; tenant?: string; + prompt?: ProjectOAuth2MicrosoftPrompt[]; enabled?: boolean; }): Promise; /** @@ -3762,6 +3832,7 @@ export class Project { * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -3771,6 +3842,7 @@ export class Project { applicationId?: string, applicationSecret?: string, tenant?: string, + prompt?: ProjectOAuth2MicrosoftPrompt[], enabled?: boolean, ): Promise; updateOAuth2Microsoft( @@ -3779,15 +3851,17 @@ export class Project { applicationId?: string; applicationSecret?: string; tenant?: string; + prompt?: ProjectOAuth2MicrosoftPrompt[]; enabled?: boolean; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [string?, string?, ProjectOAuth2MicrosoftPrompt[]?, boolean?] ): Promise { let params: { applicationId?: string; applicationSecret?: string; tenant?: string; + prompt?: ProjectOAuth2MicrosoftPrompt[]; enabled?: boolean; }; @@ -3801,6 +3875,7 @@ export class Project { applicationId?: string; applicationSecret?: string; tenant?: string; + prompt?: ProjectOAuth2MicrosoftPrompt[]; enabled?: boolean; }; } else { @@ -3808,13 +3883,15 @@ export class Project { applicationId: paramsOrFirst as string, applicationSecret: rest[0] as string, tenant: rest[1] as string, - enabled: rest[2] as boolean, + prompt: rest[2] as ProjectOAuth2MicrosoftPrompt[], + enabled: rest[3] as boolean, }; } const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/microsoft'; @@ -3828,6 +3905,9 @@ export class Project { if (typeof tenant !== 'undefined') { payload['tenant'] = tenant; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -4110,6 +4190,7 @@ export class Project { * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -4119,6 +4200,7 @@ export class Project { clientSecret?: string; domain?: string; authorizationServerId?: string; + prompt?: ProjectOAuth2OktaPrompt[]; enabled?: boolean; }): Promise; /** @@ -4128,6 +4210,7 @@ export class Project { * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -4138,6 +4221,7 @@ export class Project { clientSecret?: string, domain?: string, authorizationServerId?: string, + prompt?: ProjectOAuth2OktaPrompt[], enabled?: boolean, ): Promise; updateOAuth2Okta( @@ -4147,16 +4231,24 @@ export class Project { clientSecret?: string; domain?: string; authorizationServerId?: string; + prompt?: ProjectOAuth2OktaPrompt[]; enabled?: boolean; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + string?, + string?, + ProjectOAuth2OktaPrompt[]?, + boolean?, + ] ): Promise { let params: { clientId?: string; clientSecret?: string; domain?: string; authorizationServerId?: string; + prompt?: ProjectOAuth2OktaPrompt[]; enabled?: boolean; }; @@ -4171,6 +4263,7 @@ export class Project { clientSecret?: string; domain?: string; authorizationServerId?: string; + prompt?: ProjectOAuth2OktaPrompt[]; enabled?: boolean; }; } else { @@ -4179,7 +4272,8 @@ export class Project { clientSecret: rest[0] as string, domain: rest[1] as string, authorizationServerId: rest[2] as string, - enabled: rest[3] as boolean, + prompt: rest[3] as ProjectOAuth2OktaPrompt[], + enabled: rest[4] as boolean, }; } @@ -4187,6 +4281,7 @@ export class Project { const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/okta'; @@ -4203,6 +4298,9 @@ export class Project { if (typeof authorizationServerId !== 'undefined') { payload['authorizationServerId'] = authorizationServerId; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -4566,6 +4664,7 @@ export class Project { * * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -4573,6 +4672,7 @@ export class Project { updateOAuth2Salesforce(params?: { customerKey?: string; customerSecret?: string; + prompt?: ProjectOAuth2SalesforcePrompt[]; enabled?: boolean; }): Promise; /** @@ -4580,6 +4680,7 @@ export class Project { * * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -4588,6 +4689,7 @@ export class Project { updateOAuth2Salesforce( customerKey?: string, customerSecret?: string, + prompt?: ProjectOAuth2SalesforcePrompt[], enabled?: boolean, ): Promise; updateOAuth2Salesforce( @@ -4595,14 +4697,16 @@ export class Project { | { customerKey?: string; customerSecret?: string; + prompt?: ProjectOAuth2SalesforcePrompt[]; enabled?: boolean; } | string, - ...rest: [string?, boolean?] + ...rest: [string?, ProjectOAuth2SalesforcePrompt[]?, boolean?] ): Promise { let params: { customerKey?: string; customerSecret?: string; + prompt?: ProjectOAuth2SalesforcePrompt[]; enabled?: boolean; }; @@ -4615,18 +4719,21 @@ export class Project { params = (paramsOrFirst || {}) as { customerKey?: string; customerSecret?: string; + prompt?: ProjectOAuth2SalesforcePrompt[]; enabled?: boolean; }; } else { params = { customerKey: paramsOrFirst as string, customerSecret: rest[0] as string, - enabled: rest[1] as boolean, + prompt: rest[1] as ProjectOAuth2SalesforcePrompt[], + enabled: rest[2] as boolean, }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/salesforce'; @@ -4637,6 +4744,9 @@ export class Project { if (typeof customerSecret !== 'undefined') { payload['customerSecret'] = customerSecret; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -5610,6 +5720,7 @@ export class Project { * * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -5617,6 +5728,7 @@ export class Project { updateOAuth2Zoho(params?: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2ZohoPrompt[]; enabled?: boolean; }): Promise; /** @@ -5624,6 +5736,7 @@ export class Project { * * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} * @returns {Promise} @@ -5632,17 +5745,24 @@ export class Project { updateOAuth2Zoho( clientId?: string, clientSecret?: string, + prompt?: ProjectOAuth2ZohoPrompt[], enabled?: boolean, ): Promise; updateOAuth2Zoho( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2ZohoPrompt[]; + enabled?: boolean; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, ProjectOAuth2ZohoPrompt[]?, boolean?] ): Promise { let params: { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2ZohoPrompt[]; enabled?: boolean; }; @@ -5655,18 +5775,21 @@ export class Project { params = (paramsOrFirst || {}) as { clientId?: string; clientSecret?: string; + prompt?: ProjectOAuth2ZohoPrompt[]; enabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + prompt: rest[1] as ProjectOAuth2ZohoPrompt[], + enabled: rest[2] as boolean, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; + const prompt = params.prompt; const enabled = params.enabled; const apiPath = '/project/oauth2/zoho'; @@ -5677,6 +5800,9 @@ export class Project { if (typeof clientSecret !== 'undefined') { payload['clientSecret'] = clientSecret; } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } @@ -7856,11 +7982,11 @@ export class Project { } /** - * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, a password that appears in any known breach cannot be set or changed. Enable `sessions` to check passwords on sign-in too. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. + * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, every password a user signs up, signs in or resets with is checked and the result is recorded on the user as `passwordPwned`. On its own the policy only records. Enable `users` to reject a breached password when a user signs up or sets a new password, and `sessions` to refuse a sign-in with a breached password until it is reset. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. * - * @param {boolean} params.enabled - Toggle password pwned policy. Set to true to block passwords exposed in known data breaches, or false to allow them. Default is true. When changing this policy, existing passwords remain valid. - * @param {boolean} params.sessions - Whether passwords are checked when a session is created. When enabled, signing in records whether the password appears in a known data breach. Default is false. - * @param {boolean} params.users - Whether users signing in with a breached password are blocked until they reset it. Only applies when sessions are checked. Default is false, which allows the sign-in. + * @param {boolean} params.enabled - Toggle password pwned policy. Set to true to check passwords against known data breaches and record the result on the user, or false to never check. Default is true. On its own this only records; use `users` and `sessions` to block. When changing this policy, existing passwords remain valid. + * @param {boolean} params.sessions - Whether a sign-in with a breached password is refused until the password is reset. Default is false, which allows the sign-in and only records the result. + * @param {boolean} params.users - Whether a breached password is rejected when a user signs up or sets a new password. Default is false, which allows the password and only records the result. * @throws {AppwriteException} * @returns {Promise} */ @@ -7870,11 +7996,11 @@ export class Project { users?: boolean; }): Promise; /** - * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, a password that appears in any known breach cannot be set or changed. Enable `sessions` to check passwords on sign-in too. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. + * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, every password a user signs up, signs in or resets with is checked and the result is recorded on the user as `passwordPwned`. On its own the policy only records. Enable `users` to reject a breached password when a user signs up or sets a new password, and `sessions` to refuse a sign-in with a breached password until it is reset. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. * - * @param {boolean} enabled - Toggle password pwned policy. Set to true to block passwords exposed in known data breaches, or false to allow them. Default is true. When changing this policy, existing passwords remain valid. - * @param {boolean} sessions - Whether passwords are checked when a session is created. When enabled, signing in records whether the password appears in a known data breach. Default is false. - * @param {boolean} users - Whether users signing in with a breached password are blocked until they reset it. Only applies when sessions are checked. Default is false, which allows the sign-in. + * @param {boolean} enabled - Toggle password pwned policy. Set to true to check passwords against known data breaches and record the result on the user, or false to never check. Default is true. On its own this only records; use `users` and `sessions` to block. When changing this policy, existing passwords remain valid. + * @param {boolean} sessions - Whether a sign-in with a breached password is refused until the password is reset. Default is false, which allows the sign-in and only records the result. + * @param {boolean} users - Whether a breached password is rejected when a user signs up or sets a new password. Default is false, which allows the password and only records the result. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -8927,7 +9053,7 @@ export class Project { /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification + * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -8951,7 +9077,7 @@ export class Project { /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification + * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @param {string} subject - Subject of the email template. Can be up to 255 characters. * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -9097,7 +9223,7 @@ export class Project { /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification + * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} @@ -9109,7 +9235,7 @@ export class Project { /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification + * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} diff --git a/src/services/push.ts b/src/services/push.ts new file mode 100644 index 00000000..2d197c90 --- /dev/null +++ b/src/services/push.ts @@ -0,0 +1,754 @@ +import { Buffer } from 'buffer'; +import mqtt, { + type IClientOptions, + type IConnackPacket, + type IPublishPacket, + type MqttClient, +} from 'mqtt'; + +import { Client } from '../client'; +import { Service } from '../service'; +import type { ResolvedTopic, Topic } from '../topic'; + +/** A message delivered on a subscribed topic (the MQTT analog of a Realtime event). */ +export interface PushMessage { + topic: string; + /** The payload decoded as UTF-8 text, as it was sent. */ + data: string; + /** The raw payload, for binary messages. */ + payload: Uint8Array; + qos: number; +} + +export type MessageCallback = (message: PushMessage) => void | Promise; + +/** Per-subscription options passed to `subscribe` and `PushSubscription.update`. */ +export interface SubscribeOptions { + /** + * Also surface each matching message as a browser notification while the tab is + * open. Defaults to false. + */ + background?: boolean; + /** Notification title for this subscription. Defaults to the message topic. */ + title?: string; + /** + * Retry delivery of messages missed while disconnected. `true` (the default) subscribes + * at QoS 1 so the broker holds this topic's messages and redelivers them on reconnect; + * `false` uses QoS 0 (at-most-once, may be lost). Per-subscription — the connection + * always keeps its session (clean start off). + */ + retry?: boolean; +} + +/** + * Handle for a live subscription. `unsubscribe()` drops it (and closes the connection + * once the last one is gone); `update()` toggles this subscription's per-message options + * without resubscribing. + */ +export interface PushSubscription { + unsubscribe(): void; + update(options: SubscribeOptions): void; +} + +type AuthMethod = 'appwrite-jwt' | 'appwrite-session' | ''; + +// Fixed connection tuning — not exposed as options. +const KEEP_ALIVE_SECONDS = 60; +const RECONNECT_PERIOD_MS = 2000; + +/** + * Appwrite native push service — the Realtime analog over an MQTT broker, without + * FCM or APNS. In the browser the transport is MQTT 5 over WebSocket: while the page is + * open the connection stays up and each message is handed to your callback, and a + * subscription may also opt into a browser notification per message. + * + * The connection has no tunables — it always keeps its session (clean start off) so the + * broker can redeliver missed messages, and reliability is chosen per subscription via + * `retry`. `subscribe` opens the connection lazily and returns a + * {@link PushSubscription} handle (unlike Realtime's bare unsubscribe callable — Push + * carries per-subscription state). The credential is read off the client — set a JWT or + * session on it (`Client.setJWT` / `Client.setSession`), the same way every other service + * reads auth. + * + * const client = new Client().setEndpoint(...).setProject(...).setJWT(jwt); + * const push = new Push(client); + * const sub = await push.subscribe('user/123/#', (m) => + * console.log(m.topic, m.data), + * ); + * // sub.update({ background: true }); sub.unsubscribe(); + */ +export class Push extends Service { + private mqtt: MqttClient | null = null; + private connecting: Promise | null = null; + /** Set once the first CONNACK lands, so 'connect' events after are reconnects. */ + private everConnected = false; + + private onOpenCb?: () => void; + private onCloseCb?: () => void; + private onErrorCb?: (error: Error) => void; + /** Errors already handed to onError, so one failure is reported once. */ + private reported = new WeakSet(); + /** mqtt.js connect errors mapped to the error handed out for them (see connectError). */ + private connectErrors = new WeakMap(); + /** True while the first connect is in flight: its errors go to the waiting caller. */ + private opening = false; + + // Local id -> subscription state. The id is never sent to the broker; it only lets + // the same topic carry more than one callback (each with its own options). + /** + * The client id when the credential names no user (and none was set): random, but kept for + * this instance so reconnects resume the same broker session. + */ + private readonly fallbackClientId = randomId(); + + private readonly subscriptions = new Map< + string, + { + topic: string; + callback: MessageCallback; + background: boolean; + title?: string; + qos: 0 | 1; + } + >(); + + constructor(client: Client) { + super(client); + } + + // The broker subscription for a filter uses the highest QoS any local subscription on + // it wants, so a QoS-0 subscription never downgrades a QoS-1 one sharing the filter. + private effectiveQos(filter: string): 0 | 1 { + for (const sub of this.subscriptions.values()) { + if (sub.topic === filter && sub.qos === 1) { + return 1; + } + } + return 0; + } + + /** Register a callback invoked when the connection opens (CONNACK success). */ + onOpen(callback: () => void): this { + this.onOpenCb = callback; + return this; + } + + /** Register a callback invoked when the connection closes. */ + onClose(callback: () => void): this { + this.onCloseCb = callback; + return this; + } + + /** Register a callback invoked on a connection error. */ + onError(callback: (error: Error) => void): this { + this.onErrorCb = callback; + return this; + } + + /** + * The signed-in user's own topic, `users/`, for a topic-less subscribe. The id comes + * from the credential the connection authenticates with: the JWT when one is set (never + * the session, which could belong to a different user), else the session. + */ + private userTopic(): string { + const { jwt, session } = this.client.config; + const userId = jwt ? userIdFromJwt(jwt) : userIdFromSession(session); + if (!userId) { + throw new Error( + 'subscribe() without a topic needs a signed-in user: set a JWT or session on the client', + ); + } + return `users/${userId}`; + } + + /** + * Hand an error to the onError callback, once per error. These errors happen outside any + * call (reconnects, broker DISCONNECTs, background re-subscribes), so they are never + * thrown, which would crash the app from inside mqtt.js: with no callback registered + * they are logged, like Realtime does. + */ + private report(error: unknown): void { + const err = toError(error); + if (this.reported.has(err)) { + return; + } + this.reported.add(err); + if (!this.onErrorCb) { + console.error('Appwrite Push error:', err); + return; + } + try { + this.onErrorCb(err); + } catch (callbackError) { + console.error('Appwrite Push onError threw:', callbackError); + } + } + + /** + * For a call that fails to its caller: report the error to onError when a callback is + * registered, then throw it to the caller, who can catch it. + */ + private fail(error: unknown): never { + const err = toError(error); + if (this.onErrorCb) { + this.report(err); + } + throw err; + } + + // --- realtime-like API --- + + /** + * Subscribe to one or more topics. Resolves to a {@link PushSubscription} handle. + * + * Each topic is a string or a `Topic` builder, e.g. + * `Topic.path(['user', userId]).all()`. + * + * Called with only a callback, `subscribe((message) => {...}, options)` subscribes to the + * signed-in user's own topic, `users/`, like FCM/APNs delivery to a device. The + * user id is read from the JWT (or session) set on the client. This form defaults to + * `background: true` and `retry: true` (QoS 1); pass either in the options to override. + * + * Awaiting resolves only once the broker has acked every SUBSCRIBE (SUBACK): + * the broker only starts routing a topic once its subscription is registered, + * so publishing before the ack races the message ahead of the subscription and + * it is dropped (no retained replay on MQTT). Awaiting here makes + * subscribe-then-publish reliable. + * + * Pass `{ background: true, title }` to also show a browser notification per matching + * message while the tab is open, and `{ retry: false }` for at-most-once + * (QoS 0) delivery; toggle either later with the handle's `update`. + */ + subscribe( + callback: MessageCallback, + options?: SubscribeOptions, + ): Promise; + subscribe( + topics: + string | Topic | ResolvedTopic | (string | Topic | ResolvedTopic)[], + callback: MessageCallback, + options?: SubscribeOptions, + ): Promise; + async subscribe( + topicsOrCallback: + | string + | Topic + | ResolvedTopic + | (string | Topic | ResolvedTopic)[] + | MessageCallback, + callbackOrOptions?: MessageCallback | SubscribeOptions, + topicOptions: SubscribeOptions = {}, + ): Promise { + // Every failure reaches onError (when registered) and is thrown to the caller. + try { + return await this.subscribeWith( + topicsOrCallback, + callbackOrOptions, + topicOptions, + ); + } catch (err) { + this.fail(err); + } + } + + private async subscribeWith( + topicsOrCallback: + | string + | Topic + | ResolvedTopic + | (string | Topic | ResolvedTopic)[] + | MessageCallback, + callbackOrOptions: MessageCallback | SubscribeOptions | undefined, + topicOptions: SubscribeOptions, + ): Promise { + // Topic-less form: subscribe(callback, options) targets the signed-in user's topic. + const userForm = typeof topicsOrCallback === 'function'; + const topics = userForm ? this.userTopic() : topicsOrCallback; + const callback = ( + userForm ? topicsOrCallback : callbackOrOptions + ) as MessageCallback; + const options = ( + userForm ? (callbackOrOptions ?? {}) : topicOptions + ) as SubscribeOptions; + const topicList = (Array.isArray(topics) ? topics : [topics]).map( + (topic) => topic.toString(), + ); + // The user topic defaults to background delivery, like FCM/APNs; topics default off. + const background = options.background ?? userForm; + const qos: 0 | 1 = (options.retry ?? true) ? 1 : 0; + + if (background) { + this.requestNotificationPermission(); + } + + const client = await this.connect(); + + const ids: string[] = []; + const acks: Promise[] = []; + for (const topic of topicList) { + const id = randomId(); + ids.push(id); + this.subscriptions.set(id, { + topic, + callback, + background, + title: options.title, + qos, + }); + acks.push( + new Promise((resolve, reject) => { + client.subscribe( + topic, + { qos: this.effectiveQos(topic) }, + (err) => (err ? reject(err) : resolve()), + ); + }), + ); + } + + const unsubscribe = () => { + // Filters whose removed sub was QoS 1: their effective QoS may now drop. + const maybeDowngrade = new Set(); + for (const id of ids) { + const entry = this.subscriptions.get(id); + this.subscriptions.delete(id); + if (entry?.qos === 1) { + maybeDowngrade.add(entry.topic); + } + // Only unsubscribe the broker filter once its last local callback is gone. + const stillUsed = [...this.subscriptions.values()].some( + (s) => s.topic === entry?.topic, + ); + if (entry && this.mqtt && !stillUsed) { + this.mqtt.unsubscribe(entry.topic, (err) => { + if (err) { + this.report(err); + } + }); + } + } + // A filter that lost its last QoS-1 sub but still has QoS-0 subs must be + // re-SUBSCRIBEd at the lower QoS, or the broker keeps replaying to at-most-once subs. + for (const filter of maybeDowngrade) { + const stillUsed = [...this.subscriptions.values()].some( + (s) => s.topic === filter, + ); + if (stillUsed && this.effectiveQos(filter) === 0) { + this.mqtt?.subscribe(filter, { qos: 0 }, (err) => { + if (err) { + this.report(err); + } + }); + } + } + if (this.subscriptions.size === 0) { + this.close(); + } + }; + + // If any topic's subscribe fails, roll this call's registrations back (and drop + // any now-unused broker filter) so a failed subscribe leaks no callback, then rethrow. + try { + await Promise.all(acks); + } catch (err) { + unsubscribe(); + throw err; + } + + const update = (next: SubscribeOptions) => { + const enabling = next.background === true; + const changedFilters = new Set(); + // Remember the pre-update QoS per id so a rejected re-SUBSCRIBE can be rolled back. + const previous = new Map(); + for (const id of ids) { + const entry = this.subscriptions.get(id); + if (!entry) { + continue; + } + if (next.background !== undefined) { + entry.background = next.background; + } + if (next.title !== undefined) { + entry.title = next.title; + } + if (next.retry !== undefined) { + const q: 0 | 1 = next.retry ? 1 : 0; + if (q !== entry.qos) { + previous.set(id, entry.qos); + entry.qos = q; + changedFilters.add(entry.topic); + } + } + } + if (enabling) { + this.requestNotificationPermission(); + } + // Re-SUBSCRIBE the affected filters at their new effective QoS (a SUBSCRIBE to an + // existing filter just updates its QoS — no unsubscribe gap). If the broker rejects + // it, the old subscription still stands, so restore the local QoS to match and + // surface the error rather than silently assuming the change took effect. + for (const filter of changedFilters) { + this.mqtt?.subscribe( + filter, + { qos: this.effectiveQos(filter) }, + (err) => { + if (!err) { + return; + } + for (const [id, q] of previous) { + const entry = this.subscriptions.get(id); + if (entry && entry.topic === filter) { + entry.qos = q; + } + } + this.report(err); + }, + ); + } + }; + + return { unsubscribe, update }; + } + + /** Tear down the connection and drop all active subscriptions. */ + close(): void { + if (this.mqtt) { + this.mqtt.end(true); + this.mqtt = null; + } + this.connecting = null; + this.everConnected = false; + this.subscriptions.clear(); + } + + /** + * Re-register every active subscription. Called on each reconnect so a client that + * reconnects with a fresh (or cleared) session does not silently stop receiving; + * re-subscribing an existing filter is idempotent. + */ + private resubscribeAll(): void { + const client = this.mqtt; + if (!client) { + return; + } + const filters = new Set( + [...this.subscriptions.values()].map((s) => s.topic), + ); + for (const filter of filters) { + client.subscribe( + filter, + { qos: this.effectiveQos(filter) }, + (err) => { + if (err) { + this.report(err); + } + }, + ); + } + } + + // --- internals --- + + private connect(): Promise { + if (this.mqtt) { + return Promise.resolve(this.mqtt); + } + if (!this.connecting) { + this.connecting = this.open(); + // A failed open must not poison future attempts — clear the cached + // in-flight promise so a later subscribe/publish can retry. + this.connecting.catch(() => { + this.connecting = null; + }); + } + return this.connecting.then(() => this.mqtt!); + } + + private endpointUrl(): string { + // The push endpoint set on the client (Client.setPushEndpoint) wins. + if (this.client.config.endpointPush !== '') { + return this.client.config.endpointPush; + } + // Otherwise default to a `push.` host on the regular API endpoint (not the + // independently-configurable realtime endpoint), scheme switched to ws/wss. + const wsEndpoint = this.client.config.endpoint + .replace('https://', 'wss://') + .replace('http://', 'ws://'); + // Prefix the host with `push.` (scheme://host/path -> scheme://push.host/path). + const separator = '://'; + const at = wsEndpoint.indexOf(separator); + return at === -1 + ? wsEndpoint + : `${wsEndpoint.slice(0, at + separator.length)}push.${wsEndpoint.slice(at + separator.length)}`; + } + + private async open(): Promise { + // Read the credential set on the client (via Client.setJWT / setSession). + let authMethod: AuthMethod; + let credential: string; + if (this.client.config.jwt) { + authMethod = 'appwrite-jwt'; + credential = this.client.config.jwt; + } else if (this.client.config.session) { + authMethod = 'appwrite-session'; + credential = this.client.config.session; + } else { + throw new Error( + 'No credential set on the client; call Client.setJWT() or Client.setSession() first.', + ); + } + + const project = this.client.config.project ?? ''; + // Client id, when the app did not set one with Client.setPushClientId(). Unlike the + // native SDKs (which send an empty id and let the broker derive a stable one), mqtt.js + // rejects an empty id with clean start off, so derive a stable per-user id here from the + // credential this connection authenticates with: the JWT's userId, or the session's user + // id. A stable id keeps the broker's replay cursor resuming across reloads. The + // credential itself is never used as the id. + const clientId = + this.client.config.pushClientId || + (authMethod === 'appwrite-jwt' + ? userIdFromJwt(credential) + : userIdFromSession(credential)) || + this.fallbackClientId; + + const options: IClientOptions = { + clientId, + protocolVersion: 5, + clean: false, // always keep the session so the broker can replay QoS-1 topics + keepalive: KEEP_ALIVE_SECONDS, + reconnectPeriod: RECONNECT_PERIOD_MS, + manualConnect: true, + // Enhanced auth carried in CONNECT properties. + properties: { + authenticationMethod: authMethod, + authenticationData: Buffer.from(credential), + userProperties: { projectId: project }, + }, + }; + + const client = mqtt.connect(this.endpointUrl(), options); + this.mqtt = client; + + client.on('message', (_topic, _payload, packet) => { + this.dispatch(packet).catch((err) => this.report(err)); + }); + + // Persistent lifecycle listeners. Re-register every subscription on reconnect + // (harmless if the broker resumed our session), and surface the lifecycle to the + // caller's onOpen/onClose/onError hooks. + client.on('connect', () => { + if (this.everConnected) { + this.resubscribeAll(); + } + this.everConnected = true; + this.onOpenCb?.(); + }); + client.on('close', () => this.onCloseCb?.()); + // The broker explains a refused CONNECT (CONNACK) or a server-initiated DISCONNECT + // with an MQTT 5 Reason String. mqtt.js reports only the reason code, so capture the + // string off the packet (packetreceive fires before mqtt.js handles it) and hand it + // to onError as the error message. + let refusedReason: string | undefined; + client.on('packetreceive', (packet) => { + if (packet.cmd === 'connack') { + refusedReason = + (packet.reasonCode ?? 0) !== 0 + ? packet.properties?.reasonString + : undefined; + } + }); + client.on('error', (err) => { + const error = this.connectError(err, refusedReason); + // While the first connect is pending its caller receives the error (and reports it + // through fail()); afterwards, e.g. on reconnect, report it here. + if (!this.opening) { + this.report(error); + } + }); + client.on('disconnect', (packet) => { + if ((packet.reasonCode ?? 0) !== 0) { + this.report( + new Error( + packet.properties?.reasonString ?? + `Disconnected by the broker (reason ${packet.reasonCode})`, + ), + ); + } + }); + + this.opening = true; + await new Promise((resolve, reject) => { + const onConnect = (packet: IConnackPacket) => { + cleanup(); + const rc = packet.reasonCode ?? packet.returnCode ?? 0; + if (rc !== 0) { + this.close(); + reject( + new Error( + refusedReason ?? + `MQTT authentication failed (CONNACK reason ${rc})`, + ), + ); + } else { + resolve(); + } + }; + const onError = (err: Error) => { + cleanup(); + this.close(); + reject(this.connectError(err, refusedReason)); + }; + const cleanup = () => { + this.opening = false; + client.removeListener('connect', onConnect); + client.removeListener('error', onError); + }; + client.on('connect', onConnect); + client.on('error', onError); + client.connect(); + }); + } + + /** + * The error for a failed connect: the broker's Reason String when it sent one (a refused + * CONNACK), else mqtt.js's error. Memoized so both error listeners hand out the same + * object and it is reported once. + */ + private connectError(err: unknown, reason: string | undefined): Error { + const source = toError(err); + let error = this.connectErrors.get(source); + if (!error) { + error = reason ? new Error(reason) : source; + this.connectErrors.set(source, error); + } + return error; + } + + /** Fan a delivered packet out to every subscription whose filter matches. */ + private async dispatch(packet: IPublishPacket): Promise { + const payload = Buffer.isBuffer(packet.payload) + ? packet.payload + : Buffer.from(packet.payload); + const message: PushMessage = { + topic: packet.topic.toString(), + data: new TextDecoder().decode(payload), + payload, + qos: packet.qos, + }; + for (const sub of this.subscriptions.values()) { + if (matches(sub.topic, message.topic)) { + await sub.callback(message); + // Notification is per-subscription: only subs that opted in post one, + // each with its own title. + if (sub.background) { + this.notify(message, sub.title); + } + } + } + } + + private requestNotificationPermission(): void { + if ( + typeof Notification !== 'undefined' && + Notification.permission === 'default' + ) { + Promise.resolve(Notification.requestPermission()).catch((err) => + this.report(err), + ); + } + } + + /** Post a browser notification for a message a background subscription matched. */ + private notify(message: PushMessage, title?: string): void { + if ( + typeof Notification === 'undefined' || + Notification.permission !== 'granted' + ) { + return; + } + try { + new Notification(title ?? message.topic, { + body: message.data, + }); + } catch { + // Some browsers only allow notifications from a service worker; ignore. + } + } +} + +/** Normalize anything thrown or passed to an error handler into an `Error`. */ +function toError(error: unknown): Error { + return error instanceof Error ? error : new Error(String(error)); +} + +/** + * The userId claim from an Appwrite JWT, used as the default MQTT client id so the + * broker's replay cursor is stable per user. Returns '' when the token is not a decodable JWT + * (e.g. a plain string), so the caller can fall back to the session or raw credential. + */ +function userIdFromJwt(jwt?: string): string { + if (!jwt) { + return ''; + } + const parts = jwt.split('.'); + if (parts.length < 2) { + return ''; + } + try { + const json = Buffer.from( + parts[1].replace(/-/g, '+').replace(/_/g, '/'), + 'base64', + ).toString('utf-8'); + const payload = JSON.parse(json); + return typeof payload.userId === 'string' ? payload.userId : ''; + } catch { + return ''; + } +} + +/** + * The user id inside a session secret, which is base64 of JSON `{"id": , "secret": ...}`. + * Returns '' when the value is not such a secret. + */ +function userIdFromSession(session?: string): string { + if (!session) { + return ''; + } + try { + const payload = JSON.parse( + Buffer.from(session, 'base64').toString('utf-8'), + ); + return typeof payload.id === 'string' ? payload.id : ''; + } catch { + return ''; + } +} + +/** A hex id, uuid4-like enough for a client-generated client id suffix. */ +function randomId(): string { + let out = ''; + for (let i = 0; i < 32; i++) { + out += Math.floor(Math.random() * 16).toString(16); + } + return out; +} + +/** MQTT topic-filter match with '+' (single level) and '#' (multi level). */ +function matches(filter: string, topic: string): boolean { + const filterParts = filter.split('/'); + const topicParts = topic.split('/'); + for (let i = 0; i < filterParts.length; i++) { + const part = filterParts[i]; + if (part === '#') { + return true; + } + if (i >= topicParts.length) { + return false; + } + if (part !== '+' && part !== topicParts[i]) { + return false; + } + } + return filterParts.length === topicParts.length; +} diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 2f2636e1..dd0cb4f8 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -6292,6 +6292,129 @@ export class TablesDB { return this.client.call('post', uri, apiHeaders, payload); } + /** + * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRelationshipColumn(params: { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }): Promise; + /** + * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRelationshipColumn( + databaseId: string, + tableId: string, + key: string, + onDelete?: RelationMutate, + newKey?: string, + ): Promise; + updateRelationshipColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + } + | string, + ...rest: [string?, string?, RelationMutate?, string?] + ): Promise { + let params: { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + onDelete: rest[2] as RelationMutate, + newKey: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const onDelete = params.onDelete; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof tableId === 'undefined' || tableId === '') { + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + if (typeof key === 'undefined' || key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const payload: Payload = {}; + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, payload); + } + /** * Create a string column. * @@ -7552,7 +7675,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getColumn(params: { databaseId: string; @@ -7560,6 +7683,7 @@ export class TablesDB { key: string; }): Promise< | Models.ColumnBoolean + | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail @@ -7568,6 +7692,13 @@ export class TablesDB { | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext | Models.ColumnString >; /** @@ -7577,7 +7708,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getColumn( @@ -7586,6 +7717,7 @@ export class TablesDB { key: string, ): Promise< | Models.ColumnBoolean + | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail @@ -7594,6 +7726,13 @@ export class TablesDB { | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext | Models.ColumnString >; getColumn( @@ -7602,6 +7741,7 @@ export class TablesDB { ...rest: [string?, string?] ): Promise< | Models.ColumnBoolean + | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail @@ -7610,6 +7750,13 @@ export class TablesDB { | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext | Models.ColumnString > { let params: { databaseId: string; tableId: string; key: string }; @@ -7747,129 +7894,6 @@ export class TablesDB { return this.client.call('delete', uri, apiHeaders, payload); } - /** - * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. - * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Column Key. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateRelationshipColumn(params: { - databaseId: string; - tableId: string; - key: string; - onDelete?: RelationMutate; - newKey?: string; - }): Promise; - /** - * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. - * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Column Key. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateRelationshipColumn( - databaseId: string, - tableId: string, - key: string, - onDelete?: RelationMutate, - newKey?: string, - ): Promise; - updateRelationshipColumn( - paramsOrFirst: - | { - databaseId: string; - tableId: string; - key: string; - onDelete?: RelationMutate; - newKey?: string; - } - | string, - ...rest: [string?, string?, RelationMutate?, string?] - ): Promise { - let params: { - databaseId: string; - tableId: string; - key: string; - onDelete?: RelationMutate; - newKey?: string; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - databaseId: string; - tableId: string; - key: string; - onDelete?: RelationMutate; - newKey?: string; - }; - } else { - params = { - databaseId: paramsOrFirst as string, - tableId: rest[0] as string, - key: rest[1] as string, - onDelete: rest[2] as RelationMutate, - newKey: rest[3] as string, - }; - } - - const databaseId = params.databaseId; - const tableId = params.tableId; - const key = params.key; - const onDelete = params.onDelete; - const newKey = params.newKey; - - if (typeof databaseId === 'undefined' || databaseId === '') { - throw new AppwriteException( - 'Missing required parameter: "databaseId"', - ); - } - if (typeof tableId === 'undefined' || tableId === '') { - throw new AppwriteException( - 'Missing required parameter: "tableId"', - ); - } - if (typeof key === 'undefined' || key === '') { - throw new AppwriteException('Missing required parameter: "key"'); - } - const apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' - .replace('{databaseId}', encodeURIComponent(String(databaseId))) - .replace('{tableId}', encodeURIComponent(String(tableId))) - .replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; - if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - return this.client.call('patch', uri, apiHeaders, payload); - } - /** * List indexes on the table. * diff --git a/src/services/users.ts b/src/services/users.ts index 78f9795f..ea6678f5 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1554,7 +1554,7 @@ export class Users { } /** - * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account. * * * @param {string} params.userId - User ID. @@ -1569,7 +1569,7 @@ export class Users { impersonator: boolean; }): Promise>; /** - * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account. * * * @param {string} userId - User ID. diff --git a/src/topic.ts b/src/topic.ts new file mode 100644 index 00000000..cd6cea01 --- /dev/null +++ b/src/topic.ts @@ -0,0 +1,103 @@ +/** + * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding + * the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). + */ +function levelsOf(levels: unknown): string[] { + if (!Array.isArray(levels)) { + throw new Error("path() expects an array, e.g. path(['user'])"); + } + if (levels.length === 0) { + throw new Error('path() needs at least one level'); + } + return levels.map((level: unknown, index: number) => { + if (typeof level !== 'string') { + const type = level === null ? 'null' : typeof level; + throw new Error( + `level at index ${index} must be a string, got ${type}`, + ); + } + if (level === '') { + throw new Error(`empty level at index ${index}`); + } + if (level.includes('/')) { + const parts = level + .split('/') + .map((part) => `'${part}'`) + .join(', '); + throw new Error( + `"${level}" contains "/", split it: path([${parts}])`, + ); + } + if (level === '+') { + throw new Error('"+" is reserved, use any()'); + } + if (level.includes('+')) { + throw new Error(`"${level}" contains "+", use any() for wildcards`); + } + if (level === '#') { + throw new Error('"#" is reserved, use all()'); + } + if (level.includes('#')) { + throw new Error(`"${level}" contains "#", use all() for wildcards`); + } + return level; + }); +} + +/** + * Helper to build MQTT topics for `Push`, level by level. + * + * Topic.path(['user', userId, 'notification']); // "user/123/notification" + * Topic.path(['user']).any().path(['notification']); // "user/+/notification" + * Topic.path(['org']).any().path(['logs']).all(); // "org/+/logs/#" + * + * `any()` matches exactly one level and `all()` everything below, at any depth (including the + * parent itself). `all()` ends the topic, so it returns a {@link ResolvedTopic}. + */ +export class Topic { + private constructor(private readonly levels: readonly string[]) {} + + /** Start a topic with the given levels, e.g. `Topic.path(['user', userId])`. */ + static path(levels: string[]): Topic { + return new Topic(levelsOf(levels)); + } + + /** Start a topic with a single-level wildcard (`+`). */ + static any(): Topic { + return new Topic(['+']); + } + + /** The multi-level wildcard alone (`#`): matches every topic. */ + static all(): ResolvedTopic { + return new ResolvedTopic(['#']); + } + + /** Append the given levels. */ + path(levels: string[]): Topic { + return new Topic([...this.levels, ...levelsOf(levels)]); + } + + /** Append a single-level wildcard (`+`): matches exactly one level. */ + any(): Topic { + return new Topic([...this.levels, '+']); + } + + /** Append the multi-level wildcard (`#`) and end the topic. */ + all(): ResolvedTopic { + return new ResolvedTopic([...this.levels, '#']); + } + + toString(): string { + return this.levels.join('/'); + } +} + +/** A topic ended by `all()`: nothing can be appended after the `#` wildcard. */ +export class ResolvedTopic { + /** @internal Created by {@link Topic.all}. */ + constructor(private readonly levels: readonly string[]) {} + + toString(): string { + return this.levels.join('/'); + } +}