Skip to content

Commit 7faad3a

Browse files
feat: support for 0.14.x
1 parent 4f021b9 commit 7faad3a

File tree

12 files changed

+175
-97
lines changed

12 files changed

+175
-97
lines changed

README.md

Lines changed: 2 additions & 2 deletions
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.13.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-0.14.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?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
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.13.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.14.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)

docs/examples/account/delete.md renamed to docs/examples/account/update-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ client
1111
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
1212
;
1313

14-
let promise = account.delete();
14+
let promise = account.updateStatus();
1515

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

docs/examples/health/get-queue-usage.md renamed to docs/examples/users/get-memberships.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ const sdk = require('node-appwrite');
33
// Init SDK
44
let client = new sdk.Client();
55

6-
let health = new sdk.Health(client);
6+
let users = new sdk.Users(client);
77

88
client
99
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
1010
.setProject('5df5acd0d48c2') // Your project ID
1111
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
1212
;
1313

14-
let promise = health.getQueueUsage();
14+
let promise = users.getMemberships('[USER_ID]');
1515

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

index.d.ts

Lines changed: 80 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,17 +1037,21 @@ declare module "node-appwrite" {
10371037
*/
10381038
userId: string;
10391039
/**
1040-
* Team ID.
1041-
*/
1042-
teamId: string;
1043-
/**
10441040
* User name.
10451041
*/
1046-
name: string;
1042+
userName: string;
10471043
/**
10481044
* User email address.
10491045
*/
1050-
email: string;
1046+
userEmail: string;
1047+
/**
1048+
* Team ID.
1049+
*/
1050+
teamId: string;
1051+
/**
1052+
* Team name.
1053+
*/
1054+
teamName: string;
10511055
/**
10521056
* Date, the user has been invited to join the team in Unix timestamp.
10531057
*/
@@ -1241,9 +1245,9 @@ declare module "node-appwrite" {
12411245
*/
12421246
statusCode: number;
12431247
/**
1244-
* The script stdout output string. Logs the last 4,000 characters of the execution stdout output.
1248+
* The script response output string. Logs the last 4,000 characters of the execution response output.
12451249
*/
1246-
stdout: string;
1250+
response: string;
12471251
/**
12481252
* The script stderr output string. Logs the last 4,000 characters of the execution stderr output
12491253
*/
@@ -1506,19 +1510,6 @@ declare module "node-appwrite" {
15061510
* @returns {Promise}
15071511
*/
15081512
get<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>>;
1509-
/**
1510-
* Delete Account
1511-
*
1512-
* Delete a currently logged in user account. Behind the scene, the user
1513-
* record is not deleted but permanently blocked from any access. This is done
1514-
* to avoid deleted accounts being overtaken by new users with the same email
1515-
* address. Any user-related resources like documents or storage files should
1516-
* be deleted separately.
1517-
*
1518-
* @throws {AppwriteException}
1519-
* @returns {Promise}
1520-
*/
1521-
delete(): Promise<Response>;
15221513
/**
15231514
* Update Account Email
15241515
*
@@ -1564,7 +1555,7 @@ declare module "node-appwrite" {
15641555
*
15651556
* Update currently logged in user password. For validation, user is required
15661557
* to pass in the new password, and the old password. For users created with
1567-
* OAuth and Team Invites, oldPassword is optional.
1558+
* OAuth, Team Invites and Magic URL, oldPassword is optional.
15681559
*
15691560
* @param {string} password
15701561
* @param {string} oldPassword
@@ -1666,6 +1657,10 @@ declare module "node-appwrite" {
16661657
/**
16671658
* Update Session (Refresh Tokens)
16681659
*
1660+
* Access tokens have limited lifespan and expire to mitigate security risks.
1661+
* If session was created using an OAuth provider, this route can be used to
1662+
* "refresh" the access token.
1663+
*
16691664
* @param {string} sessionId
16701665
* @throws {AppwriteException}
16711666
* @returns {Promise}
@@ -1684,6 +1679,17 @@ declare module "node-appwrite" {
16841679
* @returns {Promise}
16851680
*/
16861681
deleteSession(sessionId: string): Promise<Response>;
1682+
/**
1683+
* Update Account Status
1684+
*
1685+
* Block the currently logged in user account. Behind the scene, the user
1686+
* record is not deleted but permanently blocked from any access. To
1687+
* completely delete a user, use the Users API instead.
1688+
*
1689+
* @throws {AppwriteException}
1690+
* @returns {Promise}
1691+
*/
1692+
updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>>;
16871693
/**
16881694
* Create Email Verification
16891695
*
@@ -1728,9 +1734,14 @@ declare module "node-appwrite" {
17281734
* Get Browser Icon
17291735
*
17301736
* You can use this endpoint to show different browser icons to your users.
1731-
* The code argument receives the browser code as it appears in your user
1732-
* /account/sessions endpoint. Use width, height and quality arguments to
1733-
* change the output settings.
1737+
* The code argument receives the browser code as it appears in your user [GET
1738+
* /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
1739+
* width, height and quality arguments to change the output settings.
1740+
*
1741+
* When one dimension is specified and the other is 0, the image is scaled
1742+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
1743+
* image at source quality. If dimensions are not specified, the default size
1744+
* of image returned is 100x100px.
17341745
*
17351746
* @param {string} code
17361747
* @param {number} width
@@ -1746,6 +1757,12 @@ declare module "node-appwrite" {
17461757
* The credit card endpoint will return you the icon of the credit card
17471758
* provider you need. Use width, height and quality arguments to change the
17481759
* output settings.
1760+
*
1761+
* When one dimension is specified and the other is 0, the image is scaled
1762+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
1763+
* image at source quality. If dimensions are not specified, the default size
1764+
* of image returned is 100x100px.
1765+
*
17491766
*
17501767
* @param {string} code
17511768
* @param {number} width
@@ -1773,6 +1790,12 @@ declare module "node-appwrite" {
17731790
* You can use this endpoint to show different country flags icons to your
17741791
* users. The code argument receives the 2 letter country code. Use width,
17751792
* height and quality arguments to change the output settings.
1793+
*
1794+
* When one dimension is specified and the other is 0, the image is scaled
1795+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
1796+
* image at source quality. If dimensions are not specified, the default size
1797+
* of image returned is 100x100px.
1798+
*
17761799
*
17771800
* @param {string} code
17781801
* @param {number} width
@@ -1789,6 +1812,12 @@ declare module "node-appwrite" {
17891812
* you want. This endpoint is very useful if you need to crop and display
17901813
* remote images in your app or in case you want to make sure a 3rd party
17911814
* image is properly served using a TLS protocol.
1815+
*
1816+
* When one dimension is specified and the other is 0, the image is scaled
1817+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
1818+
* image at source quality. If dimensions are not specified, the default size
1819+
* of image returned is 400x400px.
1820+
*
17921821
*
17931822
* @param {string} url
17941823
* @param {number} width
@@ -1810,6 +1839,12 @@ declare module "node-appwrite" {
18101839
* default, a random theme will be selected. The random theme will persist for
18111840
* the user's initials when reloading the same theme will always return for
18121841
* the same initials.
1842+
*
1843+
* When one dimension is specified and the other is 0, the image is scaled
1844+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
1845+
* image at source quality. If dimensions are not specified, the default size
1846+
* of image returned is 100x100px.
1847+
*
18131848
*
18141849
* @param {string} name
18151850
* @param {number} width
@@ -1825,6 +1860,7 @@ declare module "node-appwrite" {
18251860
*
18261861
* Converts a given plain text to a QR code image. You can use the query
18271862
* parameters to change the size and style of the resulting image.
1863+
*
18281864
*
18291865
* @param {string} text
18301866
* @param {number} size
@@ -2123,9 +2159,7 @@ declare module "node-appwrite" {
21232159
/**
21242160
* Delete Document
21252161
*
2126-
* Delete a document by its unique ID. This endpoint deletes only the parent
2127-
* documents, its attributes and relations to other documents. Child documents
2128-
* **will not** be deleted.
2162+
* Delete a document by its unique ID.
21292163
*
21302164
* @param {string} collectionId
21312165
* @param {string} documentId
@@ -2209,7 +2243,7 @@ declare module "node-appwrite" {
22092243
*/
22102244
create(functionId: string, name: string, execute: string[], runtime: string, vars?: object, events?: string[], schedule?: string, timeout?: number): Promise<Models.Function>;
22112245
/**
2212-
* List the currently active function runtimes.
2246+
* List runtimes
22132247
*
22142248
* Get a list of all runtimes that are currently active on your instance.
22152249
*
@@ -2448,16 +2482,6 @@ declare module "node-appwrite" {
24482482
* @returns {Promise}
24492483
*/
24502484
getQueueLogs(): Promise<Models.HealthQueue>;
2451-
/**
2452-
* Get Usage Queue
2453-
*
2454-
* Get the number of usage stats that are waiting to be processed in the
2455-
* Appwrite internal queue server.
2456-
*
2457-
* @throws {AppwriteException}
2458-
* @returns {Promise}
2459-
*/
2460-
getQueueUsage(): Promise<Models.HealthQueue>;
24612485
/**
24622486
* Get Webhooks Queue
24632487
*
@@ -3000,7 +3024,11 @@ declare module "node-appwrite" {
30003024
/**
30013025
* Delete User
30023026
*
3003-
* Delete a user by its unique ID.
3027+
* Delete a user by its unique ID, thereby releasing it's ID. Since ID is
3028+
* released and can be reused, all user-related resources like documents or
3029+
* storage files should be deleted before user deletion. If you want to keep
3030+
* ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus)
3031+
* endpoint instead.
30043032
*
30053033
* @param {string} userId
30063034
* @throws {AppwriteException}
@@ -3030,6 +3058,16 @@ declare module "node-appwrite" {
30303058
* @returns {Promise}
30313059
*/
30323060
getLogs(userId: string, limit?: number, offset?: number): Promise<Models.LogList>;
3061+
/**
3062+
* Get User Memberships
3063+
*
3064+
* Get the user membership list by its unique ID.
3065+
*
3066+
* @param {string} userId
3067+
* @throws {AppwriteException}
3068+
* @returns {Promise}
3069+
*/
3070+
getMemberships(userId: string): Promise<Models.MembershipList>;
30333071
/**
30343072
* Update Name
30353073
*
@@ -3109,7 +3147,8 @@ declare module "node-appwrite" {
31093147
/**
31103148
* Update User Status
31113149
*
3112-
* Update the user status by its unique ID.
3150+
* Update the user status by its unique ID. Use this endpoint as an
3151+
* alternative to deleting a user if you want to keep user's ID reserved.
31133152
*
31143153
* @param {string} userId
31153154
* @param {boolean} status

lib/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Client {
1010
this.endpoint = 'https://HOSTNAME/v1';
1111
this.headers = {
1212
'content-type': '',
13-
'x-sdk-version': 'appwrite:nodejs:5.1.0',
13+
'x-sdk-version': 'appwrite:nodejs:6.0.0',
1414
'X-Appwrite-Response-Format' : '0.13.0',
1515
};
1616
this.selfSigned = false;

lib/services/account.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,6 @@ class Account extends Service {
2323
}, payload);
2424
}
2525

26-
/**
27-
* Delete Account
28-
*
29-
* Delete a currently logged in user account. Behind the scene, the user
30-
* record is not deleted but permanently blocked from any access. This is done
31-
* to avoid deleted accounts being overtaken by new users with the same email
32-
* address. Any user-related resources like documents or storage files should
33-
* be deleted separately.
34-
*
35-
* @throws {AppwriteException}
36-
* @returns {Promise}
37-
*/
38-
async delete() {
39-
let path = '/account';
40-
let payload = {};
41-
42-
return await this.client.call('delete', path, {
43-
'content-type': 'application/json',
44-
}, payload);
45-
}
46-
4726
/**
4827
* Update Account Email
4928
*
@@ -145,7 +124,7 @@ class Account extends Service {
145124
*
146125
* Update currently logged in user password. For validation, user is required
147126
* to pass in the new password, and the old password. For users created with
148-
* OAuth and Team Invites, oldPassword is optional.
127+
* OAuth, Team Invites and Magic URL, oldPassword is optional.
149128
*
150129
* @param {string} password
151130
* @param {string} oldPassword
@@ -383,6 +362,10 @@ class Account extends Service {
383362
/**
384363
* Update Session (Refresh Tokens)
385364
*
365+
* Access tokens have limited lifespan and expire to mitigate security risks.
366+
* If session was created using an OAuth provider, this route can be used to
367+
* "refresh" the access token.
368+
*
386369
* @param {string} sessionId
387370
* @throws {AppwriteException}
388371
* @returns {Promise}
@@ -425,6 +408,25 @@ class Account extends Service {
425408
}, payload);
426409
}
427410

411+
/**
412+
* Update Account Status
413+
*
414+
* Block the currently logged in user account. Behind the scene, the user
415+
* record is not deleted but permanently blocked from any access. To
416+
* completely delete a user, use the Users API instead.
417+
*
418+
* @throws {AppwriteException}
419+
* @returns {Promise}
420+
*/
421+
async updateStatus() {
422+
let path = '/account/status';
423+
let payload = {};
424+
425+
return await this.client.call('patch', path, {
426+
'content-type': 'application/json',
427+
}, payload);
428+
}
429+
428430
/**
429431
* Create Email Verification
430432
*

0 commit comments

Comments
 (0)