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: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '24.14.1'
registry-url: 'https://registry.npmjs.org'
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 12.1.0

* Added: `setSession` method on `Client` for `X-Appwrite-Session` authentication
* Added: `setDevKey` method on `Client` for `X-Appwrite-Dev-Key` authentication
* Added: `suggestQueries` method on `Console` service
* Added: `QuerySuggestionResource` enum for supported list resource types
* Added: `project.policies.read`, `project.policies.write`, `backups.policies.read`, `backups.policies.write` scopes
* Updated: `setCookie` documentation clarified for server-side runtimes

## 12.0.0

* Breaking: Renamed `AuthMethod` enum to `MethodId`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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@12.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@12.1.0"></script>
```


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/create-program-membership.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.createProgramMembership({
const result = await xconsole.createProgramMembership({
programId: '<PROGRAM_ID>'
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/create-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.createSource({
const result = await xconsole.createSource({
ref: '<REF>', // optional
referrer: 'https://example.com', // optional
utmSource: '<UTM_SOURCE>', // optional
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/get-campaign.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.getCampaign({
const result = await xconsole.getCampaign({
campaignId: '<CAMPAIGN_ID>'
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/get-coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.getCoupon({
const result = await xconsole.getCoupon({
couponId: '<COUPON_ID>'
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/get-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.getPlan({
const result = await xconsole.getPlan({
planId: '<PLAN_ID>'
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/get-plans.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.getPlans({
const result = await xconsole.getPlans({
platform: Platform.Appwrite // optional
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/get-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.getProgram({
const result = await xconsole.getProgram({
programId: '<PROGRAM_ID>'
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/get-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.getResource({
const result = await xconsole.getResource({
value: '<VALUE>',
type: ConsoleResourceType.Rules
});
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/list-o-auth-2-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.listOAuth2Providers();
const result = await xconsole.listOAuth2Providers();

console.log(result);
```
4 changes: 2 additions & 2 deletions docs/examples/console/list-project-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.listProjectScopes();
const result = await xconsole.listProjectScopes();

console.log(result);
```
4 changes: 2 additions & 2 deletions docs/examples/console/list-regions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.listRegions();
const result = await xconsole.listRegions();

console.log(result);
```
4 changes: 2 additions & 2 deletions docs/examples/console/suggest-columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.suggestColumns({
const result = await xconsole.suggestColumns({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
context: '<CONTEXT>', // optional
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/console/suggest-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.suggestIndexes({
const result = await xconsole.suggestIndexes({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
min: 1, // optional
Expand Down
18 changes: 18 additions & 0 deletions docs/examples/console/suggest-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
```javascript
import { Client, Console, QuerySuggestionResource } 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 xconsole = new Console(client);

const result = await xconsole.suggestQueries({
resource: QuerySuggestionResource.Activities,
input: '<INPUT>',
databaseId: '<DATABASE_ID>', // optional
tableId: '<TABLE_ID>' // optional
});

Comment thread
greptile-apps[bot] marked this conversation as resolved.
console.log(result);
```
4 changes: 2 additions & 2 deletions docs/examples/console/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const console = new Console(client);
const xconsole = new Console(client);

const result = await console.variables();
const result = await xconsole.variables();

console.log(result);
```
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": "@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": "12.0.0",
"version": "12.1.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
38 changes: 34 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,13 @@ class Client {
locale: string;
mode: string;
cookie: string;
session: string;
devkey: string;
impersonateuserid: string;
impersonateuseremail: string;
impersonateuserphone: string;
platform: string;
selfSigned: boolean;
session?: string;
} = {
endpoint: 'https://cloud.appwrite.io/v1',
endpointRealtime: '',
Expand All @@ -374,12 +375,13 @@ class Client {
locale: '',
mode: '',
cookie: '',
session: '',
devkey: '',
impersonateuserid: '',
impersonateuseremail: '',
impersonateuserphone: '',
platform: '',
selfSigned: false,
session: undefined,
};
/**
* Custom headers for API requests.
Expand All @@ -388,7 +390,7 @@ class Client {
'x-sdk-name': 'Console',
'x-sdk-platform': 'console',
'x-sdk-language': 'web',
'x-sdk-version': '12.0.0',
'x-sdk-version': '12.1.0',
'X-Appwrite-Response-Format': '1.9.3',
};

Expand Down Expand Up @@ -529,7 +531,7 @@ class Client {
/**
* Set Cookie
*
* The user cookie to authenticate with
* The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes.
*
* @param value string
*
Expand All @@ -540,6 +542,34 @@ class Client {
this.config.cookie = value;
return this;
}
/**
* Set Session
*
* The user session to authenticate with
*
* @param value string
*
* @return {this}
*/
setSession(value: string): this {
this.headers['X-Appwrite-Session'] = value;
this.config.session = value;
return this;
}
/**
* Set DevKey
*
* Your secret dev API key
*
* @param value string
*
* @return {this}
*/
setDevKey(value: string): this {
this.headers['X-Appwrite-Dev-Key'] = value;
this.config.devkey = value;
return this;
}
/**
* Set ImpersonateUserId
*
Expand Down
Loading