diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ddc46d3..1262e64c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,27 @@ # Change Log -## 7.0.0 - -* Breaking: Updated `$sequence` type from `number` to `string` for rows and documents. -* Updated: Compatibility note now refers to Appwrite server `1.9.x`. -* Updated: README badge shows API version `1.9.0`. -* Updated: Set header `X-Appwrite-Response-Format` to `1.9.0`. +## 8.0.0 + +* [BREAKING] Changed `$sequence` type from `number` to `string` for `Row` and `Document` models +* [BREAKING] Renamed `IndexType` enum: split into `DatabasesIndexType` (for Databases) and `TablesDBIndexType` (for TablesDB) +* [BREAKING] `Project.createVariable` now requires `variableId` as a new first parameter +* [BREAKING] Removed `ProviderRepositoryRuntime`, `ProviderRepositoryRuntimeList`, and `DetectionRuntime` models +* [BREAKING] Removed all RC (release candidate) runtime variants from `Runtime`, `Runtimes`, and `BuildRuntime` enums +* Added new `Domains.updateAutoRenewal()` method for enabling/disabling domain auto-renewal +* Added new `Users.updateImpersonator()` method for enabling/disabling user impersonation +* Added impersonation support: `setImpersonateUserId()`, `setImpersonateUserEmail()`, `setImpersonateUserPhone()` on `Client` +* Added `impersonator` and `impersonatorUserId` optional fields to `User` model +* Added `autoRenewal` optional parameter to `Domains.createPurchase()` and `Domains.createTransferIn()` +* Added optional `queries` and `total` parameters to `Project.listVariables()` +* Added `Documentsdb` and `Vectorsdb` values to `DatabaseType` and `BackupServices` enums +* Added new scopes: `Account`, `ProjectRead`, `ProjectWrite`, `PlatformsRead`, `PlatformsWrite`, `ProjectsRead`, `ProjectsWrite`, `KeysRead`, `KeysWrite`, `DevKeysRead`, `DevKeysWrite` +* Added VectorsDB and DocumentsDB usage metrics to `UsagePeriod` model +* Added embeddings metrics (`embeddingsText*`) to `UsagePeriod` model +* Added `realtimeMessages` and `realtimeBandwidth` fields to `Plan` model +* Changed `Project.updateVariable` `key` parameter from required to optional +* Updated `Log` model field descriptions to clarify impersonation behavior +* Updated `X-Appwrite-Response-Format` header to `1.9.0` +* Updated devDependencies: Rollup 2→3, TypeScript 4.7→5.7, and related plugin upgrades ## 6.0.0 diff --git a/README.md b/README.md index ee7e83c4..63ea43a1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-console/releases).** +**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).** 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 - + ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 4df9565e..0f5fe9d2 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Databases, IndexType, 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 @@ -11,7 +11,7 @@ const result = await databases.createIndex({ databaseId: '', collectionId: '', key: '', - type: IndexType.Key, + type: DatabasesIndexType.Key, attributes: [], orders: [OrderBy.Asc], // optional lengths: [] // optional diff --git a/docs/examples/domains/create-purchase.md b/docs/examples/domains/create-purchase.md index ab33c5e8..0e13e044 100644 --- a/docs/examples/domains/create-purchase.md +++ b/docs/examples/domains/create-purchase.md @@ -18,7 +18,8 @@ const result = await domains.createPurchase({ paymentMethodId: '', addressLine3: '', // optional companyName: '', // optional - periodYears: 1 // optional + periodYears: 1, // optional + autoRenewal: false // optional }); console.log(result); diff --git a/docs/examples/domains/create-transfer-in.md b/docs/examples/domains/create-transfer-in.md index f26fa0c3..a5705d04 100644 --- a/docs/examples/domains/create-transfer-in.md +++ b/docs/examples/domains/create-transfer-in.md @@ -11,7 +11,8 @@ const result = await domains.createTransferIn({ domain: '', organizationId: '', authCode: '', - paymentMethodId: '' + paymentMethodId: '', + autoRenewal: false // optional }); console.log(result); diff --git a/docs/examples/domains/update-auto-renewal.md b/docs/examples/domains/update-auto-renewal.md new file mode 100644 index 00000000..48512c06 --- /dev/null +++ b/docs/examples/domains/update-auto-renewal.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Domains } 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.updateAutoRenewal({ + domainId: '', + autoRenewal: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md index c788af94..c27a58dd 100644 --- a/docs/examples/project/create-variable.md +++ b/docs/examples/project/create-variable.md @@ -8,6 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.createVariable({ + variableId: '', key: '', value: '', secret: false // optional diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md index ec14f99c..52cdb733 100644 --- a/docs/examples/project/list-variables.md +++ b/docs/examples/project/list-variables.md @@ -7,7 +7,10 @@ const client = new Client() const project = new Project(client); -const result = await project.listVariables(); +const result = await project.listVariables({ + queries: [], // optional + total: false // optional +}); console.log(result); ``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md index 8d22cd0b..2eedd902 100644 --- a/docs/examples/project/update-variable.md +++ b/docs/examples/project/update-variable.md @@ -9,7 +9,7 @@ const project = new Project(client); const result = await project.updateVariable({ variableId: '', - key: '', + key: '', // optional value: '', // optional secret: false // optional }); diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 648f033d..aa5aa3e4 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -1,5 +1,5 @@ ```javascript -import { Client, TablesDB, IndexType, 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 @@ -11,7 +11,7 @@ const result = await tablesDB.createIndex({ databaseId: '', tableId: '', key: '', - type: IndexType.Key, + type: TablesDBIndexType.Key, columns: [], orders: [OrderBy.Asc], // optional lengths: [] // optional diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md new file mode 100644 index 00000000..955af032 --- /dev/null +++ b/docs/examples/users/update-impersonator.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.updateImpersonator({ + userId: '', + impersonator: false +}); + +console.log(result); +``` diff --git a/package.json b/package.json index 2b6e924a..3931e1ac 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": "7.0.0", + "version": "8.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { @@ -28,15 +28,15 @@ "json-bigint": "1.0.0" }, "devDependencies": { - "@rollup/plugin-commonjs": "22.0.0", - "@rollup/plugin-node-resolve": "13.3.0", - "@rollup/plugin-typescript": "8.3.2", + "@rollup/plugin-commonjs": "25.0.8", + "@rollup/plugin-node-resolve": "15.3.1", + "@rollup/plugin-typescript": "11.1.6", "@types/json-bigint": "1.0.4", "playwright": "1.56.1", - "rollup": "2.79.2", + "rollup": "3.29.5", "serve-handler": "6.1.0", - "tslib": "2.4.0", - "typescript": "4.7.2" + "tslib": "2.8.1", + "typescript": "5.7.3" }, "jsdelivr": "dist/iife/sdk.js", "unpkg": "dist/iife/sdk.js" diff --git a/rollup.config.js b/rollup.config.js index a02bbc3e..72a093a3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,4 +1,5 @@ -import pkg from "./package.json"; +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"; diff --git a/src/client.ts b/src/client.ts index 7a62d359..1f9d3526 100644 --- a/src/client.ts +++ b/src/client.ts @@ -377,6 +377,9 @@ class Client { locale: string; mode: string; cookie: string; + impersonateuserid: string; + impersonateuseremail: string; + impersonateuserphone: string; platform: string; selfSigned: boolean; session?: string; @@ -389,6 +392,9 @@ class Client { locale: '', mode: '', cookie: '', + impersonateuserid: '', + impersonateuseremail: '', + impersonateuserphone: '', platform: '', selfSigned: false, session: undefined, @@ -400,7 +406,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '7.0.0', + 'x-sdk-version': '8.0.0', 'X-Appwrite-Response-Format': '1.9.0', }; @@ -540,6 +546,48 @@ class Client { this.config.cookie = value; return this; } + /** + * Set ImpersonateUserId + * + * Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param value string + * + * @return {this} + */ + setImpersonateUserId(value: string): this { + this.headers['X-Appwrite-Impersonate-User-Id'] = value; + this.config.impersonateuserid = value; + return this; + } + /** + * Set ImpersonateUserEmail + * + * Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param value string + * + * @return {this} + */ + setImpersonateUserEmail(value: string): this { + this.headers['X-Appwrite-Impersonate-User-Email'] = value; + this.config.impersonateuseremail = value; + return this; + } + /** + * Set ImpersonateUserPhone + * + * Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param value string + * + * @return {this} + */ + setImpersonateUserPhone(value: string): this { + this.headers['X-Appwrite-Impersonate-User-Phone'] = value; + this.config.impersonateuserphone = value; + return this; + } /** * Set Platform * diff --git a/src/enums/appwrite-migration-resource.ts b/src/enums/appwrite-migration-resource.ts index 30284bbe..bd3a26bc 100644 --- a/src/enums/appwrite-migration-resource.ts +++ b/src/enums/appwrite-migration-resource.ts @@ -10,6 +10,8 @@ export enum AppwriteMigrationResource { Document = 'document', Attribute = 'attribute', Collection = 'collection', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', Bucket = 'bucket', File = 'file', Function = 'function', diff --git a/src/enums/backup-services.ts b/src/enums/backup-services.ts index f0f829ab..bd0582ce 100644 --- a/src/enums/backup-services.ts +++ b/src/enums/backup-services.ts @@ -1,5 +1,8 @@ export enum BackupServices { Databases = 'databases', + Tablesdb = 'tablesdb', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', Functions = 'functions', Storage = 'storage', } \ No newline at end of file diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index be56a9f4..3f85913f 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -85,90 +85,4 @@ export enum BuildRuntime { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', - Node145rc = 'node-14.5-rc', - Node160rc = 'node-16.0-rc', - Node180rc = 'node-18.0-rc', - Node190rc = 'node-19.0-rc', - Node200rc = 'node-20.0-rc', - Node210rc = 'node-21.0-rc', - Node22rc = 'node-22-rc', - Node23rc = 'node-23-rc', - Node24rc = 'node-24-rc', - Node25rc = 'node-25-rc', - Php80rc = 'php-8.0-rc', - Php81rc = 'php-8.1-rc', - Php82rc = 'php-8.2-rc', - Php83rc = 'php-8.3-rc', - Php84rc = 'php-8.4-rc', - Ruby30rc = 'ruby-3.0-rc', - Ruby31rc = 'ruby-3.1-rc', - Ruby32rc = 'ruby-3.2-rc', - Ruby33rc = 'ruby-3.3-rc', - Ruby34rc = 'ruby-3.4-rc', - Ruby40rc = 'ruby-4.0-rc', - Python38rc = 'python-3.8-rc', - Python39rc = 'python-3.9-rc', - Python310rc = 'python-3.10-rc', - Python311rc = 'python-3.11-rc', - Python312rc = 'python-3.12-rc', - Python313rc = 'python-3.13-rc', - Python314rc = 'python-3.14-rc', - Pythonml311rc = 'python-ml-3.11-rc', - Pythonml312rc = 'python-ml-3.12-rc', - Pythonml313rc = 'python-ml-3.13-rc', - Deno140rc = 'deno-1.40-rc', - Deno146rc = 'deno-1.46-rc', - Deno20rc = 'deno-2.0-rc', - Deno25rc = 'deno-2.5-rc', - Deno26rc = 'deno-2.6-rc', - Dart215rc = 'dart-2.15-rc', - Dart216rc = 'dart-2.16-rc', - Dart217rc = 'dart-2.17-rc', - Dart218rc = 'dart-2.18-rc', - Dart219rc = 'dart-2.19-rc', - Dart30rc = 'dart-3.0-rc', - Dart31rc = 'dart-3.1-rc', - Dart33rc = 'dart-3.3-rc', - Dart35rc = 'dart-3.5-rc', - Dart38rc = 'dart-3.8-rc', - Dart39rc = 'dart-3.9-rc', - Dart310rc = 'dart-3.10-rc', - Dotnet60rc = 'dotnet-6.0-rc', - Dotnet70rc = 'dotnet-7.0-rc', - Dotnet80rc = 'dotnet-8.0-rc', - Dotnet10rc = 'dotnet-10-rc', - Java80rc = 'java-8.0-rc', - Java110rc = 'java-11.0-rc', - Java170rc = 'java-17.0-rc', - Java180rc = 'java-18.0-rc', - Java210rc = 'java-21.0-rc', - Java22rc = 'java-22-rc', - Java25rc = 'java-25-rc', - Swift55rc = 'swift-5.5-rc', - Swift58rc = 'swift-5.8-rc', - Swift59rc = 'swift-5.9-rc', - Swift510rc = 'swift-5.10-rc', - Swift62rc = 'swift-6.2-rc', - Kotlin16rc = 'kotlin-1.6-rc', - Kotlin18rc = 'kotlin-1.8-rc', - Kotlin19rc = 'kotlin-1.9-rc', - Kotlin20rc = 'kotlin-2.0-rc', - Kotlin23rc = 'kotlin-2.3-rc', - Cpp17rc = 'cpp-17-rc', - Cpp20rc = 'cpp-20-rc', - Bun10rc = 'bun-1.0-rc', - Bun11rc = 'bun-1.1-rc', - Bun12rc = 'bun-1.2-rc', - Bun13rc = 'bun-1.3-rc', - Go123rc = 'go-1.23-rc', - Go124rc = 'go-1.24-rc', - Go125rc = 'go-1.25-rc', - Go126rc = 'go-1.26-rc', - Static1rc = 'static-1-rc', - Flutter324rc = 'flutter-3.24-rc', - Flutter327rc = 'flutter-3.27-rc', - Flutter329rc = 'flutter-3.29-rc', - Flutter332rc = 'flutter-3.32-rc', - Flutter335rc = 'flutter-3.35-rc', - Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts index 71d1ed9d..8ccd9699 100644 --- a/src/enums/database-type.ts +++ b/src/enums/database-type.ts @@ -1,4 +1,6 @@ export enum DatabaseType { Legacy = 'legacy', Tablesdb = 'tablesdb', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', } \ No newline at end of file diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts new file mode 100644 index 00000000..85ccf867 --- /dev/null +++ b/src/enums/databases-index-type.ts @@ -0,0 +1,6 @@ +export enum DatabasesIndexType { + Key = 'key', + Fulltext = 'fulltext', + Unique = 'unique', + Spatial = 'spatial', +} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index cfd4a735..fda3bab3 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -85,90 +85,4 @@ export enum Runtime { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', - Node145rc = 'node-14.5-rc', - Node160rc = 'node-16.0-rc', - Node180rc = 'node-18.0-rc', - Node190rc = 'node-19.0-rc', - Node200rc = 'node-20.0-rc', - Node210rc = 'node-21.0-rc', - Node22rc = 'node-22-rc', - Node23rc = 'node-23-rc', - Node24rc = 'node-24-rc', - Node25rc = 'node-25-rc', - Php80rc = 'php-8.0-rc', - Php81rc = 'php-8.1-rc', - Php82rc = 'php-8.2-rc', - Php83rc = 'php-8.3-rc', - Php84rc = 'php-8.4-rc', - Ruby30rc = 'ruby-3.0-rc', - Ruby31rc = 'ruby-3.1-rc', - Ruby32rc = 'ruby-3.2-rc', - Ruby33rc = 'ruby-3.3-rc', - Ruby34rc = 'ruby-3.4-rc', - Ruby40rc = 'ruby-4.0-rc', - Python38rc = 'python-3.8-rc', - Python39rc = 'python-3.9-rc', - Python310rc = 'python-3.10-rc', - Python311rc = 'python-3.11-rc', - Python312rc = 'python-3.12-rc', - Python313rc = 'python-3.13-rc', - Python314rc = 'python-3.14-rc', - Pythonml311rc = 'python-ml-3.11-rc', - Pythonml312rc = 'python-ml-3.12-rc', - Pythonml313rc = 'python-ml-3.13-rc', - Deno140rc = 'deno-1.40-rc', - Deno146rc = 'deno-1.46-rc', - Deno20rc = 'deno-2.0-rc', - Deno25rc = 'deno-2.5-rc', - Deno26rc = 'deno-2.6-rc', - Dart215rc = 'dart-2.15-rc', - Dart216rc = 'dart-2.16-rc', - Dart217rc = 'dart-2.17-rc', - Dart218rc = 'dart-2.18-rc', - Dart219rc = 'dart-2.19-rc', - Dart30rc = 'dart-3.0-rc', - Dart31rc = 'dart-3.1-rc', - Dart33rc = 'dart-3.3-rc', - Dart35rc = 'dart-3.5-rc', - Dart38rc = 'dart-3.8-rc', - Dart39rc = 'dart-3.9-rc', - Dart310rc = 'dart-3.10-rc', - Dotnet60rc = 'dotnet-6.0-rc', - Dotnet70rc = 'dotnet-7.0-rc', - Dotnet80rc = 'dotnet-8.0-rc', - Dotnet10rc = 'dotnet-10-rc', - Java80rc = 'java-8.0-rc', - Java110rc = 'java-11.0-rc', - Java170rc = 'java-17.0-rc', - Java180rc = 'java-18.0-rc', - Java210rc = 'java-21.0-rc', - Java22rc = 'java-22-rc', - Java25rc = 'java-25-rc', - Swift55rc = 'swift-5.5-rc', - Swift58rc = 'swift-5.8-rc', - Swift59rc = 'swift-5.9-rc', - Swift510rc = 'swift-5.10-rc', - Swift62rc = 'swift-6.2-rc', - Kotlin16rc = 'kotlin-1.6-rc', - Kotlin18rc = 'kotlin-1.8-rc', - Kotlin19rc = 'kotlin-1.9-rc', - Kotlin20rc = 'kotlin-2.0-rc', - Kotlin23rc = 'kotlin-2.3-rc', - Cpp17rc = 'cpp-17-rc', - Cpp20rc = 'cpp-20-rc', - Bun10rc = 'bun-1.0-rc', - Bun11rc = 'bun-1.1-rc', - Bun12rc = 'bun-1.2-rc', - Bun13rc = 'bun-1.3-rc', - Go123rc = 'go-1.23-rc', - Go124rc = 'go-1.24-rc', - Go125rc = 'go-1.25-rc', - Go126rc = 'go-1.26-rc', - Static1rc = 'static-1-rc', - Flutter324rc = 'flutter-3.24-rc', - Flutter327rc = 'flutter-3.27-rc', - Flutter329rc = 'flutter-3.29-rc', - Flutter332rc = 'flutter-3.32-rc', - Flutter335rc = 'flutter-3.35-rc', - Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file diff --git a/src/enums/runtimes.ts b/src/enums/runtimes.ts index 5b1deeac..546822bf 100644 --- a/src/enums/runtimes.ts +++ b/src/enums/runtimes.ts @@ -85,90 +85,4 @@ export enum Runtimes { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', - Node145rc = 'node-14.5-rc', - Node160rc = 'node-16.0-rc', - Node180rc = 'node-18.0-rc', - Node190rc = 'node-19.0-rc', - Node200rc = 'node-20.0-rc', - Node210rc = 'node-21.0-rc', - Node22rc = 'node-22-rc', - Node23rc = 'node-23-rc', - Node24rc = 'node-24-rc', - Node25rc = 'node-25-rc', - Php80rc = 'php-8.0-rc', - Php81rc = 'php-8.1-rc', - Php82rc = 'php-8.2-rc', - Php83rc = 'php-8.3-rc', - Php84rc = 'php-8.4-rc', - Ruby30rc = 'ruby-3.0-rc', - Ruby31rc = 'ruby-3.1-rc', - Ruby32rc = 'ruby-3.2-rc', - Ruby33rc = 'ruby-3.3-rc', - Ruby34rc = 'ruby-3.4-rc', - Ruby40rc = 'ruby-4.0-rc', - Python38rc = 'python-3.8-rc', - Python39rc = 'python-3.9-rc', - Python310rc = 'python-3.10-rc', - Python311rc = 'python-3.11-rc', - Python312rc = 'python-3.12-rc', - Python313rc = 'python-3.13-rc', - Python314rc = 'python-3.14-rc', - Pythonml311rc = 'python-ml-3.11-rc', - Pythonml312rc = 'python-ml-3.12-rc', - Pythonml313rc = 'python-ml-3.13-rc', - Deno140rc = 'deno-1.40-rc', - Deno146rc = 'deno-1.46-rc', - Deno20rc = 'deno-2.0-rc', - Deno25rc = 'deno-2.5-rc', - Deno26rc = 'deno-2.6-rc', - Dart215rc = 'dart-2.15-rc', - Dart216rc = 'dart-2.16-rc', - Dart217rc = 'dart-2.17-rc', - Dart218rc = 'dart-2.18-rc', - Dart219rc = 'dart-2.19-rc', - Dart30rc = 'dart-3.0-rc', - Dart31rc = 'dart-3.1-rc', - Dart33rc = 'dart-3.3-rc', - Dart35rc = 'dart-3.5-rc', - Dart38rc = 'dart-3.8-rc', - Dart39rc = 'dart-3.9-rc', - Dart310rc = 'dart-3.10-rc', - Dotnet60rc = 'dotnet-6.0-rc', - Dotnet70rc = 'dotnet-7.0-rc', - Dotnet80rc = 'dotnet-8.0-rc', - Dotnet10rc = 'dotnet-10-rc', - Java80rc = 'java-8.0-rc', - Java110rc = 'java-11.0-rc', - Java170rc = 'java-17.0-rc', - Java180rc = 'java-18.0-rc', - Java210rc = 'java-21.0-rc', - Java22rc = 'java-22-rc', - Java25rc = 'java-25-rc', - Swift55rc = 'swift-5.5-rc', - Swift58rc = 'swift-5.8-rc', - Swift59rc = 'swift-5.9-rc', - Swift510rc = 'swift-5.10-rc', - Swift62rc = 'swift-6.2-rc', - Kotlin16rc = 'kotlin-1.6-rc', - Kotlin18rc = 'kotlin-1.8-rc', - Kotlin19rc = 'kotlin-1.9-rc', - Kotlin20rc = 'kotlin-2.0-rc', - Kotlin23rc = 'kotlin-2.3-rc', - Cpp17rc = 'cpp-17-rc', - Cpp20rc = 'cpp-20-rc', - Bun10rc = 'bun-1.0-rc', - Bun11rc = 'bun-1.1-rc', - Bun12rc = 'bun-1.2-rc', - Bun13rc = 'bun-1.3-rc', - Go123rc = 'go-1.23-rc', - Go124rc = 'go-1.24-rc', - Go125rc = 'go-1.25-rc', - Go126rc = 'go-1.26-rc', - Static1rc = 'static-1-rc', - Flutter324rc = 'flutter-3.24-rc', - Flutter327rc = 'flutter-3.27-rc', - Flutter329rc = 'flutter-3.29-rc', - Flutter332rc = 'flutter-3.32-rc', - Flutter335rc = 'flutter-3.35-rc', - Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts index cd8f0474..8287d582 100644 --- a/src/enums/scopes.ts +++ b/src/enums/scopes.ts @@ -1,9 +1,10 @@ export enum Scopes { + Account = 'account', + TeamsRead = 'teams.read', + TeamsWrite = 'teams.write', SessionsWrite = 'sessions.write', UsersRead = 'users.read', UsersWrite = 'users.write', - TeamsRead = 'teams.read', - TeamsWrite = 'teams.write', DatabasesRead = 'databases.read', DatabasesWrite = 'databases.write', CollectionsRead = 'collections.read', @@ -58,6 +59,8 @@ export enum Scopes { TokensWrite = 'tokens.write', WebhooksRead = 'webhooks.read', WebhooksWrite = 'webhooks.write', + ProjectRead = 'project.read', + ProjectWrite = 'project.write', PoliciesWrite = 'policies.write', PoliciesRead = 'policies.read', ArchivesRead = 'archives.read', @@ -67,4 +70,12 @@ export enum Scopes { DomainsRead = 'domains.read', DomainsWrite = 'domains.write', EventsRead = 'events.read', + PlatformsRead = 'platforms.read', + PlatformsWrite = 'platforms.write', + ProjectsRead = 'projects.read', + ProjectsWrite = 'projects.write', + KeysRead = 'keys.read', + KeysWrite = 'keys.write', + DevKeysRead = 'devKeys.read', + DevKeysWrite = 'devKeys.write', } \ No newline at end of file diff --git a/src/enums/index-type.ts b/src/enums/tables-db-index-type.ts similarity index 74% rename from src/enums/index-type.ts rename to src/enums/tables-db-index-type.ts index e5b5bbab..a199cd9c 100644 --- a/src/enums/index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -1,4 +1,4 @@ -export enum IndexType { +export enum TablesDBIndexType { Key = 'key', Fulltext = 'fulltext', Unique = 'unique', diff --git a/src/enums/template-reference-type.ts b/src/enums/template-reference-type.ts index c714c2c8..bd72cfb5 100644 --- a/src/enums/template-reference-type.ts +++ b/src/enums/template-reference-type.ts @@ -1,5 +1,5 @@ export enum TemplateReferenceType { - Branch = 'branch', Commit = 'commit', + Branch = 'branch', Tag = 'tag', } \ No newline at end of file diff --git a/src/enums/use-cases.ts b/src/enums/use-cases.ts index d014c1ae..d8e7306c 100644 --- a/src/enums/use-cases.ts +++ b/src/enums/use-cases.ts @@ -1,11 +1,16 @@ export enum UseCases { - Portfolio = 'portfolio', Starter = 'starter', + Databases = 'databases', + Ai = 'ai', + Messaging = 'messaging', + Utilities = 'utilities', + Devtools = 'dev-tools', + Auth = 'auth', + Portfolio = 'portfolio', Events = 'events', Ecommerce = 'ecommerce', Documentation = 'documentation', Blog = 'blog', - Ai = 'ai', Forms = 'forms', Dashboard = 'dashboard', } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index a452a5a5..f058b3a0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -58,7 +58,7 @@ export { ConsoleResourceType } from './enums/console-resource-type'; export { UsageRange } from './enums/usage-range'; export { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; -export { IndexType } from './enums/index-type'; +export { DatabasesIndexType } from './enums/databases-index-type'; export { OrderBy } from './enums/order-by'; export { RegistrationType } from './enums/registration-type'; export { FilterType } from './enums/filter-type'; @@ -97,6 +97,7 @@ export { Adapter } from './enums/adapter'; export { Frameworks } from './enums/frameworks'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; +export { TablesDBIndexType } from './enums/tables-db-index-type'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; export { VCSDetectionType } from './enums/vcs-detection-type'; diff --git a/src/models.ts b/src/models.ts index 7018c1e5..94df077b 100644 --- a/src/models.ts +++ b/src/models.ts @@ -330,20 +330,6 @@ export namespace Models { frameworkProviderRepositories: ProviderRepositoryFramework[]; } - /** - * Runtime Provider Repositories List - */ - export type ProviderRepositoryRuntimeList = { - /** - * Total number of runtimeProviderRepositories that matched your query. - */ - total: number; - /** - * List of runtimeProviderRepositories. - */ - runtimeProviderRepositories: ProviderRepositoryRuntime[]; - } - /** * Branches List */ @@ -2707,15 +2693,15 @@ export namespace Models { */ event: string; /** - * User ID. + * 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. + * User email of the actor recorded for this log. During impersonation, this is the original impersonator. */ userEmail: string; /** - * User Name. + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. */ userName: string; /** @@ -2868,6 +2854,14 @@ export namespace Models { * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ accessedAt: string; + /** + * Whether the user can impersonate other users. + */ + impersonator?: boolean; + /** + * 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; } /** @@ -4105,56 +4099,6 @@ export namespace Models { framework: string; } - /** - * ProviderRepositoryRuntime - */ - export type ProviderRepositoryRuntime = { - /** - * VCS (Version Control System) repository ID. - */ - id: string; - /** - * VCS (Version Control System) repository name. - */ - name: string; - /** - * VCS (Version Control System) organization name - */ - organization: string; - /** - * VCS (Version Control System) provider name. - */ - provider: string; - /** - * Is VCS (Version Control System) repository private? - */ - private: boolean; - /** - * VCS (Version Control System) repository's default branch name. - */ - defaultBranch: string; - /** - * VCS (Version Control System) installation ID. - */ - providerInstallationId: string; - /** - * Is VCS (Version Control System) repository authorized for the installation? - */ - authorized: boolean; - /** - * Last commit date in ISO 8601 format. - */ - pushedAt: string; - /** - * Environment variables found in .env files - */ - variables: string[]; - /** - * Auto-detected runtime. Empty if type is not "runtime". - */ - runtime: string; - } - /** * DetectionFramework */ @@ -4181,28 +4125,6 @@ export namespace Models { outputDirectory: string; } - /** - * DetectionRuntime - */ - export type DetectionRuntime = { - /** - * Environment variables found in .env files - */ - variables?: DetectionVariable[]; - /** - * Runtime - */ - runtime: string; - /** - * Function Entrypoint - */ - entrypoint: string; - /** - * Function install and build commands - */ - commands: string; - } - /** * DetectionVariable */ @@ -6034,9 +5956,13 @@ export namespace Models { */ executionsTotal: number; /** - * Total aggregated number of documents. + * Total aggregated number of documents in legacy/tablesdb. */ documentsTotal: number; + /** + * Total aggregated number of documents in documentsdb. + */ + documentsdbDocumentsTotal: number; /** * Total aggregated number of rows. */ @@ -6045,10 +5971,18 @@ export namespace Models { * 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. */ @@ -6089,6 +6023,14 @@ export namespace Models { * 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. */ @@ -6149,6 +6091,18 @@ export namespace Models { * 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. */ @@ -6157,6 +6111,86 @@ export namespace Models { * 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: Metric; + /** + * Total aggregated number of tokens processed by text. + */ + embeddingsTextTokensTotal: Metric; + /** + * Total aggregated duration spent generating text embeddings. + */ + embeddingsTextDurationTotal: Metric; + /** + * Total aggregated number of errors while generating text embeddings. + */ + embeddingsTextErrorsTotal: Metric; /** * Aggregated number of function executions per period. */ @@ -7497,6 +7531,10 @@ export namespace Models { * Realtime connections */ realtime: number; + /** + * Realtime messages + */ + realtimeMessages: number; /** * Messages per month */ @@ -8917,6 +8955,14 @@ export namespace Models { * Realtime additional resources */ realtime: AdditionalResource; + /** + * Realtime messages additional resources + */ + realtimeMessages: AdditionalResource; + /** + * Realtime bandwidth additional resources + */ + realtimeBandwidth: AdditionalResource; /** * Storage additional resources */ diff --git a/src/services/databases.ts b/src/services/databases.ts index ff923c5e..ce8902e3 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -5,7 +5,7 @@ import type { Models } from '../models'; import { UsageRange } from '../enums/usage-range'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; -import { IndexType } from '../enums/index-type'; +import { DatabasesIndexType } from '../enums/databases-index-type'; import { OrderBy } from '../enums/order-by'; export class Databases { @@ -5885,7 +5885,7 @@ export class Databases { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} params.key - Index Key. - * @param {IndexType} params.type - Index type. + * @param {DatabasesIndexType} params.type - Index type. * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} params.lengths - Length of index. Maximum of 100 @@ -5893,7 +5893,7 @@ 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: IndexType, 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`. @@ -5901,7 +5901,7 @@ export class Databases { * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Index Key. - * @param {IndexType} type - Index type. + * @param {DatabasesIndexType} type - Index type. * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} lengths - Length of index. Maximum of 100 @@ -5909,21 +5909,21 @@ 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: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; + 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: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (IndexType)?, (string[])?, (OrderBy[])?, (number[])?] + 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: IndexType, 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: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, - type: rest[2] as IndexType, + type: rest[2] as DatabasesIndexType, attributes: rest[3] as string[], orders: rest[4] as OrderBy[], lengths: rest[5] as number[] diff --git a/src/services/domains.ts b/src/services/domains.ts index 087d486f..6277582f 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -207,7 +207,7 @@ export class Domains { } /** - * Create a domain purchase with registrant information. + * 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. * * @param {string} params.domain - Fully qualified domain name to purchase (for example, example.com). * @param {string} params.organizationId - Team ID that will own the domain. @@ -220,12 +220,13 @@ export class Domains { * @param {string} params.addressLine3 - Additional address line for the registrant (line 3). * @param {string} params.companyName - Company or organization name for the registrant. * @param {number} params.periodYears - Registration term in years (1-10). + * @param {boolean} params.autoRenewal - Whether the domain should renew automatically after purchase. * @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 }): 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; /** - * Create a domain purchase with registrant information. + * 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. * * @param {string} domain - Fully qualified domain name to purchase (for example, example.com). * @param {string} organizationId - Team ID that will own the domain. @@ -238,19 +239,20 @@ export class Domains { * @param {string} addressLine3 - Additional address line for the registrant (line 3). * @param {string} companyName - Company or organization name for the registrant. * @param {number} periodYears - Registration term in years (1-10). + * @param {boolean} autoRenewal - Whether the domain should renew automatically after purchase. * @throws {AppwriteException} * @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): Promise; + 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 } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?] + 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 }; + 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 }; + 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, @@ -263,7 +265,8 @@ export class Domains { paymentMethodId: rest[6] as string, addressLine3: rest[7] as string, companyName: rest[8] as string, - periodYears: rest[9] as number + periodYears: rest[9] as number, + autoRenewal: rest[10] as boolean }; } @@ -278,6 +281,7 @@ export class Domains { const addressLine3 = params.addressLine3; const companyName = params.companyName; const periodYears = params.periodYears; + const autoRenewal = params.autoRenewal; if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); @@ -336,6 +340,9 @@ export class Domains { if (typeof periodYears !== 'undefined') { payload['periodYears'] = periodYears; } + if (typeof autoRenewal !== 'undefined') { + payload['autoRenewal'] = autoRenewal; + } if (typeof paymentMethodId !== 'undefined') { payload['paymentMethodId'] = paymentMethodId; } @@ -354,7 +361,7 @@ export class Domains { } /** - * Confirm and complete a domain purchase after payment authentication. + * 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. * * @param {string} params.domainId - Domain ID to confirm purchase for. * @param {string} params.organizationId - Team ID that owns the domain. @@ -363,7 +370,7 @@ export class Domains { */ updatePurchase(params: { domainId: string, organizationId: string }): Promise; /** - * Confirm and complete a domain purchase after payment authentication. + * 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. * * @param {string} domainId - Domain ID to confirm purchase for. * @param {string} organizationId - Team ID that owns the domain. @@ -507,42 +514,45 @@ export class Domains { } /** - * Create a domain transfer in with authorization code and registrant information. + * 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. * * @param {string} params.domain - Domain name to transfer in. * @param {string} params.organizationId - Organization ID that this domain will belong to. * @param {string} params.authCode - Authorization code for the domain transfer. * @param {string} params.paymentMethodId - Payment method ID to authorize and capture the transfer. + * @param {boolean} params.autoRenewal - Whether the domain should renew automatically after transfer. * @throws {AppwriteException} * @returns {Promise} */ - createTransferIn(params: { domain: string, organizationId: string, authCode: string, paymentMethodId: string }): Promise; + createTransferIn(params: { domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean }): Promise; /** - * Create a domain transfer in with authorization code and registrant information. + * 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. * * @param {string} domain - Domain name to transfer in. * @param {string} organizationId - Organization ID that this domain will belong to. * @param {string} authCode - Authorization code for the domain transfer. * @param {string} paymentMethodId - Payment method ID to authorize and capture the transfer. + * @param {boolean} autoRenewal - Whether the domain should renew automatically after transfer. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTransferIn(domain: string, organizationId: string, authCode: string, paymentMethodId: string): Promise; + createTransferIn(domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean): Promise; createTransferIn( - paramsOrFirst: { domain: string, organizationId: string, authCode: string, paymentMethodId: string } | string, - ...rest: [(string)?, (string)?, (string)?] + 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 }; + 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 }; + 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 + paymentMethodId: rest[2] as string, + autoRenewal: rest[3] as boolean }; } @@ -550,6 +560,7 @@ export class Domains { const organizationId = params.organizationId; const authCode = params.authCode; const paymentMethodId = params.paymentMethodId; + const autoRenewal = params.autoRenewal; if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); @@ -575,6 +586,9 @@ export class Domains { if (typeof authCode !== 'undefined') { payload['authCode'] = authCode; } + if (typeof autoRenewal !== 'undefined') { + payload['autoRenewal'] = autoRenewal; + } if (typeof paymentMethodId !== 'undefined') { payload['paymentMethodId'] = paymentMethodId; } @@ -593,7 +607,7 @@ export class Domains { } /** - * Confirm and complete a domain transfer in after payment authentication. + * 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. * * @param {string} params.domainId - Domain ID to confirm transfer for. * @param {string} params.organizationId - Team ID that owns the domain. @@ -602,7 +616,7 @@ export class Domains { */ updateTransferIn(params: { domainId: string, organizationId: string }): Promise; /** - * Confirm and complete a domain transfer in after payment authentication. + * 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. * * @param {string} domainId - Domain ID to confirm transfer for. * @param {string} organizationId - Team ID that owns the domain. @@ -656,7 +670,7 @@ export class Domains { } /** - * Create a domain transfer out and return the authorization code. + * 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. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.organizationId - Organization ID that this domain belongs to. @@ -665,7 +679,7 @@ export class Domains { */ createTransferOut(params: { domainId: string, organizationId: string }): Promise; /** - * Create a domain transfer out and return the authorization code. + * 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. * * @param {string} domainId - Domain unique ID. * @param {string} organizationId - Organization ID that this domain belongs to. @@ -826,6 +840,69 @@ export class Domains { ); } + /** + * Enable or disable auto-renewal for a domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {boolean} params.autoRenewal - Whether the domain should renew automatically. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAutoRenewal(params: { domainId: string, autoRenewal: boolean }): Promise; + /** + * Enable or disable auto-renewal for a domain. + * + * @param {string} domainId - Domain unique ID. + * @param {boolean} autoRenewal - Whether the domain should renew automatically. + * @throws {AppwriteException} + * @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)?] + ): Promise { + 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 + }; + } + + const domainId = params.domainId; + const autoRenewal = params.autoRenewal; + + if (typeof domainId === 'undefined') { + throw new AppwriteException('Missing required parameter: "domainId"'); + } + if (typeof autoRenewal === 'undefined') { + throw new AppwriteException('Missing required parameter: "autoRenewal"'); + } + + const apiPath = '/domains/{domainId}/auto-renewal'.replace('{domainId}', domainId); + const payload: Payload = {}; + if (typeof autoRenewal !== 'undefined') { + payload['autoRenewal'] = autoRenewal; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + /** * Verify which NS records are used and update the domain accordingly. This will check the domain's * nameservers and update the domain's status based on whether the nameservers match the expected @@ -3817,7 +3894,7 @@ export class Domains { } /** - * Get the transfer status for a domain. + * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -3825,7 +3902,7 @@ export class Domains { */ getTransferStatus(params: { domainId: string }): Promise; /** - * Get the transfer status for a domain. + * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} diff --git a/src/services/project.ts b/src/services/project.ts index cd4c5720..d9fe9435 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -84,15 +84,51 @@ export class Project { } /** - * Get a list of all project variables. These variables will be accessible in all Appwrite Functions at runtime. + * Get a list of all project environment variables. * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listVariables(): Promise { + listVariables(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all project environment variables. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @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. + */ + listVariables(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 }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/variables'; 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 } = { @@ -107,18 +143,20 @@ export class Project { } /** - * Create a new project variable. This variable will be accessible in all Appwrite Functions at runtime. + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * + * @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.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: { key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { variableId: string, key: string, value: string, secret?: boolean }): Promise; /** - * Create a new project variable. This variable will be accessible in all Appwrite Functions at runtime. + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * + * @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} 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. @@ -126,27 +164,32 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(key: string, value: string, secret?: boolean): Promise; + createVariable(variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (boolean)?] + paramsOrFirst: { variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] ): Promise { - let params: { 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 { key: string, value: string, secret?: boolean }; + params = (paramsOrFirst || {}) as { variableId: string, key: string, value: string, secret?: boolean }; } else { params = { - key: paramsOrFirst as string, - value: rest[0] as string, - secret: rest[1] as boolean + variableId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + 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 key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } @@ -156,6 +199,9 @@ export class Project { const apiPath = '/project/variables'; const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; + } if (typeof key !== 'undefined') { payload['key'] = key; } @@ -180,17 +226,17 @@ export class Project { } /** - * Get a project variable by its unique ID. + * Get a variable by its unique ID. * - * @param {string} params.variableId - Variable unique ID. + * @param {string} params.variableId - Variable ID. * @throws {AppwriteException} * @returns {Promise} */ getVariable(params: { variableId: string }): Promise; /** - * Get a project variable by its unique ID. + * Get a variable by its unique ID. * - * @param {string} variableId - Variable unique ID. + * @param {string} variableId - Variable ID. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -231,20 +277,20 @@ export class Project { } /** - * Update project variable by its unique ID. This variable will be accessible in all Appwrite Functions at runtime. + * Update variable by its unique ID. * - * @param {string} params.variableId - Variable unique ID. + * @param {string} params.variableId - Variable ID. * @param {string} params.key - Variable key. 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 project variable by its unique ID. This variable will be accessible in all Appwrite Functions at runtime. + * Update variable by its unique ID. * - * @param {string} variableId - Variable unique ID. + * @param {string} variableId - Variable ID. * @param {string} key - Variable key. 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. @@ -252,15 +298,15 @@ export class Project { * @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(variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { variableId: string, key: string, value?: string, secret?: boolean } | string, + 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 }; + 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 }; + params = (paramsOrFirst || {}) as { variableId: string, key?: string, value?: string, secret?: boolean }; } else { params = { variableId: paramsOrFirst as string, @@ -278,9 +324,6 @@ export class Project { if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); const payload: Payload = {}; @@ -308,17 +351,17 @@ export class Project { } /** - * Delete a project variable by its unique ID. + * Delete a variable by its unique ID. * - * @param {string} params.variableId - Variable unique ID. + * @param {string} params.variableId - Variable ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteVariable(params: { variableId: string }): Promise<{}>; /** - * Delete a project variable by its unique ID. + * Delete a variable by its unique ID. * - * @param {string} variableId - Variable unique ID. + * @param {string} variableId - Variable ID. * @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 c37d8768..add71230 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -5,7 +5,7 @@ import type { Models } from '../models'; import { UsageRange } from '../enums/usage-range'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; -import { IndexType } from '../enums/index-type'; +import { TablesDBIndexType } from '../enums/tables-db-index-type'; import { OrderBy } from '../enums/order-by'; export class TablesDB { @@ -4746,14 +4746,14 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Index Key. - * @param {IndexType} params.type - Index type. + * @param {TablesDBIndexType} params.type - Index type. * @param {string[]} params.columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} params.lengths - Length of index. Maximum of 100 * @throws {AppwriteException} * @returns {Promise} */ - createIndex(params: { databaseId: string, tableId: string, key: string, type: IndexType, 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`. @@ -4761,7 +4761,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Index Key. - * @param {IndexType} type - Index type. + * @param {TablesDBIndexType} type - Index type. * @param {string[]} columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} lengths - Length of index. Maximum of 100 @@ -4769,21 +4769,21 @@ 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: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[]): Promise; + 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: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (IndexType)?, (string[])?, (OrderBy[])?, (number[])?] + 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: IndexType, 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: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, - type: rest[2] as IndexType, + type: rest[2] as TablesDBIndexType, columns: rest[3] as string[], orders: rest[4] as OrderBy[], lengths: rest[5] as number[] diff --git a/src/services/users.ts b/src/services/users.ts index 5451dc68..0d0555d2 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -17,7 +17,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 + * @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 * @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} @@ -27,7 +27,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 + * @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 * @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} @@ -1169,6 +1169,71 @@ 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. + * + * + * @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>; + /** + * 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. + * @throws {AppwriteException} + * @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)?] + ): Promise> { + 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 + }; + } + + const userId = params.userId; + const impersonator = params.impersonator; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof impersonator === 'undefined') { + throw new AppwriteException('Missing required parameter: "impersonator"'); + } + + const apiPath = '/users/{userId}/impersonator'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof impersonator !== 'undefined') { + payload['impersonator'] = impersonator; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + 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. *