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
92 changes: 64 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,70 @@
# Change Log

## 30.0.0-rc.2

* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants)
* Added: `Topic` and `ResolvedTopic` exports
* Added: `Models.Account` and `Models.OAuth2Webflow` types
* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums
* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods
* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions
* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file
* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object

## 30.0.0

* Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed
* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed
* Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed
* Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block`
* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification`
* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start`
* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model
* Added: `domains` service for domains, DNS records, email presets, prices and transfers
* Added: `account.createIdTokenSession` and email verification and recovery OTP methods
## 30.0.1

* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes
* Breaking: removed `account.listLogs`, `users.listLogs` and the `Models.Log`/`Models.LogList` models
* Breaking: removed `organization.createKey`, `getKey`, `listKeys`, `updateKey` and `deleteKey`, and `OrganizationKeyScopes`; use `organization.listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` instead
* Breaking: removed `Client.setDevKey`, `Models.DevKey` and `Project.devKeys`
* Breaking: removed `BillingPlanGroup.Starter`; use `BillingPlanGroup.Free`
* Breaking: `listSpecifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `pricing` field and the `DedicatedDatabaseSpecificationPricing` model
* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan`
* Breaking: OAuth2 `resource` params now take `string[]`
* Breaking: `project.updateOAuth2Kakao` takes `enabled` before `prompt`
* Breaking: `BackupRestoration.options` is now an object
* Breaking: nullable response fields are typed `T | null`; some became optional, such as `BillingPlan.usage`
* Added: `Topic` helper to build MQTT topics for push messages
* Added: `mongo`, `mysql` and `postgresql` `promoteRestoration`, `restoreMode`, `targetName` and `autoPromote` on `createRestoration`, and `DedicatedDatabaseRestoration.restoreMode`
* Added: `proxy.createSMTPRule`, the `ProxyRuleProtocol` enum and `ProxyRule.protocol`
* Added: `emailEnabled` on `functions.update` and `Function`, and `ExecutionTrigger.Email`
* Added: `Query` aggregates (`count`, `countDistinct`, `sum`, `avg`, `min`, `max` and more), `groupBy`, `having`, `distinct`, joins, `relationship`, `covers`, `spatialEquals` and `page`
* Added: `Query.builder()` to chain queries into a list
* Updated: nullable request params accept `null`, such as `qos` on topics and the Appwrite provider
* Updated: missing response fields fall back to their documented defaults
* Updated: OAuth2 `prompt` and native fields, `PlatformAndroid.fingerprints` and `Identity.providerIdToken` are always returned
* Fixed: list and object defaults filled into a response are copied per model, and object defaults are `{}` instead of `[]`

## 29.4.0

* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones
* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules
* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP`
* Added: `account.createIdTokenSession` and `Identity.providerIdToken`
* Added: `oauth2.introspect`
* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment`
* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey`
* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow`
* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google
* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned`
* Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider`
* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned`
* Added: Kakao and TikTok OAuth2 providers
* Added: native client IDs on the Apple and Google OAuth2 providers
* Added: reply-to on email messages, `qos` and `expiry` on topics
* Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes
* Updated: requests send `X-Appwrite-Response-Format` `2.3.0`
* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics
* Added: `avatars.updatePhoto` and `avatars.deletePhoto`
* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms
* Added: optional `total` on the locale, transaction, runtime, specification and framework lists
* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes
* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup`

## 29.3.1

* Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys
* Fixed: added `ProjectPolicyId.Passkey` and the `Models.PolicyPasskey` model, so `getPolicy` and `listPolicies` return the passkey policy

## 29.3.0

* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification`
* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in
* Added: `users.listPasskeys`, `users.getPasskey`, `users.updatePasskey` and `users.deletePasskey`
* Added: `project.updatePasskeyPolicy` to configure passkey sign-in
* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models

## 29.2.0

* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes
* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model

## 29.1.0

* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs

## 29.0.0

Expand Down
58 changes: 38 additions & 20 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-2.3.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ.
**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 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 Expand Up @@ -50,7 +50,13 @@ Once your SDK object is set, create any of the Appwrite service objects and choo
```js
let users = new sdk.Users(client);

let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien");
let promise = users.create({
userId: sdk.ID.unique(),
email: "email@example.com",
phone: "+123456789",
password: "password",
name: "Walter O'Brien"
});

promise.then(function (response) {
console.log(response);
Expand All @@ -73,7 +79,13 @@ client
;

let users = new sdk.Users(client);
let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien");
let promise = users.create({
userId: sdk.ID.unique(),
email: "email@example.com",
phone: "+123456789",
password: "password",
name: "Walter O'Brien"
});

promise.then(function (response) {
console.log(response);
Expand All @@ -84,11 +96,11 @@ promise.then(function (response) {

### Type Safety with Models

The Appwrite Node SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety.
The Appwrite Node SDK provides type safety when working with table rows through generic methods. Methods like `listRows`, `getRow`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety.

**TypeScript:**
```typescript
interface Book {
interface Book extends Models.Row {
name: string;
author: string;
releaseYear?: string;
Expand All @@ -97,15 +109,15 @@ interface Book {
isCheckedOut: boolean;
}

const databases = new Databases(client);
const tablesDB = new TablesDB(client);

try {
const documents = await databases.listDocuments<Book>(
'your-database-id',
'your-collection-id'
);
const result = await tablesDB.listRows<Book>({
databaseId: 'your-database-id',
tableId: 'your-table-id'
});

documents.documents.forEach(book => {
result.rows.forEach(book => {
console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety
});
} catch (error) {
Expand All @@ -125,16 +137,16 @@ try {
* @property {boolean} isCheckedOut
*/

const databases = new Databases(client);
const tablesDB = new TablesDB(client);

try {
/** @type {Models.DocumentList<Book>} */
const documents = await databases.listDocuments(
'your-database-id',
'your-collection-id'
);
/** @type {Models.RowList<Book>} */
const result = await tablesDB.listRows({
databaseId: 'your-database-id',
tableId: 'your-table-id'
});

documents.documents.forEach(book => {
result.rows.forEach(book => {
console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE
});
} catch (error) {
Expand All @@ -152,7 +164,13 @@ The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` a
let users = new sdk.Users(client);

try {
let res = await users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien");
let res = await users.create({
userId: sdk.ID.unique(),
email: "email@example.com",
phone: "+123456789",
password: "password",
name: "Walter O'Brien"
});
} catch(e) {
console.log(e.message);
}
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-o-auth-2-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({
success: 'https://example.com', // optional
failure: 'https://example.com', // optional
scopes: [], // optional
state: '<STATE>', // optional
});
```
12 changes: 12 additions & 0 deletions docs/examples/account/create-passkey-token.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.createPasskeyToken();
```
15 changes: 15 additions & 0 deletions docs/examples/account/create-passkey.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.createPasskey({
passkeyId: '<PASSKEY_ID>', // optional
name: '<NAME>', // optional
});
```
14 changes: 14 additions & 0 deletions docs/examples/account/delete-passkey.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.deletePasskey({
passkeyId: '<PASSKEY_ID>',
});
```
14 changes: 14 additions & 0 deletions docs/examples/account/get-passkey.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.getPasskey({
passkeyId: '<PASSKEY_ID>',
});
```
15 changes: 15 additions & 0 deletions docs/examples/account/list-passkeys.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.listPasskeys({
queries: [], // optional
total: false, // optional
});
```
15 changes: 15 additions & 0 deletions docs/examples/account/update-passkey-token.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.updatePasskeyToken({
challengeId: '<CHALLENGE_ID>',
credential: {},
});
```
15 changes: 15 additions & 0 deletions docs/examples/account/update-passkey-verification.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.updatePasskeyVerification({
passkeyId: '<PASSKEY_ID>',
credential: {},
});
```
15 changes: 15 additions & 0 deletions docs/examples/account/update-passkey.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
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.updatePasskey({
passkeyId: '<PASSKEY_ID>',
name: '<NAME>',
});
```
2 changes: 1 addition & 1 deletion docs/examples/domains/get-price.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client);

const result = await domains.getPrice({
domain: 'example.com',
periodYears: null, // optional
periodYears: 1, // optional
registrationType: sdk.DomainRegistrationType.New, // optional
});
```
2 changes: 1 addition & 1 deletion docs/examples/domains/list-prices.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client);

const result = await domains.listPrices({
domains: [],
periodYears: null, // optional
periodYears: 1, // optional
registrationType: sdk.DomainRegistrationType.New, // optional
});
```
1 change: 1 addition & 0 deletions docs/examples/functions/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ const result = await functions.create({
buildSpecification: 's-1vcpu-512mb', // optional
runtimeSpecification: 's-1vcpu-512mb', // optional
deploymentRetention: 0, // optional
interval: 0, // optional
});
```
2 changes: 2 additions & 0 deletions docs/examples/functions/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ const result = await functions.update({
buildSpecification: 's-1vcpu-512mb', // optional
runtimeSpecification: 's-1vcpu-512mb', // optional
deploymentRetention: 0, // optional
interval: 0, // optional
emailEnabled: false, // optional
});
```
4 changes: 2 additions & 2 deletions docs/examples/messaging/create-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const result = await messaging.createEmail({
cc: [], // optional
bcc: [], // optional
attachments: [], // optional
replyToEmail: 'email@example.com', // optional
replyToName: '<REPLY_TO_NAME>', // optional
draft: false, // optional
html: false, // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional
replyToEmail: 'email@example.com', // optional
replyToName: '<REPLY_TO_NAME>', // optional
});
```
Loading