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
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ jobs:

- name: Determine release tag
id: release_tag
env:
REF: ${{ github.ref }}
run: |
if [[ "${{ github.ref }}" == *"-rc"* ]] || [[ "${{ github.ref }}" == *"-RC"* ]]; then
if [[ "$REF" == *"-rc"* ]] || [[ "$REF" == *"-RC"* ]]; then
echo "tag=next" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## 31.1.0

* Added: `Migrations` service to run Appwrite, Firebase, NHost, Supabase, CSV and JSON migrations, plus retries and listing
* Added: `AppwriteMigrationResource`, `FirebaseMigrationResource`, `NHostMigrationResource`, `SupabaseMigrationResource` and `OnDuplicate` enums
* Added: `project.updateDenyRealtimeGuestsPolicy`, `Models.PolicyDenyRealtimeGuests` and `ProjectPolicyId.Denyrealtimeguests`
* Added: `project.deleteSessions` to sign out every user in the project
* Added: `BillingPlan.deploymentRetention`, `deploymentRetentionMax` and `deploymentsRetentionCount`
* Added: `python-3.15`, `deno-2.9`, `go-1.27` and `rust-1.99` to `Runtime` and `BuildRuntime`
* Updated: requests send `X-Appwrite-Response-Format: 2.6.2`; README targets Appwrite 2.6.x
* Updated: redirects are no longer followed; a 3xx throws `AppwriteException` naming the `Location`
* Fixed: path parameters `.` and `..` throw `AppwriteException` instead of changing the request URL
* Updated: dev dependencies `eslint`, `typescript-eslint`, `prettier` and `@types/node` refreshed

## 31.0.0

* Breaking: positional `tablesDB`, `documentsDB` and `vectorsDB` `create` and `update` take `description` before `specification`
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Appwrite Node.js SDK

![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-2.6.2-blue.svg?style=flat-square)
[![X Account](https://img.shields.io/badge/follow-%40appwrite-000000?logo=x&style=flat-square)](https://x.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ.
**This SDK targets Appwrite server version 2.6.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
2 changes: 1 addition & 1 deletion docs/examples/backups/update-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const result = await backups.updatePolicy({
policyId: '<POLICY_ID>',
name: '<NAME>', // optional
retention: 1, // optional
schedule: '', // optional
schedule: undefined, // optional
enabled: false, // optional
});
```
18 changes: 18 additions & 0 deletions docs/examples/migrations/create-appwrite-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createAppwriteMigration({
resources: [sdk.AppwriteMigrationResource.User],
endpoint: 'https://example.com',
projectId: '<PROJECT_ID>',
apiKey: '<API_KEY>',
onDuplicate: sdk.OnDuplicate.Fail, // optional
});
```
23 changes: 23 additions & 0 deletions docs/examples/migrations/create-csv-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createCSVExport({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
filename: '<FILENAME>',
columns: [], // optional
queries: [], // optional
delimiter: '<DELIMITER>', // optional
enclosure: '<ENCLOSURE>', // optional
escape: '<ESCAPE>', // optional
header: false, // optional
notify: false, // optional
});
```
19 changes: 19 additions & 0 deletions docs/examples/migrations/create-csv-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createCSVImport({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
internalFile: false, // optional
onDuplicate: sdk.OnDuplicate.Fail, // optional
});
```
15 changes: 15 additions & 0 deletions docs/examples/migrations/create-firebase-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createFirebaseMigration({
resources: [sdk.FirebaseMigrationResource.User],
serviceAccount: '<SERVICE_ACCOUNT>',
});
```
19 changes: 19 additions & 0 deletions docs/examples/migrations/create-json-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createJSONExport({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
filename: '<FILENAME>',
columns: [], // optional
queries: [], // optional
notify: false, // optional
});
```
19 changes: 19 additions & 0 deletions docs/examples/migrations/create-json-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createJSONImport({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
internalFile: false, // optional
onDuplicate: sdk.OnDuplicate.Fail, // optional
});
```
21 changes: 21 additions & 0 deletions docs/examples/migrations/create-n-host-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createNHostMigration({
resources: [sdk.NHostMigrationResource.User],
subdomain: '<SUBDOMAIN>',
region: '<REGION>',
adminSecret: '<ADMIN_SECRET>',
database: '<DATABASE>',
username: '<USERNAME>',
password: 'password',
port: 5432, // optional
});
```
20 changes: 20 additions & 0 deletions docs/examples/migrations/create-supabase-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.createSupabaseMigration({
resources: [sdk.SupabaseMigrationResource.User],
endpoint: 'https://example.com',
apiKey: '<API_KEY>',
databaseHost: '<DATABASE_HOST>',
username: '<USERNAME>',
password: 'password',
port: 5432, // optional
});
```
14 changes: 14 additions & 0 deletions docs/examples/migrations/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.delete({
migrationId: '<MIGRATION_ID>',
});
```
14 changes: 14 additions & 0 deletions docs/examples/migrations/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.get({
migrationId: '<MIGRATION_ID>',
});
```
16 changes: 16 additions & 0 deletions docs/examples/migrations/list.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 migrations = new sdk.Migrations(client);

const result = await migrations.list({
queries: [], // optional
search: '<SEARCH>', // optional
total: false, // optional
});
```
14 changes: 14 additions & 0 deletions docs/examples/migrations/retry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```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 migrations = new sdk.Migrations(client);

const result = await migrations.retry({
migrationId: '<MIGRATION_ID>',
});
```
2 changes: 1 addition & 1 deletion docs/examples/mongo/update-backup-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const result = await mongo.updateBackupPolicy({
databaseId: '<DATABASE_ID>',
policyId: '<POLICY_ID>',
name: '<NAME>', // optional
schedule: '', // optional
schedule: undefined, // optional
retention: 1, // optional
enabled: false, // optional
});
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/mongo/update-backup-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const result = await mongo.updateBackupStorage({
secretKey: '<SECRET_KEY>',
region: '<REGION>', // optional
prefix: '<PREFIX>', // optional
endpoint: '<ENDPOINT>', // optional
endpoint: 'https://example.com', // optional
});
```
2 changes: 1 addition & 1 deletion docs/examples/mysql/update-backup-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const result = await mysql.updateBackupPolicy({
databaseId: '<DATABASE_ID>',
policyId: '<POLICY_ID>',
name: '<NAME>', // optional
schedule: '', // optional
schedule: undefined, // optional
retention: 1, // optional
enabled: false, // optional
});
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/mysql/update-backup-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const result = await mysql.updateBackupStorage({
secretKey: '<SECRET_KEY>',
region: '<REGION>', // optional
prefix: '<PREFIX>', // optional
endpoint: '<ENDPOINT>', // optional
endpoint: 'https://example.com', // optional
});
```
2 changes: 1 addition & 1 deletion docs/examples/oauth2/authorize-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const oauth2 = new sdk.Oauth2(client);
const result = await oauth2.authorizePost({
clientId: '<CLIENT_ID>', // optional
redirectUri: 'https://example.com', // optional
responseType: '', // optional
responseType: undefined, // optional
scope: '<SCOPE>', // optional
state: '<STATE>', // optional
nonce: '<NONCE>', // optional
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/oauth2/authorize.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const oauth2 = new sdk.Oauth2(client);
const result = await oauth2.authorize({
clientId: '<CLIENT_ID>', // optional
redirectUri: 'https://example.com', // optional
responseType: '', // optional
responseType: undefined, // optional
scope: '<SCOPE>', // optional
state: '<STATE>', // optional
nonce: '<NONCE>', // optional
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/postgresql/update-backup-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const result = await postgresql.updateBackupPolicy({
databaseId: '<DATABASE_ID>',
policyId: '<POLICY_ID>',
name: '<NAME>', // optional
schedule: '', // optional
schedule: undefined, // optional
retention: 1, // optional
enabled: false, // optional
});
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/postgresql/update-backup-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const result = await postgresql.updateBackupStorage({
secretKey: '<SECRET_KEY>',
region: '<REGION>', // optional
prefix: '<PREFIX>', // optional
endpoint: '<ENDPOINT>', // optional
endpoint: 'https://example.com', // optional
});
```
10 changes: 10 additions & 0 deletions docs/examples/project/create-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ const project = new sdk.Project(client);
const result = await project.createEnvironment({
environmentId: '<ENVIRONMENT_ID>',
name: '<NAME>',
resources: [
sdk.EnvironmentResource.Database,
sdk.EnvironmentResource.Table,
sdk.EnvironmentResource.Column,
sdk.EnvironmentResource.Index,
sdk.EnvironmentResource.Bucket,
sdk.EnvironmentResource.Team,
sdk.EnvironmentResource.Function,
sdk.EnvironmentResource.EnvironmentVariable,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the exported environment resource member

The enum exports Environmentvariable (lowercase v), so EnvironmentVariable is undefined. JavaScript will serialize this array entry as null and TypeScript users will get a compile error; please use the exported member name.

Suggested change
sdk.EnvironmentResource.EnvironmentVariable,
sdk.EnvironmentResource.Environmentvariable,
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/examples/project/create-environment.md
Line: 22

Comment:
**Use the exported environment resource member**

The enum exports `Environmentvariable` (lowercase `v`), so `EnvironmentVariable` is undefined. JavaScript will serialize this array entry as `null` and TypeScript users will get a compile error; please use the exported member name.

```suggestion
        sdk.EnvironmentResource.Environmentvariable,
```

---

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

🟡 Minor · documentation · Reply if this doesn't apply.

], // optional
});
```
12 changes: 12 additions & 0 deletions docs/examples/project/delete-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```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.deleteSessions();
```
14 changes: 14 additions & 0 deletions docs/examples/project/update-deny-realtime-guests-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```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.updateDenyRealtimeGuestsPolicy({
enabled: false,
});
```
2 changes: 1 addition & 1 deletion docs/examples/storage/update-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const storage = new sdk.Storage(client);
const result = await storage.updateFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
name: '<NAME>', // optional
name: undefined, // optional
permissions: [sdk.Permission.read(sdk.Role.any())], // optional
});
```
Loading