Skip to content

Commit

Permalink
Merge pull request #88 from appwrite/dev
Browse files Browse the repository at this point in the history
fix: minor bugs
  • Loading branch information
stnguyen90 authored May 29, 2024
2 parents 0dc59ba + 5584303 commit 8113032
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 82 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish to NPM

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Setup Node.js environment
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

# Determine release tag based on the tag name
- name: Determine release tag
id: release_tag
run: |
if [[ "${{ github.ref }}" == *"-rc"* ]] || [[ "${{ github.ref }}" == *"-RC"* ]]; then
echo "tag=next" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
# Install dependencies (if any) and build your project (if necessary)
- name: Install dependencies and build
run: |
npm install
npm run build
# Publish to NPM with the appropriate tag
- name: Publish
run: npm publish --tag ${{ steps.release_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.5.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.6-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)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const messaging = new sdk.Messaging(client);
const result = await messaging.createMsg91Provider(
'<PROVIDER_ID>', // providerId
'<NAME>', // name
'+12065550100', // from (optional)
'<TEMPLATE_ID>', // templateId (optional)
'<SENDER_ID>', // senderId (optional)
'<AUTH_KEY>', // authKey (optional)
false // enabled (optional)
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 @@ -18,5 +18,6 @@ const result = await messaging.updateEmail(
false, // html (optional)
[], // cc (optional)
[], // bcc (optional)
'' // scheduledAt (optional)
'', // scheduledAt (optional)
[] // attachments (optional)
);
4 changes: 2 additions & 2 deletions docs/examples/messaging/update-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const result = await messaging.updateMsg91Provider(
'<PROVIDER_ID>', // providerId
'<NAME>', // name (optional)
false, // enabled (optional)
'<TEMPLATE_ID>', // templateId (optional)
'<SENDER_ID>', // senderId (optional)
'<AUTH_KEY>', // authKey (optional)
'<FROM>' // from (optional)
'<AUTH_KEY>' // authKey (optional)
);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "12.1.0-rc.4",
"version": "13.0.0",
"license": "BSD-3-Clause",
"main": "dist/index.js",
"type": "commonjs",
Expand Down Expand Up @@ -31,6 +31,9 @@
}
}
},
"files": [
"dist"
],
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"repository": {
Expand All @@ -40,6 +43,7 @@
"devDependencies": {
"@types/node": "20.11.25",
"tsup": "7.2.0",
"esbuild-plugin-file-path-extensions": "^2.0.0",
"tslib": "2.6.2",
"typescript": "5.4.2"
},
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppwriteException extends Error {
}

function getUserAgent() {
let ua = 'AppwriteNodeJSSDK/12.1.0-rc.4';
let ua = 'AppwriteNodeJSSDK/13.0.0';

// `process` is a global in Node.js, but not fully available in all runtimes.
const platform: string[] = [];
Expand Down Expand Up @@ -82,7 +82,7 @@ class Client {
'x-sdk-name': 'Node.js',
'x-sdk-platform': 'server',
'x-sdk-language': 'nodejs',
'x-sdk-version': '12.1.0-rc.4',
'x-sdk-version': '13.0.0',
'user-agent' : getUserAgent(),
'X-Appwrite-Response-Format': '1.5.0',
};
Expand Down
2 changes: 1 addition & 1 deletion src/enums/credit-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export enum CreditCard {
AmericanExpress = 'amex',
Argencard = 'argencard',
Cabal = 'cabal',
Consosud = 'censosud',
Cencosud = 'cencosud',
DinersClub = 'diners',
Discover = 'discover',
Elo = 'elo',
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
1 change: 0 additions & 1 deletion src/enums/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export enum Name {
V1builds = 'v1-builds',
V1messaging = 'v1-messaging',
V1migrations = 'v1-migrations',
Hamsterv1 = 'hamsterv1',
}
1 change: 1 addition & 0 deletions src/enums/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum Runtime {
Python310 = 'python-3.10',
Python311 = 'python-3.11',
Python312 = 'python-3.12',
Pythonml311 = 'python-ml-3.11',
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 @@ -1190,6 +1190,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 @@ -2176,17 +2180,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 @@ -266,7 +266,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
/**
* Add 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#verifyAuthenticator) method.
* 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.
*
* @param {AuthenticatorType} type
* @throws {AppwriteException}
Expand Down Expand Up @@ -294,7 +294,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
/**
* Verify Authenticator
*
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method.
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add
*
* @param {AuthenticatorType} type
* @param {string} otp
Expand Down Expand Up @@ -334,9 +334,9 @@ This endpoint can also be used to convert an anonymous account to a normal one,
* @param {AuthenticatorType} type
* @param {string} otp
* @throws {AppwriteException}
* @returns {Promise<Models.User<Preferences>>}
* @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
24 changes: 14 additions & 10 deletions src/services/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ export class Messaging {
* @param {string[]} cc
* @param {string[]} bcc
* @param {string} scheduledAt
* @param {string[]} attachments
* @throws {AppwriteException}
* @returns {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): 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 @@ -178,6 +179,9 @@ export class Messaging {
if (typeof scheduledAt !== 'undefined') {
payload['scheduledAt'] = scheduledAt;
}
if (typeof attachments !== 'undefined') {
payload['attachments'] = attachments;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -986,14 +990,14 @@ export class Messaging {
*
* @param {string} providerId
* @param {string} name
* @param {string} from
* @param {string} templateId
* @param {string} senderId
* @param {string} authKey
* @param {boolean} enabled
* @throws {AppwriteException}
* @returns {Promise<Models.Provider>}
*/
async createMsg91Provider(providerId: string, name: string, from?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> {
async createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
Expand All @@ -1008,8 +1012,8 @@ export class Messaging {
if (typeof name !== 'undefined') {
payload['name'] = name;
}
if (typeof from !== 'undefined') {
payload['from'] = from;
if (typeof templateId !== 'undefined') {
payload['templateId'] = templateId;
}
if (typeof senderId !== 'undefined') {
payload['senderId'] = senderId;
Expand Down Expand Up @@ -1041,13 +1045,13 @@ export class Messaging {
* @param {string} providerId
* @param {string} name
* @param {boolean} enabled
* @param {string} templateId
* @param {string} senderId
* @param {string} authKey
* @param {string} from
* @throws {AppwriteException}
* @returns {Promise<Models.Provider>}
*/
async updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, senderId?: string, authKey?: string, from?: string): Promise<Models.Provider> {
async updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider> {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
Expand All @@ -1059,15 +1063,15 @@ export class Messaging {
if (typeof enabled !== 'undefined') {
payload['enabled'] = enabled;
}
if (typeof templateId !== 'undefined') {
payload['templateId'] = templateId;
}
if (typeof senderId !== 'undefined') {
payload['senderId'] = senderId;
}
if (typeof authKey !== 'undefined') {
payload['authKey'] = authKey;
}
if (typeof from !== 'undefined') {
payload['from'] = from;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down
3 changes: 2 additions & 1 deletion src/services/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,8 @@ If you want to generate a token for a custom authentication flow, use the [POST
/**
* Create token
*
* Returns a token with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) endpoint to complete the login process.
* Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process.
*
* @param {string} userId
* @param {number} length
Expand Down
19 changes: 0 additions & 19 deletions tsup.config.js

This file was deleted.

Loading

0 comments on commit 8113032

Please sign in to comment.