Skip to content

Commit

Permalink
chore: release console SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed May 15, 2024
1 parent 3067bb4 commit cf96109
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/messaging/update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 1 addition & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -22,10 +22,6 @@ export default {
file: pkg.jsdelivr,
name: "Appwrite",
extend: true,
globals: {
"cross-fetch": "window",
"FormData": "FormData",
},
},
],
};
13 changes: 9 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'isomorphic-form-data';
import { fetch } from 'cross-fetch';
import { Models } from './models';
import { Service } from './service';

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions src/enums/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export enum Flag {
Palau = 'pw',
PapuaNewGuinea = 'pg',
Poland = 'pl',
FrenchPolynesia = 'pf',
NorthKorea = 'kp',
Portugal = 'pt',
Paraguay = 'py',
Expand Down
4 changes: 4 additions & 0 deletions src/enums/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 11 additions & 3 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -337,7 +337,7 @@ export class Account extends Service {
* @throws {AppwriteException}
* @returns {Promise}
*/
async deleteMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> {
async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}> {
if (typeof type === 'undefined') {
throw new AppwriteException('Missing required parameter: "type"');
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Models.Message> {
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<Models.Message> {
if (typeof messageId === 'undefined') {
throw new AppwriteException('Missing required parameter: "messageId"');
}
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit cf96109

Please sign in to comment.