Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 0 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# Change Log

## 5.0.0

* Breaking: Channel.collection() and Channel.table() now require explicit IDs
* Added DomainTransferStatusStatus enum
* Added migration resource enums: AppwriteMigrationResource, FirebaseMigrationResource, NHostMigrationResource, SupabaseMigrationResource
* Added ttl option to listDocuments and listRows
* Added new docs/examples across domains, health, migrations, projects, sites
* Updated docs and examples to reflect new resources and transfers
* Updated README compatibility note to latest server version

## 4.0.0

* Breaking: Channel.collection() and Channel.table() now require explicit IDs
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-console/releases).**
**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-console/releases).**

Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand All @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@23.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@4.0.0"></script>
```


Expand Down
16 changes: 16 additions & 0 deletions docs/examples/domains/confirm-purchase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Domains } from "@appwrite.io/console";

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

const domains = new Domains(client);

const result = await domains.confirmPurchase({
domainId: '<DOMAIN_ID>',
organizationId: '<ORGANIZATION_ID>'
});

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/domains/confirm-transfer-in.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Domains } from "@appwrite.io/console";

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

const domains = new Domains(client);

const result = await domains.confirmTransferIn({
domainId: '<DOMAIN_ID>',
organizationId: '<ORGANIZATION_ID>'
});

console.log(result);
```
4 changes: 3 additions & 1 deletion docs/examples/functions/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const result = await functions.create({
providerBranch: '<PROVIDER_BRANCH>', // optional
providerSilentMode: false, // optional
providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional
specification: '' // optional
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
});

console.log(result);
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/functions/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const result = await functions.update({
providerBranch: '<PROVIDER_BRANCH>', // optional
providerSilentMode: false, // optional
providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional
specification: '' // optional
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
Comment on lines +28 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid destructive literal values in the update example.

For update, '' and 0 are concrete mutations. A copied example can wipe the current specifications/retention instead of leaving them unchanged.

Suggested doc fix
-    buildSpecification: '', // optional
-    runtimeSpecification: '', // optional
-    deploymentRetention: 0 // optional
+    // buildSpecification: '<BUILD_SPECIFICATION>', // optional
+    // runtimeSpecification: '<RUNTIME_SPECIFICATION>', // optional
+    // deploymentRetention: <DEPLOYMENT_RETENTION> // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
// buildSpecification: '<BUILD_SPECIFICATION>', // optional
// runtimeSpecification: '<RUNTIME_SPECIFICATION>', // optional
// deploymentRetention: <DEPLOYMENT_RETENTION> // optional
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/functions/update.md` around lines 28 - 30, The example uses
concrete destructive literals for update fields (buildSpecification,
runtimeSpecification, deploymentRetention) which can overwrite existing values;
change the example so these optional fields are omitted when not updating (or
set to undefined/null as appropriate for your API) instead of using empty string
'' or 0—remove or comment out the lines for buildSpecification,
runtimeSpecification, and deploymentRetention in the update example so callers
don't accidentally wipe existing specifications/retention.

});

console.log(result);
Expand Down
5 changes: 4 additions & 1 deletion docs/examples/sites/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const result = await sites.create({
timeout: 1, // optional
installCommand: '<INSTALL_COMMAND>', // optional
buildCommand: '<BUILD_COMMAND>', // optional
startCommand: '<START_COMMAND>', // optional
outputDirectory: '<OUTPUT_DIRECTORY>', // optional
adapter: Adapter.Static, // optional
installationId: '<INSTALLATION_ID>', // optional
Expand All @@ -25,7 +26,9 @@ const result = await sites.create({
providerBranch: '<PROVIDER_BRANCH>', // optional
providerSilentMode: false, // optional
providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional
specification: '' // optional
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
Comment on lines +29 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use placeholders or omit these optional fields in the example.

'' and 0 are real values, not placeholders. Copy-pasting this snippet will send concrete settings instead of leaving the optional fields unset.

Suggested doc fix
-    buildSpecification: '', // optional
-    runtimeSpecification: '', // optional
-    deploymentRetention: 0 // optional
+    // buildSpecification: '<BUILD_SPECIFICATION>', // optional
+    // runtimeSpecification: '<RUNTIME_SPECIFICATION>', // optional
+    // deploymentRetention: <DEPLOYMENT_RETENTION> // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
// buildSpecification: '<BUILD_SPECIFICATION>', // optional
// runtimeSpecification: '<RUNTIME_SPECIFICATION>', // optional
// deploymentRetention: <DEPLOYMENT_RETENTION> // optional
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/sites/create.md` around lines 29 - 31, The example currently
sets optional fields to concrete values (buildSpecification: '',
runtimeSpecification: '', deploymentRetention: 0) which will be interpreted as
real settings; update the snippet to either remove those keys entirely or
replace them with clear placeholders (e.g., "<optional>" or omit) so
copy-pasting does not submit actual empty-string or zero values—look for the
buildSpecification, runtimeSpecification, and deploymentRetention entries in the
create.md example and adjust them accordingly.

});

console.log(result);
Expand Down
5 changes: 4 additions & 1 deletion docs/examples/sites/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const result = await sites.update({
timeout: 1, // optional
installCommand: '<INSTALL_COMMAND>', // optional
buildCommand: '<BUILD_COMMAND>', // optional
startCommand: '<START_COMMAND>', // optional
outputDirectory: '<OUTPUT_DIRECTORY>', // optional
buildRuntime: BuildRuntime.Node145, // optional
adapter: Adapter.Static, // optional
Expand All @@ -25,7 +26,9 @@ const result = await sites.update({
providerBranch: '<PROVIDER_BRANCH>', // optional
providerSilentMode: false, // optional
providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional
specification: '' // optional
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
Comment on lines +29 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Make the optional update fields copy-paste safe.

These literals send actual values. In an update example, that can unintentionally reset spec fields or retention instead of preserving the existing configuration.

Suggested doc fix
-    buildSpecification: '', // optional
-    runtimeSpecification: '', // optional
-    deploymentRetention: 0 // optional
+    // buildSpecification: '<BUILD_SPECIFICATION>', // optional
+    // runtimeSpecification: '<RUNTIME_SPECIFICATION>', // optional
+    // deploymentRetention: <DEPLOYMENT_RETENTION> // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
buildSpecification: '', // optional
runtimeSpecification: '', // optional
deploymentRetention: 0 // optional
// buildSpecification: '<BUILD_SPECIFICATION>', // optional
// runtimeSpecification: '<RUNTIME_SPECIFICATION>', // optional
// deploymentRetention: <DEPLOYMENT_RETENTION> // optional
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/sites/update.md` around lines 29 - 31, The example uses literal
empty strings and 0 for optional update fields (buildSpecification,
runtimeSpecification, deploymentRetention) which can accidentally overwrite
existing values; change the example to either omit these keys or set them to
undefined (or clearly comment them as "omit to keep existing") so copy-pasting
the example won't reset specs or retention—update the snippet around
buildSpecification, runtimeSpecification, and deploymentRetention to reflect
that behavior.

});

console.log(result);
Expand Down
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": "@appwrite.io/console",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
"version": "23.0.0",
"version": "4.0.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
6 changes: 5 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class Client {
'x-sdk-name': 'Console',
'x-sdk-platform': 'console',
'x-sdk-language': 'web',
'x-sdk-version': '23.0.0',
'x-sdk-version': '4.0.0',
'X-Appwrite-Response-Format': '1.8.0',
};

Expand Down Expand Up @@ -995,6 +995,10 @@ class Client {
window.localStorage.setItem('cookieFallback', cookieFallback);
}

if (data && typeof data === 'object') {
data.toString = () => JSONbig.stringify(data);
}
Comment on lines +998 to +1000
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C3 "responseType\s*=\s*'arrayBuffer'|arrayBuffer\(" src
rg -n -C3 "\[key:\s*string\]\s*:\s*any|DocumentList|Document<|type Payload" src

Repository: appwrite/sdk-for-console

Length of output: 33400


Limit toString assignment to plain JSON objects and define it non-enumerably.

The current code mutates all object responses—including ArrayBuffers from responseType === 'arrayBuffer' paths (line 974)—and overwrites any legitimate toString fields returned by the API or stored in user-controlled document data. Direct property assignment also creates an enumerable own property that leaks into Object.keys() and spread operations. Restrict this to plain objects and use Object.defineProperty with enumerable: false to prevent shape mutations.

Suggested fix
-        if (data && typeof data === 'object') {
-            data.toString = () => JSONbig.stringify(data);
+        if (
+            data &&
+            Object.prototype.toString.call(data) === '[object Object]' &&
+            !Object.prototype.hasOwnProperty.call(data, 'toString')
+        ) {
+            Object.defineProperty(data, 'toString', {
+                value() {
+                    return JSONbig.stringify(this);
+                },
+                enumerable: false,
+            });
+        }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client.ts` around lines 998 - 1000, The current assignment mutates all
objects by directly setting data.toString, which can overwrite legitimate
properties and makes the property enumerable; change the logic around the data
variable so you only modify plain JSON objects (e.g., check via
Object.prototype.toString.call(data) === '[object Object]' or an isPlainObject
helper) and set the toString as a non-enumerable property using
Object.defineProperty(data, 'toString', { value: () => JSONbig.stringify(data),
writable: true, configurable: true, enumerable: false }); also ensure you skip
this for binary/ArrayBuffer response paths (responseType === 'arrayBuffer') and
for cases where data already has an own non-configurable toString to avoid
throwing.


return data;
}

Expand Down
4 changes: 4 additions & 0 deletions src/enums/appwrite-migration-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export enum AppwriteMigrationResource {
Function = 'function',
Deployment = 'deployment',
Environmentvariable = 'environment-variable',
Provider = 'provider',
Topic = 'topic',
Subscriber = 'subscriber',
Message = 'message',
Site = 'site',
Sitedeployment = 'site-deployment',
Sitevariable = 'site-variable',
Expand Down
3 changes: 3 additions & 0 deletions src/enums/build-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export enum BuildRuntime {
Pythonml311 = 'python-ml-3.11',
Pythonml312 = 'python-ml-3.12',
Pythonml313 = 'python-ml-3.13',
Deno121 = 'deno-1.21',
Deno124 = 'deno-1.24',
Deno135 = 'deno-1.35',
Deno140 = 'deno-1.40',
Deno146 = 'deno-1.46',
Deno20 = 'deno-2.0',
Expand Down
10 changes: 10 additions & 0 deletions src/enums/domain-purchase-payment-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum DomainPurchasePaymentStatus {
Pending = 'pending',
PendingConfirmation = 'pending_confirmation',
PendingPaymentProcessing = 'pending_payment_processing',
Authorized = 'authorized',
Captured = 'captured',
Failed = 'failed',
CaptureFailed = 'capture_failed',
RenewalCaptureFailed = 'renewal_capture_failed',
}
3 changes: 3 additions & 0 deletions src/enums/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export enum Runtime {
Pythonml311 = 'python-ml-3.11',
Pythonml312 = 'python-ml-3.12',
Pythonml313 = 'python-ml-3.13',
Deno121 = 'deno-1.21',
Deno124 = 'deno-1.24',
Deno135 = 'deno-1.35',
Deno140 = 'deno-1.40',
Deno146 = 'deno-1.46',
Deno20 = 'deno-2.0',
Expand Down
3 changes: 3 additions & 0 deletions src/enums/runtimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export enum Runtimes {
Pythonml311 = 'python-ml-3.11',
Pythonml312 = 'python-ml-3.12',
Pythonml313 = 'python-ml-3.13',
Deno121 = 'deno-1.21',
Deno124 = 'deno-1.24',
Deno135 = 'deno-1.35',
Deno140 = 'deno-1.40',
Deno146 = 'deno-1.46',
Deno20 = 'deno-2.0',
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-r
export { ProxyRuleStatus } from './enums/proxy-rule-status';
export { MessageStatus } from './enums/message-status';
export { BillingPlanGroup } from './enums/billing-plan-group';
export { DomainPurchasePaymentStatus } from './enums/domain-purchase-payment-status';
export { DomainTransferStatusStatus } from './enums/domain-transfer-status-status';
95 changes: 90 additions & 5 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ProxyRuleDeploymentResourceType } from "./enums/proxy-rule-deployment-r
import { ProxyRuleStatus } from "./enums/proxy-rule-status"
import { MessageStatus } from "./enums/message-status"
import { BillingPlanGroup } from "./enums/billing-plan-group"
import { DomainPurchasePaymentStatus } from "./enums/domain-purchase-payment-status"
import { DomainTransferStatusStatus } from "./enums/domain-transfer-status-status"

/**
Expand Down Expand Up @@ -3524,6 +3525,10 @@ export namespace Models {
* Site framework.
*/
framework: string;
/**
* How many days to keep the non-active deployments before they will be automatically deleted.
*/
deploymentRetention: number;
/**
* Site's active deployment ID.
*/
Expand Down Expand Up @@ -3568,6 +3573,10 @@ export namespace Models {
* The build command used to build the site.
*/
buildCommand: string;
/**
* Custom command to use when starting site runtime.
*/
startCommand: string;
/**
* The directory where the site build output is located.
*/
Expand All @@ -3593,9 +3602,13 @@ export namespace Models {
*/
providerSilentMode: boolean;
/**
* Machine specification for builds and executions.
* Machine specification for deployment builds.
*/
buildSpecification: string;
/**
* Machine specification for SSR executions.
*/
specification: string;
runtimeSpecification: string;
/**
* Site build runtime.
*/
Expand Down Expand Up @@ -3750,6 +3763,10 @@ export namespace Models {
* Function execution and build runtime.
*/
runtime: string;
/**
* How many days to keep the non-active deployments before they will be automatically deleted.
*/
deploymentRetention: number;
/**
* Function's active deployment ID.
*/
Expand Down Expand Up @@ -3823,9 +3840,13 @@ export namespace Models {
*/
providerSilentMode: boolean;
/**
* Machine specification for builds and executions.
* Machine specification for deployment builds.
*/
buildSpecification: string;
/**
* Machine specification for executions.
*/
specification: string;
runtimeSpecification: string;
}

/**
Expand Down Expand Up @@ -6136,6 +6157,22 @@ export namespace Models {
* Total aggregated number of image transformations.
*/
imageTransformationsTotal: number;
/**
* Aggregated number of function executions per period.
*/
functionsExecutions: Metric[];
/**
* Total aggregated number of function executions.
*/
functionsExecutionsTotal: number;
/**
* Aggregated number of site executions per period.
*/
sitesExecutions: Metric[];
/**
* Total aggregated number of site executions.
*/
sitesExecutionsTotal: number;
Comment on lines +6160 to +6175
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Clarify how functionsExecutions* differs from the existing executions* pair.

Line 6033 still documents executionsTotal as function executions, so after adding functionsExecutionsTotal this type now exposes two totals that appear to mean the same thing. Please either mark the legacy pair as aggregate/deprecated or update the docs so consumers know which pair to read.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models.ts` around lines 6160 - 6175, The docs currently expose both
executions/executionsTotal and the new
functionsExecutions/functionsExecutionsTotal which look like duplicates; update
the TypeDoc comments to clarify intent by either marking the legacy
executions/executionsTotal pair as deprecated (add a deprecation note) or
explicitly documenting that executions/executionsTotal are legacy/aggregate
across both functions and sites while
functionsExecutions/functionsExecutionsTotal are function-only metrics; apply
the change in the comment blocks that document executions, executionsTotal,
functionsExecutions, and functionsExecutionsTotal so consumers know which pair
to read and prefer the new functions* pair for function-specific counts.

/**
* Aggregated stats for total network bandwidth.
*/
Expand All @@ -6160,6 +6197,30 @@ export namespace Models {
* Total aggregated number of Imagine credits.
*/
imagineCreditsTotal: number;
/**
* Current aggregated number of open Realtime connections.
*/
realtimeConnectionsTotal: number;
/**
* Total number of Realtime messages sent to clients.
*/
realtimeMessagesTotal: number;
/**
* Total consumed Realtime bandwidth (in bytes).
*/
realtimeBandwidthTotal: number;
/**
* Aggregated number of open Realtime connections per period.
*/
realtimeConnections: Metric[];
/**
* Aggregated number of Realtime messages sent to clients per period.
*/
realtimeMessages: Metric[];
/**
* Aggregated consumed Realtime bandwidth (in bytes) per period.
*/
realtimeBandwidth: Metric[];
}

/**
Expand Down Expand Up @@ -6890,6 +6951,22 @@ export namespace Models {
* Number of sites to be migrated.
*/
site: number;
/**
* Number of providers to be migrated.
*/
provider: number;
/**
* Number of topics to be migrated.
*/
topic: number;
/**
* Number of subscribers to be migrated.
*/
subscriber: number;
/**
* Number of messages to be migrated.
*/
message: number;
/**
* Size of files to be migrated in mb.
*/
Expand Down Expand Up @@ -8651,7 +8728,11 @@ export namespace Models {
/**
* Payment status for domain purchase.
*/
paymentStatus: string;
paymentStatus: DomainPurchasePaymentStatus;
/**
* Client secret for payment confirmation. Present only when paymentStatus is pending_confirmation.
*/
clientSecret: string;
/**
* Nameservers setting. "Appwrite" or empty string.
*/
Expand Down Expand Up @@ -8684,6 +8765,10 @@ export namespace Models {
* Domain transfer status (e.g., "pending", "completed", "failed").
*/
transferStatus: string;
/**
* Retry attempts for the current domain payment flow. Development only.
*/
attempts: number;
}

/**
Expand Down
Loading
Loading