node-appwrite 4.0.0 → 5.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.
- package/README.md +2 -2
- package/docs/examples/account/update-session.md +20 -0
- package/docs/examples/functions/{create-tag.md → create-deployment.md} +1 -1
- package/docs/examples/functions/{delete-tag.md → delete-deployment.md} +1 -1
- package/docs/examples/functions/{update-tag.md → get-deployment.md} +1 -1
- package/docs/examples/functions/{list-tags.md → list-deployments.md} +1 -1
- package/docs/examples/functions/retry-build.md +20 -0
- package/docs/examples/functions/{get-tag.md → update-deployment.md} +1 -1
- package/docs/examples/storage/create-bucket.md +20 -0
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/delete-bucket.md +20 -0
- package/docs/examples/storage/delete-file.md +1 -1
- package/docs/examples/storage/get-bucket.md +20 -0
- package/docs/examples/storage/get-file-download.md +1 -1
- package/docs/examples/storage/get-file-preview.md +1 -1
- package/docs/examples/storage/get-file-view.md +1 -1
- package/docs/examples/storage/get-file.md +1 -1
- package/docs/examples/storage/list-buckets.md +20 -0
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +20 -0
- package/docs/examples/storage/update-file.md +1 -1
- package/index.d.ts +411 -151
- package/index.js +3 -1
- package/lib/client.js +7 -5
- package/lib/exception.js +2 -1
- package/lib/query.js +2 -0
- package/lib/services/account.js +28 -3
- package/lib/services/avatars.js +3 -0
- package/lib/services/database.js +6 -3
- package/lib/services/functions.js +207 -116
- package/lib/services/health.js +3 -0
- package/lib/services/locale.js +3 -0
- package/lib/services/storage.js +379 -33
- package/lib/services/teams.js +7 -0
- package/lib/services/users.js +6 -2
- 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
|
@@ -4,13 +4,14 @@ const FormData = require('form-data');
|
|
|
4
4
|
const AppwriteException = require('./exception.js');
|
|
5
5
|
|
|
6
6
|
class Client {
|
|
7
|
+
static CHUNK_SIZE = 5*1024*1024; // 5MB
|
|
7
8
|
|
|
8
9
|
constructor() {
|
|
9
10
|
this.endpoint = 'https://HOSTNAME/v1';
|
|
10
11
|
this.headers = {
|
|
11
12
|
'content-type': '',
|
|
12
|
-
'x-sdk-version': 'appwrite:nodejs:
|
|
13
|
-
'X-Appwrite-Response-Format' : '0.
|
|
13
|
+
'x-sdk-version': 'appwrite:nodejs:5.0.0',
|
|
14
|
+
'X-Appwrite-Response-Format' : '0.13.0',
|
|
14
15
|
};
|
|
15
16
|
this.selfSigned = false;
|
|
16
17
|
}
|
|
@@ -115,7 +116,8 @@ class Client {
|
|
|
115
116
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
|
|
120
|
+
headers = Object.assign({}, this.headers, headers);
|
|
119
121
|
|
|
120
122
|
let contentType = headers['content-type'].toLowerCase();
|
|
121
123
|
|
|
@@ -155,9 +157,9 @@ class Client {
|
|
|
155
157
|
if('response' in error && error.response !== undefined) {
|
|
156
158
|
if(error.response && 'data' in error.response) {
|
|
157
159
|
if (typeof(error.response.data) === 'string') {
|
|
158
|
-
throw new AppwriteException(error.response.data, error.response.status, error.response.data);
|
|
160
|
+
throw new AppwriteException(error.response.data, error.response.status, '', error.response.data);
|
|
159
161
|
} else {
|
|
160
|
-
throw new AppwriteException(error.response.data.message, error.response.status, error.response.data);
|
|
162
|
+
throw new AppwriteException(error.response.data.message, error.response.status, error.response.data.type, error.response.data);
|
|
161
163
|
}
|
|
162
164
|
} else {
|
|
163
165
|
throw new AppwriteException(error.response.statusText, error.response.status, error.response.data);
|
package/lib/exception.js
CHANGED
package/lib/query.js
CHANGED
package/lib/services/account.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const Service = require('../service.js');
|
|
2
2
|
const AppwriteException = require('../exception.js');
|
|
3
|
+
const client = require('../client.js');
|
|
4
|
+
const { promisify } = require('util');
|
|
5
|
+
const fs = require('fs');
|
|
3
6
|
|
|
4
7
|
class Account extends Service {
|
|
5
8
|
|
|
@@ -190,8 +193,9 @@ class Account extends Service {
|
|
|
190
193
|
/**
|
|
191
194
|
* Update Account Preferences
|
|
192
195
|
*
|
|
193
|
-
* Update currently logged in user account preferences.
|
|
194
|
-
*
|
|
196
|
+
* Update currently logged in user account preferences. The object you pass is
|
|
197
|
+
* stored as is, and replaces any previous value. The maximum allowed prefs
|
|
198
|
+
* size is 64kB and throws error if exceeded.
|
|
195
199
|
*
|
|
196
200
|
* @param {object} prefs
|
|
197
201
|
* @throws {AppwriteException}
|
|
@@ -376,12 +380,33 @@ class Account extends Service {
|
|
|
376
380
|
}, payload);
|
|
377
381
|
}
|
|
378
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Update Session (Refresh Tokens)
|
|
385
|
+
*
|
|
386
|
+
* @param {string} sessionId
|
|
387
|
+
* @throws {AppwriteException}
|
|
388
|
+
* @returns {Promise}
|
|
389
|
+
*/
|
|
390
|
+
async updateSession(sessionId) {
|
|
391
|
+
if (typeof sessionId === 'undefined') {
|
|
392
|
+
throw new AppwriteException('Missing required parameter: "sessionId"');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
396
|
+
let payload = {};
|
|
397
|
+
|
|
398
|
+
return await this.client.call('patch', path, {
|
|
399
|
+
'content-type': 'application/json',
|
|
400
|
+
}, payload);
|
|
401
|
+
}
|
|
402
|
+
|
|
379
403
|
/**
|
|
380
404
|
* Delete Account Session
|
|
381
405
|
*
|
|
382
406
|
* Use this endpoint to log out the currently logged in user from all their
|
|
383
407
|
* account sessions across all of their different devices. When using the
|
|
384
|
-
*
|
|
408
|
+
* Session ID argument, only the unique session ID provided is deleted.
|
|
409
|
+
*
|
|
385
410
|
*
|
|
386
411
|
* @param {string} sessionId
|
|
387
412
|
* @throws {AppwriteException}
|
package/lib/services/avatars.js
CHANGED
package/lib/services/database.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const Service = require('../service.js');
|
|
2
2
|
const AppwriteException = require('../exception.js');
|
|
3
|
+
const client = require('../client.js');
|
|
4
|
+
const { promisify } = require('util');
|
|
5
|
+
const fs = require('fs');
|
|
3
6
|
|
|
4
7
|
class Database extends Service {
|
|
5
8
|
|
|
@@ -405,9 +408,9 @@ class Database extends Service {
|
|
|
405
408
|
* @param {string} collectionId
|
|
406
409
|
* @param {string} key
|
|
407
410
|
* @param {boolean} required
|
|
408
|
-
* @param {
|
|
409
|
-
* @param {
|
|
410
|
-
* @param {
|
|
411
|
+
* @param {number} min
|
|
412
|
+
* @param {number} max
|
|
413
|
+
* @param {number} xdefault
|
|
411
414
|
* @param {boolean} array
|
|
412
415
|
* @throws {AppwriteException}
|
|
413
416
|
* @returns {Promise}
|