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/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
@@ -9,11 +9,12 @@ class Client {
9
9
  constructor() {
10
10
  this.endpoint = 'https://HOSTNAME/v1';
11
11
  this.headers = {
12
+ 'accept-encoding': '*',
12
13
  'content-type': '',
13
14
  'x-sdk-name': 'Node.js',
14
15
  'x-sdk-platform': 'server',
15
16
  'x-sdk-language': 'nodejs',
16
- 'x-sdk-version': '8.1.0',
17
+ 'x-sdk-version': '9.0.0',
17
18
  'X-Appwrite-Response-Format' : '1.0.0',
18
19
  };
19
20
  this.selfSigned = false;
package/lib/inputFile.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const { Readable } = require('stream');
2
2
  const fs = require('fs');
3
- const { promisify } = require('util');
4
3
 
5
4
  class InputFile {
6
5
  stream; // Content of file, readable stream
@@ -14,16 +13,15 @@ class InputFile {
14
13
  };
15
14
 
16
15
  static fromBuffer = (buffer, filename) => {
17
- const stream = Readable.from(buffer.toString());
16
+ const stream = Readable.from(buffer);
18
17
  const size = Buffer.byteLength(buffer);
19
18
  return new InputFile(stream, filename, size);
20
19
  };
21
20
 
22
- static fromBlob = (blob, filename) => {
23
- const buffer = blob.arrayBuffer();
24
- const stream = Readable.from(buffer.toString());
25
- const size = Buffer.byteLength(buffer);
26
- return new InputFile(stream, filename);
21
+ static fromBlob = async (blob, filename) => {
22
+ const arrayBuffer = await blob.arrayBuffer();
23
+ const buffer = Buffer.from(arrayBuffer);
24
+ return InputFile.fromBuffer(buffer, filename);
27
25
  };
28
26
 
29
27
  static fromStream = (stream, filename, size) => {
@@ -32,7 +30,7 @@ class InputFile {
32
30
 
33
31
  static fromPlainText = (content, filename) => {
34
32
  const buffer = Buffer.from(content, "utf-8");
35
- const stream = Readable.from(buffer.toString());
33
+ const stream = Readable.from(buffer);
36
34
  const size = Buffer.byteLength(buffer);
37
35
  return new InputFile(stream, filename, size);
38
36
  };
package/lib/query.js CHANGED
@@ -17,6 +17,24 @@ class Query {
17
17
  static greaterThanEqual = (attribute, value) =>
18
18
  Query.addQuery(attribute, "greaterThanEqual", value);
19
19
 
20
+ static isNull = (attribute) =>
21
+ `isNull("${attribute}")`;
22
+
23
+ static isNotNull = (attribute) =>
24
+ `isNotNull("${attribute}")`;
25
+
26
+ static between = (attribute, start, end) =>
27
+ Query.addQuery(attribute, "between", [start, end]);
28
+
29
+ static startsWith = (attribute, value) =>
30
+ Query.addQuery(attribute, "startsWith", value);
31
+
32
+ static endsWith = (attribute, value) =>
33
+ Query.addQuery(attribute, "endsWith", value);
34
+
35
+ static select = (attributes) =>
36
+ `select([${attributes.map((attr) => `"${attr}"`).join(",")}])`;
37
+
20
38
  static search = (attribute, value) =>
21
39
  Query.addQuery(attribute, "search", value);
22
40
 
@@ -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