diff --git a/CHANGELOG.md b/CHANGELOG.md index 209c432..a715f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,42 +1,28 @@ # Change Log - -## 28.2.0-rc.7 - -* Added: `Analytics` service and the `Tracking` auto-tracking helper, which were missing from `28.2.0-rc.5` and `rc.6` -* Changed: `Tracking` takes `new Analytics(client)` and a property id instead of an emitter callback; the adapter to `createEvent` now lives inside the SDK -* Changed: `enableAllAutoTracking()` is now `start()` -* Removed: `AnalyticsEventEmitter`; the option types are now `TrackingEventOptions` and `TrackingOptions` - -## 28.2.0-rc.6 - -* Added: `Push.onNotificationOpened()` fires when a user taps a shown notification -* Added: `Push.getInitialNotification()` (returns `null` on web) and the `PushNotificationOpened` type -* Added: tapping a push notification focuses then closes the page -* Fixed: `subscribe()` resolves the signed-in user from `cookieFallback`, not just an explicit session -* Fixed: background notifications de-duplicate by title, so each distinct title posts once -* Updated: clearer error messages for missing credentials in push - -## 28.2.0-rc.5 - -* Updated: regenerated with sdk-generator 5.5.0; no SDK code changes - -## 28.2.0-rc.3 - -* Added: background push notifications render the server `notification` title, body, and image -* Added: notification `data` now carries `topic` and `payload` -* Fixed: a server-sent title dedupes to one notification per topic instead of one per subscription -* Fixed: malformed push payloads no longer break notification rendering - -## 28.2.0-rc.2 - -* Added: `Push` service for MQTT realtime push messages -* Added: `Topic` and `ResolvedTopic` builders for push topic filters +## 29.0.0 + +* Breaking: `Oauth2` `resource` parameter is now `string[]` instead of `string` +* Breaking: `Teams.createMembership` takes `membershipId` after `roles`; positional callers must update +* Added: `Account.listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey` and `deletePasskey` +* Added: `Account.updatePasskeyVerification` to finish registering a passkey +* Added: `Account.createPasskeyToken` and `Account.updatePasskeyToken` for passkey sign-in +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models +* Added: `Push` service for MQTT realtime push, with `Topic` and `ResolvedTopic` builders * Added: `Client.setPushEndpoint()` and `Client.setPushClientId()` -* Added: `Avatars.deletePhoto()` method -* Added: `Models.Account` type +* Added: background push notifications render the server `notification` title, body, and image +* Added: `Push.onNotificationOpened()`, `Push.getInitialNotification()` and the `PushNotificationOpened` type +* Added: `Analytics` service with `createEvent` +* Added: `Tracking` helper for automatic pageviews, outbound links, downloads, scroll depth and engagement +* Added: `Avatars.updatePhoto()` and `Avatars.deletePhoto()` methods, and the `Models.Account` type +* Added: `state` parameter to `Account.createOAuth2Session` and `Account.createOAuth2Token` +* Added: `duration` parameter to `Account.createEmailPasswordSession` +* Added: `current` parameter to `Account.deleteSessions` +* Added: `total` parameter to `Account.listSessions`, `Locale` list methods and `listTransactions` * Added: `Webflow` to the `OAuthProvider` enum +* Fixed: response models fill missing fields from spec defaults instead of throwing * Updated: `Client.chunkedUpload()` accepts a `responseType`, supports `text`, and falls back without a file +* Updated: SDK now targets Appwrite 2.4 (`X-Appwrite-Response-Format: 2.4.0`) ## 28.1.0 @@ -250,4 +236,3 @@ * Fix pong response & chunked upload * Add `ping` support to `Realtime` service - diff --git a/README.md b/README.md index 02c0483..ed79bfb 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Web SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-web.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.4.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-web/releases) when APIs differ. +**This SDK targets Appwrite server version 2.4.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-web/releases) when APIs differ. 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 Web 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) @@ -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 tag, but before you use any Appwrite services: ```html - + ``` ## Getting Started diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..7c55296 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createPasskeyToken(); + +console.log(result); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..675fa31 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createPasskey({ + passkeyId: '', // optional + name: '', // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..e9ef2c8 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.deletePasskey({ + passkeyId: '', +}); + +console.log(result); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..17873ae --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.getPasskey({ + passkeyId: '', +}); + +console.log(result); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..799444e --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..4392a00 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '', + credential: {}, +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..13ea6eb --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '', + credential: {}, +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..86462a0 --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Account } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updatePasskey({ + passkeyId: '', + name: '', +}); + +console.log(result); +``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 7664d10..f0ac30a 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -19,7 +19,7 @@ const result = await oauth2.authorizePost({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index 495fd11..cd48dcf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -19,7 +19,7 @@ const result = await oauth2.authorize({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 56c0236..56e15ae 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -11,7 +11,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional }); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index c345b2c..a2ce80e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -19,7 +19,7 @@ const result = await oauth2.createPAR({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional }); diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index 0a2a3c7..f9d5d1b 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -16,7 +16,7 @@ const result = await oauth2.createToken({ clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional }); diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index e7e03ea..5256ed5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -10,6 +10,7 @@ const teams = new Teams(client); const result = await teams.createMembership({ teamId: '', roles: ['editor'], + membershipId: '', // optional email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/package-lock.json b/package-lock.json index 794a463..af6fe77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "appwrite", - "version": "28.2.0-rc.7", + "version": "29.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "appwrite", - "version": "28.2.0-rc.7", + "version": "29.0.0", "license": "BSD-3-Clause", "dependencies": { "buffer": "6.0.3", diff --git a/package.json b/package.json index b0d5e1d..b7cbd40 100644 --- a/package.json +++ b/package.json @@ -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": "28.2.0-rc.7", + "version": "29.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index eb7140a..1837b46 100644 --- a/src/client.ts +++ b/src/client.ts @@ -45,6 +45,50 @@ export const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record; + properties?: Record; +}; + +type Defaults = { + root: DefaultsShape; + models: Record; +}; + +export function applyDefaults(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record = { ...model.defaults, ...value }; + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + return result; +} + /** * Payload type representing a key-value pair with string keys and any values. */ @@ -401,8 +445,8 @@ class Client { 'x-sdk-name': 'Web', 'x-sdk-platform': 'client', 'x-sdk-language': 'web', - 'x-sdk-version': '28.2.0-rc.7', - 'X-Appwrite-Response-Format': '2.3.0', + 'x-sdk-version': '29.0.0', + 'X-Appwrite-Response-Format': '2.4.0', }; /** diff --git a/src/index.ts b/src/index.ts index 377b0ca..3b1129a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ /** * Appwrite Web SDK * - * This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud. + * This SDK targets Appwrite server version 2.4.x as shipped on Appwrite Cloud. * Self-hosted releases can lag behind Cloud — if you run an older self-hosted * build, use a matching older SDK from * [previous releases](https://github.com/appwrite/sdk-for-web/releases) diff --git a/src/models.ts b/src/models.ts index 11354fb..fd06606 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1384,6 +1384,102 @@ export namespace Models { expire: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + */ + phrase: string; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ diff --git a/src/services/account.ts b/src/services/account.ts index 8d95139..cc3555e 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +186,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -208,7 +297,38 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -264,7 +384,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -403,7 +544,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +650,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -633,7 +828,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -702,7 +939,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -812,7 +1081,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -873,7 +1154,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -932,7 +1255,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -990,7 +1326,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1071,7 +1420,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1151,7 +1542,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1325,7 +1758,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1385,7 +1833,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1463,7 +1926,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1540,7 +2043,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1560,7 +2103,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1579,7 +2138,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1599,7 +2174,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1618,7 +2205,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1639,7 +2238,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1659,7 +2270,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1680,7 +2303,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1700,7 +2335,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1761,7 +2408,542 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPasskey(params: { passkeyId: string }): Promise; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1841,7 +3023,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1921,7 +3145,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2006,7 +3272,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2075,7 +3383,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +3495,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2245,7 +3587,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2338,7 +3697,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2390,7 +3766,57 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2463,7 +3889,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2555,7 +4021,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2718,7 +4224,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2794,7 +4340,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3005,7 +4591,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3077,7 +4703,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3133,7 +4799,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3190,7 +4896,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3267,7 +5013,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3362,7 +5150,26 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3441,7 +5248,26 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3590,7 +5416,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3698,7 +5541,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3841,6 +5701,138 @@ export class Account { } } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + createPasskeyToken(): Promise { + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. * @@ -3911,7 +5903,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3972,7 +5981,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4034,7 +6060,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4109,7 +6152,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4182,7 +6242,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4243,7 +6320,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4320,7 +6414,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4340,7 +6451,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4415,6 +6543,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/analytics-tracking.ts b/src/services/analytics-tracking.ts index 04f6b31..e1bed9a 100644 --- a/src/services/analytics-tracking.ts +++ b/src/services/analytics-tracking.ts @@ -213,6 +213,7 @@ export class Tracking { name, url: options.url ?? this.currentPageUrl(), referrer: options.referrer, + screenWidth: this.viewportWidth(), scrollDepth: options.scrollDepth, engagementTime: options.engagementTime, // The endpoint takes props as a flat alternating key/value list. @@ -636,6 +637,15 @@ export class Tracking { return window.location.href; } + // The endpoint buckets this as viewport width in CSS pixels, so it is + // `innerWidth` rather than `screen.width` scaled by devicePixelRatio. + private viewportWidth(): number | undefined { + if (typeof window === 'undefined' || !window.innerWidth) { + return undefined; + } + return window.innerWidth; + } + private findAnchor(target: EventTarget | null): HTMLAnchorElement | null { let node = target as Node | null; while (node) { diff --git a/src/services/analytics.ts b/src/services/analytics.ts index 176a25f..bcafef2 100644 --- a/src/services/analytics.ts +++ b/src/services/analytics.ts @@ -10,7 +10,7 @@ export class Analytics { /** * Send a tracking event from a browser, native app, or server-side SDK. * - * @param {string} params.propertyId - Analytics property ID or snippet ID identifying the property. + * @param {string} params.propertyId - Analytics property ID. * @param {string} params.name - Event name. "pageview" is just a conventional event name; events are not modeled specially. * @param {string} params.url - Full page URL or screen identifier. * @param {string} params.domain - Hostname (e.g. example.com). @@ -44,7 +44,7 @@ export class Analytics { /** * Send a tracking event from a browser, native app, or server-side SDK. * - * @param {string} propertyId - Analytics property ID or snippet ID identifying the property. + * @param {string} propertyId - Analytics property ID. * @param {string} name - Event name. "pageview" is just a conventional event name; events are not modeled specially. * @param {string} url - Full page URL or screen identifier. * @param {string} domain - Hostname (e.g. example.com). diff --git a/src/services/apps.ts b/src/services/apps.ts index bd67c75..f3e42e2 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -71,7 +76,70 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -382,7 +450,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -401,7 +522,33 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -420,7 +567,33 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -472,7 +645,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -791,7 +1017,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -926,7 +1205,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1001,7 +1310,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1479,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1232,7 +1577,36 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1287,7 +1661,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1348,7 +1741,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1492,7 +1904,36 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1547,7 +1988,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1616,7 +2076,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1749,7 +2228,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/avatars.ts b/src/services/avatars.ts index eaec088..930bb5e 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; diff --git a/src/services/databases.ts b/src/services/databases.ts index 98102c1..0dc70e7 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Databases { @@ -75,7 +80,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -129,7 +161,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -188,7 +237,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -279,7 +345,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -414,7 +497,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -551,7 +651,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -722,7 +849,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -853,7 +997,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1024,7 +1185,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1195,7 +1373,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1473,7 +1668,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1633,6 +1845,23 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 82a86a9..21fb60d 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class DocumentsDB { @@ -74,7 +79,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -127,7 +159,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -185,7 +234,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -275,7 +341,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -408,7 +491,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -544,7 +644,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -714,7 +841,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -832,7 +976,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -962,7 +1133,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1132,7 +1320,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1302,7 +1507,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1578,7 +1800,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1737,6 +1976,23 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 7ab3248..bfec623 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ExecutionMethod } from '../enums/execution-method'; @@ -91,7 +96,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -240,7 +293,45 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -314,6 +405,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/locale.ts b/src/services/locale.ts index d7e6a82..d721721 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -78,7 +96,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -130,7 +171,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -182,7 +246,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -234,7 +321,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -288,7 +398,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -340,7 +474,35 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -392,6 +554,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 740ecf1..dba2024 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Messaging { @@ -101,7 +106,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 0cb439c..b94d4fc 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -97,7 +102,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -114,7 +131,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -132,7 +149,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise; @@ -150,7 +167,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -169,7 +186,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise; @@ -187,7 +204,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -203,7 +220,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -220,7 +237,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -243,7 +260,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -260,7 +277,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -334,7 +351,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +381,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -369,7 +399,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise; @@ -387,7 +417,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -406,7 +436,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise; @@ -424,7 +454,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -440,7 +470,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -457,7 +487,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -480,7 +510,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -497,7 +527,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -572,7 +602,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -581,7 +624,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -590,7 +633,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise; /** @@ -599,7 +642,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -609,7 +652,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise; createDeviceAuthorization( @@ -618,17 +661,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -642,7 +685,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -650,7 +693,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -688,7 +731,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +807,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -804,7 +887,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1247,29 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1158,7 +1286,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1175,7 +1303,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise; /** @@ -1192,7 +1320,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1210,7 +1338,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise; createPAR( @@ -1227,7 +1355,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1242,7 +1370,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, ] ): Promise { @@ -1258,7 +1386,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1279,7 +1407,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1295,7 +1423,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1380,7 +1508,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1462,7 +1603,31 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1521,7 +1686,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1641,7 +1818,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1655,7 +1832,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise; /** @@ -1669,7 +1846,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1684,7 +1861,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise; createToken( @@ -1698,7 +1875,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1710,7 +1887,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise { @@ -1723,7 +1900,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1741,7 +1918,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1754,7 +1931,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1817,6 +1994,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 4ae3386..877e946 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Organization { @@ -74,7 +79,37 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -147,7 +182,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -205,7 +260,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +355,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/presences.ts b/src/services/presences.ts index df362c3..c72accd 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -87,7 +92,33 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -145,7 +176,23 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -268,7 +315,23 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -400,7 +463,23 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index bd0220f..ffd08c2 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; @@ -117,7 +118,44 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -341,7 +379,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -446,7 +511,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 00acbed..f5b4251 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class TablesDB { @@ -74,7 +79,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -127,7 +159,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -185,7 +234,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -275,7 +341,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -408,7 +491,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -538,7 +638,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -695,7 +822,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +958,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -969,7 +1130,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1124,7 +1302,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1378,7 +1573,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1524,6 +1736,23 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 692cb2b..9996702 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -87,7 +92,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -175,7 +206,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -233,7 +280,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +371,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -443,7 +522,37 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -534,7 +643,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -609,7 +738,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -705,7 +854,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -881,7 +1050,43 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -896,6 +1101,7 @@ export class Teams { * * @param {string} params.teamId - Team ID. * @param {string[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.email - Email of the new team member. * @param {string} params.userId - ID of the user to be added to a team. * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -907,6 +1113,7 @@ export class Teams { createMembership(params: { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -925,6 +1132,7 @@ export class Teams { * * @param {string} teamId - Team ID. * @param {string[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} email - Email of the new team member. * @param {string} userId - ID of the user to be added to a team. * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -937,6 +1145,7 @@ export class Teams { createMembership( teamId: string, roles: string[], + membershipId?: string, email?: string, userId?: string, phone?: string, @@ -948,6 +1157,7 @@ export class Teams { | { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -955,11 +1165,20 @@ export class Teams { name?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { let params: { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -975,6 +1194,7 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -985,16 +1205,18 @@ export class Teams { params = { teamId: paramsOrFirst as string, roles: rest[0] as string[], - email: rest[1] as string, - userId: rest[2] as string, - phone: rest[3] as string, - url: rest[4] as string, - name: rest[5] as string, + membershipId: rest[1] as string, + email: rest[2] as string, + userId: rest[3] as string, + phone: rest[4] as string, + url: rest[5] as string, + name: rest[6] as string, }; } const teamId = params.teamId; const roles = params.roles; + const membershipId = params.membershipId; const email = params.email; const userId = params.userId; const phone = params.phone; @@ -1012,6 +1234,9 @@ export class Teams { encodeURIComponent(String(teamId)), ); const apiPayload: Payload = {}; + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } if (typeof email !== 'undefined') { apiPayload['email'] = email; } @@ -1038,7 +1263,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1113,7 +1364,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1205,7 +1482,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1398,7 +1701,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index af957f3..c4def23 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class VectorsDB { @@ -74,7 +79,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -127,7 +159,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -185,7 +234,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -275,7 +341,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -408,7 +491,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -544,7 +644,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -714,7 +841,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -853,7 +997,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -983,7 +1154,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1341,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1323,7 +1528,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /**