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.
- package/LICENSE +1 -1
- package/README.md +6 -6
- package/docs/examples/database/create-boolean-attribute.md +20 -0
- package/docs/examples/database/create-collection.md +1 -1
- package/docs/examples/database/create-document.md +1 -1
- package/docs/examples/database/create-email-attribute.md +20 -0
- package/docs/examples/database/create-enum-attribute.md +20 -0
- package/docs/examples/database/create-float-attribute.md +20 -0
- package/docs/examples/database/create-index.md +20 -0
- package/docs/examples/database/create-integer-attribute.md +20 -0
- package/docs/examples/database/create-ip-attribute.md +20 -0
- package/docs/examples/database/create-string-attribute.md +20 -0
- package/docs/examples/database/create-url-attribute.md +20 -0
- package/docs/examples/database/delete-attribute.md +20 -0
- package/docs/examples/database/delete-index.md +20 -0
- package/docs/examples/database/get-attribute.md +20 -0
- package/docs/examples/database/get-index.md +20 -0
- package/docs/examples/database/list-attributes.md +20 -0
- package/docs/examples/database/list-indexes.md +20 -0
- package/docs/examples/database/update-collection.md +1 -1
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/{health/get-queue-tasks.md → functions/list-runtimes.md} +2 -2
- package/docs/examples/health/{get-anti-virus.md → get-antivirus.md} +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/teams/create.md +1 -1
- package/docs/examples/teams/get-membership.md +20 -0
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/update-status.md +1 -1
- package/index.d.ts +1667 -246
- package/index.js +3 -1
- package/lib/client.js +3 -3
- package/lib/query.js +36 -0
- package/lib/services/account.js +19 -6
- package/lib/services/database.js +706 -47
- package/lib/services/functions.js +63 -12
- package/lib/services/health.js +4 -22
- package/lib/services/storage.js +21 -2
- package/lib/services/teams.js +89 -30
- package/lib/services/users.js +37 -7
- 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://
|
|
9
|
+
this.endpoint = 'https://HOSTNAME/v1';
|
|
10
10
|
this.headers = {
|
|
11
11
|
'content-type': '',
|
|
12
|
-
'x-sdk-version': 'appwrite:nodejs:
|
|
13
|
-
'X-Appwrite-Response-Format' : '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;
|
package/lib/services/account.js
CHANGED
|
@@ -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
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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.
|
|
182
|
-
*
|
|
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}
|