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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## 26.0.0

* Breaking: Renamed `Theme` enum to `BrowserTheme`, changing `avatars.getScreenshot()` `theme` param type.
* Breaking: Made `presences` `list`/`get`/`upsert`/`update` non-generic and removed `Models.DefaultPresence`.
* Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`).
* Added: `Membership.userAccessedAt` and `Presence.metadata` fields.
* Fixed: Removed `Client.setKey()` and `Client.setForwardedUserAgent()` methods that were exposed on the client SDK by mistake.
* Fixed: `toString()` on response objects now returns valid JSON via `JSONbig.stringify`, preserving large integers.
* Updated: Requests now send an explicit `accept` header matching each endpoint's response type.

## 25.1.1

* Fixed: Removed `Advisor` service and `Insight`, `InsightCTA`, `InsightList`, `Report`, `ReportList` models (admin-only endpoints, not intended for client SDKs)
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";
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@25.1.1"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@26.0.0"></script>
```


Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const account = new Account(client);

const result = await account.updatePassword({
password: '',
oldPassword: 'password' // optional
oldPassword: '<OLD_PASSWORD>' // optional
});

console.log(result);
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/avatars/get-screenshot.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```javascript
import { Client, Avatars, Theme, Timezone, BrowserPermission, ImageFormat } from "appwrite";
import { Client, Avatars, BrowserTheme, Timezone, BrowserPermission, ImageFormat } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
Expand All @@ -16,11 +16,11 @@ const result = avatars.getScreenshot({
viewportWidth: 1920, // optional
viewportHeight: 1080, // optional
scale: 2, // optional
theme: Theme.Dark, // optional
theme: BrowserTheme.Dark, // optional
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional
fullpage: true, // optional
locale: 'en-US', // optional
timezone: Timezone.AmericaNewYork, // optional
timezone: Timezone.AfricaAbidjan, // optional
latitude: 37.7749, // optional
longitude: -122.4194, // optional
accuracy: 100, // optional
Expand Down
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",
"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": "25.2.0",
"version": "26.0.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
48 changes: 11 additions & 37 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,9 @@ class Client {
endpoint: string;
endpointRealtime: string;
project: string;
key: string;
jwt: string;
locale: string;
session: string;
forwardeduseragent: string;
devkey: string;
cookie: string;
impersonateuserid: string;
Expand All @@ -368,11 +366,9 @@ class Client {
endpoint: 'https://cloud.appwrite.io/v1',
endpointRealtime: '',
project: '',
key: '',
jwt: '',
locale: '',
session: '',
forwardeduseragent: '',
devkey: '',
cookie: '',
impersonateuserid: '',
Expand All @@ -384,9 +380,9 @@ class Client {
*/
headers: Headers = {
'x-sdk-name': 'Web',
'x-sdk-platform': 'server',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
'x-sdk-version': '25.2.0',
'x-sdk-version': '26.0.0',
'X-Appwrite-Response-Format': '1.9.5',
};

Expand Down Expand Up @@ -456,24 +452,9 @@ class Client {
* @return {this}
*/
setProject(value: string): this {
this.headers['X-Appwrite-Project'] = value;
this.config.project = value;
return this;
}
/**
* Set Key
*
* Your secret API key
*
* @param value string
*
* @return {this}
*/
setKey(value: string): this {
this.headers['X-Appwrite-Key'] = value;
this.config.key = value;
return this;
}
/**
* Set JWT
*
Expand Down Expand Up @@ -514,20 +495,6 @@ class Client {
this.config.session = value;
return this;
}
/**
* Set ForwardedUserAgent
*
* The user agent string of the client that made the request
*
* @param value string
*
* @return {this}
*/
setForwardedUserAgent(value: string): this {
this.headers['X-Forwarded-User-Agent'] = value;
this.config.forwardeduseragent = value;
return this;
}
/**
* Set DevKey
*
Expand Down Expand Up @@ -1075,7 +1042,9 @@ class Client {
}

async ping(): Promise<unknown> {
return this.call('GET', new URL(this.config.endpoint + '/ping'));
return this.call('GET', new URL(this.config.endpoint + '/ping'), {
'X-Appwrite-Project': this.config.project,
});
}

async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {
Expand Down Expand Up @@ -1128,7 +1097,12 @@ class Client {
}

if (data && typeof data === 'object') {
data.toString = () => JSONbig.stringify(data);
Object.defineProperty(data, 'toString', {
value: () => JSONbig.stringify(data),
writable: true,
enumerable: false,
configurable: true,
});
}

return data;
Expand Down
2 changes: 1 addition & 1 deletion src/enums/theme.ts → src/enums/browser-theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum Theme {
export enum BrowserTheme {
Light = 'light',
Dark = 'dark',
}
Comment on lines 3 to 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Missing trailing newline at end of file — most editors and linters expect it.

Suggested change
Dark = 'dark',
}
Dark = 'dark',
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export { OAuthProvider } from './enums/o-auth-provider';
export { Browser } from './enums/browser';
export { CreditCard } from './enums/credit-card';
export { Flag } from './enums/flag';
export { Theme } from './enums/theme';
export { BrowserTheme } from './enums/browser-theme';
export { Timezone } from './enums/timezone';
export { BrowserPermission } from './enums/browser-permission';
export { ImageFormat } from './enums/image-format';
Expand Down
35 changes: 29 additions & 6 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export namespace Models {
/**
* Presences List
*/
export type PresenceList<Presence extends Models.Presence = Models.DefaultPresence> = {
export type PresenceList = {
/**
* Total number of presences that matched your query.
*/
Expand Down Expand Up @@ -360,13 +360,12 @@ export namespace Models {
* Presence expiry date in ISO 8601 format.
*/
expiresAt?: string;
/**
* Presence metadata.
*/
metadata?: object;
}

export type DefaultPresence = Presence & {
[key: string]: any;
[__default]: true;
};

/**
* Log
*/
Expand Down Expand Up @@ -521,6 +520,26 @@ export namespace Models {
* Email verification status.
*/
emailVerification: boolean;
/**
* Canonical form of the user email address.
*/
emailCanonical?: string;
/**
* Whether the user email is from a free email provider.
*/
emailIsFree?: boolean;
/**
* Whether the user email is from a disposable email provider.
*/
emailIsDisposable?: boolean;
/**
* Whether the user email is from a corporate domain.
*/
emailIsCorporate?: boolean;
/**
* Whether the user email is in its canonical form.
*/
emailIsCanonical?: boolean;
/**
* Phone verification status.
*/
Expand Down Expand Up @@ -1076,6 +1095,10 @@ export namespace Models {
* Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console.
*/
mfa: boolean;
/**
* Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console.
*/
userAccessedAt: string;
/**
* User list of roles
*/
Expand Down
Loading