From b8bd37b5bf2cd9c3e2462658588285653c9aa4a1 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Sep 2024 15:34:08 +0000 Subject: [PATCH 1/6] SDK binary support for executions --- docs/examples/functions/create-deployment.md | 2 +- docs/examples/functions/create-execution.md | 3 +- docs/examples/storage/create-file.md | 2 +- package.json | 15 +--- src/client.ts | 78 ++++++++++++---- src/enums/runtime.ts | 3 + src/index.ts | 3 +- src/inputFile.ts | 23 ----- src/models.ts | 2 + src/payload.ts | 43 +++++++++ src/services/account.ts | 89 +++++++++--------- src/services/avatars.ts | 17 ++-- src/services/databases.ts | 87 +++++++++--------- src/services/functions.ts | 63 ++++++------- src/services/graphql.ts | 7 +- src/services/health.ts | 49 +++++----- src/services/locale.ts | 19 ++-- src/services/messaging.ts | 95 ++++++++++---------- src/services/storage.ts | 33 +++---- src/services/teams.ts | 29 +++--- src/services/users.ts | 87 +++++++++--------- 21 files changed, 412 insertions(+), 337 deletions(-) delete mode 100644 src/inputFile.ts create mode 100644 src/payload.ts diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 1928e4c..c86e95d 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -10,7 +10,7 @@ const functions = new sdk.Functions(client); const result = await functions.createDeployment( '', // functionId - InputFile.fromPath('/path/to/file', 'filename'), // code + Payload.fromBinary(fs.readFileSync('/path/to/file.png'), 'file.png'), // code false, // activate '', // entrypoint (optional) '' // commands (optional) diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 4eec409..ddb1de0 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,4 +1,5 @@ const sdk = require('node-appwrite'); +const fs = require('fs'); const client = new sdk.Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +10,7 @@ const functions = new sdk.Functions(client); const result = await functions.createExecution( '', // functionId - '', // body (optional) + Payload.fromJson({ x: "y" }), // body (optional) false, // async (optional) '', // path (optional) sdk.ExecutionMethod.GET, // method (optional) diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 067307c..baf5ddf 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -11,6 +11,6 @@ const storage = new sdk.Storage(client); const result = await storage.createFile( '', // bucketId '', // fileId - InputFile.fromPath('/path/to/file', 'filename'), // file + Payload.fromBinary(fs.readFileSync('/path/to/file.png'), 'file.png'), // file ["read("any")"] // permissions (optional) ); diff --git a/package.json b/package.json index c8dcded..524bbef 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "14.1.0", + "version": "15.0.0-rc1", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", @@ -19,16 +19,6 @@ "types": "./dist/index.d.ts", "default": "./dist/index.js" } - }, - "./file": { - "import": { - "types": "./dist/inputFile.d.mts", - "default": "./dist/inputFile.mjs" - }, - "require": { - "types": "./dist/inputFile.d.ts", - "default": "./dist/inputFile.js" - } } }, "files": [ @@ -48,6 +38,7 @@ "typescript": "5.4.2" }, "dependencies": { - "node-fetch-native-with-agent": "1.7.2" + "node-fetch-native-with-agent": "1.7.2", + "parse-multipart-data": "^1.5.0" } } diff --git a/src/client.ts b/src/client.ts index afe642d..4cbb897 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,8 +1,10 @@ -import { fetch, FormData, File } from 'node-fetch-native-with-agent'; +import { fetch, FormData, Blob } from 'node-fetch-native-with-agent'; import { createAgent } from 'node-fetch-native-with-agent/agent'; import { Models } from './models'; +import { Payload } from './payload'; +import * as multipart from 'parse-multipart-data'; -type Payload = { +type Params = { [key: string]: any; } @@ -33,7 +35,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/14.1.0'; + let ua = 'AppwriteNodeJSSDK/15.0.0-rc1'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +84,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '14.1.0', + 'x-sdk-version': '15.0.0-rc1', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.6.0', }; @@ -217,7 +219,7 @@ class Client { return this; } - prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } { + prepareRequest(method: string, url: URL, headers: Headers = {}, params: Params = {}): { uri: string, options: RequestInit } { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); @@ -242,8 +244,8 @@ class Client { const formData = new FormData(); for (const [key, value] of Object.entries(params)) { - if (value instanceof File) { - formData.append(key, value, value.name); + if (value instanceof Payload) { + formData.append(key, new Blob([value.toBinary()]), value.filename); } else if (Array.isArray(value)) { for (const nestedValue of value) { formData.append(`${key}[]`, nestedValue); @@ -255,6 +257,7 @@ class Client { options.body = formData; delete headers['content-type']; + headers['accept'] = 'multipart/form-data'; break; } } @@ -262,8 +265,18 @@ class Client { return { uri: url.toString(), options }; } - async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { - const file = Object.values(originalPayload).find((value) => value instanceof File); + async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Params = {}, onProgress: (progress: UploadProgress) => void) { + let file; + for (const value of Object.values(originalPayload)) { + if (value instanceof Payload) { + file = value; + break; + } + } + + if (!file) { + throw new Error('No payload found in params'); + } if (file.size <= Client.CHUNK_SIZE) { return await this.call(method, url, headers, originalPayload); @@ -279,9 +292,9 @@ class Client { } headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`; - const chunk = file.slice(start, end); + const chunk = file.toBinary(start, end - start); - let payload = { ...originalPayload, file: new File([chunk], file.name)}; + let payload = { ...originalPayload, file: new Payload(Buffer.from(chunk), file.filename)}; response = await this.call(method, url, headers, payload); @@ -305,7 +318,7 @@ class Client { return response; } - async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise { + async redirect(method: string, url: URL, headers: Headers = {}, params: Params = {}): Promise { const { uri, options } = this.prepareRequest(method, url, headers, params); const response = await fetch(uri, { @@ -320,7 +333,7 @@ class Client { return response.headers.get('location') || ''; } - async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { + async call(method: string, url: URL, headers: Headers = {}, params: Params = {}, responseType = 'json'): Promise { const { uri, options } = this.prepareRequest(method, url, headers, params); let data: any = null; @@ -336,6 +349,39 @@ class Client { data = await response.json(); } else if (responseType === 'arrayBuffer') { data = await response.arrayBuffer(); + } else if (response.headers.get('content-type')?.includes('multipart/form-data')) { + const chunks = []; + for await (const chunk of (response.body as AsyncIterable)) { + chunks.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk)); + } + const body = Buffer.concat(chunks); + const boundary = multipart.getBoundary( + response.headers.get("content-type") || "" + ); + const parts = multipart.parse(body, boundary); + const partsObject: { [key: string]: any } = {}; + + for (const part of parts) { + if (!part.name) { + continue; + } + if (part.name === "responseBody") { + partsObject[part.name] = Payload.fromBinary(part.data, part.filename); + } else if (part.name === "responseStatusCode") { + partsObject[part.name] = parseInt(part.data.toString()); + } else if (part.name === "duration") { + partsObject[part.name] = parseFloat(part.data.toString()); + } else if (part.type === 'application/json') { + try { + partsObject[part.name] = JSON.parse(part.data.toString()); + } catch (e) { + throw new Error(`Error parsing JSON for part ${part.name}: ${e instanceof Error ? e.message : 'Unknown error'}`); + } + } else { + partsObject[part.name] = part.data.toString(); + } + } + data = partsObject; } else { data = { message: await response.text() @@ -349,8 +395,8 @@ class Client { return data; } - static flatten(data: Payload, prefix = ''): Payload { - let output: Payload = {}; + static flatten(data: Params, prefix = ''): Params { + let output: Params = {}; for (const [key, value] of Object.entries(data)) { let finalKey = prefix ? prefix + '[' + key +']' : key; @@ -367,5 +413,5 @@ class Client { export { Client, AppwriteException }; export { Query } from './query'; -export type { Models, Payload, UploadProgress }; +export type { Models, Params, UploadProgress }; export type { QueryTypes, QueryTypesList } from './query'; diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index f0524b5..658bb96 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -19,6 +19,9 @@ export enum Runtime { Python311 = 'python-3.11', Python312 = 'python-3.12', Pythonml311 = 'python-ml-3.11', + Deno121 = 'deno-1.21', + Deno124 = 'deno-1.24', + Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Dart215 = 'dart-2.15', Dart216 = 'dart-2.16', diff --git a/src/index.ts b/src/index.ts index 38ceb0d..18f4151 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,11 +10,12 @@ export { Messaging } from './services/messaging'; export { Storage } from './services/storage'; export { Teams } from './services/teams'; export { Users } from './services/users'; -export type { Models, Payload, UploadProgress } from './client'; +export type { Models, Params, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; +export { Payload } from './payload'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; export { OAuthProvider } from './enums/o-auth-provider'; diff --git a/src/inputFile.ts b/src/inputFile.ts deleted file mode 100644 index a30ea55..0000000 --- a/src/inputFile.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { File } from "node-fetch-native-with-agent"; -import { realpathSync, readFileSync } from "fs"; -import type { BinaryLike } from "crypto"; - -export class InputFile { - static fromBuffer( - parts: Blob | BinaryLike, - name: string - ): File { - return new File([parts], name); - } - - static fromPath(path: string, name: string): File { - const realPath = realpathSync(path); - const contents = readFileSync(realPath); - return this.fromBuffer(contents, name); - } - - static fromPlainText(content: string, name: string): File { - const arrayBytes = new TextEncoder().encode(content); - return this.fromBuffer(arrayBytes, name); - } -} diff --git a/src/models.ts b/src/models.ts index 1cbd00c..e07d221 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,3 +1,5 @@ +import type { Payload } from './payload'; + /** * Appwrite Models */ diff --git a/src/payload.ts b/src/payload.ts new file mode 100644 index 0000000..1bb8858 --- /dev/null +++ b/src/payload.ts @@ -0,0 +1,43 @@ +export class Payload { + private data: Buffer; + public filename?: string; + public size: number; + + constructor(data: Buffer, filename?: string) { + this.data = data; + this.filename = filename; + this.size = data.byteLength; + } + + public toBinary(offset: number = 0, length?: number): Buffer { + if (offset === 0 && length === undefined) { + return this.data; + } else if (length === undefined) { + return this.data.subarray(offset); + } else { + return this.data.subarray(offset, offset + length); + } + } + + public toJson(): T { + return JSON.parse(this.toString()); + } + + public toString(): string { + return this.data.toString("utf-8"); + } + + public static fromBinary(bytes: Buffer, filename?: string): Payload { + return new Payload(bytes, filename); + } + + public static fromJson(object: any, filename?: string): Payload { + const data = Buffer.from(JSON.stringify(object), "utf-8"); + return new Payload(data, filename); + } + + public static fromString(text: string, filename?: string): Payload { + const data = Buffer.from(text, "utf-8"); + return new Payload(data, filename); + } +} diff --git a/src/services/account.ts b/src/services/account.ts index 213b137..13568db 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; @@ -21,7 +22,7 @@ export class Account { */ async get(): Promise> { const apiPath = '/account'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -58,7 +59,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -104,7 +105,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/email'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -135,7 +136,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async listIdentities(queries?: string[]): Promise { const apiPath = '/account/identities'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -166,7 +167,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "identityId"'); } const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -190,7 +191,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async createJWT(): Promise { const apiPath = '/account/jwts'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -215,7 +216,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async listLogs(queries?: string[]): Promise { const apiPath = '/account/logs'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -246,7 +247,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "mfa"'); } const apiPath = '/account/mfa'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof mfa !== 'undefined') { payload['mfa'] = mfa; } @@ -277,7 +278,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -309,7 +310,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "otp"'); } const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Payload = {}; + const payload: Params = {}; if (typeof otp !== 'undefined') { payload['otp'] = otp; } @@ -340,7 +341,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -368,7 +369,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "factor"'); } const apiPath = '/account/mfa/challenge'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof factor !== 'undefined') { payload['factor'] = factor; } @@ -403,7 +404,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "otp"'); } const apiPath = '/account/mfa/challenge'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof challengeId !== 'undefined') { payload['challengeId'] = challengeId; } @@ -433,7 +434,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async listMfaFactors(): Promise { const apiPath = '/account/mfa/factors'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -457,7 +458,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async getMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -481,7 +482,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async createMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -505,7 +506,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async updateMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -533,7 +534,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/account/name'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -565,7 +566,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/password'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof password !== 'undefined') { payload['password'] = password; } @@ -603,7 +604,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/phone'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof phone !== 'undefined') { payload['phone'] = phone; } @@ -633,7 +634,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async getPrefs(): Promise { const apiPath = '/account/prefs'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -661,7 +662,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "prefs"'); } const apiPath = '/account/prefs'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; } @@ -696,7 +697,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/account/recovery'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -740,7 +741,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/recovery'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -773,7 +774,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async listSessions(): Promise { const apiPath = '/account/sessions'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -797,7 +798,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async deleteSessions(): Promise<{}> { const apiPath = '/account/sessions'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -821,7 +822,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async createAnonymousSession(): Promise { const apiPath = '/account/sessions/anonymous'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -855,7 +856,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/sessions/email'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -893,7 +894,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/sessions/magic-url'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -931,7 +932,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/sessions/phone'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -969,7 +970,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/sessions/token'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1003,7 +1004,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1031,7 +1032,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1059,7 +1060,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1083,7 +1084,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about */ async updateStatus(): Promise> { const apiPath = '/account/status'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1118,7 +1119,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "email"'); } const apiPath = '/account/tokens/email'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1164,7 +1165,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "email"'); } const apiPath = '/account/tokens/magic-url'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1211,7 +1212,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "provider"'); } const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider); - const payload: Payload = {}; + const payload: Params = {}; if (typeof success !== 'undefined') { payload['success'] = success; } @@ -1254,7 +1255,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "phone"'); } const apiPath = '/account/tokens/phone'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1291,7 +1292,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/account/verification'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof url !== 'undefined') { payload['url'] = url; } @@ -1326,7 +1327,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/verification'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1356,7 +1357,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async createPhoneVerification(): Promise { const apiPath = '/account/verification/phone'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1388,7 +1389,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/verification/phone'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 3111f49..e38829f 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; @@ -30,7 +31,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "code"'); } const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); - const payload: Payload = {}; + const payload: Params = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -74,7 +75,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "code"'); } const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); - const payload: Payload = {}; + const payload: Params = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -114,7 +115,7 @@ This endpoint does not follow HTTP redirects. throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/avatars/favicon'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof url !== 'undefined') { payload['url'] = url; } @@ -152,7 +153,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "code"'); } const apiPath = '/avatars/flags/{code}'.replace('{code}', code); - const payload: Payload = {}; + const payload: Params = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -196,7 +197,7 @@ This endpoint does not follow HTTP redirects. throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/avatars/image'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof url !== 'undefined') { payload['url'] = url; } @@ -239,7 +240,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre */ async getInitials(name?: string, width?: number, height?: number, background?: string): Promise { const apiPath = '/avatars/initials'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -284,7 +285,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "text"'); } const apiPath = '/avatars/qr'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof text !== 'undefined') { payload['text'] = text; } diff --git a/src/services/databases.ts b/src/services/databases.ts index c200f04..7070a0c 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; @@ -23,7 +24,7 @@ export class Databases { */ async list(queries?: string[], search?: string): Promise { const apiPath = '/databases'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -63,7 +64,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof databaseId !== 'undefined') { payload['databaseId'] = databaseId; } @@ -100,7 +101,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "databaseId"'); } const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -133,7 +134,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -167,7 +168,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "databaseId"'); } const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -197,7 +198,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "databaseId"'); } const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -242,7 +243,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof collectionId !== 'undefined') { payload['collectionId'] = collectionId; } @@ -289,7 +290,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -328,7 +329,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -372,7 +373,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -405,7 +406,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -451,7 +452,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -508,7 +509,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -559,7 +560,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -616,7 +617,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -668,7 +669,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -726,7 +727,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -782,7 +783,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -847,7 +848,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof elements !== 'undefined') { payload['elements'] = elements; } @@ -904,7 +905,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -976,7 +977,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1036,7 +1037,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1108,7 +1109,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1166,7 +1167,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1224,7 +1225,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1278,7 +1279,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof relatedCollectionId !== 'undefined') { payload['relatedCollectionId'] = relatedCollectionId; } @@ -1344,7 +1345,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1409,7 +1410,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1464,7 +1465,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1522,7 +1523,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1567,7 +1568,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1603,7 +1604,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1642,7 +1643,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; if (typeof onDelete !== 'undefined') { payload['onDelete'] = onDelete; } @@ -1681,7 +1682,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1725,7 +1726,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "data"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof documentId !== 'undefined') { payload['documentId'] = documentId; } @@ -1771,7 +1772,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "documentId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1812,7 +1813,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "documentId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof data !== 'undefined') { payload['data'] = data; } @@ -1854,7 +1855,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "documentId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1887,7 +1888,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1936,7 +1937,7 @@ Attributes can be `key`, `fulltext`, and `unique`. throw new AppwriteException('Missing required parameter: "attributes"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1984,7 +1985,7 @@ Attributes can be `key`, `fulltext`, and `unique`. throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2020,7 +2021,7 @@ Attributes can be `key`, `fulltext`, and `unique`. throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/functions.ts b/src/services/functions.ts index f78e272..345d1c2 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { Runtime } from '../enums/runtime'; import { ExecutionMethod } from '../enums/execution-method'; @@ -22,7 +23,7 @@ export class Functions { */ async list(queries?: string[], search?: string): Promise { const apiPath = '/functions'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -83,7 +84,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "runtime"'); } const apiPath = '/functions'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof functionId !== 'undefined') { payload['functionId'] = functionId; } @@ -173,7 +174,7 @@ export class Functions { */ async listRuntimes(): Promise { const apiPath = '/functions/runtimes'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -198,7 +199,7 @@ export class Functions { */ async listSpecifications(): Promise { const apiPath = '/functions/specifications'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -226,7 +227,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -274,7 +275,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -353,7 +354,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -383,7 +384,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -413,14 +414,14 @@ This endpoint accepts a tar.gz file compressed with your code. Make sure to incl Use the "command" param to set the entrypoint used to execute your code. * * @param {string} functionId - * @param {File} code + * @param {Payload} code * @param {boolean} activate * @param {string} entrypoint * @param {string} commands * @throws {AppwriteException} * @returns {Promise} */ - async createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise { + async createDeployment(functionId: string, code: Payload, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -431,7 +432,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "activate"'); } const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof entrypoint !== 'undefined') { payload['entrypoint'] = entrypoint; } @@ -476,7 +477,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -508,7 +509,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -540,7 +541,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -572,7 +573,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}/build'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof buildId !== 'undefined') { payload['buildId'] = buildId; } @@ -606,7 +607,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}/build'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -638,7 +639,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -669,7 +670,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -695,7 +696,7 @@ Use the "command" param to set the entrypoint used to execute your cod * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * * @param {string} functionId - * @param {string} body + * @param {Payload} body * @param {boolean} async * @param {string} xpath * @param {ExecutionMethod} method @@ -704,14 +705,14 @@ Use the "command" param to set the entrypoint used to execute your cod * @throws {AppwriteException} * @returns {Promise} */ - async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise { + async createExecution(functionId: string, body?: Payload, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string, onProgress = (progress: UploadProgress) => {}): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof body !== 'undefined') { - payload['body'] = body; + payload['body'] = body.toBinary(); } if (typeof async !== 'undefined') { payload['async'] = async; @@ -731,7 +732,7 @@ Use the "command" param to set the entrypoint used to execute your cod const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', + 'content-type': 'multipart/form-data', } return await this.client.call( @@ -759,7 +760,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "executionId"'); } const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -792,7 +793,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "executionId"'); } const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -820,7 +821,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -856,7 +857,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "value"'); } const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -894,7 +895,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "variableId"'); } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -931,7 +932,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -969,7 +970,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "variableId"'); } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/graphql.ts b/src/services/graphql.ts index ca0219d..a6a78eb 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; export class Graphql { @@ -22,7 +23,7 @@ export class Graphql { throw new AppwriteException('Missing required parameter: "query"'); } const apiPath = '/graphql'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof query !== 'undefined') { payload['query'] = query; } @@ -54,7 +55,7 @@ export class Graphql { throw new AppwriteException('Missing required parameter: "query"'); } const apiPath = '/graphql/mutation'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof query !== 'undefined') { payload['query'] = query; } diff --git a/src/services/health.ts b/src/services/health.ts index ef4e6d1..b7fa907 100644 --- a/src/services/health.ts +++ b/src/services/health.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { Name } from '../enums/name'; @@ -19,7 +20,7 @@ export class Health { */ async get(): Promise { const apiPath = '/health'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -43,7 +44,7 @@ export class Health { */ async getAntivirus(): Promise { const apiPath = '/health/anti-virus'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -67,7 +68,7 @@ export class Health { */ async getCache(): Promise { const apiPath = '/health/cache'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -92,7 +93,7 @@ export class Health { */ async getCertificate(domain?: string): Promise { const apiPath = '/health/certificate'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof domain !== 'undefined') { payload['domain'] = domain; } @@ -119,7 +120,7 @@ export class Health { */ async getDB(): Promise { const apiPath = '/health/db'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -143,7 +144,7 @@ export class Health { */ async getPubSub(): Promise { const apiPath = '/health/pubsub'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -167,7 +168,7 @@ export class Health { */ async getQueue(): Promise { const apiPath = '/health/queue'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -192,7 +193,7 @@ export class Health { */ async getQueueBuilds(threshold?: number): Promise { const apiPath = '/health/queue/builds'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -220,7 +221,7 @@ export class Health { */ async getQueueCertificates(threshold?: number): Promise { const apiPath = '/health/queue/certificates'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -249,7 +250,7 @@ export class Health { */ async getQueueDatabases(name?: string, threshold?: number): Promise { const apiPath = '/health/queue/databases'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -280,7 +281,7 @@ export class Health { */ async getQueueDeletes(threshold?: number): Promise { const apiPath = '/health/queue/deletes'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -313,7 +314,7 @@ export class Health { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/health/queue/failed/{name}'.replace('{name}', name); - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -341,7 +342,7 @@ export class Health { */ async getQueueFunctions(threshold?: number): Promise { const apiPath = '/health/queue/functions'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -369,7 +370,7 @@ export class Health { */ async getQueueLogs(threshold?: number): Promise { const apiPath = '/health/queue/logs'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -397,7 +398,7 @@ export class Health { */ async getQueueMails(threshold?: number): Promise { const apiPath = '/health/queue/mails'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -425,7 +426,7 @@ export class Health { */ async getQueueMessaging(threshold?: number): Promise { const apiPath = '/health/queue/messaging'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -453,7 +454,7 @@ export class Health { */ async getQueueMigrations(threshold?: number): Promise { const apiPath = '/health/queue/migrations'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -481,7 +482,7 @@ export class Health { */ async getQueueUsage(threshold?: number): Promise { const apiPath = '/health/queue/usage'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -509,7 +510,7 @@ export class Health { */ async getQueueUsageDump(threshold?: number): Promise { const apiPath = '/health/queue/usage-dump'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -537,7 +538,7 @@ export class Health { */ async getQueueWebhooks(threshold?: number): Promise { const apiPath = '/health/queue/webhooks'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -564,7 +565,7 @@ export class Health { */ async getStorage(): Promise { const apiPath = '/health/storage'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -588,7 +589,7 @@ export class Health { */ async getStorageLocal(): Promise { const apiPath = '/health/storage/local'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -612,7 +613,7 @@ export class Health { */ async getTime(): Promise { const apiPath = '/health/time'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/locale.ts b/src/services/locale.ts index aae0dca..b82d051 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; export class Locale { @@ -20,7 +21,7 @@ export class Locale { */ async get(): Promise { const apiPath = '/locale'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -44,7 +45,7 @@ export class Locale { */ async listCodes(): Promise { const apiPath = '/locale/codes'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -68,7 +69,7 @@ export class Locale { */ async listContinents(): Promise { const apiPath = '/locale/continents'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -92,7 +93,7 @@ export class Locale { */ async listCountries(): Promise { const apiPath = '/locale/countries'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -116,7 +117,7 @@ export class Locale { */ async listCountriesEU(): Promise { const apiPath = '/locale/countries/eu'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -140,7 +141,7 @@ export class Locale { */ async listCountriesPhones(): Promise { const apiPath = '/locale/countries/phones'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -164,7 +165,7 @@ export class Locale { */ async listCurrencies(): Promise { const apiPath = '/locale/currencies'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -188,7 +189,7 @@ export class Locale { */ async listLanguages(): Promise { const apiPath = '/locale/languages'; - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/messaging.ts b/src/services/messaging.ts index c9200a6..4c634cd 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { SmtpEncryption } from '../enums/smtp-encryption'; @@ -21,7 +22,7 @@ export class Messaging { */ async listMessages(queries?: string[], search?: string): Promise { const apiPath = '/messaging/messages'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -72,7 +73,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "content"'); } const apiPath = '/messaging/messages/email'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof messageId !== 'undefined') { payload['messageId'] = messageId; } @@ -148,7 +149,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; } @@ -230,7 +231,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "body"'); } const apiPath = '/messaging/messages/push'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof messageId !== 'undefined') { payload['messageId'] = messageId; } @@ -322,7 +323,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; } @@ -404,7 +405,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "content"'); } const apiPath = '/messaging/messages/sms'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof messageId !== 'undefined') { payload['messageId'] = messageId; } @@ -460,7 +461,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; } @@ -507,7 +508,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -535,7 +536,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -564,7 +565,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}/logs'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -596,7 +597,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}/targets'.replace('{messageId}', messageId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -625,7 +626,7 @@ export class Messaging { */ async listProviders(queries?: string[], search?: string): Promise { const apiPath = '/messaging/providers'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -669,7 +670,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/apns'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -728,7 +729,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -783,7 +784,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/fcm'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -826,7 +827,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -875,7 +876,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/mailgun'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -942,7 +943,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/mailgun/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1005,7 +1006,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/msg91'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1056,7 +1057,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1109,7 +1110,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/sendgrid'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1168,7 +1169,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1236,7 +1237,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "host"'); } const apiPath = '/messaging/providers/smtp'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1319,7 +1320,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1394,7 +1395,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/telesign'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1445,7 +1446,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/telesign/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1496,7 +1497,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/textmagic'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1547,7 +1548,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/textmagic/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1598,7 +1599,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/twilio'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1649,7 +1650,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/twilio/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1700,7 +1701,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/vonage'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1751,7 +1752,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/vonage/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1795,7 +1796,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1823,7 +1824,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1852,7 +1853,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/{providerId}/logs'.replace('{providerId}', providerId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1884,7 +1885,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/subscribers/{subscriberId}/logs'.replace('{subscriberId}', subscriberId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1913,7 +1914,7 @@ export class Messaging { */ async listTopics(queries?: string[], search?: string): Promise { const apiPath = '/messaging/topics'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1952,7 +1953,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/topics'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof topicId !== 'undefined') { payload['topicId'] = topicId; } @@ -1990,7 +1991,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2021,7 +2022,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -2055,7 +2056,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2084,7 +2085,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}/logs'.replace('{topicId}', topicId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -2117,7 +2118,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -2159,7 +2160,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof subscriberId !== 'undefined') { payload['subscriberId'] = subscriberId; } @@ -2198,7 +2199,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2230,7 +2231,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/storage.ts b/src/services/storage.ts index 649c1ae..de0219e 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; @@ -23,7 +24,7 @@ export class Storage { */ async listBuckets(queries?: string[], search?: string): Promise { const apiPath = '/storage/buckets'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -69,7 +70,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/storage/buckets'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof bucketId !== 'undefined') { payload['bucketId'] = bucketId; } @@ -127,7 +128,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "bucketId"'); } const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -167,7 +168,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -222,7 +223,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "bucketId"'); } const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -252,7 +253,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "bucketId"'); } const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -286,12 +287,12 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk * * @param {string} bucketId * @param {string} fileId - * @param {File} file + * @param {Payload} file * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} */ - async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise { + async createFile(bucketId: string, fileId: string, file: Payload, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -302,7 +303,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "file"'); } const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof fileId !== 'undefined') { payload['fileId'] = fileId; } @@ -344,7 +345,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -378,7 +379,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -416,7 +417,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -448,7 +449,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -492,7 +493,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -558,7 +559,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/teams.ts b/src/services/teams.ts index 6ef54a9..2ba96c9 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; export class Teams { @@ -20,7 +21,7 @@ export class Teams { */ async list(queries?: string[], search?: string): Promise> { const apiPath = '/teams'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -59,7 +60,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/teams'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof teamId !== 'undefined') { payload['teamId'] = teamId; } @@ -96,7 +97,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -128,7 +129,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -159,7 +160,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -189,7 +190,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -239,7 +240,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "roles"'); } const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -289,7 +290,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "membershipId"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -326,7 +327,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "roles"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof roles !== 'undefined') { payload['roles'] = roles; } @@ -361,7 +362,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "membershipId"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -404,7 +405,7 @@ If the request is successful, a session for the user is automatically created. throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -438,7 +439,7 @@ If the request is successful, a session for the user is automatically created. throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -470,7 +471,7 @@ If the request is successful, a session for the user is automatically created. throw new AppwriteException('Missing required parameter: "prefs"'); } const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; } diff --git a/src/services/users.ts b/src/services/users.ts index ba1843f..b7f01f1 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,5 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Params, UploadProgress } from '../client'; +import { Payload } from '../payload'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -23,7 +24,7 @@ export class Users { */ async list(queries?: string[], search?: string): Promise> { const apiPath = '/users'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -61,7 +62,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -113,7 +114,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/argon2'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -162,7 +163,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/bcrypt'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -200,7 +201,7 @@ export class Users { */ async listIdentities(queries?: string[], search?: string): Promise { const apiPath = '/users/identities'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -234,7 +235,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "identityId"'); } const apiPath = '/users/identities/{identityId}'.replace('{identityId}', identityId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -271,7 +272,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/md5'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -320,7 +321,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/phpass'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -389,7 +390,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "passwordLength"'); } const apiPath = '/users/scrypt'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -465,7 +466,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); } const apiPath = '/users/scrypt-modified'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -524,7 +525,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/sha'; - const payload: Payload = {}; + const payload: Params = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -567,7 +568,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -595,7 +596,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -627,7 +628,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } const apiPath = '/users/{userId}/email'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -660,7 +661,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/jwts'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof sessionId !== 'undefined') { payload['sessionId'] = sessionId; } @@ -700,7 +701,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "labels"'); } const apiPath = '/users/{userId}/labels'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof labels !== 'undefined') { payload['labels'] = labels; } @@ -732,7 +733,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/logs'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -763,7 +764,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/memberships'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -795,7 +796,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "mfa"'); } const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof mfa !== 'undefined') { payload['mfa'] = mfa; } @@ -830,7 +831,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -858,7 +859,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -886,7 +887,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -914,7 +915,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -942,7 +943,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -974,7 +975,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/users/{userId}/name'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1009,7 +1010,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/{userId}/password'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof password !== 'undefined') { payload['password'] = password; } @@ -1044,7 +1045,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "number"'); } const apiPath = '/users/{userId}/phone'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof number !== 'undefined') { payload['number'] = number; } @@ -1075,7 +1076,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1107,7 +1108,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "prefs"'); } const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; } @@ -1138,7 +1139,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1168,7 +1169,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1196,7 +1197,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1228,7 +1229,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1260,7 +1261,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "status"'); } const apiPath = '/users/{userId}/status'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof status !== 'undefined') { payload['status'] = status; } @@ -1292,7 +1293,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1337,7 +1338,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "identifier"'); } const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof targetId !== 'undefined') { payload['targetId'] = targetId; } @@ -1384,7 +1385,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1419,7 +1420,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof identifier !== 'undefined') { payload['identifier'] = identifier; } @@ -1460,7 +1461,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); - const payload: Payload = {}; + const payload: Params = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1491,7 +1492,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/tokens'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof length !== 'undefined') { payload['length'] = length; } @@ -1529,7 +1530,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "emailVerification"'); } const apiPath = '/users/{userId}/verification'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof emailVerification !== 'undefined') { payload['emailVerification'] = emailVerification; } @@ -1564,7 +1565,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "phoneVerification"'); } const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', userId); - const payload: Payload = {}; + const payload: Params = {}; if (typeof phoneVerification !== 'undefined') { payload['phoneVerification'] = phoneVerification; } From 4697b480bfda977bfb69e8d6a54c526ed80cdf3d Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:28:38 +0100 Subject: [PATCH 2/6] fix: multipart testing --- package.json | 2 +- src/client.ts | 16 ++++++---------- src/models.ts | 2 +- src/services/account.ts | 20 ++++++++++---------- src/services/locale.ts | 2 +- src/services/storage.ts | 2 +- src/services/users.ts | 20 ++++++++++---------- 7 files changed, 30 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 524bbef..55add45 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "15.0.0-rc1", + "version": "14.1.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 4cbb897..d1b9c2d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,8 +1,8 @@ import { fetch, FormData, Blob } from 'node-fetch-native-with-agent'; +import { getBoundary, parse as parseMultipart} from 'parse-multipart-data'; import { createAgent } from 'node-fetch-native-with-agent/agent'; import { Models } from './models'; import { Payload } from './payload'; -import * as multipart from 'parse-multipart-data'; type Params = { [key: string]: any; @@ -35,7 +35,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/15.0.0-rc1'; + let ua = 'AppwriteNodeJSSDK/14.1.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -84,7 +84,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '15.0.0-rc1', + 'x-sdk-version': '14.1.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.6.0', }; @@ -350,15 +350,11 @@ class Client { } else if (responseType === 'arrayBuffer') { data = await response.arrayBuffer(); } else if (response.headers.get('content-type')?.includes('multipart/form-data')) { - const chunks = []; - for await (const chunk of (response.body as AsyncIterable)) { - chunks.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk)); - } - const body = Buffer.concat(chunks); - const boundary = multipart.getBoundary( + const body = await response.arrayBuffer(); + const boundary = getBoundary( response.headers.get("content-type") || "" ); - const parts = multipart.parse(body, boundary); + const parts = parseMultipart(Buffer.from(body), boundary); const partsObject: { [key: string]: any } = {}; for (const part of parts) { diff --git a/src/models.ts b/src/models.ts index e07d221..8a4485c 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1924,7 +1924,7 @@ export namespace Models { /** * HTTP response body. This will return empty unless execution is created as synchronous. */ - responseBody: string; + responseBody: Payload; /** * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ diff --git a/src/services/account.ts b/src/services/account.ts index 13568db..0655fd7 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -126,7 +126,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * List Identities + * List identities * * Get the list of identities for the currently logged in user. * @@ -265,7 +265,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Create Authenticator + * Create authenticator * * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -293,7 +293,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Verify Authenticator + * Verify authenticator * * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -328,7 +328,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Delete Authenticator + * Delete authenticator * * Delete an authenticator for a user by ID. * @@ -356,7 +356,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Create MFA Challenge + * Create MFA challenge * * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -387,7 +387,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Create MFA Challenge (confirmation) + * Create MFA challenge (confirmation) * * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -425,7 +425,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * List Factors + * List factors * * List the factors available on the account to be used as a MFA challange. * @@ -449,7 +449,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Get MFA Recovery Codes + * Get MFA recovery codes * * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * @@ -473,7 +473,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Create MFA Recovery Codes + * Create MFA recovery codes * * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -497,7 +497,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ); } /** - * Regenerate MFA Recovery Codes + * Regenerate MFA recovery codes * * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * diff --git a/src/services/locale.ts b/src/services/locale.ts index b82d051..81b43aa 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -36,7 +36,7 @@ export class Locale { ); } /** - * List Locale Codes + * List locale codes * * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). * diff --git a/src/services/storage.ts b/src/services/storage.ts index de0219e..566e0df 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -400,7 +400,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk ); } /** - * Delete File + * Delete file * * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * diff --git a/src/services/users.ts b/src/services/users.ts index b7f01f1..2d06ac5 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -190,7 +190,7 @@ export class Users { ); } /** - * List Identities + * List identities * * Get identities for all users. * @@ -814,7 +814,7 @@ Labels can be used to grant access to resources. While teams are a way for user& ); } /** - * Delete Authenticator + * Delete authenticator * * Delete an authenticator app. * @@ -846,7 +846,7 @@ Labels can be used to grant access to resources. While teams are a way for user& ); } /** - * List Factors + * List factors * * List the factors available on the account to be used as a MFA challange. * @@ -874,7 +874,7 @@ Labels can be used to grant access to resources. While teams are a way for user& ); } /** - * Get MFA Recovery Codes + * Get MFA recovery codes * * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -902,7 +902,7 @@ Labels can be used to grant access to resources. While teams are a way for user& ); } /** - * Regenerate MFA Recovery Codes + * Regenerate MFA recovery codes * * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -930,7 +930,7 @@ Labels can be used to grant access to resources. While teams are a way for user& ); } /** - * Create MFA Recovery Codes + * Create MFA recovery codes * * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. * @@ -1279,7 +1279,7 @@ If you want to generate a token for a custom authentication flow, use the [POST ); } /** - * List User Targets + * List user targets * * List the messaging targets that are associated with a user. * @@ -1311,7 +1311,7 @@ If you want to generate a token for a custom authentication flow, use the [POST ); } /** - * Create User Target + * Create user target * * Create a messaging target. * @@ -1368,7 +1368,7 @@ If you want to generate a token for a custom authentication flow, use the [POST ); } /** - * Get User Target + * Get user target * * Get a user's push notification target by ID. * @@ -1400,7 +1400,7 @@ If you want to generate a token for a custom authentication flow, use the [POST ); } /** - * Update User target + * Update user target * * Update a messaging target. * From 3df9d26dd2987d461af8bda892e71c7f2bff626a Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:21:54 +0100 Subject: [PATCH 3/6] feat: multipart --- src/enums/image-format.ts | 1 + src/models.ts | 88 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index 7e96fd8..8599e30 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -4,4 +4,5 @@ export enum ImageFormat { Gif = 'gif', Png = 'png', Webp = 'webp', + Avif = 'avif', } \ No newline at end of file diff --git a/src/models.ts b/src/models.ts index 8a4485c..35fb1a2 100644 --- a/src/models.ts +++ b/src/models.ts @@ -492,6 +492,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * Attribute size. */ @@ -529,6 +537,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * Minimum value to enforce for new documents. */ @@ -570,6 +586,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * Minimum value to enforce for new documents. */ @@ -611,6 +635,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ @@ -644,6 +676,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * String format. */ @@ -681,6 +721,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * Array of elements in enumerated type. */ @@ -722,6 +770,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * String format. */ @@ -759,6 +815,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * String format. */ @@ -796,6 +860,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * ISO 8601 format. */ @@ -833,6 +905,14 @@ export namespace Models { * Is attribute an array? */ array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; /** * The ID of the related collection. */ @@ -886,6 +966,14 @@ export namespace Models { * Index orders. */ orders?: string[]; + /** + * Index creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Index update date in ISO 8601 format. + */ + $updatedAt: string; } /** * Document From 0e38355fb0172fd029d3b1f4a1110438ec333237 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Dec 2024 00:35:07 +1300 Subject: [PATCH 4/6] Add new push message parameters --- README.md | 2 +- .../databases/update-string-attribute.md | 2 +- docs/examples/functions/create-deployment.md | 2 +- docs/examples/functions/create-execution.md | 3 +- docs/examples/messaging/create-push.md | 11 +- docs/examples/messaging/update-push.md | 5 +- docs/examples/storage/create-file.md | 2 +- package.json | 15 +- src/client.ts | 78 +++-------- src/enums/message-priority.ts | 4 + src/enums/runtime.ts | 12 +- src/index.ts | 4 +- src/inputFile.ts | 23 +++ src/models.ts | 16 ++- src/payload.ts | 43 ------ src/services/account.ts | 91 ++++++------ src/services/avatars.ts | 17 ++- src/services/databases.ts | 87 ++++++------ src/services/functions.ts | 63 ++++----- src/services/graphql.ts | 7 +- src/services/health.ts | 49 ++++--- src/services/locale.ts | 19 ++- src/services/messaging.ts | 132 ++++++++++-------- src/services/storage.ts | 33 +++-- src/services/teams.ts | 33 +++-- src/services/users.ts | 87 ++++++------ 26 files changed, 410 insertions(+), 430 deletions(-) create mode 100644 src/enums/message-priority.ts create mode 100644 src/inputFile.ts delete mode 100644 src/payload.ts diff --git a/README.md b/README.md index d77ecca..af47ac1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.1-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) diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index f379fdc..6aecbb5 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -13,6 +13,6 @@ const result = await databases.updateStringAttribute( '', // key false, // required '', // default - null, // size (optional) + 1, // size (optional) '' // newKey (optional) ); diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index c86e95d..1928e4c 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -10,7 +10,7 @@ const functions = new sdk.Functions(client); const result = await functions.createDeployment( '', // functionId - Payload.fromBinary(fs.readFileSync('/path/to/file.png'), 'file.png'), // code + InputFile.fromPath('/path/to/file', 'filename'), // code false, // activate '', // entrypoint (optional) '' // commands (optional) diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index ddb1de0..4eec409 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,5 +1,4 @@ const sdk = require('node-appwrite'); -const fs = require('fs'); const client = new sdk.Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +9,7 @@ const functions = new sdk.Functions(client); const result = await functions.createExecution( '', // functionId - Payload.fromJson({ x: "y" }), // body (optional) + '', // body (optional) false, // async (optional) '', // path (optional) sdk.ExecutionMethod.GET, // method (optional) diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 54103e1..bb98538 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -9,8 +9,8 @@ const messaging = new sdk.Messaging(client); const result = await messaging.createPush( '', // messageId - '', // title - '<BODY>', // body + '<TITLE>', // title (optional) + '<BODY>', // body (optional) [], // topics (optional) [], // users (optional) [], // targets (optional) @@ -21,7 +21,10 @@ const result = await messaging.createPush( '<SOUND>', // sound (optional) '<COLOR>', // color (optional) '<TAG>', // tag (optional) - '<BADGE>', // badge (optional) + null, // badge (optional) false, // draft (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + sdk.MessagePriority.Normal // priority (optional) ); diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index ec87ecf..700c3a9 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -23,5 +23,8 @@ const result = await messaging.updatePush( '<TAG>', // tag (optional) null, // badge (optional) false, // draft (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + false, // contentAvailable (optional) + false, // critical (optional) + sdk.MessagePriority.Normal // priority (optional) ); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index baf5ddf..067307c 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -11,6 +11,6 @@ const storage = new sdk.Storage(client); const result = await storage.createFile( '<BUCKET_ID>', // bucketId '<FILE_ID>', // fileId - Payload.fromBinary(fs.readFileSync('/path/to/file.png'), 'file.png'), // file + InputFile.fromPath('/path/to/file', 'filename'), // file ["read("any")"] // permissions (optional) ); diff --git a/package.json b/package.json index 55add45..84975d6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "14.1.0", + "version": "14.2.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", @@ -19,6 +19,16 @@ "types": "./dist/index.d.ts", "default": "./dist/index.js" } + }, + "./file": { + "import": { + "types": "./dist/inputFile.d.mts", + "default": "./dist/inputFile.mjs" + }, + "require": { + "types": "./dist/inputFile.d.ts", + "default": "./dist/inputFile.js" + } } }, "files": [ @@ -38,7 +48,6 @@ "typescript": "5.4.2" }, "dependencies": { - "node-fetch-native-with-agent": "1.7.2", - "parse-multipart-data": "^1.5.0" + "node-fetch-native-with-agent": "1.7.2" } } diff --git a/src/client.ts b/src/client.ts index d1b9c2d..ff7673d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,10 +1,8 @@ -import { fetch, FormData, Blob } from 'node-fetch-native-with-agent'; -import { getBoundary, parse as parseMultipart} from 'parse-multipart-data'; +import { fetch, FormData, File } from 'node-fetch-native-with-agent'; import { createAgent } from 'node-fetch-native-with-agent/agent'; import { Models } from './models'; -import { Payload } from './payload'; -type Params = { +type Payload = { [key: string]: any; } @@ -35,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/14.1.0'; + let ua = 'AppwriteNodeJSSDK/14.2.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -84,7 +82,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '14.1.0', + 'x-sdk-version': '14.2.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.6.0', }; @@ -219,7 +217,7 @@ class Client { return this; } - prepareRequest(method: string, url: URL, headers: Headers = {}, params: Params = {}): { uri: string, options: RequestInit } { + prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); @@ -244,8 +242,8 @@ class Client { const formData = new FormData(); for (const [key, value] of Object.entries(params)) { - if (value instanceof Payload) { - formData.append(key, new Blob([value.toBinary()]), value.filename); + if (value instanceof File) { + formData.append(key, value, value.name); } else if (Array.isArray(value)) { for (const nestedValue of value) { formData.append(`${key}[]`, nestedValue); @@ -257,7 +255,6 @@ class Client { options.body = formData; delete headers['content-type']; - headers['accept'] = 'multipart/form-data'; break; } } @@ -265,18 +262,8 @@ class Client { return { uri: url.toString(), options }; } - async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Params = {}, onProgress: (progress: UploadProgress) => void) { - let file; - for (const value of Object.values(originalPayload)) { - if (value instanceof Payload) { - file = value; - break; - } - } - - if (!file) { - throw new Error('No payload found in params'); - } + async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { + const file = Object.values(originalPayload).find((value) => value instanceof File); if (file.size <= Client.CHUNK_SIZE) { return await this.call(method, url, headers, originalPayload); @@ -292,9 +279,9 @@ class Client { } headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`; - const chunk = file.toBinary(start, end - start); + const chunk = file.slice(start, end); - let payload = { ...originalPayload, file: new Payload(Buffer.from(chunk), file.filename)}; + let payload = { ...originalPayload, file: new File([chunk], file.name)}; response = await this.call(method, url, headers, payload); @@ -318,7 +305,11 @@ class Client { return response; } - async redirect(method: string, url: URL, headers: Headers = {}, params: Params = {}): Promise<string> { + async ping(): Promise<string> { + return this.call('GET', new URL(this.config.endpoint + '/ping')); + } + + async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<string> { const { uri, options } = this.prepareRequest(method, url, headers, params); const response = await fetch(uri, { @@ -333,7 +324,7 @@ class Client { return response.headers.get('location') || ''; } - async call(method: string, url: URL, headers: Headers = {}, params: Params = {}, responseType = 'json'): Promise<any> { + async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> { const { uri, options } = this.prepareRequest(method, url, headers, params); let data: any = null; @@ -349,35 +340,6 @@ class Client { data = await response.json(); } else if (responseType === 'arrayBuffer') { data = await response.arrayBuffer(); - } else if (response.headers.get('content-type')?.includes('multipart/form-data')) { - const body = await response.arrayBuffer(); - const boundary = getBoundary( - response.headers.get("content-type") || "" - ); - const parts = parseMultipart(Buffer.from(body), boundary); - const partsObject: { [key: string]: any } = {}; - - for (const part of parts) { - if (!part.name) { - continue; - } - if (part.name === "responseBody") { - partsObject[part.name] = Payload.fromBinary(part.data, part.filename); - } else if (part.name === "responseStatusCode") { - partsObject[part.name] = parseInt(part.data.toString()); - } else if (part.name === "duration") { - partsObject[part.name] = parseFloat(part.data.toString()); - } else if (part.type === 'application/json') { - try { - partsObject[part.name] = JSON.parse(part.data.toString()); - } catch (e) { - throw new Error(`Error parsing JSON for part ${part.name}: ${e instanceof Error ? e.message : 'Unknown error'}`); - } - } else { - partsObject[part.name] = part.data.toString(); - } - } - data = partsObject; } else { data = { message: await response.text() @@ -391,8 +353,8 @@ class Client { return data; } - static flatten(data: Params, prefix = ''): Params { - let output: Params = {}; + static flatten(data: Payload, prefix = ''): Payload { + let output: Payload = {}; for (const [key, value] of Object.entries(data)) { let finalKey = prefix ? prefix + '[' + key +']' : key; @@ -409,5 +371,5 @@ class Client { export { Client, AppwriteException }; export { Query } from './query'; -export type { Models, Params, UploadProgress }; +export type { Models, Payload, UploadProgress }; export type { QueryTypes, QueryTypesList } from './query'; diff --git a/src/enums/message-priority.ts b/src/enums/message-priority.ts new file mode 100644 index 0000000..f3113a8 --- /dev/null +++ b/src/enums/message-priority.ts @@ -0,0 +1,4 @@ +export enum MessagePriority { + Normal = 'normal', + High = 'high', +} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 658bb96..a4042bb 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -5,6 +5,7 @@ export enum Runtime { Node190 = 'node-19.0', Node200 = 'node-20.0', Node210 = 'node-21.0', + Node22 = 'node-22', Php80 = 'php-8.0', Php81 = 'php-8.1', Php82 = 'php-8.2', @@ -23,6 +24,8 @@ export enum Runtime { Deno124 = 'deno-1.24', Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', + Deno146 = 'deno-1.46', + Deno20 = 'deno-2.0', Dart215 = 'dart-2.15', Dart216 = 'dart-2.16', Dart217 = 'dart-2.17', @@ -30,22 +33,29 @@ export enum Runtime { Dart30 = 'dart-3.0', Dart31 = 'dart-3.1', Dart33 = 'dart-3.3', - Dotnet31 = 'dotnet-3.1', + Dart35 = 'dart-3.5', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', + Dotnet80 = 'dotnet-8.0', Java80 = 'java-8.0', Java110 = 'java-11.0', Java170 = 'java-17.0', Java180 = 'java-18.0', Java210 = 'java-21.0', + Java22 = 'java-22', Swift55 = 'swift-5.5', Swift58 = 'swift-5.8', Swift59 = 'swift-5.9', + Swift510 = 'swift-5.10', Kotlin16 = 'kotlin-1.6', Kotlin18 = 'kotlin-1.8', Kotlin19 = 'kotlin-1.9', + Kotlin20 = 'kotlin-2.0', Cpp17 = 'cpp-17', Cpp20 = 'cpp-20', Bun10 = 'bun-1.0', + Bun11 = 'bun-1.1', Go123 = 'go-1.23', + Static1 = 'static-1', + Flutter324 = 'flutter-3.24', } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 18f4151..bb34374 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,12 +10,11 @@ export { Messaging } from './services/messaging'; export { Storage } from './services/storage'; export { Teams } from './services/teams'; export { Users } from './services/users'; -export type { Models, Params, UploadProgress } from './client'; +export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; -export { Payload } from './payload'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; export { OAuthProvider } from './enums/o-auth-provider'; @@ -28,6 +27,7 @@ export { IndexType } from './enums/index-type'; export { Runtime } from './enums/runtime'; export { ExecutionMethod } from './enums/execution-method'; export { Name } from './enums/name'; +export { MessagePriority } from './enums/message-priority'; export { SmtpEncryption } from './enums/smtp-encryption'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; diff --git a/src/inputFile.ts b/src/inputFile.ts new file mode 100644 index 0000000..a30ea55 --- /dev/null +++ b/src/inputFile.ts @@ -0,0 +1,23 @@ +import { File } from "node-fetch-native-with-agent"; +import { realpathSync, readFileSync } from "fs"; +import type { BinaryLike } from "crypto"; + +export class InputFile { + static fromBuffer( + parts: Blob | BinaryLike, + name: string + ): File { + return new File([parts], name); + } + + static fromPath(path: string, name: string): File { + const realPath = realpathSync(path); + const contents = readFileSync(realPath); + return this.fromBuffer(contents, name); + } + + static fromPlainText(content: string, name: string): File { + const arrayBytes = new TextEncoder().encode(content); + return this.fromBuffer(arrayBytes, name); + } +} diff --git a/src/models.ts b/src/models.ts index 35fb1a2..93edb69 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,5 +1,3 @@ -import type { Payload } from './payload'; - /** * Appwrite Models */ @@ -1686,11 +1684,11 @@ export namespace Models { */ userId: string; /** - * User name. + * User name. Hide this attribute by toggling membership privacy in the Console. */ userName: string; /** - * User email address. + * User email address. Hide this attribute by toggling membership privacy in the Console. */ userEmail: string; /** @@ -1714,7 +1712,7 @@ export namespace Models { */ confirm: boolean; /** - * Multi factor authentication status, true if the user has MFA enabled or false otherwise. + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. */ mfa: boolean; /** @@ -1779,7 +1777,7 @@ export namespace Models { */ events: string[]; /** - * Function execution schedult in CRON format. + * Function execution schedule in CRON format. */ schedule: string; /** @@ -2012,7 +2010,7 @@ export namespace Models { /** * HTTP response body. This will return empty unless execution is created as synchronous. */ - responseBody: Payload; + responseBody: string; /** * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ @@ -2596,5 +2594,9 @@ export namespace Models { * The target identifier. */ identifier: string; + /** + * Is the target expired. + */ + expired: boolean; } } diff --git a/src/payload.ts b/src/payload.ts deleted file mode 100644 index 1bb8858..0000000 --- a/src/payload.ts +++ /dev/null @@ -1,43 +0,0 @@ -export class Payload { - private data: Buffer; - public filename?: string; - public size: number; - - constructor(data: Buffer, filename?: string) { - this.data = data; - this.filename = filename; - this.size = data.byteLength; - } - - public toBinary(offset: number = 0, length?: number): Buffer { - if (offset === 0 && length === undefined) { - return this.data; - } else if (length === undefined) { - return this.data.subarray(offset); - } else { - return this.data.subarray(offset, offset + length); - } - } - - public toJson<T = unknown>(): T { - return JSON.parse(this.toString()); - } - - public toString(): string { - return this.data.toString("utf-8"); - } - - public static fromBinary(bytes: Buffer, filename?: string): Payload { - return new Payload(bytes, filename); - } - - public static fromJson(object: any, filename?: string): Payload { - const data = Buffer.from(JSON.stringify(object), "utf-8"); - return new Payload(data, filename); - } - - public static fromString(text: string, filename?: string): Payload { - const data = Buffer.from(text, "utf-8"); - return new Payload(data, filename); - } -} diff --git a/src/services/account.ts b/src/services/account.ts index 0655fd7..51c11c3 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; @@ -22,7 +21,7 @@ export class Account { */ async get<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> { const apiPath = '/account'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -59,7 +58,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -105,7 +104,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/email'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -136,7 +135,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async listIdentities(queries?: string[]): Promise<Models.IdentityList> { const apiPath = '/account/identities'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -167,7 +166,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "identityId"'); } const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -191,7 +190,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async createJWT(): Promise<Models.Jwt> { const apiPath = '/account/jwts'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -216,7 +215,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async listLogs(queries?: string[]): Promise<Models.LogList> { const apiPath = '/account/logs'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -247,7 +246,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "mfa"'); } const apiPath = '/account/mfa'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof mfa !== 'undefined') { payload['mfa'] = mfa; } @@ -278,7 +277,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -310,7 +309,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "otp"'); } const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Params = {}; + const payload: Payload = {}; if (typeof otp !== 'undefined') { payload['otp'] = otp; } @@ -341,7 +340,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -369,7 +368,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "factor"'); } const apiPath = '/account/mfa/challenge'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof factor !== 'undefined') { payload['factor'] = factor; } @@ -404,7 +403,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "otp"'); } const apiPath = '/account/mfa/challenge'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof challengeId !== 'undefined') { payload['challengeId'] = challengeId; } @@ -434,7 +433,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async listMfaFactors(): Promise<Models.MfaFactors> { const apiPath = '/account/mfa/factors'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -458,7 +457,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async getMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { const apiPath = '/account/mfa/recovery-codes'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -482,7 +481,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async createMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { const apiPath = '/account/mfa/recovery-codes'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -506,7 +505,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async updateMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { const apiPath = '/account/mfa/recovery-codes'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -534,7 +533,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/account/name'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -566,7 +565,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/password'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof password !== 'undefined') { payload['password'] = password; } @@ -604,7 +603,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/phone'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof phone !== 'undefined') { payload['phone'] = phone; } @@ -634,7 +633,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, */ async getPrefs<Preferences extends Models.Preferences>(): Promise<Preferences> { const apiPath = '/account/prefs'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -662,7 +661,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "prefs"'); } const apiPath = '/account/prefs'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; } @@ -697,7 +696,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/account/recovery'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -741,7 +740,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/recovery'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -774,7 +773,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async listSessions(): Promise<Models.SessionList> { const apiPath = '/account/sessions'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -798,7 +797,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async deleteSessions(): Promise<{}> { const apiPath = '/account/sessions'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -822,7 +821,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async createAnonymousSession(): Promise<Models.Session> { const apiPath = '/account/sessions/anonymous'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -856,7 +855,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/account/sessions/email'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -894,7 +893,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/sessions/magic-url'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -932,7 +931,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/sessions/phone'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -970,7 +969,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/sessions/token'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1004,7 +1003,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1032,7 +1031,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1060,7 +1059,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1084,7 +1083,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about */ async updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> { const apiPath = '/account/status'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1119,7 +1118,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "email"'); } const apiPath = '/account/tokens/email'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1145,7 +1144,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about /** * Create magic URL token * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to 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 link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to 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 link sent to the user's email address is valid for 1 hour. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). @@ -1165,7 +1164,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "email"'); } const apiPath = '/account/tokens/magic-url'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1212,7 +1211,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "provider"'); } const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider); - const payload: Params = {}; + const payload: Payload = {}; if (typeof success !== 'undefined') { payload['success'] = success; } @@ -1255,7 +1254,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about throw new AppwriteException('Missing required parameter: "phone"'); } const apiPath = '/account/tokens/phone'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1292,7 +1291,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/account/verification'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof url !== 'undefined') { payload['url'] = url; } @@ -1327,7 +1326,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/verification'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -1357,7 +1356,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ */ async createPhoneVerification(): Promise<Models.Token> { const apiPath = '/account/verification/phone'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1389,7 +1388,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/account/verification/phone'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } diff --git a/src/services/avatars.ts b/src/services/avatars.ts index e38829f..3111f49 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; @@ -31,7 +30,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "code"'); } const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); - const payload: Params = {}; + const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -75,7 +74,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "code"'); } const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); - const payload: Params = {}; + const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -115,7 +114,7 @@ This endpoint does not follow HTTP redirects. throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/avatars/favicon'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof url !== 'undefined') { payload['url'] = url; } @@ -153,7 +152,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "code"'); } const apiPath = '/avatars/flags/{code}'.replace('{code}', code); - const payload: Params = {}; + const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -197,7 +196,7 @@ This endpoint does not follow HTTP redirects. throw new AppwriteException('Missing required parameter: "url"'); } const apiPath = '/avatars/image'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof url !== 'undefined') { payload['url'] = url; } @@ -240,7 +239,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre */ async getInitials(name?: string, width?: number, height?: number, background?: string): Promise<ArrayBuffer> { const apiPath = '/avatars/initials'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -285,7 +284,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre throw new AppwriteException('Missing required parameter: "text"'); } const apiPath = '/avatars/qr'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof text !== 'undefined') { payload['text'] = text; } diff --git a/src/services/databases.ts b/src/services/databases.ts index 7070a0c..c200f04 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; @@ -24,7 +23,7 @@ export class Databases { */ async list(queries?: string[], search?: string): Promise<Models.DatabaseList> { const apiPath = '/databases'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -64,7 +63,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof databaseId !== 'undefined') { payload['databaseId'] = databaseId; } @@ -101,7 +100,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "databaseId"'); } const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -134,7 +133,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -168,7 +167,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "databaseId"'); } const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -198,7 +197,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "databaseId"'); } const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -243,7 +242,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof collectionId !== 'undefined') { payload['collectionId'] = collectionId; } @@ -290,7 +289,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -329,7 +328,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -373,7 +372,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -406,7 +405,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -452,7 +451,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -509,7 +508,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -560,7 +559,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -617,7 +616,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -669,7 +668,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -727,7 +726,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -783,7 +782,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -848,7 +847,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof elements !== 'undefined') { payload['elements'] = elements; } @@ -905,7 +904,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -977,7 +976,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1037,7 +1036,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1109,7 +1108,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1167,7 +1166,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1225,7 +1224,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1279,7 +1278,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof relatedCollectionId !== 'undefined') { payload['relatedCollectionId'] = relatedCollectionId; } @@ -1345,7 +1344,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1410,7 +1409,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1465,7 +1464,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "required"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1523,7 +1522,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "xdefault"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof required !== 'undefined') { payload['required'] = required; } @@ -1568,7 +1567,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1604,7 +1603,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1643,7 +1642,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; if (typeof onDelete !== 'undefined') { payload['onDelete'] = onDelete; } @@ -1682,7 +1681,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1726,7 +1725,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "data"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof documentId !== 'undefined') { payload['documentId'] = documentId; } @@ -1772,7 +1771,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "documentId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1813,7 +1812,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "documentId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof data !== 'undefined') { payload['data'] = data; } @@ -1855,7 +1854,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "documentId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1888,7 +1887,7 @@ export class Databases { throw new AppwriteException('Missing required parameter: "collectionId"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1937,7 +1936,7 @@ Attributes can be `key`, `fulltext`, and `unique`. throw new AppwriteException('Missing required parameter: "attributes"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1985,7 +1984,7 @@ Attributes can be `key`, `fulltext`, and `unique`. throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2021,7 +2020,7 @@ Attributes can be `key`, `fulltext`, and `unique`. throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/functions.ts b/src/services/functions.ts index 345d1c2..f78e272 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { Runtime } from '../enums/runtime'; import { ExecutionMethod } from '../enums/execution-method'; @@ -23,7 +22,7 @@ export class Functions { */ async list(queries?: string[], search?: string): Promise<Models.FunctionList> { const apiPath = '/functions'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -84,7 +83,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "runtime"'); } const apiPath = '/functions'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof functionId !== 'undefined') { payload['functionId'] = functionId; } @@ -174,7 +173,7 @@ export class Functions { */ async listRuntimes(): Promise<Models.RuntimeList> { const apiPath = '/functions/runtimes'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -199,7 +198,7 @@ export class Functions { */ async listSpecifications(): Promise<Models.SpecificationList> { const apiPath = '/functions/specifications'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -227,7 +226,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -275,7 +274,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -354,7 +353,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -384,7 +383,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -414,14 +413,14 @@ This endpoint accepts a tar.gz file compressed with your code. Make sure to incl Use the "command" param to set the entrypoint used to execute your code. * * @param {string} functionId - * @param {Payload} code + * @param {File} code * @param {boolean} activate * @param {string} entrypoint * @param {string} commands * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - async createDeployment(functionId: string, code: Payload, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> { + async createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -432,7 +431,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "activate"'); } const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof entrypoint !== 'undefined') { payload['entrypoint'] = entrypoint; } @@ -477,7 +476,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -509,7 +508,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -541,7 +540,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -573,7 +572,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}/build'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof buildId !== 'undefined') { payload['buildId'] = buildId; } @@ -607,7 +606,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}/build'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -639,7 +638,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "deploymentId"'); } const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -670,7 +669,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -696,7 +695,7 @@ Use the "command" param to set the entrypoint used to execute your cod * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * * @param {string} functionId - * @param {Payload} body + * @param {string} body * @param {boolean} async * @param {string} xpath * @param {ExecutionMethod} method @@ -705,14 +704,14 @@ Use the "command" param to set the entrypoint used to execute your cod * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ - async createExecution(functionId: string, body?: Payload, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Execution> { + async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution> { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof body !== 'undefined') { - payload['body'] = body.toBinary(); + payload['body'] = body; } if (typeof async !== 'undefined') { payload['async'] = async; @@ -732,7 +731,7 @@ Use the "command" param to set the entrypoint used to execute your cod const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'multipart/form-data', + 'content-type': 'application/json', } return await this.client.call( @@ -760,7 +759,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "executionId"'); } const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -793,7 +792,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "executionId"'); } const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -821,7 +820,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "functionId"'); } const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -857,7 +856,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "value"'); } const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -895,7 +894,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "variableId"'); } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -932,7 +931,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "key"'); } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof key !== 'undefined') { payload['key'] = key; } @@ -970,7 +969,7 @@ Use the "command" param to set the entrypoint used to execute your cod throw new AppwriteException('Missing required parameter: "variableId"'); } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/graphql.ts b/src/services/graphql.ts index a6a78eb..ca0219d 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; export class Graphql { @@ -23,7 +22,7 @@ export class Graphql { throw new AppwriteException('Missing required parameter: "query"'); } const apiPath = '/graphql'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof query !== 'undefined') { payload['query'] = query; } @@ -55,7 +54,7 @@ export class Graphql { throw new AppwriteException('Missing required parameter: "query"'); } const apiPath = '/graphql/mutation'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof query !== 'undefined') { payload['query'] = query; } diff --git a/src/services/health.ts b/src/services/health.ts index b7fa907..ef4e6d1 100644 --- a/src/services/health.ts +++ b/src/services/health.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { Name } from '../enums/name'; @@ -20,7 +19,7 @@ export class Health { */ async get(): Promise<Models.HealthStatus> { const apiPath = '/health'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -44,7 +43,7 @@ export class Health { */ async getAntivirus(): Promise<Models.HealthAntivirus> { const apiPath = '/health/anti-virus'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -68,7 +67,7 @@ export class Health { */ async getCache(): Promise<Models.HealthStatus> { const apiPath = '/health/cache'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -93,7 +92,7 @@ export class Health { */ async getCertificate(domain?: string): Promise<Models.HealthCertificate> { const apiPath = '/health/certificate'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof domain !== 'undefined') { payload['domain'] = domain; } @@ -120,7 +119,7 @@ export class Health { */ async getDB(): Promise<Models.HealthStatus> { const apiPath = '/health/db'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -144,7 +143,7 @@ export class Health { */ async getPubSub(): Promise<Models.HealthStatus> { const apiPath = '/health/pubsub'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -168,7 +167,7 @@ export class Health { */ async getQueue(): Promise<Models.HealthStatus> { const apiPath = '/health/queue'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -193,7 +192,7 @@ export class Health { */ async getQueueBuilds(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/builds'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -221,7 +220,7 @@ export class Health { */ async getQueueCertificates(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/certificates'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -250,7 +249,7 @@ export class Health { */ async getQueueDatabases(name?: string, threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/databases'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -281,7 +280,7 @@ export class Health { */ async getQueueDeletes(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/deletes'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -314,7 +313,7 @@ export class Health { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/health/queue/failed/{name}'.replace('{name}', name); - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -342,7 +341,7 @@ export class Health { */ async getQueueFunctions(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/functions'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -370,7 +369,7 @@ export class Health { */ async getQueueLogs(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/logs'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -398,7 +397,7 @@ export class Health { */ async getQueueMails(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/mails'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -426,7 +425,7 @@ export class Health { */ async getQueueMessaging(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/messaging'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -454,7 +453,7 @@ export class Health { */ async getQueueMigrations(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/migrations'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -482,7 +481,7 @@ export class Health { */ async getQueueUsage(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/usage'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -510,7 +509,7 @@ export class Health { */ async getQueueUsageDump(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/usage-dump'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -538,7 +537,7 @@ export class Health { */ async getQueueWebhooks(threshold?: number): Promise<Models.HealthQueue> { const apiPath = '/health/queue/webhooks'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof threshold !== 'undefined') { payload['threshold'] = threshold; } @@ -565,7 +564,7 @@ export class Health { */ async getStorage(): Promise<Models.HealthStatus> { const apiPath = '/health/storage'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -589,7 +588,7 @@ export class Health { */ async getStorageLocal(): Promise<Models.HealthStatus> { const apiPath = '/health/storage/local'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -613,7 +612,7 @@ export class Health { */ async getTime(): Promise<Models.HealthTime> { const apiPath = '/health/time'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/locale.ts b/src/services/locale.ts index 81b43aa..c59818d 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; export class Locale { @@ -21,7 +20,7 @@ export class Locale { */ async get(): Promise<Models.Locale> { const apiPath = '/locale'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -45,7 +44,7 @@ export class Locale { */ async listCodes(): Promise<Models.LocaleCodeList> { const apiPath = '/locale/codes'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -69,7 +68,7 @@ export class Locale { */ async listContinents(): Promise<Models.ContinentList> { const apiPath = '/locale/continents'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -93,7 +92,7 @@ export class Locale { */ async listCountries(): Promise<Models.CountryList> { const apiPath = '/locale/countries'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -117,7 +116,7 @@ export class Locale { */ async listCountriesEU(): Promise<Models.CountryList> { const apiPath = '/locale/countries/eu'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -141,7 +140,7 @@ export class Locale { */ async listCountriesPhones(): Promise<Models.PhoneList> { const apiPath = '/locale/countries/phones'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -165,7 +164,7 @@ export class Locale { */ async listCurrencies(): Promise<Models.CurrencyList> { const apiPath = '/locale/currencies'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -189,7 +188,7 @@ export class Locale { */ async listLanguages(): Promise<Models.LanguageList> { const apiPath = '/locale/languages'; - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 4c634cd..ed15db2 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,6 +1,6 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { MessagePriority } from '../enums/message-priority'; import { SmtpEncryption } from '../enums/smtp-encryption'; export class Messaging { @@ -22,7 +22,7 @@ export class Messaging { */ async listMessages(queries?: string[], search?: string): Promise<Models.MessageList> { const apiPath = '/messaging/messages'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -73,7 +73,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "content"'); } const apiPath = '/messaging/messages/email'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof messageId !== 'undefined') { payload['messageId'] = messageId; } @@ -149,7 +149,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; } @@ -214,24 +214,21 @@ export class Messaging { * @param {string} sound * @param {string} color * @param {string} tag - * @param {string} badge + * @param {number} badge * @param {boolean} draft * @param {string} scheduledAt + * @param {boolean} contentAvailable + * @param {boolean} critical + * @param {MessagePriority} priority * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ - async createPush(messageId: string, title: string, body: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message> { + async createPush(messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message> { if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } - if (typeof title === 'undefined') { - throw new AppwriteException('Missing required parameter: "title"'); - } - if (typeof body === 'undefined') { - throw new AppwriteException('Missing required parameter: "body"'); - } const apiPath = '/messaging/messages/push'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof messageId !== 'undefined') { payload['messageId'] = messageId; } @@ -280,6 +277,15 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { payload['scheduledAt'] = scheduledAt; } + if (typeof contentAvailable !== 'undefined') { + payload['contentAvailable'] = contentAvailable; + } + if (typeof critical !== 'undefined') { + payload['critical'] = critical; + } + if (typeof priority !== 'undefined') { + payload['priority'] = priority; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -315,15 +321,18 @@ export class Messaging { * @param {number} badge * @param {boolean} draft * @param {string} scheduledAt + * @param {boolean} contentAvailable + * @param {boolean} critical + * @param {MessagePriority} priority * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ - async updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string): Promise<Models.Message> { + async updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message> { if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; } @@ -369,6 +378,15 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { payload['scheduledAt'] = scheduledAt; } + if (typeof contentAvailable !== 'undefined') { + payload['contentAvailable'] = contentAvailable; + } + if (typeof critical !== 'undefined') { + payload['critical'] = critical; + } + if (typeof priority !== 'undefined') { + payload['priority'] = priority; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -405,7 +423,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "content"'); } const apiPath = '/messaging/messages/sms'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof messageId !== 'undefined') { payload['messageId'] = messageId; } @@ -461,7 +479,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof topics !== 'undefined') { payload['topics'] = topics; } @@ -508,7 +526,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -536,7 +554,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -565,7 +583,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}/logs'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -597,7 +615,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "messageId"'); } const apiPath = '/messaging/messages/{messageId}/targets'.replace('{messageId}', messageId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -626,7 +644,7 @@ export class Messaging { */ async listProviders(queries?: string[], search?: string): Promise<Models.ProviderList> { const apiPath = '/messaging/providers'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -670,7 +688,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/apns'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -729,7 +747,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -784,7 +802,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/fcm'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -827,7 +845,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -876,7 +894,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/mailgun'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -943,7 +961,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/mailgun/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1006,7 +1024,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/msg91'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1057,7 +1075,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1110,7 +1128,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/sendgrid'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1169,7 +1187,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1237,7 +1255,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "host"'); } const apiPath = '/messaging/providers/smtp'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1320,7 +1338,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1395,7 +1413,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/telesign'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1446,7 +1464,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/telesign/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1497,7 +1515,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/textmagic'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1548,7 +1566,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/textmagic/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1599,7 +1617,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/twilio'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1650,7 +1668,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/twilio/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1701,7 +1719,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/providers/vonage'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; } @@ -1752,7 +1770,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/vonage/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1796,7 +1814,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1824,7 +1842,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1853,7 +1871,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "providerId"'); } const apiPath = '/messaging/providers/{providerId}/logs'.replace('{providerId}', providerId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1885,7 +1903,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/subscribers/{subscriberId}/logs'.replace('{subscriberId}', subscriberId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1914,7 +1932,7 @@ export class Messaging { */ async listTopics(queries?: string[], search?: string): Promise<Models.TopicList> { const apiPath = '/messaging/topics'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1953,7 +1971,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/messaging/topics'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof topicId !== 'undefined') { payload['topicId'] = topicId; } @@ -1991,7 +2009,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2022,7 +2040,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -2056,7 +2074,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2085,7 +2103,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}/logs'.replace('{topicId}', topicId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -2118,7 +2136,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "topicId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -2160,7 +2178,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof subscriberId !== 'undefined') { payload['subscriberId'] = subscriberId; } @@ -2199,7 +2217,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2231,7 +2249,7 @@ export class Messaging { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/storage.ts b/src/services/storage.ts index 566e0df..923dda4 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; @@ -24,7 +23,7 @@ export class Storage { */ async listBuckets(queries?: string[], search?: string): Promise<Models.BucketList> { const apiPath = '/storage/buckets'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -70,7 +69,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/storage/buckets'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof bucketId !== 'undefined') { payload['bucketId'] = bucketId; } @@ -128,7 +127,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "bucketId"'); } const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -168,7 +167,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -223,7 +222,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "bucketId"'); } const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -253,7 +252,7 @@ export class Storage { throw new AppwriteException('Missing required parameter: "bucketId"'); } const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -287,12 +286,12 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk * * @param {string} bucketId * @param {string} fileId - * @param {Payload} file + * @param {File} file * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise<Models.File>} */ - async createFile(bucketId: string, fileId: string, file: Payload, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> { + async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -303,7 +302,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "file"'); } const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof fileId !== 'undefined') { payload['fileId'] = fileId; } @@ -345,7 +344,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -379,7 +378,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -417,7 +416,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -449,7 +448,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -493,7 +492,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof width !== 'undefined') { payload['width'] = width; } @@ -559,7 +558,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk throw new AppwriteException('Missing required parameter: "fileId"'); } const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/teams.ts b/src/services/teams.ts index 2ba96c9..3911e30 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; export class Teams { @@ -21,7 +20,7 @@ export class Teams { */ async list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.TeamList<Preferences>> { const apiPath = '/teams'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -60,7 +59,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/teams'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof teamId !== 'undefined') { payload['teamId'] = teamId; } @@ -97,7 +96,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -129,7 +128,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -160,7 +159,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -177,7 +176,7 @@ export class Teams { /** * List team memberships * - * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. + * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @param {string} teamId * @param {string[]} queries @@ -190,7 +189,7 @@ export class Teams { throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -240,7 +239,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "roles"'); } const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -275,7 +274,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee /** * Get team membership * - * Get a team member by the membership unique id. All team members have read access for this resource. + * Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @param {string} teamId * @param {string} membershipId @@ -290,7 +289,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "membershipId"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -327,7 +326,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "roles"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof roles !== 'undefined') { payload['roles'] = roles; } @@ -362,7 +361,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee throw new AppwriteException('Missing required parameter: "membershipId"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -405,7 +404,7 @@ If the request is successful, a session for the user is automatically created. throw new AppwriteException('Missing required parameter: "secret"'); } const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -439,7 +438,7 @@ If the request is successful, a session for the user is automatically created. throw new AppwriteException('Missing required parameter: "teamId"'); } const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -471,7 +470,7 @@ If the request is successful, a session for the user is automatically created. throw new AppwriteException('Missing required parameter: "prefs"'); } const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; } diff --git a/src/services/users.ts b/src/services/users.ts index 2d06ac5..7efc333 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,5 +1,4 @@ -import { AppwriteException, Client, type Params, UploadProgress } from '../client'; -import { Payload } from '../payload'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -24,7 +23,7 @@ export class Users { */ async list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.UserList<Preferences>> { const apiPath = '/users'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -62,7 +61,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -114,7 +113,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/argon2'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -163,7 +162,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/bcrypt'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -201,7 +200,7 @@ export class Users { */ async listIdentities(queries?: string[], search?: string): Promise<Models.IdentityList> { const apiPath = '/users/identities'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -235,7 +234,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "identityId"'); } const apiPath = '/users/identities/{identityId}'.replace('{identityId}', identityId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -272,7 +271,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/md5'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -321,7 +320,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/phpass'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -390,7 +389,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "passwordLength"'); } const apiPath = '/users/scrypt'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -466,7 +465,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); } const apiPath = '/users/scrypt-modified'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -525,7 +524,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/sha'; - const payload: Params = {}; + const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } @@ -568,7 +567,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -596,7 +595,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -628,7 +627,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } const apiPath = '/users/{userId}/email'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof email !== 'undefined') { payload['email'] = email; } @@ -661,7 +660,7 @@ export class Users { throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/jwts'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof sessionId !== 'undefined') { payload['sessionId'] = sessionId; } @@ -701,7 +700,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "labels"'); } const apiPath = '/users/{userId}/labels'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof labels !== 'undefined') { payload['labels'] = labels; } @@ -733,7 +732,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/logs'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -764,7 +763,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/memberships'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -796,7 +795,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "mfa"'); } const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof mfa !== 'undefined') { payload['mfa'] = mfa; } @@ -831,7 +830,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "type"'); } const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -859,7 +858,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -887,7 +886,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -915,7 +914,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -943,7 +942,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -975,7 +974,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "name"'); } const apiPath = '/users/{userId}/name'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1010,7 +1009,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "password"'); } const apiPath = '/users/{userId}/password'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof password !== 'undefined') { payload['password'] = password; } @@ -1045,7 +1044,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "number"'); } const apiPath = '/users/{userId}/phone'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof number !== 'undefined') { payload['number'] = number; } @@ -1076,7 +1075,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1108,7 +1107,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "prefs"'); } const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof prefs !== 'undefined') { payload['prefs'] = prefs; } @@ -1139,7 +1138,7 @@ Labels can be used to grant access to resources. While teams are a way for user& throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1169,7 +1168,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1197,7 +1196,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1229,7 +1228,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "sessionId"'); } const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1261,7 +1260,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "status"'); } const apiPath = '/users/{userId}/status'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof status !== 'undefined') { payload['status'] = status; } @@ -1293,7 +1292,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } @@ -1338,7 +1337,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "identifier"'); } const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof targetId !== 'undefined') { payload['targetId'] = targetId; } @@ -1385,7 +1384,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1420,7 +1419,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof identifier !== 'undefined') { payload['identifier'] = identifier; } @@ -1461,7 +1460,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); - const payload: Params = {}; + const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1492,7 +1491,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "userId"'); } const apiPath = '/users/{userId}/tokens'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof length !== 'undefined') { payload['length'] = length; } @@ -1530,7 +1529,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "emailVerification"'); } const apiPath = '/users/{userId}/verification'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof emailVerification !== 'undefined') { payload['emailVerification'] = emailVerification; } @@ -1565,7 +1564,7 @@ If you want to generate a token for a custom authentication flow, use the [POST throw new AppwriteException('Missing required parameter: "phoneVerification"'); } const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', userId); - const payload: Params = {}; + const payload: Payload = {}; if (typeof phoneVerification !== 'undefined') { payload['phoneVerification'] = phoneVerification; } From 8e8a243af57e1f5105c2167a20e6d85b0151b3e3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 28 Jan 2025 18:29:28 +0000 Subject: [PATCH 5/6] fix: pong response & chunked upload --- LICENSE | 2 +- package.json | 2 +- src/client.ts | 4 ++-- src/enums/image-format.ts | 1 + src/services/account.ts | 4 ++-- src/services/functions.ts | 2 ++ src/services/messaging.ts | 2 +- src/services/users.ts | 4 ++-- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 5479bb8..c1602fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/package.json b/package.json index 84975d6..590ba3a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "14.2.0", + "version": "14.2.1", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index ff7673d..3870639 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/14.2.0'; + let ua = 'AppwriteNodeJSSDK/14.2.1'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +82,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '14.2.0', + 'x-sdk-version': '14.2.1', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.6.0', }; diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index 8599e30..bcbe3e9 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -4,5 +4,6 @@ export enum ImageFormat { Gif = 'gif', Png = 'png', Webp = 'webp', + Heic = 'heic', Avif = 'avif', } \ No newline at end of file diff --git a/src/services/account.ts b/src/services/account.ts index 51c11c3..1f45cc9 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -393,9 +393,9 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @param {string} challengeId * @param {string} otp * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise<Models.Session>} */ - async updateMfaChallenge(challengeId: string, otp: string): Promise<{}> { + async updateMfaChallenge(challengeId: string, otp: string): Promise<Models.Session> { if (typeof challengeId === 'undefined') { throw new AppwriteException('Missing required parameter: "challengeId"'); } diff --git a/src/services/functions.ts b/src/services/functions.ts index f78e272..7c49eaa 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -557,6 +557,7 @@ Use the "command" param to set the entrypoint used to execute your cod /** * Rebuild deployment * + * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * * @param {string} functionId * @param {string} deploymentId @@ -592,6 +593,7 @@ Use the "command" param to set the entrypoint used to execute your cod /** * Cancel deployment * + * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * * @param {string} functionId * @param {string} deploymentId diff --git a/src/services/messaging.ts b/src/services/messaging.ts index ed15db2..e076318 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -461,7 +461,7 @@ export class Messaging { /** * Update SMS * - * Update an email message by its unique ID. + * Update an SMS message by its unique ID. * * @param {string} messageId diff --git a/src/services/users.ts b/src/services/users.ts index 7efc333..f47662f 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -820,9 +820,9 @@ Labels can be used to grant access to resources. While teams are a way for user& * @param {string} userId * @param {AuthenticatorType} type * @throws {AppwriteException} - * @returns {Promise<Models.User<Preferences>>} + * @returns {Promise<{}>} */ - async deleteMfaAuthenticator<Preferences extends Models.Preferences>(userId: string, type: AuthenticatorType): Promise<Models.User<Preferences>> { + async deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<{}> { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } From 47d120927767c3827cd509a0f371b854cc08d958 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:03:43 +0000 Subject: [PATCH 6/6] chore: bump versions --- package.json | 2 +- src/client.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 590ba3a..beac70a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "14.2.1", + "version": "15.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 3870639..902ae7b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/14.2.1'; + let ua = 'AppwriteNodeJSSDK/15.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +82,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '14.2.1', + 'x-sdk-version': '15.0.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.6.0', };