From 764e4a49dac16c094e24e83b1771f0c6fc340d2c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 2 Sep 2026 14:05:22 +0100 Subject: [PATCH] chore: update Node.js SDK to 29.0.0 --- CHANGELOG.md | 11 ++ README.md | 4 +- docs/examples/documentsdb/create-document.md | 1 + docs/examples/documentsdb/create-documents.md | 1 + .../project/update-o-auth-2-cloudflare.md | 16 ++ .../project/update-o-auth-2-resend.md | 16 ++ ...cutover-migration.md => create-cutover.md} | 2 +- docs/examples/vectorsdb/create-document.md | 1 + docs/examples/vectorsdb/create-documents.md | 1 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 6 +- src/enums/o-auth-provider.ts | 2 + src/enums/project-key-scopes.ts | 4 + src/enums/project-o-auth-provider-id.ts | 2 + src/models.ts | 60 +++++- src/services/account.ts | 4 +- src/services/avatars.ts | 16 +- src/services/documents-db.ts | 33 +++- src/services/mongo.ts | 16 +- src/services/mysql.ts | 16 +- src/services/postgresql.ts | 16 +- src/services/project.ts | 180 +++++++++++++++++- src/services/tables-db.ts | 8 +- src/services/vectors-db.ts | 33 +++- test/services/documents-d-b.test.js | 1 + test/services/mongo.test.js | 60 ++---- test/services/mysql.test.js | 60 ++---- test/services/postgresql.test.js | 62 ++---- test/services/project.test.js | 32 ++++ test/services/tables-d-b.test.js | 5 +- test/services/vectors-d-b.test.js | 1 + 32 files changed, 486 insertions(+), 190 deletions(-) create mode 100644 docs/examples/project/update-o-auth-2-cloudflare.md create mode 100644 docs/examples/project/update-o-auth-2-resend.md rename docs/examples/tablesdb/{cutover-migration.md => create-cutover.md} (88%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d247dd..658b743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## 29.0.0 + +* Stable release of the dedicated database APIs: `mysql`, `postgresql`, `mongo`, `documentsDB`, and `vectorsDB` services, previously released as release candidates +* Breaking: `tablesDB.cutoverMigration` is renamed to `tablesDB.createCutover` +* Breaking: `Execution.functionId` is replaced by `resourceId` and `resourceType`, covering function and site executions +* Added: Cloudflare, Resend, and Hugging Face OAuth providers +* Added: `usageAggregateOnlyMetrics` on the `BillingPlan` model +* Fixed: `transactionId` is accepted again by `documentsDB` and `vectorsDB` `createDocument` and `createDocuments` +* Updated: `X-Appwrite-Response-Format` is now `2.0.0` +* Updated: `FrameworkAdapter.fallbackFile` is now optional + ## 29.0.0-rc.1 * Breaking: `Execution.functionId` is replaced by `resourceId` and `resourceType`, now that executions cover both functions and sites diff --git a/README.md b/README.md index 714b8bd..83b7e18 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-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-node/releases).** +**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index 9b3e1d1..96733e3 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -20,5 +20,6 @@ const result = await documentsDB.createDocument({ isAdmin: false, }, permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 35884cc..298af8c 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -12,5 +12,6 @@ const result = await documentsDB.createDocuments({ databaseId: '', collectionId: '', documents: [], + transactionId: '', // optional }); ``` 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 0000000..ae26fc9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-cloudflare.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Cloudflare({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); +``` 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 0000000..d6c7068 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-resend.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Resend({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/tablesdb/cutover-migration.md b/docs/examples/tablesdb/create-cutover.md similarity index 88% rename from docs/examples/tablesdb/cutover-migration.md rename to docs/examples/tablesdb/create-cutover.md index 08403b9..71f02bb 100644 --- a/docs/examples/tablesdb/cutover-migration.md +++ b/docs/examples/tablesdb/create-cutover.md @@ -8,7 +8,7 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); -const result = await tablesDB.cutoverMigration({ +const result = await tablesDB.createCutover({ databaseId: '', migrationId: '', }); diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index fc9114a..35778de 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -19,5 +19,6 @@ const result = await vectorsDB.createDocument({ }, }, permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 906ec6a..bcaedd4 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -12,5 +12,6 @@ const result = await vectorsDB.createDocuments({ databaseId: '', collectionId: '', documents: [], + transactionId: '', // optional }); ``` diff --git a/package-lock.json b/package-lock.json index d1bb80e..6c386f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "29.0.0-rc.1", + "version": "29.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "29.0.0-rc.1", + "version": "29.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index baec786..1fd513c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "29.0.0-rc.1", + "version": "29.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index e83744d..10ff729 100644 --- a/src/client.ts +++ b/src/client.ts @@ -80,7 +80,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/29.0.0-rc.1'; + let ua = 'AppwriteNodeJSSDK/29.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -142,9 +142,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '29.0.0-rc.1', + 'x-sdk-version': '29.0.0', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '1.9.6', + 'X-Appwrite-Response-Format': '2.0.0', }; /** diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index 6f0a461..2d838dd 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', @@ -30,6 +31,7 @@ export enum OAuthProvider { Paypal = 'paypal', PaypalSandbox = 'paypalSandbox', Podio = 'podio', + Resend = 'resend', Salesforce = 'salesforce', Slack = 'slack', Spotify = 'spotify', diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index e960600..e17dffd 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -47,12 +47,16 @@ export enum ProjectKeyScopes { 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', diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts index 401f3d1..f7cd133 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', @@ -30,6 +31,7 @@ export enum ProjectOAuthProviderId { Paypal = 'paypal', PaypalSandbox = 'paypalSandbox', Podio = 'podio', + Resend = 'resend', Salesforce = 'salesforce', Slack = 'slack', Spotify = 'spotify', diff --git a/src/models.ts b/src/models.ts index 5ad29b7..408bbdd 100644 --- a/src/models.ts +++ b/src/models.ts @@ -4328,7 +4328,7 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile: string; + fallbackFile?: string; }; /** @@ -5471,6 +5471,28 @@ export namespace Models { 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 */ @@ -5957,6 +5979,28 @@ export namespace Models { 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; + }; + /** * OAuth2 Providers List */ @@ -6011,6 +6055,8 @@ export namespace Models { | Models.OAuth2Kick | Models.OAuth2Microsoft | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare )[]; }; @@ -7672,6 +7718,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. */ @@ -8209,7 +8259,7 @@ export namespace Models { */ specification: string; /** - * Database backend provider. Possible values: prisma, edge. + * Database backend provider. Possible values: edge. */ backend: string; /** @@ -8228,6 +8278,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). */ @@ -8587,7 +8641,7 @@ 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; /** diff --git a/src/services/account.ts b/src/services/account.ts index b871ac7..02085be 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -2901,7 +2901,7 @@ export class Account { * * 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, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {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, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -2921,7 +2921,7 @@ export class Account { * * 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, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {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, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 2ffb0da..e2f4afd 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -636,16 +636,16 @@ export class Avatars { /** * Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. * - * The photo resolves for the currently authenticated user unless `userId` points at another user. Passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the user's own identity photos, email, and name leave the chain so they never shadow the avatar being asked for. Emails are only ever accepted pre-hashed, so no address ends up in a URL. + * 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. Defaults to 'current()' for the currently authenticated user. - * @param {string} params.emailHash - SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own photo sources. Pass the hash, never the address itself. - * @param {string} params.name - Name to render initials from instead of the user's own photo sources. Max length: 128 chars. + * @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 {Promise} */ @@ -662,16 +662,16 @@ export class Avatars { /** * Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. * - * The photo resolves for the currently authenticated user unless `userId` points at another user. Passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the user's own identity photos, email, and name leave the chain so they never shadow the avatar being asked for. Emails are only ever accepted pre-hashed, so no address ends up in a URL. + * 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. Defaults to 'current()' for the currently authenticated user. - * @param {string} emailHash - SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own photo sources. Pass the hash, never the address itself. - * @param {string} name - Name to render initials from instead of the user's own photo sources. Max length: 128 chars. + * @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 {Promise} * @deprecated Use the object parameter style method for a better developer experience. diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 3e5525b..8a9eec0 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1562,6 +1562,7 @@ 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} */ @@ -1575,6 +1576,7 @@ export class DocumentsDB { ? 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. @@ -1584,6 +1586,7 @@ 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. @@ -1596,6 +1599,7 @@ export class DocumentsDB { ? Partial & Record : Partial & Omit, permissions?: string[], + transactionId?: string, ): Promise; createDocument( paramsOrFirst: @@ -1608,6 +1612,7 @@ export class DocumentsDB { : Partial & Omit; permissions?: string[]; + transactionId?: string; } | string, ...rest: [ @@ -1618,6 +1623,7 @@ export class DocumentsDB { : Partial & Omit)?, string[]?, + string?, ] ): Promise { let params: { @@ -1629,6 +1635,7 @@ export class DocumentsDB { : Partial & Omit; permissions?: string[]; + transactionId?: string; }; if ( @@ -1645,6 +1652,7 @@ export class DocumentsDB { : Partial & Omit; permissions?: string[]; + transactionId?: string; }; } else { params = { @@ -1656,6 +1664,7 @@ export class DocumentsDB { : Partial & Omit, permissions: rest[3] as string[], + transactionId: rest[4] as string, }; } @@ -1664,6 +1673,7 @@ export class DocumentsDB { 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"', @@ -1699,6 +1709,9 @@ export class DocumentsDB { if (typeof permissions !== 'undefined') { apiPayload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1716,6 +1729,7 @@ 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>} */ @@ -1725,6 +1739,7 @@ export class DocumentsDB { 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. @@ -1732,6 +1747,7 @@ export class DocumentsDB { * @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. @@ -1740,17 +1756,24 @@ export class DocumentsDB { databaseId: string, collectionId: string, documents: object[], + transactionId?: string, ): Promise>; createDocuments( paramsOrFirst: - | { databaseId: string; collectionId: string; documents: object[] } + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } | string, - ...rest: [string?, object[]?] + ...rest: [string?, object[]?, string?] ): Promise> { let params: { databaseId: string; collectionId: string; documents: object[]; + transactionId?: string; }; if ( @@ -1762,18 +1785,21 @@ export class DocumentsDB { databaseId: string; collectionId: string; documents: object[]; + transactionId?: string; }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], + transactionId: rest[2] as string, }; } const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -1800,6 +1826,9 @@ export class DocumentsDB { if (typeof documents !== 'undefined') { apiPayload['documents'] = documents; } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/mongo.ts b/src/services/mongo.ts index ad151b2..c649216 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1947,27 +1947,29 @@ export class Mongo { } /** - * 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; + }): 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( + databaseId: string, + ): Promise; updateCredentials( paramsOrFirst: { databaseId: string } | string, - ): Promise { + ): Promise { let params: { databaseId: string }; if ( diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 95b850e..61fc35d 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1947,27 +1947,29 @@ export class Mysql { } /** - * 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; + }): 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( + databaseId: string, + ): Promise; updateCredentials( paramsOrFirst: { databaseId: string } | string, - ): Promise { + ): Promise { let params: { databaseId: string }; if ( diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index 414d7be..330ee27 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1947,27 +1947,29 @@ export class Postgresql { } /** - * 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; + }): 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( + databaseId: string, + ): Promise; updateCredentials( paramsOrFirst: { databaseId: string } | string, - ): Promise { + ): Promise { let params: { databaseId: string }; if ( diff --git a/src/services/project.ts b/src/services/project.ts index 2c6ea0a..cc63f31 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -2019,6 +2019,91 @@ export class Project { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * 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 ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + const apiPath = '/project/oauth2/cloudflare'; + const apiPayload: Payload = {}; + if (typeof clientId !== 'undefined') { + apiPayload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + apiPayload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + /** * Update the project OAuth2 Dailymotion configuration. * @@ -4087,6 +4172,91 @@ export class Project { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * 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 ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + const apiPath = '/project/oauth2/resend'; + const apiPayload: Payload = {}; + if (typeof clientId !== 'undefined') { + apiPayload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + apiPayload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + /** * Update the project OAuth2 Salesforce configuration. * @@ -5209,7 +5379,7 @@ export class Project { * * @param {ProjectOAuthProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getOAuth2Provider(params: { providerId: ProjectOAuthProviderId; @@ -5238,6 +5408,8 @@ export class Project { | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon @@ -5261,7 +5433,7 @@ export class Project { * * @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( @@ -5291,6 +5463,8 @@ export class Project { | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon @@ -5337,6 +5511,8 @@ export class Project { | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2HuggingFace + | Models.OAuth2Resend + | Models.OAuth2Cloudflare | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index c24744d..b57d096 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1243,7 +1243,7 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - cutoverMigration(params: { + createCutover(params: { databaseId: string; migrationId: string; }): Promise; @@ -1256,11 +1256,11 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - cutoverMigration( + createCutover( databaseId: string, migrationId: string, ): Promise; - cutoverMigration( + createCutover( paramsOrFirst: { databaseId: string; migrationId: string } | string, ...rest: [string?] ): Promise { @@ -1295,7 +1295,7 @@ export class TablesDB { ); } const apiPath = - '/tablesdb/{databaseId}/migrations/{migrationId}/cutover' + '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' .replace('{databaseId}', encodeURIComponent(String(databaseId))) .replace( '{migrationId}', diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 97ac1dd..59fec93 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1547,6 +1547,7 @@ 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} */ @@ -1560,6 +1561,7 @@ export class VectorsDB { ? 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. @@ -1569,6 +1571,7 @@ 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. @@ -1581,6 +1584,7 @@ export class VectorsDB { ? Partial & Record : Partial & Omit, permissions?: string[], + transactionId?: string, ): Promise; createDocument( paramsOrFirst: @@ -1593,6 +1597,7 @@ export class VectorsDB { : Partial & Omit; permissions?: string[]; + transactionId?: string; } | string, ...rest: [ @@ -1603,6 +1608,7 @@ export class VectorsDB { : Partial & Omit)?, string[]?, + string?, ] ): Promise { let params: { @@ -1614,6 +1620,7 @@ export class VectorsDB { : Partial & Omit; permissions?: string[]; + transactionId?: string; }; if ( @@ -1630,6 +1637,7 @@ export class VectorsDB { : Partial & Omit; permissions?: string[]; + transactionId?: string; }; } else { params = { @@ -1641,6 +1649,7 @@ export class VectorsDB { : Partial & Omit, permissions: rest[3] as string[], + transactionId: rest[4] as string, }; } @@ -1649,6 +1658,7 @@ export class VectorsDB { 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"', @@ -1684,6 +1694,9 @@ export class VectorsDB { if (typeof permissions !== 'undefined') { apiPayload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1701,6 +1714,7 @@ 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>} */ @@ -1710,6 +1724,7 @@ export class VectorsDB { 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. @@ -1717,6 +1732,7 @@ export class VectorsDB { * @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. @@ -1725,17 +1741,24 @@ export class VectorsDB { databaseId: string, collectionId: string, documents: object[], + transactionId?: string, ): Promise>; createDocuments( paramsOrFirst: - | { databaseId: string; collectionId: string; documents: object[] } + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } | string, - ...rest: [string?, object[]?] + ...rest: [string?, object[]?, string?] ): Promise> { let params: { databaseId: string; collectionId: string; documents: object[]; + transactionId?: string; }; if ( @@ -1747,18 +1770,21 @@ export class VectorsDB { databaseId: string; collectionId: string; documents: object[]; + transactionId?: string; }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], + transactionId: rest[2] as string, }; } const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -1785,6 +1811,9 @@ export class VectorsDB { if (typeof documents !== 'undefined') { apiPayload['documents'] = documents; } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 26a4f93..75f1be0 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -625,6 +625,7 @@ describe('DocumentsDB', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index eb7d7dc..e70b2be 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -40,6 +40,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -112,6 +113,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -170,6 +172,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -448,6 +451,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,6 +510,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -555,51 +560,12 @@ describe('Mongo', () => { const data = { '\\$id': '5e5ea5c16897e', '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - projectId: '5e5ea5c16897e', - name: 'My Production Database', - api: 'postgresql', - engine: 'postgresql', - version: '16', - specification: 's-2vcpu-2gb', - backend: 'edge', - hostname: 'db-myproject-mydb.fra.appwrite.center', - connectionPort: 5432, - connectionUser: 'appwrite_user', - connectionPassword: '••••••••', - connectionString: - 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', - ssl: true, - status: 'ready', - containerStatus: 'active', - lifecycleState: 'active', - idleTimeoutMinutes: 15, - cpu: 2000, - memory: 4096, - storage: 100, - storageClass: 'ssd', - storageMaxGb: 100, - nodePool: 'db-pool-4vcpu-8gb', - replicas: 2, - syncMode: 'async', - networkMaxConnections: 500, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 14, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 500, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: true, - sqlApiEnabled: true, - sqlApiAllowedStatements: [], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', + databaseId: '5e5ea5c16897e', + type: 'update', + status: 'completed', + attempts: 1, + errorCode: 'Interrupted', + errorMessage: '', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await mongo.updateCredentials(''); @@ -625,6 +591,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -683,6 +650,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -745,6 +713,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -931,6 +900,7 @@ describe('Mongo', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 3cd1e69..7ff39f8 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -40,6 +40,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -112,6 +113,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -170,6 +172,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -448,6 +451,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,6 +510,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -555,51 +560,12 @@ describe('Mysql', () => { const data = { '\\$id': '5e5ea5c16897e', '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - projectId: '5e5ea5c16897e', - name: 'My Production Database', - api: 'postgresql', - engine: 'postgresql', - version: '16', - specification: 's-2vcpu-2gb', - backend: 'edge', - hostname: 'db-myproject-mydb.fra.appwrite.center', - connectionPort: 5432, - connectionUser: 'appwrite_user', - connectionPassword: '••••••••', - connectionString: - 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', - ssl: true, - status: 'ready', - containerStatus: 'active', - lifecycleState: 'active', - idleTimeoutMinutes: 15, - cpu: 2000, - memory: 4096, - storage: 100, - storageClass: 'ssd', - storageMaxGb: 100, - nodePool: 'db-pool-4vcpu-8gb', - replicas: 2, - syncMode: 'async', - networkMaxConnections: 500, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 14, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 500, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: true, - sqlApiEnabled: true, - sqlApiAllowedStatements: [], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', + databaseId: '5e5ea5c16897e', + type: 'update', + status: 'completed', + attempts: 1, + errorCode: 'Interrupted', + errorMessage: '', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await mysql.updateCredentials(''); @@ -642,6 +608,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -700,6 +667,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -762,6 +730,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -990,6 +959,7 @@ describe('Mysql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index eb277f2..7e8b1f6 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -40,6 +40,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -112,6 +113,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -170,6 +172,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -451,6 +454,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -509,6 +513,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -558,51 +563,12 @@ describe('Postgresql', () => { const data = { '\\$id': '5e5ea5c16897e', '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - projectId: '5e5ea5c16897e', - name: 'My Production Database', - api: 'postgresql', - engine: 'postgresql', - version: '16', - specification: 's-2vcpu-2gb', - backend: 'edge', - hostname: 'db-myproject-mydb.fra.appwrite.center', - connectionPort: 5432, - connectionUser: 'appwrite_user', - connectionPassword: '••••••••', - connectionString: - 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', - ssl: true, - status: 'ready', - containerStatus: 'active', - lifecycleState: 'active', - idleTimeoutMinutes: 15, - cpu: 2000, - memory: 4096, - storage: 100, - storageClass: 'ssd', - storageMaxGb: 100, - nodePool: 'db-pool-4vcpu-8gb', - replicas: 2, - syncMode: 'async', - networkMaxConnections: 500, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 14, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 500, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: true, - sqlApiEnabled: true, - sqlApiAllowedStatements: [], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', + databaseId: '5e5ea5c16897e', + type: 'update', + status: 'completed', + attempts: 1, + errorCode: 'Interrupted', + errorMessage: '', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await postgresql.updateCredentials(''); @@ -662,6 +628,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -723,6 +690,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -784,6 +752,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -842,6 +811,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -904,6 +874,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1135,6 +1106,7 @@ describe('Postgresql', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/project.test.js b/test/services/project.test.js index 0093f1e..026c953 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -484,6 +484,22 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updateOAuth2Cloudflare()', async () => { + const data = { + '\\$id': 'github', + enabled: true, + clientId: '4b866000000000000000000000c9e4e2', + clientSecret: + 'cfoc_5Q6YRl0000000000000000000000000000000000003d214f', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2Cloudflare(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updateOAuth2Dailymotion()', async () => { const data = { '\\$id': 'github', @@ -841,6 +857,22 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updateOAuth2Resend()', async () => { + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', + clientSecret: + '9c1e4b00000000000000000000000000000000000000000000000000a72d5f4', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2Resend(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updateOAuth2Salesforce()', async () => { const data = { '\\$id': 'github', diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 21e3719..4c412e4 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -206,6 +206,7 @@ describe('TablesDB', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -336,7 +337,7 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method cutoverMigration()', async () => { + test('test method createCutover()', async () => { const data = { '\\$id': '5e5ea5c16897e', '\\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -357,7 +358,7 @@ describe('TablesDB', () => { paused: true, }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.cutoverMigration( + const response = await tablesDB.createCutover( '', '', ); diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index c36293a..ce941cd 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -597,6 +597,7 @@ describe('VectorsDB', () => { connectionPort: 5432, connectionUser: 'appwrite_user', connectionPassword: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true,