Skip to content

Commit d25d795

Browse files
Merge pull request #17 from appwrite/dev
feat: update version
2 parents c078669 + 676b4ee commit d25d795

File tree

11 files changed

+145
-22
lines changed

11 files changed

+145
-22
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# Appwrite Node.js SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
5+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
56
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
67
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
78

8-
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).**
9+
**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).**
910

1011
> This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code.
1112
If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web)
1213

13-
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
14-
Use the Node.js SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
15-
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
14+
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Node.js SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1615

1716
![Appwrite](https://appwrite.io/images/github.png)
1817

@@ -28,7 +27,7 @@ npm install node-appwrite --save
2827
## Getting Started
2928

3029
### Init your SDK
31-
Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key project API keys section.
30+
Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.
3231

3332
```js
3433
const sdk = require('node-appwrite');
@@ -44,7 +43,7 @@ client
4443
```
4544

4645
### Make Your First Request
47-
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
46+
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
4847

4948
```js
5049
let users = new sdk.Users(client);
@@ -95,7 +94,7 @@ try {
9594
```
9695

9796
### Learn more
98-
You can use followng resources to learn more and get help
97+
You can use following resources to learn more and get help
9998
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
10099
- 📜 [Appwrite Docs](https://appwrite.io/docs)
101100
- 💬 [Discord Community](https://appwrite.io/discord)

docs/examples/account/get-session.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const sdk = require('node-appwrite');
2+
3+
// Init SDK
4+
let client = new sdk.Client();
5+
6+
let account = new sdk.Account(client);
7+
8+
client
9+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10+
.setProject('5df5acd0d48c2') // Your project ID
11+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
12+
;
13+
14+
let promise = account.getSession('[SESSION_ID]');
15+
16+
promise.then(function (response) {
17+
console.log(response);
18+
}, function (error) {
19+
console.log(error);
20+
});

docs/examples/functions/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ client
1111
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
1212
;
1313

14-
let promise = functions.create('[NAME]', [], 'dotnet-3.1');
14+
let promise = functions.create('[NAME]', [], 'java-11.0');
1515

1616
promise.then(function (response) {
1717
console.log(response);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const sdk = require('node-appwrite');
2+
3+
// Init SDK
4+
let client = new sdk.Client();
5+
6+
let users = new sdk.Users(client);
7+
8+
client
9+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10+
.setProject('5df5acd0d48c2') // Your project ID
11+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12+
;
13+
14+
let promise = users.updateVerification('[USER_ID]', false);
15+
16+
promise.then(function (response) {
17+
console.log(response);
18+
}, function (error) {
19+
console.log(error);
20+
});

index.d.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,18 @@ declare module "node-appwrite" {
236236
*/
237237
deleteSessions<T extends unknown>(): Promise<T>;
238238

239+
/**
240+
* Get Session By ID
241+
*
242+
* Use this endpoint to get a logged in user's session using a Session ID.
243+
* Inputting 'current' will return the current session being used.
244+
*
245+
* @param {string} sessionId
246+
* @throws {AppwriteException}
247+
* @returns {Promise}
248+
*/
249+
getSession<T extends unknown>(sessionId: string): Promise<T>;
250+
239251
/**
240252
* Delete Account Session
241253
*
@@ -590,15 +602,15 @@ declare module "node-appwrite" {
590602
*
591603
* @param {string} name
592604
* @param {string[]} execute
593-
* @param {string} env
605+
* @param {string} runtime
594606
* @param {object} vars
595607
* @param {string[]} events
596608
* @param {string} schedule
597609
* @param {number} timeout
598610
* @throws {AppwriteException}
599611
* @returns {Promise}
600612
*/
601-
create<T extends unknown>(name: string, execute: string[], env: string, vars?: object, events?: string[], schedule?: string, timeout?: number): Promise<T>;
613+
create<T extends unknown>(name: string, execute: string[], runtime: string, vars?: object, events?: string[], schedule?: string, timeout?: number): Promise<T>;
602614

603615
/**
604616
* Get Function
@@ -1072,6 +1084,7 @@ declare module "node-appwrite" {
10721084
* @param {string} fileId
10731085
* @param {number} width
10741086
* @param {number} height
1087+
* @param {string} gravity
10751088
* @param {number} quality
10761089
* @param {number} borderWidth
10771090
* @param {string} borderColor
@@ -1083,7 +1096,7 @@ declare module "node-appwrite" {
10831096
* @throws {AppwriteException}
10841097
* @returns {Promise}
10851098
*/
1086-
getFilePreview(fileId: string, width?: number, height?: number, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): Promise<Buffer>;
1099+
getFilePreview(fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): Promise<Buffer>;
10871100

10881101
/**
10891102
* Get File for View
@@ -1385,5 +1398,17 @@ declare module "node-appwrite" {
13851398
* @returns {Promise}
13861399
*/
13871400
updateStatus<T extends unknown>(userId: string, status: number): Promise<T>;
1401+
1402+
/**
1403+
* Update Email Verification
1404+
*
1405+
* Update the user email verification status by its unique ID.
1406+
*
1407+
* @param {string} userId
1408+
* @param {boolean} emailVerification
1409+
* @throws {AppwriteException}
1410+
* @returns {Promise}
1411+
*/
1412+
updateVerification<T extends unknown>(userId: string, emailVerification: boolean): Promise<T>;
13881413
}
13891414
}

lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class Client {
99
this.endpoint = 'https://appwrite.io/v1';
1010
this.headers = {
1111
'content-type': '',
12-
'x-sdk-version': 'appwrite:nodejs:2.3.0',
13-
'X-Appwrite-Response-Format' : '0.8.0',
12+
'x-sdk-version': 'appwrite:nodejs:2.4.0',
13+
'X-Appwrite-Response-Format' : '0.9.0',
1414
};
1515
this.selfSigned = false;
1616
}

lib/services/account.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,29 @@ class Account extends Service {
341341
}, payload);
342342
}
343343

344+
/**
345+
* Get Session By ID
346+
*
347+
* Use this endpoint to get a logged in user's session using a Session ID.
348+
* Inputting 'current' will return the current session being used.
349+
*
350+
* @param {string} sessionId
351+
* @throws {AppwriteException}
352+
* @returns {Promise}
353+
*/
354+
async getSession(sessionId) {
355+
if (typeof sessionId === 'undefined') {
356+
throw new AppwriteException('Missing required parameter: "sessionId"');
357+
}
358+
359+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
360+
let payload = {};
361+
362+
return await this.client.call('get', path, {
363+
'content-type': 'application/json',
364+
}, payload);
365+
}
366+
344367
/**
345368
* Delete Account Session
346369
*

lib/services/functions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ class Functions extends Service {
5050
*
5151
* @param {string} name
5252
* @param {string[]} execute
53-
* @param {string} env
53+
* @param {string} runtime
5454
* @param {object} vars
5555
* @param {string[]} events
5656
* @param {string} schedule
5757
* @param {number} timeout
5858
* @throws {AppwriteException}
5959
* @returns {Promise}
6060
*/
61-
async create(name, execute, env, vars, events, schedule, timeout) {
61+
async create(name, execute, runtime, vars, events, schedule, timeout) {
6262
if (typeof name === 'undefined') {
6363
throw new AppwriteException('Missing required parameter: "name"');
6464
}
@@ -67,8 +67,8 @@ class Functions extends Service {
6767
throw new AppwriteException('Missing required parameter: "execute"');
6868
}
6969

70-
if (typeof env === 'undefined') {
71-
throw new AppwriteException('Missing required parameter: "env"');
70+
if (typeof runtime === 'undefined') {
71+
throw new AppwriteException('Missing required parameter: "runtime"');
7272
}
7373

7474
let path = '/functions';
@@ -82,8 +82,8 @@ class Functions extends Service {
8282
payload['execute'] = execute;
8383
}
8484

85-
if (typeof env !== 'undefined') {
86-
payload['env'] = env;
85+
if (typeof runtime !== 'undefined') {
86+
payload['runtime'] = runtime;
8787
}
8888

8989
if (typeof vars !== 'undefined') {

lib/services/storage.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ class Storage extends Service {
202202
* @param {string} fileId
203203
* @param {number} width
204204
* @param {number} height
205+
* @param {string} gravity
205206
* @param {number} quality
206207
* @param {number} borderWidth
207208
* @param {string} borderColor
@@ -213,7 +214,7 @@ class Storage extends Service {
213214
* @throws {AppwriteException}
214215
* @returns {Promise}
215216
*/
216-
async getFilePreview(fileId, width, height, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) {
217+
async getFilePreview(fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) {
217218
if (typeof fileId === 'undefined') {
218219
throw new AppwriteException('Missing required parameter: "fileId"');
219220
}
@@ -229,6 +230,10 @@ class Storage extends Service {
229230
payload['height'] = height;
230231
}
231232

233+
if (typeof gravity !== 'undefined') {
234+
payload['gravity'] = gravity;
235+
}
236+
232237
if (typeof quality !== 'undefined') {
233238
payload['quality'] = quality;
234239
}

lib/services/users.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,37 @@ class Users extends Service {
302302
'content-type': 'application/json',
303303
}, payload);
304304
}
305+
306+
/**
307+
* Update Email Verification
308+
*
309+
* Update the user email verification status by its unique ID.
310+
*
311+
* @param {string} userId
312+
* @param {boolean} emailVerification
313+
* @throws {AppwriteException}
314+
* @returns {Promise}
315+
*/
316+
async updateVerification(userId, emailVerification) {
317+
if (typeof userId === 'undefined') {
318+
throw new AppwriteException('Missing required parameter: "userId"');
319+
}
320+
321+
if (typeof emailVerification === 'undefined') {
322+
throw new AppwriteException('Missing required parameter: "emailVerification"');
323+
}
324+
325+
let path = '/users/{userId}/verification'.replace('{userId}', userId);
326+
let payload = {};
327+
328+
if (typeof emailVerification !== 'undefined') {
329+
payload['emailVerification'] = emailVerification;
330+
}
331+
332+
return await this.client.call('patch', path, {
333+
'content-type': 'application/json',
334+
}, payload);
335+
}
305336
}
306337

307338
module.exports = Users;

0 commit comments

Comments
 (0)