Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/documentsdb/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ const result = await documentsDB.createDocument({
isAdmin: false,
},
permissions: [sdk.Permission.read(sdk.Role.any())], // optional
transactionId: '<TRANSACTION_ID>', // optional
});
```
1 change: 1 addition & 0 deletions docs/examples/documentsdb/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const result = await documentsDB.createDocuments({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documents: [],
transactionId: '<TRANSACTION_ID>', // optional
});
```
16 changes: 16 additions & 0 deletions docs/examples/project/update-o-auth-2-cloudflare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
const sdk = require('node-appwrite');

const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

const project = new sdk.Project(client);

const result = await project.updateOAuth2Cloudflare({
clientId: '<CLIENT_ID>', // optional
clientSecret: '<CLIENT_SECRET>', // optional
enabled: false, // optional
});
```
16 changes: 16 additions & 0 deletions docs/examples/project/update-o-auth-2-resend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
const sdk = require('node-appwrite');

const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

const project = new sdk.Project(client);

const result = await project.updateOAuth2Resend({
clientId: '<CLIENT_ID>', // optional
clientSecret: '<CLIENT_SECRET>', // optional
enabled: false, // optional
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<DATABASE_ID>',
migrationId: '<MIGRATION_ID>',
});
Expand Down
1 change: 1 addition & 0 deletions docs/examples/vectorsdb/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ const result = await vectorsDB.createDocument({
},
},
permissions: [sdk.Permission.read(sdk.Role.any())], // optional
transactionId: '<TRANSACTION_ID>', // optional
});
```
1 change: 1 addition & 0 deletions docs/examples/vectorsdb/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const result = await vectorsDB.createDocuments({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documents: [],
transactionId: '<TRANSACTION_ID>', // optional
});
```
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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',
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/enums/o-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum OAuthProvider {
Bitbucket = 'bitbucket',
Bitly = 'bitly',
Box = 'box',
Cloudflare = 'cloudflare',
Dailymotion = 'dailymotion',
Discord = 'discord',
Disqus = 'disqus',
Expand All @@ -30,6 +31,7 @@ export enum OAuthProvider {
Paypal = 'paypal',
PaypalSandbox = 'paypalSandbox',
Podio = 'podio',
Resend = 'resend',
Salesforce = 'salesforce',
Slack = 'slack',
Spotify = 'spotify',
Expand Down
4 changes: 4 additions & 0 deletions src/enums/project-key-scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/enums/project-o-auth-provider-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum ProjectOAuthProviderId {
Bitbucket = 'bitbucket',
Bitly = 'bitly',
Box = 'box',
Cloudflare = 'cloudflare',
Dailymotion = 'dailymotion',
Discord = 'discord',
Disqus = 'disqus',
Expand All @@ -30,6 +31,7 @@ export enum ProjectOAuthProviderId {
Paypal = 'paypal',
PaypalSandbox = 'paypalSandbox',
Podio = 'podio',
Resend = 'resend',
Salesforce = 'salesforce',
Slack = 'slack',
Spotify = 'spotify',
Expand Down
60 changes: 57 additions & 3 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -6011,6 +6055,8 @@ export namespace Models {
| Models.OAuth2Kick
| Models.OAuth2Microsoft
| Models.OAuth2HuggingFace
| Models.OAuth2Resend
| Models.OAuth2Cloudflare
)[];
};

Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -8209,7 +8259,7 @@ export namespace Models {
*/
specification: string;
/**
* Database backend provider. Possible values: prisma, edge.
* Database backend provider. Possible values: edge.
*/
backend: string;
/**
Expand All @@ -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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Credential generation excludes null

When a dedicated database's credential-rotation contract has not been initialized, the API contract permits credentialGeneration to be null, but this model declares it as an unconditional number, causing consumers to make unsafe numeric assumptions about the response.

Suggested change
credentialGeneration: number;
credentialGeneration: number | null;

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/models.ts
Line: 8284

Comment:
**Credential generation excludes null**

When a dedicated database's credential-rotation contract has not been initialized, the API contract permits `credentialGeneration` to be null, but this model declares it as an unconditional `number`, causing consumers to make unsafe numeric assumptions about the response.

```suggestion
        credentialGeneration: number | null;
```

**Knowledge Base Used:**
- [Generated models and enum vocabulary](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-node/-/docs/models-and-enums.md)
- [SDK data contracts and helpers](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-node/-/docs/sdk-data-contracts.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

/**
* Full database connection string (URI format).
*/
Expand Down Expand Up @@ -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;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Loading
Loading