node-appwrite 8.0.0 → 8.2.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.
package/LICENSE CHANGED
@@ -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.2.0-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.2.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.updatePhone('', 'password');
14
+ const promise = account.updatePhone('+12065550100', 'password');
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.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);
@@ -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 = 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);
package/index.d.ts CHANGED
@@ -869,26 +869,46 @@ declare module "node-appwrite" {
869
869
  * AlgoMD5
870
870
  */
871
871
  export type AlgoMd5 = {
872
+ /**
873
+ * Algo type.
874
+ */
875
+ type: string;
872
876
  }
873
877
  /**
874
878
  * AlgoSHA
875
879
  */
876
880
  export type AlgoSha = {
881
+ /**
882
+ * Algo type.
883
+ */
884
+ type: string;
877
885
  }
878
886
  /**
879
887
  * AlgoPHPass
880
888
  */
881
889
  export type AlgoPhpass = {
890
+ /**
891
+ * Algo type.
892
+ */
893
+ type: string;
882
894
  }
883
895
  /**
884
896
  * AlgoBcrypt
885
897
  */
886
898
  export type AlgoBcrypt = {
899
+ /**
900
+ * Algo type.
901
+ */
902
+ type: string;
887
903
  }
888
904
  /**
889
905
  * AlgoScrypt
890
906
  */
891
907
  export type AlgoScrypt = {
908
+ /**
909
+ * Algo type.
910
+ */
911
+ type: string;
892
912
  /**
893
913
  * CPU complexity of computed hash.
894
914
  */
@@ -910,6 +930,10 @@ declare module "node-appwrite" {
910
930
  * AlgoScryptModified
911
931
  */
912
932
  export type AlgoScryptModified = {
933
+ /**
934
+ * Algo type.
935
+ */
936
+ type: string;
913
937
  /**
914
938
  * Salt used to compute hash.
915
939
  */
@@ -927,6 +951,10 @@ declare module "node-appwrite" {
927
951
  * AlgoArgon2
928
952
  */
929
953
  export type AlgoArgon2 = {
954
+ /**
955
+ * Algo type.
956
+ */
957
+ type: string;
930
958
  /**
931
959
  * Memory used to compute hash.
932
960
  */
@@ -1487,6 +1515,10 @@ declare module "node-appwrite" {
1487
1515
  * The build stderr.
1488
1516
  */
1489
1517
  buildStderr: string;
1518
+ /**
1519
+ * The current build time in seconds.
1520
+ */
1521
+ buildTime: number;
1490
1522
  }
1491
1523
  /**
1492
1524
  * Execution
@@ -1830,13 +1862,35 @@ declare module "node-appwrite" {
1830
1862
 
1831
1863
  static limit(value: number): string;
1832
1864
 
1833
- static offset = (value: number): string;
1865
+ static offset(value: number): string;
1834
1866
 
1835
1867
  private static addQuery(attribute: string, method: string, value: QueryTypes): string;
1836
1868
 
1837
1869
  private static parseValues(value: QueryTypes): string;
1838
1870
  }
1839
1871
 
1872
+ export class ID {
1873
+ static unique(): string;
1874
+ static custom(id: string): string;
1875
+ }
1876
+
1877
+ export class Permission {
1878
+ static read(role: string): string;
1879
+ static write(role: string): string;
1880
+ static create(role: string): string;
1881
+ static update(role: string): string;
1882
+ static delete(role: string): string;
1883
+ }
1884
+
1885
+ export class Role {
1886
+ static any(): string;
1887
+ static user(id: string, status?: string): string;
1888
+ static users(status?: string): string;
1889
+ static guests(): string;
1890
+ static team(id: string, role?: string): string;
1891
+ static member(id: string): string;
1892
+ }
1893
+
1840
1894
  export class Account extends Service {
1841
1895
  constructor(client: Client);
1842
1896
 
@@ -1850,7 +1904,7 @@ declare module "node-appwrite" {
1850
1904
  */
1851
1905
  get<Preferences extends Models.Preferences>(): Promise<Models.Account<Preferences>>;
1852
1906
  /**
1853
- * Update Account Email
1907
+ * Update Email
1854
1908
  *
1855
1909
  * Update currently logged in user account email address. After changing user
1856
1910
  * address, the user confirmation status will get reset. A new confirmation
@@ -1868,7 +1922,7 @@ declare module "node-appwrite" {
1868
1922
  */
1869
1923
  updateEmail<Preferences extends Models.Preferences>(email: string, password: string): Promise<Models.Account<Preferences>>;
1870
1924
  /**
1871
- * List Account Logs
1925
+ * List Logs
1872
1926
  *
1873
1927
  * Get currently logged in user list of latest security activity logs. Each
1874
1928
  * log returns user IP address, location and date and time of log.
@@ -1879,7 +1933,7 @@ declare module "node-appwrite" {
1879
1933
  */
1880
1934
  listLogs(queries?: string[]): Promise<Models.LogList>;
1881
1935
  /**
1882
- * Update Account Name
1936
+ * Update Name
1883
1937
  *
1884
1938
  * Update currently logged in user account name.
1885
1939
  *
@@ -1889,7 +1943,7 @@ declare module "node-appwrite" {
1889
1943
  */
1890
1944
  updateName<Preferences extends Models.Preferences>(name: string): Promise<Models.Account<Preferences>>;
1891
1945
  /**
1892
- * Update Account Password
1946
+ * Update Password
1893
1947
  *
1894
1948
  * Update currently logged in user password. For validation, user is required
1895
1949
  * to pass in the new password, and the old password. For users created with
@@ -1902,7 +1956,7 @@ declare module "node-appwrite" {
1902
1956
  */
1903
1957
  updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.Account<Preferences>>;
1904
1958
  /**
1905
- * Update Account Phone
1959
+ * Update Phone
1906
1960
  *
1907
1961
  * Update the currently logged in user's phone number. After updating the
1908
1962
  * phone number, the phone verification status will be reset. A confirmation
@@ -1926,7 +1980,7 @@ declare module "node-appwrite" {
1926
1980
  */
1927
1981
  getPrefs<Preferences extends Models.Preferences>(): Promise<Preferences>;
1928
1982
  /**
1929
- * Update Account Preferences
1983
+ * Update Preferences
1930
1984
  *
1931
1985
  * Update currently logged in user account preferences. The object you pass is
1932
1986
  * stored as is, and replaces any previous value. The maximum allowed prefs
@@ -1977,7 +2031,7 @@ declare module "node-appwrite" {
1977
2031
  */
1978
2032
  updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise<Models.Token>;
1979
2033
  /**
1980
- * List Account Sessions
2034
+ * List Sessions
1981
2035
  *
1982
2036
  * Get currently logged in user list of active sessions across different
1983
2037
  * devices.
@@ -1987,7 +2041,7 @@ declare module "node-appwrite" {
1987
2041
  */
1988
2042
  listSessions(): Promise<Models.SessionList>;
1989
2043
  /**
1990
- * Delete All Account Sessions
2044
+ * Delete Sessions
1991
2045
  *
1992
2046
  * Delete all sessions from the user account and remove any sessions cookies
1993
2047
  * from the end client.
@@ -1997,7 +2051,7 @@ declare module "node-appwrite" {
1997
2051
  */
1998
2052
  deleteSessions(): Promise<Response>;
1999
2053
  /**
2000
- * Get Session By ID
2054
+ * Get Session
2001
2055
  *
2002
2056
  * Use this endpoint to get a logged in user's session using a Session ID.
2003
2057
  * Inputting 'current' will return the current session being used.
@@ -2008,7 +2062,7 @@ declare module "node-appwrite" {
2008
2062
  */
2009
2063
  getSession(sessionId: string): Promise<Models.Session>;
2010
2064
  /**
2011
- * Update Session (Refresh Tokens)
2065
+ * Update OAuth Session (Refresh Tokens)
2012
2066
  *
2013
2067
  * Access tokens have limited lifespan and expire to mitigate security risks.
2014
2068
  * If session was created using an OAuth provider, this route can be used to
@@ -2020,7 +2074,7 @@ declare module "node-appwrite" {
2020
2074
  */
2021
2075
  updateSession(sessionId: string): Promise<Models.Session>;
2022
2076
  /**
2023
- * Delete Account Session
2077
+ * Delete Session
2024
2078
  *
2025
2079
  * Use this endpoint to log out the currently logged in user from all their
2026
2080
  * account sessions across all of their different devices. When using the
@@ -2033,7 +2087,7 @@ declare module "node-appwrite" {
2033
2087
  */
2034
2088
  deleteSession(sessionId: string): Promise<Response>;
2035
2089
  /**
2036
- * Update Account Status
2090
+ * Update Status
2037
2091
  *
2038
2092
  * Block the currently logged in user account. Behind the scene, the user
2039
2093
  * record is not deleted but permanently blocked from any access. To
@@ -2562,9 +2616,7 @@ declare module "node-appwrite" {
2562
2616
  * List Documents
2563
2617
  *
2564
2618
  * Get a list of all the user's documents in a given collection. You can use
2565
- * the query params to filter your results. On admin mode, this endpoint will
2566
- * return a list of all of documents belonging to the provided collectionId.
2567
- * [Learn more about different API modes](/docs/admin).
2619
+ * the query params to filter your results.
2568
2620
  *
2569
2621
  * @param {string} databaseId
2570
2622
  * @param {string} collectionId
@@ -2823,7 +2875,7 @@ declare module "node-appwrite" {
2823
2875
  */
2824
2876
  deleteDeployment(functionId: string, deploymentId: string): Promise<Response>;
2825
2877
  /**
2826
- * Retry Build
2878
+ * Create Build
2827
2879
  *
2828
2880
  * @param {string} functionId
2829
2881
  * @param {string} deploymentId
@@ -2831,14 +2883,12 @@ declare module "node-appwrite" {
2831
2883
  * @throws {AppwriteException}
2832
2884
  * @returns {Promise}
2833
2885
  */
2834
- retryBuild(functionId: string, deploymentId: string, buildId: string): Promise<Response>;
2886
+ createBuild(functionId: string, deploymentId: string, buildId: string): Promise<Response>;
2835
2887
  /**
2836
2888
  * List Executions
2837
2889
  *
2838
2890
  * Get a list of all the current user function execution logs. You can use the
2839
- * query params to filter your results. On admin mode, this endpoint will
2840
- * return a list of all of the project's executions. [Learn more about
2841
- * different API modes](/docs/admin).
2891
+ * query params to filter your results.
2842
2892
  *
2843
2893
  * @param {string} functionId
2844
2894
  * @param {string[]} queries
@@ -2932,6 +2982,30 @@ declare module "node-appwrite" {
2932
2982
  */
2933
2983
  deleteVariable(functionId: string, variableId: string): Promise<Response>;
2934
2984
  }
2985
+ export class Graphql extends Service {
2986
+ constructor(client: Client);
2987
+
2988
+ /**
2989
+ * GraphQL Endpoint
2990
+ *
2991
+ * Execute a GraphQL mutation.
2992
+ *
2993
+ * @param {object} query
2994
+ * @throws {AppwriteException}
2995
+ * @returns {Promise}
2996
+ */
2997
+ query(query: object): Promise<Response>;
2998
+ /**
2999
+ * GraphQL Endpoint
3000
+ *
3001
+ * Execute a GraphQL mutation.
3002
+ *
3003
+ * @param {object} query
3004
+ * @throws {AppwriteException}
3005
+ * @returns {Promise}
3006
+ */
3007
+ mutation(query: object): Promise<Response>;
3008
+ }
2935
3009
  export class Health extends Service {
2936
3010
  constructor(client: Client);
2937
3011
 
@@ -3192,8 +3266,7 @@ declare module "node-appwrite" {
3192
3266
  * List Files
3193
3267
  *
3194
3268
  * Get a list of all the user files. You can use the query params to filter
3195
- * your results. On admin mode, this endpoint will return a list of all of the
3196
- * project's files. [Learn more about different API modes](/docs/admin).
3269
+ * your results.
3197
3270
  *
3198
3271
  * @param {string} bucketId
3199
3272
  * @param {string[]} queries
@@ -3329,10 +3402,7 @@ declare module "node-appwrite" {
3329
3402
  * List Teams
3330
3403
  *
3331
3404
  * Get a list of all the teams in which the current user is a member. You can
3332
- * use the parameters to filter your results.
3333
- *
3334
- * In admin mode, this endpoint returns a list of all the teams in the current
3335
- * project. [Learn more about different API modes](/docs/admin).
3405
+ * use the parameters to filter your results.
3336
3406
  *
3337
3407
  * @param {string[]} queries
3338
3408
  * @param {string} search
@@ -3439,7 +3509,7 @@ declare module "node-appwrite" {
3439
3509
  * @throws {AppwriteException}
3440
3510
  * @returns {Promise}
3441
3511
  */
3442
- getMembership(teamId: string, membershipId: string): Promise<Models.MembershipList>;
3512
+ getMembership(teamId: string, membershipId: string): Promise<Models.Membership>;
3443
3513
  /**
3444
3514
  * Update Membership Roles
3445
3515
  *
package/index.js CHANGED
@@ -9,6 +9,7 @@ const Account = require('./lib/services/account.js');
9
9
  const Avatars = require('./lib/services/avatars.js');
10
10
  const Databases = require('./lib/services/databases.js');
11
11
  const Functions = require('./lib/services/functions.js');
12
+ const Graphql = require('./lib/services/graphql.js');
12
13
  const Health = require('./lib/services/health.js');
13
14
  const Locale = require('./lib/services/locale.js');
14
15
  const Storage = require('./lib/services/storage.js');
@@ -27,6 +28,7 @@ module.exports = {
27
28
  Avatars,
28
29
  Databases,
29
30
  Functions,
31
+ Graphql,
30
32
  Health,
31
33
  Locale,
32
34
  Storage,
package/lib/client.js CHANGED
@@ -13,7 +13,7 @@ class Client {
13
13
  'x-sdk-name': 'Node.js',
14
14
  'x-sdk-platform': 'server',
15
15
  'x-sdk-language': 'nodejs',
16
- 'x-sdk-version': '8.0.0',
16
+ 'x-sdk-version': '8.2.0',
17
17
  'X-Appwrite-Response-Format' : '1.0.0',
18
18
  };
19
19
  this.selfSigned = false;
package/lib/role.js CHANGED
@@ -26,9 +26,6 @@ class Role {
26
26
  static member = (id) => {
27
27
  return 'member:' + id
28
28
  }
29
- static status = (status) => {
30
- return 'status:' + status
31
- }
32
29
  }
33
30
 
34
31
  module.exports = Role;
@@ -32,7 +32,7 @@ class Account extends Service {
32
32
  }
33
33
 
34
34
  /**
35
- * Update Account Email
35
+ * Update Email
36
36
  *
37
37
  * Update currently logged in user account email address. After changing user
38
38
  * address, the user confirmation status will get reset. A new confirmation
@@ -74,7 +74,7 @@ class Account extends Service {
74
74
  }
75
75
 
76
76
  /**
77
- * List Account Logs
77
+ * List Logs
78
78
  *
79
79
  * Get currently logged in user list of latest security activity logs. Each
80
80
  * log returns user IP address, location and date and time of log.
@@ -97,7 +97,7 @@ class Account extends Service {
97
97
  }
98
98
 
99
99
  /**
100
- * Update Account Name
100
+ * Update Name
101
101
  *
102
102
  * Update currently logged in user account name.
103
103
  *
@@ -123,7 +123,7 @@ class Account extends Service {
123
123
  }
124
124
 
125
125
  /**
126
- * Update Account Password
126
+ * Update Password
127
127
  *
128
128
  * Update currently logged in user password. For validation, user is required
129
129
  * to pass in the new password, and the old password. For users created with
@@ -156,7 +156,7 @@ class Account extends Service {
156
156
  }
157
157
 
158
158
  /**
159
- * Update Account Phone
159
+ * Update Phone
160
160
  *
161
161
  * Update the currently logged in user's phone number. After updating the
162
162
  * phone number, the phone verification status will be reset. A confirmation
@@ -212,7 +212,7 @@ class Account extends Service {
212
212
  }
213
213
 
214
214
  /**
215
- * Update Account Preferences
215
+ * Update Preferences
216
216
  *
217
217
  * Update currently logged in user account preferences. The object you pass is
218
218
  * stored as is, and replaces any previous value. The maximum allowed prefs
@@ -343,7 +343,7 @@ class Account extends Service {
343
343
  }
344
344
 
345
345
  /**
346
- * List Account Sessions
346
+ * List Sessions
347
347
  *
348
348
  * Get currently logged in user list of active sessions across different
349
349
  * devices.
@@ -361,7 +361,7 @@ class Account extends Service {
361
361
  }
362
362
 
363
363
  /**
364
- * Delete All Account Sessions
364
+ * Delete Sessions
365
365
  *
366
366
  * Delete all sessions from the user account and remove any sessions cookies
367
367
  * from the end client.
@@ -379,7 +379,7 @@ class Account extends Service {
379
379
  }
380
380
 
381
381
  /**
382
- * Get Session By ID
382
+ * Get Session
383
383
  *
384
384
  * Use this endpoint to get a logged in user's session using a Session ID.
385
385
  * Inputting 'current' will return the current session being used.
@@ -402,7 +402,7 @@ class Account extends Service {
402
402
  }
403
403
 
404
404
  /**
405
- * Update Session (Refresh Tokens)
405
+ * Update OAuth Session (Refresh Tokens)
406
406
  *
407
407
  * Access tokens have limited lifespan and expire to mitigate security risks.
408
408
  * If session was created using an OAuth provider, this route can be used to
@@ -426,7 +426,7 @@ class Account extends Service {
426
426
  }
427
427
 
428
428
  /**
429
- * Delete Account Session
429
+ * Delete Session
430
430
  *
431
431
  * Use this endpoint to log out the currently logged in user from all their
432
432
  * account sessions across all of their different devices. When using the
@@ -451,7 +451,7 @@ class Account extends Service {
451
451
  }
452
452
 
453
453
  /**
454
- * Update Account Status
454
+ * Update Status
455
455
  *
456
456
  * Block the currently logged in user account. Behind the scene, the user
457
457
  * record is not deleted but permanently blocked from any access. To
@@ -975,9 +975,7 @@ class Databases extends Service {
975
975
  * List Documents
976
976
  *
977
977
  * Get a list of all the user's documents in a given collection. You can use
978
- * the query params to filter your results. On admin mode, this endpoint will
979
- * return a list of all of documents belonging to the provided collectionId.
980
- * [Learn more about different API modes](/docs/admin).
978
+ * the query params to filter your results.
981
979
  *
982
980
  * @param {string} databaseId
983
981
  * @param {string} collectionId
@@ -522,7 +522,7 @@ class Functions extends Service {
522
522
  }
523
523
 
524
524
  /**
525
- * Retry Build
525
+ * Create Build
526
526
  *
527
527
  * @param {string} functionId
528
528
  * @param {string} deploymentId
@@ -530,7 +530,7 @@ class Functions extends Service {
530
530
  * @throws {AppwriteException}
531
531
  * @returns {Promise}
532
532
  */
533
- async retryBuild(functionId, deploymentId, buildId) {
533
+ async createBuild(functionId, deploymentId, buildId) {
534
534
  let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
535
535
  let payload = {};
536
536
  if (typeof functionId === 'undefined') {
@@ -555,9 +555,7 @@ class Functions extends Service {
555
555
  * List Executions
556
556
  *
557
557
  * Get a list of all the current user function execution logs. You can use the
558
- * query params to filter your results. On admin mode, this endpoint will
559
- * return a list of all of the project's executions. [Learn more about
560
- * different API modes](/docs/admin).
558
+ * query params to filter your results.
561
559
  *
562
560
  * @param {string} functionId
563
561
  * @param {string[]} queries
@@ -0,0 +1,72 @@
1
+ const Service = require('../service.js');
2
+ const AppwriteException = require('../exception.js');
3
+ const InputFile = require('../inputFile.js');
4
+ const client = require('../client.js');
5
+ const Stream = require('stream');
6
+ const { promisify } = require('util');
7
+ const fs = require('fs');
8
+
9
+ class Graphql extends Service {
10
+
11
+ constructor(client)
12
+ {
13
+ super(client);
14
+ }
15
+
16
+
17
+ /**
18
+ * GraphQL Endpoint
19
+ *
20
+ * Execute a GraphQL mutation.
21
+ *
22
+ * @param {object} query
23
+ * @throws {AppwriteException}
24
+ * @returns {Promise}
25
+ */
26
+ async query(query) {
27
+ let path = '/graphql';
28
+ let payload = {};
29
+ if (typeof query === 'undefined') {
30
+ throw new AppwriteException('Missing required parameter: "query"');
31
+ }
32
+
33
+
34
+ if (typeof query !== 'undefined') {
35
+ payload['query'] = query;
36
+ }
37
+
38
+ return await this.client.call('post', path, {
39
+ 'x-sdk-graphql': 'true',
40
+ 'content-type': 'application/json',
41
+ }, payload);
42
+ }
43
+
44
+ /**
45
+ * GraphQL Endpoint
46
+ *
47
+ * Execute a GraphQL mutation.
48
+ *
49
+ * @param {object} query
50
+ * @throws {AppwriteException}
51
+ * @returns {Promise}
52
+ */
53
+ async mutation(query) {
54
+ let path = '/graphql/mutation';
55
+ let payload = {};
56
+ if (typeof query === 'undefined') {
57
+ throw new AppwriteException('Missing required parameter: "query"');
58
+ }
59
+
60
+
61
+ if (typeof query !== 'undefined') {
62
+ payload['query'] = query;
63
+ }
64
+
65
+ return await this.client.call('post', path, {
66
+ 'x-sdk-graphql': 'true',
67
+ 'content-type': 'application/json',
68
+ }, payload);
69
+ }
70
+ }
71
+
72
+ module.exports = Graphql;
@@ -237,8 +237,7 @@ class Storage extends Service {
237
237
  * List Files
238
238
  *
239
239
  * Get a list of all the user files. You can use the query params to filter
240
- * your results. On admin mode, this endpoint will return a list of all of the
241
- * project's files. [Learn more about different API modes](/docs/admin).
240
+ * your results.
242
241
  *
243
242
  * @param {string} bucketId
244
243
  * @param {string[]} queries
@@ -18,10 +18,7 @@ class Teams extends Service {
18
18
  * List Teams
19
19
  *
20
20
  * Get a list of all the teams in which the current user is a member. You can
21
- * use the parameters to filter your results.
22
- *
23
- * In admin mode, this endpoint returns a list of all the teams in the current
24
- * project. [Learn more about different API modes](/docs/admin).
21
+ * use the parameters to filter your results.
25
22
  *
26
23
  * @param {string[]} queries
27
24
  * @param {string} search
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "node-appwrite",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "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": "8.0.0",
5
+ "version": "8.2.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "./index.js",
8
8
  "types": "./index.d.ts",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "devDependencies": {},
14
14
  "dependencies": {
15
- "axios": "^0.27.2",
15
+ "axios": "^1.1.2",
16
16
  "form-data": "^4.0.0"
17
17
  }
18
18
  }
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const 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
- const promise = account.getLogs();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const 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
- const promise = account.getSessions();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const locale = new sdk.Locale(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 = locale.getContinents();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const locale = new sdk.Locale(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 = locale.getCountriesEU();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const locale = new sdk.Locale(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 = locale.getCountriesPhones();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const locale = new sdk.Locale(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 = locale.getCountries();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const teams = new sdk.Teams(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 = teams.getMemberships('[TEAM_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const 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
- const promise = users.getLogs('[USER_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const 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
- const promise = users.getMemberships('[USER_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const 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
- const promise = users.getSessions('[USER_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });