diff --git a/.travis.yml b/.travis.yml index aae2399..564159b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: jobs: include: - stage: NPM RC Release - if: tag == *-rc* + if: tag =~ /-(rc|RC)/ node_js: "14.16" script: - npm install @@ -17,7 +17,7 @@ jobs: api_key: $NPM_API_KEY tag: next - stage: NPM Release - if: tag != *-rc* + if: not tag =~ /-(rc|RC)/ node_js: "14.16" script: - npm install diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 443912f..ea9ff13 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -17,7 +17,8 @@ const result = await messaging.updateEmail( false, // html (optional) [], // cc (optional) [], // bcc (optional) - '' // scheduledAt (optional) + '', // scheduledAt (optional) + [] // attachments (optional) ); console.log(response); diff --git a/package.json b/package.json index 09cde5d..4be9921 100644 --- a/package.json +++ b/package.json @@ -32,10 +32,6 @@ "tslib": "2.4.0", "typescript": "4.7.2" }, - "dependencies": { - "cross-fetch": "3.1.5", - "isomorphic-form-data": "2.0.0" - }, "jsdelivr": "dist/iife/sdk.js", "unpkg": "dist/iife/sdk.js" } diff --git a/rollup.config.js b/rollup.config.js index a9c3354..cae7a89 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,7 +2,7 @@ import pkg from "./package.json"; import typescript from "@rollup/plugin-typescript"; export default { - external: Object.keys(pkg.dependencies), + external: Object.keys(pkg.dependencies ?? {}), input: "src/index.ts", plugins: [typescript()], output: [ @@ -22,10 +22,6 @@ export default { file: pkg.jsdelivr, name: "Appwrite", extend: true, - globals: { - "cross-fetch": "window", - "FormData": "FormData", - }, }, ], }; diff --git a/src/client.ts b/src/client.ts index 29d5733..ff40e38 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,5 +1,3 @@ -import 'isomorphic-form-data'; -import { fetch } from 'cross-fetch'; import { Models } from './models'; import { Service } from './service'; @@ -238,7 +236,11 @@ class Client { } }, createSocket: () => { - if (this.realtime.channels.size < 1) return; + if (this.realtime.channels.size < 1) { + this.realtime.reconnect = false; + this.realtime.socket?.close(); + return; + } const channels = new URLSearchParams(); channels.set('project', this.config.project); @@ -401,7 +403,10 @@ class Client { }; if (typeof window !== 'undefined' && window.localStorage) { - headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback') ?? ''; + const cookieFallback = window.localStorage.getItem('cookieFallback'); + if (cookieFallback) { + headers['X-Fallback-Cookies'] = cookieFallback; + } } if (method === 'GET') { diff --git a/src/enums/flag.ts b/src/enums/flag.ts index 07416a4..7e1d878 100644 --- a/src/enums/flag.ts +++ b/src/enums/flag.ts @@ -140,6 +140,7 @@ export enum Flag { Palau = 'pw', PapuaNewGuinea = 'pg', Poland = 'pl', + FrenchPolynesia = 'pf', NorthKorea = 'kp', Portugal = 'pt', Paraguay = 'py', diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 160c2b5..013ba5e 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -18,6 +18,10 @@ export enum Runtime { Python310 = 'python-3.10', 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/models.ts b/src/models.ts index 78f6830..144dd73 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1320,6 +1320,10 @@ export namespace Models { * Session creation date in ISO 8601 format. */ $createdAt: string; + /** + * Session update date in ISO 8601 format. + */ + $updatedAt: string; /** * User ID. */ @@ -3266,17 +3270,21 @@ export namespace Models { */ export type MfaFactors = { /** - * TOTP + * Can TOTP be used for MFA challenge for this account. */ totp: boolean; /** - * Phone + * Can phone (SMS) be used for MFA challenge for this account. */ phone: boolean; /** - * Email + * Can email be used for MFA challenge for this account. */ email: boolean; + /** + * Can recovery code be used for MFA challenge for this account. + */ + recoveryCode: boolean; } /** * Provider diff --git a/src/services/account.ts b/src/services/account.ts index bf84958..3cc5b41 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -272,7 +272,7 @@ export class Account extends Service { * * Add an authenticator app to be used as an MFA factor. Verify the * authenticator using the [verify - * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) + * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) * method. * * @param {AuthenticatorType} type @@ -297,8 +297,8 @@ export class Account extends Service { * Verify Authenticator * * Verify an authenticator app after adding it using the [add - * authenticator](/docs/references/cloud/client-web/account#addAuthenticator) - * method. + * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + * method. add * * @param {AuthenticatorType} type * @param {string} otp @@ -337,7 +337,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { + async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}> { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 36bcf4d..2814654 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -146,10 +146,11 @@ export class Messaging extends Service { * @param {string[]} cc * @param {string[]} bcc * @param {string} scheduledAt + * @param {string[]} attachments * @throws {AppwriteException} * @returns {Promise} */ - async updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string): Promise { + async updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise { if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } @@ -197,6 +198,10 @@ export class Messaging extends Service { payload['scheduledAt'] = scheduledAt; } + if (typeof attachments !== 'undefined') { + payload['attachments'] = attachments; + } + const uri = new URL(this.client.config.endpoint + apiPath); return await this.client.call('patch', uri, { 'content-type': 'application/json',