node-appwrite 2.5.1 → 4.0.2

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 (40) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -6
  3. package/docs/examples/database/create-boolean-attribute.md +20 -0
  4. package/docs/examples/database/create-collection.md +1 -1
  5. package/docs/examples/database/create-document.md +1 -1
  6. package/docs/examples/database/create-email-attribute.md +20 -0
  7. package/docs/examples/database/create-enum-attribute.md +20 -0
  8. package/docs/examples/database/create-float-attribute.md +20 -0
  9. package/docs/examples/database/create-index.md +20 -0
  10. package/docs/examples/database/create-integer-attribute.md +20 -0
  11. package/docs/examples/database/create-ip-attribute.md +20 -0
  12. package/docs/examples/database/create-string-attribute.md +20 -0
  13. package/docs/examples/database/create-url-attribute.md +20 -0
  14. package/docs/examples/database/delete-attribute.md +20 -0
  15. package/docs/examples/database/delete-index.md +20 -0
  16. package/docs/examples/database/get-attribute.md +20 -0
  17. package/docs/examples/database/get-index.md +20 -0
  18. package/docs/examples/database/list-attributes.md +20 -0
  19. package/docs/examples/database/list-indexes.md +20 -0
  20. package/docs/examples/database/update-collection.md +1 -1
  21. package/docs/examples/functions/create.md +1 -1
  22. package/docs/examples/{health/get-queue-tasks.md → functions/list-runtimes.md} +2 -2
  23. package/docs/examples/health/{get-anti-virus.md → get-antivirus.md} +1 -1
  24. package/docs/examples/storage/create-file.md +1 -1
  25. package/docs/examples/teams/create.md +1 -1
  26. package/docs/examples/teams/get-membership.md +20 -0
  27. package/docs/examples/users/create.md +1 -1
  28. package/docs/examples/users/update-status.md +1 -1
  29. package/index.d.ts +1667 -246
  30. package/index.js +3 -1
  31. package/lib/client.js +3 -3
  32. package/lib/query.js +36 -0
  33. package/lib/services/account.js +19 -6
  34. package/lib/services/database.js +706 -47
  35. package/lib/services/functions.js +63 -12
  36. package/lib/services/health.js +4 -22
  37. package/lib/services/storage.js +21 -2
  38. package/lib/services/teams.js +89 -30
  39. package/lib/services/users.js +37 -7
  40. package/package.json +2 -2
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const Client = require('./lib/client.js');
2
+ const Query = require('./lib/query.js');
2
3
  const AppwriteException = require('./lib/exception.js');
3
4
  const Account = require('./lib/services/account.js');
4
5
  const Avatars = require('./lib/services/avatars.js');
@@ -12,6 +13,7 @@ const Users = require('./lib/services/users.js');
12
13
 
13
14
  module.exports = {
14
15
  Client,
16
+ Query,
15
17
  AppwriteException,
16
18
  Account,
17
19
  Avatars,
@@ -22,4 +24,4 @@ module.exports = {
22
24
  Storage,
23
25
  Teams,
24
26
  Users,
25
- };
27
+ };
package/lib/client.js CHANGED
@@ -6,11 +6,11 @@ const AppwriteException = require('./exception.js');
6
6
  class Client {
7
7
 
8
8
  constructor() {
9
- this.endpoint = 'https://appwrite.io/v1';
9
+ this.endpoint = 'https://HOSTNAME/v1';
10
10
  this.headers = {
11
11
  'content-type': '',
12
- 'x-sdk-version': 'appwrite:nodejs:2.5.1',
13
- 'X-Appwrite-Response-Format' : '0.11.0',
12
+ 'x-sdk-version': 'appwrite:nodejs:4.0.2',
13
+ 'X-Appwrite-Response-Format' : '0.12.0',
14
14
  };
15
15
  this.selfSigned = false;
16
16
  }
package/lib/query.js ADDED
@@ -0,0 +1,36 @@
1
+ class Query {
2
+ static equal = (attribute, value) =>
3
+ Query.addQuery(attribute, "equal", value);
4
+
5
+ static notEqual = (attribute, value) =>
6
+ Query.addQuery(attribute, "notEqual", value);
7
+
8
+ static lesser = (attribute, value) =>
9
+ Query.addQuery(attribute, "lesser", value);
10
+
11
+ static lesserEqual = (attribute, value) =>
12
+ Query.addQuery(attribute, "lesserEqual", value);
13
+
14
+ static greater = (attribute, value) =>
15
+ Query.addQuery(attribute, "greater", value);
16
+
17
+ static greaterEqual = (attribute, value) =>
18
+ Query.addQuery(attribute, "greaterEqual", value);
19
+
20
+ static search = (attribute, value) =>
21
+ Query.addQuery(attribute, "search", value);
22
+
23
+ static addQuery = (attribute, oper, value) =>
24
+ value instanceof Array
25
+ ? `${attribute}.${oper}(${value
26
+ .map((v) => Query.parseValues(v))
27
+ .join(",")})`
28
+ : `${attribute}.${oper}(${Query.parseValues(value)})`;
29
+
30
+ static parseValues = (value) =>
31
+ typeof value === "string" || value instanceof String
32
+ ? `"${value}"`
33
+ : `${value}`;
34
+ }
35
+
36
+ module.exports = Query;
@@ -45,11 +45,13 @@ class Account extends Service {
45
45
  * Update Account Email
46
46
  *
47
47
  * Update currently logged in user account email address. After changing user
48
- * address, user confirmation status is being reset and a new confirmation
49
- * mail is sent. For security measures, user password is required to complete
50
- * this request.
48
+ * address, the user confirmation status will get reset. A new confirmation
49
+ * email is not sent automatically however you can use the send confirmation
50
+ * email endpoint again to send the confirmation email. For security measures,
51
+ * user password is required to complete this request.
51
52
  * This endpoint can also be used to convert an anonymous account to a normal
52
53
  * one, by passing an email address and a new password.
54
+ *
53
55
  *
54
56
  * @param {string} email
55
57
  * @param {string} password
@@ -87,13 +89,23 @@ class Account extends Service {
87
89
  * Get currently logged in user list of latest security activity logs. Each
88
90
  * log returns user IP address, location and date and time of log.
89
91
  *
92
+ * @param {number} limit
93
+ * @param {number} offset
90
94
  * @throws {AppwriteException}
91
95
  * @returns {Promise}
92
96
  */
93
- async getLogs() {
97
+ async getLogs(limit, offset) {
94
98
  let path = '/account/logs';
95
99
  let payload = {};
96
100
 
101
+ if (typeof limit !== 'undefined') {
102
+ payload['limit'] = limit;
103
+ }
104
+
105
+ if (typeof offset !== 'undefined') {
106
+ payload['offset'] = offset;
107
+ }
108
+
97
109
  return await this.client.call('get', path, {
98
110
  'content-type': 'application/json',
99
111
  }, payload);
@@ -178,8 +190,9 @@ class Account extends Service {
178
190
  /**
179
191
  * Update Account Preferences
180
192
  *
181
- * Update currently logged in user account preferences. You can pass only the
182
- * specific settings you wish to update.
193
+ * Update currently logged in user account preferences. The object you pass is
194
+ * stored as is, and replaces any previous value. The maximum allowed prefs
195
+ * size is 64kB and throws error if exceeded.
183
196
  *
184
197
  * @param {object} prefs
185
198
  * @throws {AppwriteException}