diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b38d347..1fb25ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 0.32.0 + +* Breaking: Renamed `Theme` enum to `BrowserTheme`. +* Breaking: Removed `Models.DefaultPresence` and dropped the `Presence` generic from `presences` methods. +* Added: Email metadata fields to `User`, plus `Membership.userAccessedAt` and `Presence.metadata`. +* Updated: Requests now send an explicit `accept` header matching each endpoint's response type. + ## 0.30.1 * Fixed: Removed `Advisor` service and `Insight`, `InsightCTA`, `InsightList`, `Report`, `ReportList` models (admin-only endpoints, not intended for client SDKs) diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 7ea08255..aaaf4dbd 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.updatePassword({ password: '', - oldPassword: 'password' // optional + oldPassword: '' // optional }); console.log(result); diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 006e5af6..bf88cf2b 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars, Theme, Timezone, BrowserPermission, ImageFormat } from "react-native-appwrite"; +import { Client, Avatars, BrowserTheme, Timezone, BrowserPermission, ImageFormat } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,7 +16,7 @@ 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 diff --git a/package-lock.json b/package-lock.json index d38544c9..2b44c489 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-appwrite", - "version": "0.31.0", + "version": "0.32.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-native-appwrite", - "version": "0.31.0", + "version": "0.32.0", "license": "BSD-3-Clause", "dependencies": { "expo-file-system": "18.*.*", diff --git a/package.json b/package.json index 9e1d996f..50fa32fe 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-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": "0.31.0", + "version": "0.32.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index b389309f..82519e60 100644 --- a/src/client.ts +++ b/src/client.ts @@ -180,7 +180,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.31.0', + 'x-sdk-version': '0.32.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -264,7 +264,6 @@ class Client { * @return {this} */ setProject(value: string): this { - this.headers['X-Appwrite-Project'] = value; this.config.project = value; return this; } @@ -677,7 +676,9 @@ class Client { } async ping(): Promise { - 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 { @@ -762,7 +763,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; diff --git a/src/enums/theme.ts b/src/enums/browser-theme.ts similarity index 60% rename from src/enums/theme.ts rename to src/enums/browser-theme.ts index 5e823a9b..9f8c382a 100644 --- a/src/enums/theme.ts +++ b/src/enums/browser-theme.ts @@ -1,4 +1,4 @@ -export enum Theme { +export enum BrowserTheme { Light = 'light', Dark = 'dark', } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 52bb3e2a..1905aafd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,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'; diff --git a/src/models.ts b/src/models.ts index 9b0a9c7b..6140c788 100644 --- a/src/models.ts +++ b/src/models.ts @@ -36,7 +36,7 @@ export namespace Models { /** * Presences List */ - export type PresenceList = { + export type PresenceList = { /** * Total number of presences that matched your query. */ @@ -357,13 +357,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 */ @@ -518,6 +517,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. */ @@ -1073,6 +1092,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 */ diff --git a/src/services/account.ts b/src/services/account.ts index 86be09e7..14008ac3 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -28,6 +28,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -109,7 +111,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -175,7 +179,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -229,6 +235,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -273,6 +281,7 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -318,7 +327,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -372,6 +383,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -420,7 +433,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -466,7 +481,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -511,7 +528,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -570,7 +589,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -628,7 +649,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -674,6 +697,7 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -719,6 +743,7 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -769,7 +794,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -818,7 +845,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -881,7 +910,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -943,7 +974,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -960,6 +993,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -975,6 +1010,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -991,6 +1028,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -1006,6 +1045,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -1022,7 +1063,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1038,7 +1081,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1055,7 +1100,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1071,7 +1118,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1120,7 +1169,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1128,7 +1179,7 @@ export class Account extends Service { * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * * @param {string} params.password - New user password. Must be at least 8 chars. - * @param {string} params.oldPassword - Current user password. Must be at least 8 chars. + * @param {string} params.oldPassword - Current user password. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} */ @@ -1137,7 +1188,7 @@ export class Account extends Service { * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * * @param {string} password - New user password. Must be at least 8 chars. - * @param {string} oldPassword - Current user password. Must be at least 8 chars. + * @param {string} oldPassword - Current user password. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1178,7 +1229,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1240,7 +1293,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1256,6 +1311,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -1304,7 +1361,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1366,7 +1425,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1444,7 +1505,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1460,6 +1523,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -1475,6 +1540,7 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -1491,7 +1557,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1557,7 +1625,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1620,7 +1690,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1767,7 +1839,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1829,7 +1903,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1874,6 +1950,8 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -1918,7 +1996,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -1963,6 +2043,7 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -1979,7 +2060,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2049,7 +2132,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2107,7 +2192,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2152,6 +2239,7 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -2228,7 +2316,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2312,7 +2402,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2460,7 +2552,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2515,7 +2609,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2571,7 +2667,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2633,7 +2731,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2696,7 +2796,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2712,7 +2814,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -2774,7 +2878,9 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } }; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 87cdc112..3ab90461 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -8,7 +8,7 @@ import { Platform as RNPlatform } from 'react-native'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; import { Flag } from '../enums/flag'; -import { Theme } from '../enums/theme'; +import { BrowserTheme } from '../enums/browser-theme'; import { Timezone } from '../enums/timezone'; import { BrowserPermission } from '../enums/browser-permission'; import { ImageFormat } from '../enums/image-format'; @@ -96,6 +96,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/png', }, payload, 'arrayBuffer'); } @@ -177,6 +179,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/png', }, payload, 'arrayBuffer'); } @@ -235,6 +239,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/*', }, payload, 'arrayBuffer'); } @@ -316,6 +322,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/png', }, payload, 'arrayBuffer'); } @@ -395,6 +403,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/*', }, payload, 'arrayBuffer'); } @@ -480,6 +490,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/png', }, payload, 'arrayBuffer'); } @@ -561,6 +573,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/png', }, payload, 'arrayBuffer'); } @@ -576,7 +590,7 @@ export class Avatars extends Service { * @param {number} params.viewportWidth - Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. * @param {number} params.viewportHeight - Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. * @param {number} params.scale - Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. - * @param {Theme} params.theme - Browser theme. Pass "light" or "dark". Defaults to "light". + * @param {BrowserTheme} params.theme - Browser theme. Pass "light" or "dark". Defaults to "light". * @param {string} params.userAgent - Custom user agent string. Defaults to browser default. * @param {boolean} params.fullpage - Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. * @param {string} params.locale - Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. @@ -594,7 +608,7 @@ export class Avatars extends Service { * @throws {AppwriteException} * @returns {ArrayBuffer} */ - getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): Promise; + getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): Promise; /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. * @@ -607,7 +621,7 @@ export class Avatars extends Service { * @param {number} viewportWidth - Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. * @param {number} viewportHeight - Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. * @param {number} scale - Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. - * @param {Theme} theme - Browser theme. Pass "light" or "dark". Defaults to "light". + * @param {BrowserTheme} theme - Browser theme. Pass "light" or "dark". Defaults to "light". * @param {string} userAgent - Custom user agent string. Defaults to browser default. * @param {boolean} fullpage - Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. * @param {string} locale - Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. @@ -626,15 +640,15 @@ export class Avatars extends Service { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): Promise; + getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): Promise; getScreenshot( - paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, - ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] + paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, + ...rest: [(object)?, (number)?, (number)?, (number)?, (BrowserTheme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] ): Promise { - let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; + let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; + params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; } else { params = { url: paramsOrFirst as string, @@ -642,7 +656,7 @@ export class Avatars extends Service { viewportWidth: rest[1] as number, viewportHeight: rest[2] as number, scale: rest[3] as number, - theme: rest[4] as Theme, + theme: rest[4] as BrowserTheme, userAgent: rest[5] as string, fullpage: rest[6] as boolean, locale: rest[7] as string, @@ -776,6 +790,8 @@ export class Avatars extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/png', }, payload, 'arrayBuffer'); } @@ -1100,7 +1116,7 @@ export class Avatars extends Service { * @param {number} viewportWidth * @param {number} viewportHeight * @param {number} scale - * @param {Theme} theme + * @param {BrowserTheme} theme * @param {string} userAgent * @param {boolean} fullpage * @param {string} locale @@ -1118,7 +1134,7 @@ export class Avatars extends Service { * @throws {AppwriteException} * @returns {URL} */ - getScreenshotURL(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): URL { + getScreenshotURL(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): URL { const apiPath = '/avatars/screenshots'; const payload: Payload = {}; diff --git a/src/services/databases.ts b/src/services/databases.ts index 9bc9cda5..354eafcd 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -54,6 +54,8 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -98,7 +100,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -143,6 +147,8 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -204,7 +210,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -249,6 +257,7 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -303,7 +312,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -390,6 +401,8 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -484,7 +497,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -563,6 +578,8 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -649,7 +666,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -736,7 +755,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -807,6 +828,7 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -902,7 +924,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -997,7 +1021,9 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } }; diff --git a/src/services/functions.ts b/src/services/functions.ts index 56454f8b..b2ebf957 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -72,6 +72,8 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -165,7 +167,9 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -219,6 +223,8 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } }; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 21333efd..3b384e7b 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -58,8 +58,10 @@ export class Graphql extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'x-sdk-graphql': 'true', 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -108,8 +110,10 @@ export class Graphql extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'x-sdk-graphql': 'true', 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } }; diff --git a/src/services/locale.ts b/src/services/locale.ts index a3173a47..5c1a6e87 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -27,6 +27,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -42,6 +44,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -57,6 +61,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -72,6 +78,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -87,6 +95,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -102,6 +112,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -117,6 +129,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -132,6 +146,8 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } }; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index a29668a0..51d8fb73 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -79,7 +79,9 @@ export class Messaging extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -133,6 +135,7 @@ export class Messaging extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } diff --git a/src/services/presences.ts b/src/services/presences.ts index acf920a8..99db891a 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -23,7 +23,7 @@ export class Presences extends Service { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise>; + list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise; /** * List presence logs. Expired entries are filtered out automatically. * @@ -32,14 +32,14 @@ export class Presences extends Service { * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @param {number} ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). * @throws {AppwriteException} - * @returns {Promise>} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], total?: boolean, ttl?: number): Promise>; - list( + list(queries?: string[], total?: boolean, ttl?: number): Promise; + list( paramsOrFirst?: { queries?: string[], total?: boolean, ttl?: number } | string[], ...rest: [(boolean)?, (number)?] - ): Promise> { + ): Promise { let params: { queries?: string[], total?: boolean, ttl?: number }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -73,6 +73,8 @@ export class Presences extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -84,20 +86,20 @@ export class Presences extends Service { * @throws {AppwriteException} * @returns {Promise} */ - get(params: { presenceId: string }): Promise; + get(params: { presenceId: string }): Promise; /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. * * * @param {string} presenceId - Presence unique ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - get(presenceId: string): Promise; - get( + get(presenceId: string): Promise; + get( paramsOrFirst: { presenceId: string } | string - ): Promise { + ): Promise { let params: { presenceId: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -119,6 +121,8 @@ export class Presences extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -134,7 +138,7 @@ export class Presences extends Service { * @throws {AppwriteException} * @returns {Promise} */ - upsert(params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; + upsert(params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; /** * Create or update a presence log by its user ID. * @@ -145,14 +149,14 @@ export class Presences extends Service { * @param {string} expiresAt - Presence expiry datetime. * @param {object} metadata - Presence metadata object. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsert(presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise; - upsert( + upsert(presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise; + upsert( paramsOrFirst: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, ...rest: [(string)?, (string[])?, (string)?, (object)?] - ): Promise { + ): Promise { let params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -202,7 +206,9 @@ export class Presences extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -219,7 +225,7 @@ export class Presences extends Service { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; + update(params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -231,14 +237,14 @@ export class Presences extends Service { * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} purge - When true, purge cached responses used by list presences endpoint. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise; - update( + update(presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise; + update( paramsOrFirst: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, ...rest: [(string)?, (string)?, (object)?, (string[])?, (boolean)?] - ): Promise { + ): Promise { let params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -290,7 +296,9 @@ export class Presences extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -337,6 +345,7 @@ export class Presences extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } diff --git a/src/services/storage.ts b/src/services/storage.ts index a461717d..1aa82328 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -81,6 +81,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -179,12 +181,16 @@ export class Storage extends Service { if (size <= Service.CHUNK_SIZE) { return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'multipart/form-data', + 'accept': 'application/json', }, payload); } const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'multipart/form-data', + 'accept': 'application/json', } let offset = 0; @@ -380,6 +386,8 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -449,7 +457,9 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -503,6 +513,7 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -571,6 +582,8 @@ export class Storage extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': '*/*', }, payload, 'arrayBuffer'); } @@ -726,6 +739,8 @@ export class Storage extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'image/*', }, payload, 'arrayBuffer'); } @@ -793,6 +808,8 @@ export class Storage extends Service { uri.searchParams.append(key, value); } return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': '*/*', }, payload, 'arrayBuffer'); } diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 2d21b4b3..418198b3 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -54,6 +54,8 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -98,7 +100,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -143,6 +147,8 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -204,7 +210,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -249,6 +257,7 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -303,7 +312,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -389,6 +400,8 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -482,7 +495,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -560,6 +575,8 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -645,7 +662,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -731,7 +750,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -801,6 +822,7 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -895,7 +917,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -989,7 +1013,9 @@ export class TablesDB extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } }; diff --git a/src/services/teams.ts b/src/services/teams.ts index 5af20fb3..b991637f 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -71,6 +71,8 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -140,7 +142,9 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -185,6 +189,8 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -242,7 +248,9 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -287,6 +295,7 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -357,6 +366,8 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -468,7 +479,9 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('post', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -522,6 +535,8 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -589,7 +604,9 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -643,6 +660,7 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('delete', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', }, payload); } @@ -727,7 +745,9 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('patch', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } @@ -772,6 +792,8 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', }, payload); } @@ -829,7 +851,9 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { + 'X-Appwrite-Project': this.client.config.project, 'content-type': 'application/json', + 'accept': 'application/json', }, payload); } };