node-appwrite 8.1.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +5 -5
  3. package/docs/examples/account/update-password.md +1 -1
  4. package/docs/examples/account/update-phone.md +1 -1
  5. package/docs/examples/databases/create-relationship-attribute.md +20 -0
  6. package/docs/examples/databases/update-boolean-attribute.md +20 -0
  7. package/docs/examples/{locale/get-continents.md → databases/update-datetime-attribute.md} +2 -2
  8. package/docs/examples/databases/update-email-attribute.md +20 -0
  9. package/docs/examples/databases/update-enum-attribute.md +20 -0
  10. package/docs/examples/databases/update-float-attribute.md +20 -0
  11. package/docs/examples/databases/update-integer-attribute.md +20 -0
  12. package/docs/examples/{locale/get-countries-phones.md → databases/update-ip-attribute.md} +2 -2
  13. package/docs/examples/{locale/get-countries-e-u.md → databases/update-relationship-attribute.md} +2 -2
  14. package/docs/examples/databases/update-string-attribute.md +20 -0
  15. package/docs/examples/databases/update-url-attribute.md +20 -0
  16. package/docs/examples/functions/{retry-build.md → create-build.md} +1 -1
  17. package/docs/examples/functions/create.md +1 -1
  18. package/docs/examples/functions/update.md +1 -1
  19. package/docs/examples/{locale/get-currencies.md → graphql/mutation.md} +2 -2
  20. package/docs/examples/{locale/get-languages.md → graphql/query.md} +2 -2
  21. package/docs/examples/teams/create-membership.md +1 -1
  22. package/docs/examples/{account/get-logs.md → teams/get-prefs.md} +2 -2
  23. package/docs/examples/teams/{get-memberships.md → update-name.md} +1 -1
  24. package/docs/examples/{account/get-sessions.md → teams/update-prefs.md} +2 -2
  25. package/docs/examples/users/update-password.md +1 -1
  26. package/docs/examples/users/update-phone.md +1 -1
  27. package/index.d.ts +406 -136
  28. package/index.js +2 -0
  29. package/lib/client.js +2 -1
  30. package/lib/inputFile.js +6 -8
  31. package/lib/query.js +18 -0
  32. package/lib/services/account.js +12 -12
  33. package/lib/services/databases.js +721 -107
  34. package/lib/services/functions.js +48 -50
  35. package/lib/services/graphql.js +72 -0
  36. package/lib/services/storage.js +44 -37
  37. package/lib/services/teams.js +88 -23
  38. package/package.json +6 -4
  39. package/docs/examples/locale/get-countries.md +0 -20
  40. package/docs/examples/teams/update.md +0 -20
  41. package/docs/examples/users/get-logs.md +0 -20
  42. package/docs/examples/users/get-memberships.md +0 -20
  43. package/docs/examples/users/get-sessions.md +0 -20
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors.
1
+ Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification,
7
7
 
8
8
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
9
 
10
- 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Appwrite Node.js SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.0.0-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.3.2-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
8
8
 
9
- **This SDK is compatible with Appwrite server version 1.0.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 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).**
10
10
 
11
11
  > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code.
12
12
  If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web)
@@ -48,7 +48,7 @@ Once your SDK object is set, create any of the Appwrite service objects and choo
48
48
  ```js
49
49
  let users = new sdk.Users(client);
50
50
 
51
- let promise = users.create(ID.unique(), 'email@example.com', 'password');
51
+ let promise = users.create(sdk.ID.unique(), 'email@example.com', undefined, 'password', 'Jane Doe');
52
52
 
53
53
  promise.then(function (response) {
54
54
  console.log(response);
@@ -71,7 +71,7 @@ client
71
71
  ;
72
72
 
73
73
  let users = new sdk.Users(client);
74
- let promise = users.create(ID.unique(), 'email@example.com', 'password');
74
+ let promise = users.create(sdk.ID.unique(), 'email@example.com', undefined, 'password', 'Jane Doe');
75
75
 
76
76
  promise.then(function (response) {
77
77
  console.log(response);
@@ -87,7 +87,7 @@ The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` a
87
87
  let users = new sdk.Users(client);
88
88
 
89
89
  try {
90
- let res = await users.create(ID.unique(), 'email@example.com', 'password');
90
+ let res = await users.create(sdk.ID.unique(), 'email@example.com', 'password');
91
91
  } catch(e) {
92
92
  console.log(e.message);
93
93
  }
@@ -11,7 +11,7 @@ client
11
11
  .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
12
12
  ;
13
13
 
14
- const promise = account.updatePassword('password');
14
+ const promise = account.updatePassword('');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
12
12
  ;
13
13
 
14
- const promise = account.updatePhone('', 'password');
14
+ const promise = account.updatePhone('+12065550100', 'password');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.createRelationshipAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '[RELATED_COLLECTION_ID]', 'oneToOne');
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateBooleanAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, false);
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const locale = new sdk.Locale(client);
6
+ const databases = new sdk.Databases(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = locale.getContinents();
14
+ const promise = databases.updateDatetimeAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, '');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateEmailAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, 'email@example.com');
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateEnumAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], false, '[DEFAULT]');
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, null, null, null);
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateIntegerAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, null, null, null);
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const locale = new sdk.Locale(client);
6
+ const databases = new sdk.Databases(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = locale.getCountriesPhones();
14
+ const promise = databases.updateIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, '');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const locale = new sdk.Locale(client);
6
+ const databases = new sdk.Databases(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = locale.getCountriesEU();
14
+ const promise = databases.updateRelationshipAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, '[DEFAULT]');
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -0,0 +1,20 @@
1
+ const sdk = require('node-appwrite');
2
+
3
+ // Init SDK
4
+ const client = new sdk.Client();
5
+
6
+ const databases = new sdk.Databases(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
+ const promise = databases.updateUrlAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, 'https://example.com');
15
+
16
+ promise.then(function (response) {
17
+ console.log(response);
18
+ }, function (error) {
19
+ console.log(error);
20
+ });
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = functions.retryBuild('[FUNCTION_ID]', '[DEPLOYMENT_ID]', '[BUILD_ID]');
14
+ const promise = functions.createBuild('[FUNCTION_ID]', '[DEPLOYMENT_ID]', '[BUILD_ID]');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = functions.create('[FUNCTION_ID]', '[NAME]', ["any"], 'node-14.5');
14
+ const promise = functions.create('[FUNCTION_ID]', '[NAME]', 'node-14.5');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = functions.update('[FUNCTION_ID]', '[NAME]', ["any"]);
14
+ const promise = functions.update('[FUNCTION_ID]', '[NAME]');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const locale = new sdk.Locale(client);
6
+ const graphql = new sdk.Graphql(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = locale.getCurrencies();
14
+ const promise = graphql.mutation({});
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const locale = new sdk.Locale(client);
6
+ const graphql = new sdk.Graphql(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = locale.getLanguages();
14
+ const promise = graphql.query({});
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = teams.createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com');
14
+ const promise = teams.createMembership('[TEAM_ID]', [], 'https://example.com');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const account = new sdk.Account(client);
6
+ const teams = new sdk.Teams(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
12
12
  ;
13
13
 
14
- const promise = account.getLogs();
14
+ const promise = teams.getPrefs('[TEAM_ID]');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = teams.getMemberships('[TEAM_ID]');
14
+ const promise = teams.updateName('[TEAM_ID]', '[NAME]');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -3,7 +3,7 @@ const sdk = require('node-appwrite');
3
3
  // Init SDK
4
4
  const client = new sdk.Client();
5
5
 
6
- const account = new sdk.Account(client);
6
+ const teams = new sdk.Teams(client);
7
7
 
8
8
  client
9
9
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
@@ -11,7 +11,7 @@ client
11
11
  .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
12
12
  ;
13
13
 
14
- const promise = account.getSessions();
14
+ const promise = teams.updatePrefs('[TEAM_ID]', {});
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = users.updatePassword('[USER_ID]', 'password');
14
+ const promise = users.updatePassword('[USER_ID]', '');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);
@@ -11,7 +11,7 @@ client
11
11
  .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
12
  ;
13
13
 
14
- const promise = users.updatePhone('[USER_ID]', '');
14
+ const promise = users.updatePhone('[USER_ID]', '+12065550100');
15
15
 
16
16
  promise.then(function (response) {
17
17
  console.log(response);