Skip to content

Commit b754460

Browse files
implement realtime feature
1 parent d25d795 commit b754460

File tree

11 files changed

+214
-19
lines changed

11 files changed

+214
-19
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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.9.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-0.10.0-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

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).**
9+
**This SDK is compatible with Appwrite server version 0.10.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).**
1010

1111
> This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code.
1212
If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web)
@@ -94,7 +94,7 @@ try {
9494
```
9595

9696
### Learn more
97-
You can use following resources to learn more and get help
97+
You can use the following resources to learn more and get help
9898
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
9999
- 📜 [Appwrite Docs](https://appwrite.io/docs)
100100
- 💬 [Discord Community](https://appwrite.io/discord)

docs/examples/functions/create.md

+1-1
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]', [], 'java-11.0');
14+
let promise = functions.create('[NAME]', [], 'dotnet-5.0');
1515

1616
promise.then(function (response) {
1717
console.log(response);

docs/examples/users/update-email.md

+20
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.updateEmail('[USER_ID]', 'email@example.com');
15+
16+
promise.then(function (response) {
17+
console.log(response);
18+
}, function (error) {
19+
console.log(error);
20+
});

docs/examples/users/update-name.md

+20
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.updateName('[USER_ID]', '[NAME]');
15+
16+
promise.then(function (response) {
17+
console.log(response);
18+
}, function (error) {
19+
console.log(error);
20+
});
+20
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.updatePassword('[USER_ID]', 'password');
15+
16+
promise.then(function (response) {
17+
console.log(response);
18+
}, function (error) {
19+
console.log(error);
20+
});

index.d.ts

+45-6
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ declare module "node-appwrite" {
193193
createRecovery<T extends unknown>(email: string, url: string): Promise<T>;
194194

195195
/**
196-
* Complete Password Recovery
196+
* Create Password Recovery (confirmation)
197197
*
198198
* Use this endpoint to complete the user account password reset. Both the
199199
* **userId** and **secret** arguments will be passed as query parameters to
@@ -287,7 +287,7 @@ declare module "node-appwrite" {
287287
createVerification<T extends unknown>(url: string): Promise<T>;
288288

289289
/**
290-
* Complete Email Verification
290+
* Create Email Verification (confirmation)
291291
*
292292
* Use this endpoint to complete the user email verification process. Use both
293293
* the **userId** and **secret** parameters that were attached to your app URL
@@ -1201,14 +1201,17 @@ declare module "node-appwrite" {
12011201
/**
12021202
* Create Team Membership
12031203
*
1204-
* Use this endpoint to invite a new member to join your team. An email with a
1205-
* link to join the team will be sent to the new member email address if the
1206-
* member doesn't exist in the project it will be created automatically.
1204+
* Use this endpoint to invite a new member to join your team. If initiated
1205+
* from Client SDK, an email with a link to join the team will be sent to the
1206+
* new member's email address if the member doesn't exist in the project it
1207+
* will be created automatically. If initiated from server side SDKs, new
1208+
* member will automatically be added to the team.
12071209
*
12081210
* Use the 'URL' parameter to redirect the user from the invitation email back
12091211
* to your app. When the user is redirected, use the [Update Team Membership
12101212
* Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
1211-
* the user to accept the invitation to the team.
1213+
* the user to accept the invitation to the team. While calling from side
1214+
* SDKs the redirect url can be empty string.
12121215
*
12131216
* Please note that in order to avoid a [Redirect
12141217
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
@@ -1318,6 +1321,18 @@ declare module "node-appwrite" {
13181321
*/
13191322
delete<T extends unknown>(userId: string): Promise<T>;
13201323

1324+
/**
1325+
* Update Email
1326+
*
1327+
* Update the user email by its unique ID.
1328+
*
1329+
* @param {string} userId
1330+
* @param {string} email
1331+
* @throws {AppwriteException}
1332+
* @returns {Promise}
1333+
*/
1334+
updateEmail<T extends unknown>(userId: string, email: string): Promise<T>;
1335+
13211336
/**
13221337
* Get User Logs
13231338
*
@@ -1329,6 +1344,30 @@ declare module "node-appwrite" {
13291344
*/
13301345
getLogs<T extends unknown>(userId: string): Promise<T>;
13311346

1347+
/**
1348+
* Update Name
1349+
*
1350+
* Update the user name by its unique ID.
1351+
*
1352+
* @param {string} userId
1353+
* @param {string} name
1354+
* @throws {AppwriteException}
1355+
* @returns {Promise}
1356+
*/
1357+
updateName<T extends unknown>(userId: string, name: string): Promise<T>;
1358+
1359+
/**
1360+
* Update Password
1361+
*
1362+
* Update the user password by its unique ID.
1363+
*
1364+
* @param {string} userId
1365+
* @param {string} password
1366+
* @throws {AppwriteException}
1367+
* @returns {Promise}
1368+
*/
1369+
updatePassword<T extends unknown>(userId: string, password: string): Promise<T>;
1370+
13321371
/**
13331372
* Get User Preferences
13341373
*

lib/client.js

+2-2
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.4.0',
13-
'X-Appwrite-Response-Format' : '0.9.0',
12+
'x-sdk-version': 'appwrite:nodejs:2.5.0',
13+
'X-Appwrite-Response-Format' : '0.10.0',
1414
};
1515
this.selfSigned = false;
1616
}

lib/services/account.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Account extends Service {
245245
}
246246

247247
/**
248-
* Complete Password Recovery
248+
* Create Password Recovery (confirmation)
249249
*
250250
* Use this endpoint to complete the user account password reset. Both the
251251
* **userId** and **secret** arguments will be passed as query parameters to
@@ -429,7 +429,7 @@ class Account extends Service {
429429
}
430430

431431
/**
432-
* Complete Email Verification
432+
* Create Email Verification (confirmation)
433433
*
434434
* Use this endpoint to complete the user email verification process. Use both
435435
* the **userId** and **secret** parameters that were attached to your app URL

lib/services/teams.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,17 @@ class Teams extends Service {
201201
/**
202202
* Create Team Membership
203203
*
204-
* Use this endpoint to invite a new member to join your team. An email with a
205-
* link to join the team will be sent to the new member email address if the
206-
* member doesn't exist in the project it will be created automatically.
204+
* Use this endpoint to invite a new member to join your team. If initiated
205+
* from Client SDK, an email with a link to join the team will be sent to the
206+
* new member's email address if the member doesn't exist in the project it
207+
* will be created automatically. If initiated from server side SDKs, new
208+
* member will automatically be added to the team.
207209
*
208210
* Use the 'URL' parameter to redirect the user from the invitation email back
209211
* to your app. When the user is redirected, use the [Update Team Membership
210212
* Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
211-
* the user to accept the invitation to the team.
213+
* the user to accept the invitation to the team. While calling from side
214+
* SDKs the redirect url can be empty string.
212215
*
213216
* Please note that in order to avoid a [Redirect
214217
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)

lib/services/users.js

+93
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,37 @@ class Users extends Service {
125125
}, payload);
126126
}
127127

128+
/**
129+
* Update Email
130+
*
131+
* Update the user email by its unique ID.
132+
*
133+
* @param {string} userId
134+
* @param {string} email
135+
* @throws {AppwriteException}
136+
* @returns {Promise}
137+
*/
138+
async updateEmail(userId, email) {
139+
if (typeof userId === 'undefined') {
140+
throw new AppwriteException('Missing required parameter: "userId"');
141+
}
142+
143+
if (typeof email === 'undefined') {
144+
throw new AppwriteException('Missing required parameter: "email"');
145+
}
146+
147+
let path = '/users/{userId}/email'.replace('{userId}', userId);
148+
let payload = {};
149+
150+
if (typeof email !== 'undefined') {
151+
payload['email'] = email;
152+
}
153+
154+
return await this.client.call('patch', path, {
155+
'content-type': 'application/json',
156+
}, payload);
157+
}
158+
128159
/**
129160
* Get User Logs
130161
*
@@ -147,6 +178,68 @@ class Users extends Service {
147178
}, payload);
148179
}
149180

181+
/**
182+
* Update Name
183+
*
184+
* Update the user name by its unique ID.
185+
*
186+
* @param {string} userId
187+
* @param {string} name
188+
* @throws {AppwriteException}
189+
* @returns {Promise}
190+
*/
191+
async updateName(userId, name) {
192+
if (typeof userId === 'undefined') {
193+
throw new AppwriteException('Missing required parameter: "userId"');
194+
}
195+
196+
if (typeof name === 'undefined') {
197+
throw new AppwriteException('Missing required parameter: "name"');
198+
}
199+
200+
let path = '/users/{userId}/name'.replace('{userId}', userId);
201+
let payload = {};
202+
203+
if (typeof name !== 'undefined') {
204+
payload['name'] = name;
205+
}
206+
207+
return await this.client.call('patch', path, {
208+
'content-type': 'application/json',
209+
}, payload);
210+
}
211+
212+
/**
213+
* Update Password
214+
*
215+
* Update the user password by its unique ID.
216+
*
217+
* @param {string} userId
218+
* @param {string} password
219+
* @throws {AppwriteException}
220+
* @returns {Promise}
221+
*/
222+
async updatePassword(userId, password) {
223+
if (typeof userId === 'undefined') {
224+
throw new AppwriteException('Missing required parameter: "userId"');
225+
}
226+
227+
if (typeof password === 'undefined') {
228+
throw new AppwriteException('Missing required parameter: "password"');
229+
}
230+
231+
let path = '/users/{userId}/password'.replace('{userId}', userId);
232+
let payload = {};
233+
234+
if (typeof password !== 'undefined') {
235+
payload['password'] = password;
236+
}
237+
238+
return await this.client.call('patch', path, {
239+
'content-type': 'application/json',
240+
}, payload);
241+
}
242+
150243
/**
151244
* Get User Preferences
152245
*

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"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",
5-
"version": "2.4.0",
5+
"version": "2.5.0",
66
"license": "BSD-3-Clause",
77
"main": "./index.js",
88
"types": "./index.d.ts",

0 commit comments

Comments
 (0)