node-appwrite 8.2.0 → 10.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/LICENSE +1 -1
- package/README.md +2 -2
- package/docs/examples/account/create-phone-verification.md +1 -1
- package/docs/examples/account/create-recovery.md +1 -1
- package/docs/examples/account/create-verification.md +1 -1
- package/docs/examples/account/delete-identity.md +20 -0
- package/docs/examples/account/delete-session.md +1 -1
- package/docs/examples/account/delete-sessions.md +1 -1
- package/docs/examples/account/get-prefs.md +1 -1
- package/docs/examples/account/get-session.md +1 -1
- package/docs/examples/account/get.md +1 -1
- package/docs/examples/account/list-identities.md +20 -0
- package/docs/examples/account/list-logs.md +1 -1
- package/docs/examples/account/list-sessions.md +1 -1
- package/docs/examples/account/update-email.md +1 -1
- package/docs/examples/account/update-name.md +1 -1
- package/docs/examples/account/update-password.md +2 -2
- package/docs/examples/account/update-phone-verification.md +1 -1
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/account/update-prefs.md +1 -1
- package/docs/examples/account/update-recovery.md +1 -1
- package/docs/examples/account/update-session.md +1 -1
- package/docs/examples/account/update-status.md +1 -1
- package/docs/examples/account/update-verification.md +1 -1
- package/docs/examples/avatars/get-browser.md +1 -1
- package/docs/examples/avatars/get-credit-card.md +1 -1
- package/docs/examples/avatars/get-favicon.md +1 -1
- package/docs/examples/avatars/get-flag.md +1 -1
- package/docs/examples/avatars/get-image.md +1 -1
- package/docs/examples/avatars/get-initials.md +1 -1
- package/docs/examples/avatars/get-q-r.md +1 -1
- package/docs/examples/databases/create-boolean-attribute.md +1 -1
- package/docs/examples/databases/create-collection.md +1 -1
- package/docs/examples/databases/create-datetime-attribute.md +1 -1
- package/docs/examples/databases/create-document.md +1 -1
- package/docs/examples/databases/create-email-attribute.md +1 -1
- package/docs/examples/databases/create-enum-attribute.md +1 -1
- package/docs/examples/databases/create-float-attribute.md +1 -1
- package/docs/examples/databases/create-index.md +1 -1
- package/docs/examples/databases/create-integer-attribute.md +1 -1
- package/docs/examples/databases/create-ip-attribute.md +1 -1
- package/docs/examples/databases/create-relationship-attribute.md +20 -0
- package/docs/examples/databases/create-string-attribute.md +1 -1
- package/docs/examples/databases/create-url-attribute.md +1 -1
- package/docs/examples/databases/create.md +1 -1
- package/docs/examples/databases/delete-attribute.md +1 -1
- package/docs/examples/databases/delete-collection.md +1 -1
- package/docs/examples/databases/delete-document.md +1 -1
- package/docs/examples/databases/delete-index.md +1 -1
- package/docs/examples/databases/delete.md +1 -1
- package/docs/examples/databases/get-attribute.md +1 -1
- package/docs/examples/databases/get-collection.md +1 -1
- package/docs/examples/databases/get-document.md +1 -1
- package/docs/examples/databases/get-index.md +1 -1
- package/docs/examples/databases/get.md +1 -1
- package/docs/examples/databases/list-attributes.md +1 -1
- package/docs/examples/databases/list-collections.md +1 -1
- package/docs/examples/databases/list-documents.md +1 -1
- package/docs/examples/databases/list-indexes.md +1 -1
- package/docs/examples/databases/list.md +1 -1
- package/docs/examples/databases/update-boolean-attribute.md +20 -0
- package/docs/examples/databases/update-collection.md +1 -1
- package/docs/examples/databases/update-datetime-attribute.md +20 -0
- package/docs/examples/databases/update-document.md +1 -1
- package/docs/examples/databases/update-email-attribute.md +20 -0
- package/docs/examples/databases/update-enum-attribute.md +20 -0
- package/docs/examples/databases/update-float-attribute.md +20 -0
- package/docs/examples/databases/update-integer-attribute.md +20 -0
- package/docs/examples/databases/update-ip-attribute.md +20 -0
- package/docs/examples/databases/update-relationship-attribute.md +20 -0
- package/docs/examples/databases/update-string-attribute.md +20 -0
- package/docs/examples/databases/update-url-attribute.md +20 -0
- package/docs/examples/databases/update.md +1 -1
- package/docs/examples/functions/create-build.md +1 -1
- package/docs/examples/functions/create-deployment.md +2 -2
- package/docs/examples/functions/create-execution.md +1 -1
- package/docs/examples/functions/create-variable.md +1 -1
- package/docs/examples/functions/create.md +2 -2
- package/docs/examples/functions/delete-deployment.md +1 -1
- package/docs/examples/functions/delete-variable.md +1 -1
- package/docs/examples/functions/delete.md +1 -1
- package/docs/examples/functions/download-deployment.md +20 -0
- package/docs/examples/functions/get-deployment.md +1 -1
- package/docs/examples/functions/get-execution.md +1 -1
- package/docs/examples/functions/get-variable.md +1 -1
- package/docs/examples/functions/get.md +1 -1
- package/docs/examples/functions/list-deployments.md +1 -1
- package/docs/examples/functions/list-executions.md +1 -1
- package/docs/examples/functions/list-runtimes.md +1 -1
- package/docs/examples/functions/list-variables.md +1 -1
- package/docs/examples/functions/list.md +1 -1
- package/docs/examples/functions/update-deployment.md +1 -1
- package/docs/examples/functions/update-variable.md +1 -1
- package/docs/examples/functions/update.md +2 -2
- package/docs/examples/graphql/mutation.md +1 -1
- package/docs/examples/graphql/query.md +1 -1
- package/docs/examples/health/get-antivirus.md +1 -1
- package/docs/examples/health/get-cache.md +1 -1
- package/docs/examples/health/get-d-b.md +1 -1
- package/docs/examples/health/get-pub-sub.md +20 -0
- package/docs/examples/health/get-queue-certificates.md +1 -1
- package/docs/examples/health/get-queue-functions.md +1 -1
- package/docs/examples/health/get-queue-logs.md +1 -1
- package/docs/examples/health/get-queue-webhooks.md +1 -1
- package/docs/examples/health/get-queue.md +20 -0
- package/docs/examples/health/get-storage-local.md +1 -1
- package/docs/examples/health/get-time.md +1 -1
- package/docs/examples/health/get.md +1 -1
- package/docs/examples/locale/get.md +1 -1
- package/docs/examples/locale/list-codes.md +20 -0
- package/docs/examples/locale/list-continents.md +1 -1
- package/docs/examples/locale/list-countries-e-u.md +1 -1
- package/docs/examples/locale/list-countries-phones.md +1 -1
- package/docs/examples/locale/list-countries.md +1 -1
- package/docs/examples/locale/list-currencies.md +1 -1
- package/docs/examples/locale/list-languages.md +1 -1
- package/docs/examples/storage/create-bucket.md +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/delete-bucket.md +1 -1
- package/docs/examples/storage/delete-file.md +1 -1
- package/docs/examples/storage/get-bucket.md +1 -1
- 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 +1 -1
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +1 -1
- package/docs/examples/storage/update-file.md +1 -1
- package/docs/examples/teams/create-membership.md +2 -2
- package/docs/examples/teams/create.md +1 -1
- package/docs/examples/teams/delete-membership.md +1 -1
- package/docs/examples/teams/delete.md +1 -1
- package/docs/examples/teams/get-membership.md +1 -1
- package/docs/examples/teams/get-prefs.md +20 -0
- package/docs/examples/teams/get.md +1 -1
- package/docs/examples/teams/list-memberships.md +1 -1
- package/docs/examples/teams/list.md +1 -1
- package/docs/examples/teams/update-membership-status.md +1 -1
- package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
- package/docs/examples/teams/{update.md → update-name.md} +2 -2
- package/docs/examples/teams/update-prefs.md +20 -0
- package/docs/examples/users/create-argon2user.md +1 -1
- package/docs/examples/users/create-bcrypt-user.md +1 -1
- package/docs/examples/users/create-m-d5user.md +1 -1
- package/docs/examples/users/create-p-h-pass-user.md +1 -1
- package/docs/examples/users/create-s-h-a-user.md +1 -1
- package/docs/examples/users/create-scrypt-modified-user.md +1 -1
- package/docs/examples/users/create-scrypt-user.md +1 -1
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/delete-identity.md +20 -0
- package/docs/examples/users/delete-session.md +1 -1
- package/docs/examples/users/delete-sessions.md +1 -1
- package/docs/examples/users/delete.md +1 -1
- package/docs/examples/users/get-prefs.md +1 -1
- package/docs/examples/users/get.md +1 -1
- package/docs/examples/users/list-identities.md +20 -0
- package/docs/examples/users/list-logs.md +1 -1
- package/docs/examples/users/list-memberships.md +1 -1
- package/docs/examples/users/list-sessions.md +1 -1
- package/docs/examples/users/list.md +1 -1
- package/docs/examples/users/update-email-verification.md +1 -1
- package/docs/examples/users/update-email.md +1 -1
- package/docs/examples/users/update-labels.md +20 -0
- package/docs/examples/users/update-name.md +1 -1
- package/docs/examples/users/update-password.md +2 -2
- package/docs/examples/users/update-phone-verification.md +1 -1
- package/docs/examples/users/update-phone.md +1 -1
- package/docs/examples/users/update-prefs.md +1 -1
- package/docs/examples/users/update-status.md +1 -1
- package/index.d.ts +767 -165
- package/lib/client.js +5 -2
- package/lib/inputFile.js +6 -8
- package/lib/query.js +18 -0
- package/lib/services/account.js +94 -50
- package/lib/services/avatars.js +14 -14
- package/lib/services/databases.js +826 -180
- package/lib/services/functions.js +254 -101
- package/lib/services/graphql.js +4 -4
- package/lib/services/health.js +57 -22
- package/lib/services/locale.js +32 -14
- package/lib/services/storage.js +76 -63
- package/lib/services/teams.js +112 -43
- package/lib/services/users.js +135 -50
- package/package.json +6 -4
package/lib/services/graphql.js
CHANGED
|
@@ -24,7 +24,7 @@ class Graphql extends Service {
|
|
|
24
24
|
* @returns {Promise}
|
|
25
25
|
*/
|
|
26
26
|
async query(query) {
|
|
27
|
-
|
|
27
|
+
const apiPath = '/graphql';
|
|
28
28
|
let payload = {};
|
|
29
29
|
if (typeof query === 'undefined') {
|
|
30
30
|
throw new AppwriteException('Missing required parameter: "query"');
|
|
@@ -35,7 +35,7 @@ class Graphql extends Service {
|
|
|
35
35
|
payload['query'] = query;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
return await this.client.call('post',
|
|
38
|
+
return await this.client.call('post', apiPath, {
|
|
39
39
|
'x-sdk-graphql': 'true',
|
|
40
40
|
'content-type': 'application/json',
|
|
41
41
|
}, payload);
|
|
@@ -51,7 +51,7 @@ class Graphql extends Service {
|
|
|
51
51
|
* @returns {Promise}
|
|
52
52
|
*/
|
|
53
53
|
async mutation(query) {
|
|
54
|
-
|
|
54
|
+
const apiPath = '/graphql/mutation';
|
|
55
55
|
let payload = {};
|
|
56
56
|
if (typeof query === 'undefined') {
|
|
57
57
|
throw new AppwriteException('Missing required parameter: "query"');
|
|
@@ -62,7 +62,7 @@ class Graphql extends Service {
|
|
|
62
62
|
payload['query'] = query;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
return await this.client.call('post',
|
|
65
|
+
return await this.client.call('post', apiPath, {
|
|
66
66
|
'x-sdk-graphql': 'true',
|
|
67
67
|
'content-type': 'application/json',
|
|
68
68
|
}, payload);
|
package/lib/services/health.js
CHANGED
|
@@ -23,10 +23,10 @@ class Health extends Service {
|
|
|
23
23
|
* @returns {Promise}
|
|
24
24
|
*/
|
|
25
25
|
async get() {
|
|
26
|
-
|
|
26
|
+
const apiPath = '/health';
|
|
27
27
|
let payload = {};
|
|
28
28
|
|
|
29
|
-
return await this.client.call('get',
|
|
29
|
+
return await this.client.call('get', apiPath, {
|
|
30
30
|
'content-type': 'application/json',
|
|
31
31
|
}, payload);
|
|
32
32
|
}
|
|
@@ -40,10 +40,10 @@ class Health extends Service {
|
|
|
40
40
|
* @returns {Promise}
|
|
41
41
|
*/
|
|
42
42
|
async getAntivirus() {
|
|
43
|
-
|
|
43
|
+
const apiPath = '/health/anti-virus';
|
|
44
44
|
let payload = {};
|
|
45
45
|
|
|
46
|
-
return await this.client.call('get',
|
|
46
|
+
return await this.client.call('get', apiPath, {
|
|
47
47
|
'content-type': 'application/json',
|
|
48
48
|
}, payload);
|
|
49
49
|
}
|
|
@@ -51,17 +51,17 @@ class Health extends Service {
|
|
|
51
51
|
/**
|
|
52
52
|
* Get Cache
|
|
53
53
|
*
|
|
54
|
-
* Check the Appwrite in-memory cache
|
|
54
|
+
* Check the Appwrite in-memory cache servers are up and connection is
|
|
55
55
|
* successful.
|
|
56
56
|
*
|
|
57
57
|
* @throws {AppwriteException}
|
|
58
58
|
* @returns {Promise}
|
|
59
59
|
*/
|
|
60
60
|
async getCache() {
|
|
61
|
-
|
|
61
|
+
const apiPath = '/health/cache';
|
|
62
62
|
let payload = {};
|
|
63
63
|
|
|
64
|
-
return await this.client.call('get',
|
|
64
|
+
return await this.client.call('get', apiPath, {
|
|
65
65
|
'content-type': 'application/json',
|
|
66
66
|
}, payload);
|
|
67
67
|
}
|
|
@@ -69,16 +69,51 @@ class Health extends Service {
|
|
|
69
69
|
/**
|
|
70
70
|
* Get DB
|
|
71
71
|
*
|
|
72
|
-
* Check the Appwrite database
|
|
72
|
+
* Check the Appwrite database servers are up and connection is successful.
|
|
73
73
|
*
|
|
74
74
|
* @throws {AppwriteException}
|
|
75
75
|
* @returns {Promise}
|
|
76
76
|
*/
|
|
77
77
|
async getDB() {
|
|
78
|
-
|
|
78
|
+
const apiPath = '/health/db';
|
|
79
79
|
let payload = {};
|
|
80
80
|
|
|
81
|
-
return await this.client.call('get',
|
|
81
|
+
return await this.client.call('get', apiPath, {
|
|
82
|
+
'content-type': 'application/json',
|
|
83
|
+
}, payload);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get PubSub
|
|
88
|
+
*
|
|
89
|
+
* Check the Appwrite pub-sub servers are up and connection is successful.
|
|
90
|
+
*
|
|
91
|
+
* @throws {AppwriteException}
|
|
92
|
+
* @returns {Promise}
|
|
93
|
+
*/
|
|
94
|
+
async getPubSub() {
|
|
95
|
+
const apiPath = '/health/pubsub';
|
|
96
|
+
let payload = {};
|
|
97
|
+
|
|
98
|
+
return await this.client.call('get', apiPath, {
|
|
99
|
+
'content-type': 'application/json',
|
|
100
|
+
}, payload);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get Queue
|
|
105
|
+
*
|
|
106
|
+
* Check the Appwrite queue messaging servers are up and connection is
|
|
107
|
+
* successful.
|
|
108
|
+
*
|
|
109
|
+
* @throws {AppwriteException}
|
|
110
|
+
* @returns {Promise}
|
|
111
|
+
*/
|
|
112
|
+
async getQueue() {
|
|
113
|
+
const apiPath = '/health/queue';
|
|
114
|
+
let payload = {};
|
|
115
|
+
|
|
116
|
+
return await this.client.call('get', apiPath, {
|
|
82
117
|
'content-type': 'application/json',
|
|
83
118
|
}, payload);
|
|
84
119
|
}
|
|
@@ -94,10 +129,10 @@ class Health extends Service {
|
|
|
94
129
|
* @returns {Promise}
|
|
95
130
|
*/
|
|
96
131
|
async getQueueCertificates() {
|
|
97
|
-
|
|
132
|
+
const apiPath = '/health/queue/certificates';
|
|
98
133
|
let payload = {};
|
|
99
134
|
|
|
100
|
-
return await this.client.call('get',
|
|
135
|
+
return await this.client.call('get', apiPath, {
|
|
101
136
|
'content-type': 'application/json',
|
|
102
137
|
}, payload);
|
|
103
138
|
}
|
|
@@ -109,10 +144,10 @@ class Health extends Service {
|
|
|
109
144
|
* @returns {Promise}
|
|
110
145
|
*/
|
|
111
146
|
async getQueueFunctions() {
|
|
112
|
-
|
|
147
|
+
const apiPath = '/health/queue/functions';
|
|
113
148
|
let payload = {};
|
|
114
149
|
|
|
115
|
-
return await this.client.call('get',
|
|
150
|
+
return await this.client.call('get', apiPath, {
|
|
116
151
|
'content-type': 'application/json',
|
|
117
152
|
}, payload);
|
|
118
153
|
}
|
|
@@ -127,10 +162,10 @@ class Health extends Service {
|
|
|
127
162
|
* @returns {Promise}
|
|
128
163
|
*/
|
|
129
164
|
async getQueueLogs() {
|
|
130
|
-
|
|
165
|
+
const apiPath = '/health/queue/logs';
|
|
131
166
|
let payload = {};
|
|
132
167
|
|
|
133
|
-
return await this.client.call('get',
|
|
168
|
+
return await this.client.call('get', apiPath, {
|
|
134
169
|
'content-type': 'application/json',
|
|
135
170
|
}, payload);
|
|
136
171
|
}
|
|
@@ -145,10 +180,10 @@ class Health extends Service {
|
|
|
145
180
|
* @returns {Promise}
|
|
146
181
|
*/
|
|
147
182
|
async getQueueWebhooks() {
|
|
148
|
-
|
|
183
|
+
const apiPath = '/health/queue/webhooks';
|
|
149
184
|
let payload = {};
|
|
150
185
|
|
|
151
|
-
return await this.client.call('get',
|
|
186
|
+
return await this.client.call('get', apiPath, {
|
|
152
187
|
'content-type': 'application/json',
|
|
153
188
|
}, payload);
|
|
154
189
|
}
|
|
@@ -162,10 +197,10 @@ class Health extends Service {
|
|
|
162
197
|
* @returns {Promise}
|
|
163
198
|
*/
|
|
164
199
|
async getStorageLocal() {
|
|
165
|
-
|
|
200
|
+
const apiPath = '/health/storage/local';
|
|
166
201
|
let payload = {};
|
|
167
202
|
|
|
168
|
-
return await this.client.call('get',
|
|
203
|
+
return await this.client.call('get', apiPath, {
|
|
169
204
|
'content-type': 'application/json',
|
|
170
205
|
}, payload);
|
|
171
206
|
}
|
|
@@ -185,10 +220,10 @@ class Health extends Service {
|
|
|
185
220
|
* @returns {Promise}
|
|
186
221
|
*/
|
|
187
222
|
async getTime() {
|
|
188
|
-
|
|
223
|
+
const apiPath = '/health/time';
|
|
189
224
|
let payload = {};
|
|
190
225
|
|
|
191
|
-
return await this.client.call('get',
|
|
226
|
+
return await this.client.call('get', apiPath, {
|
|
192
227
|
'content-type': 'application/json',
|
|
193
228
|
}, payload);
|
|
194
229
|
}
|
package/lib/services/locale.js
CHANGED
|
@@ -28,10 +28,28 @@ class Locale extends Service {
|
|
|
28
28
|
* @returns {Promise}
|
|
29
29
|
*/
|
|
30
30
|
async get() {
|
|
31
|
-
|
|
31
|
+
const apiPath = '/locale';
|
|
32
32
|
let payload = {};
|
|
33
33
|
|
|
34
|
-
return await this.client.call('get',
|
|
34
|
+
return await this.client.call('get', apiPath, {
|
|
35
|
+
'content-type': 'application/json',
|
|
36
|
+
}, payload);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* List Locale Codes
|
|
41
|
+
*
|
|
42
|
+
* List of all locale codes in [ISO
|
|
43
|
+
* 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
|
|
44
|
+
*
|
|
45
|
+
* @throws {AppwriteException}
|
|
46
|
+
* @returns {Promise}
|
|
47
|
+
*/
|
|
48
|
+
async listCodes() {
|
|
49
|
+
const apiPath = '/locale/codes';
|
|
50
|
+
let payload = {};
|
|
51
|
+
|
|
52
|
+
return await this.client.call('get', apiPath, {
|
|
35
53
|
'content-type': 'application/json',
|
|
36
54
|
}, payload);
|
|
37
55
|
}
|
|
@@ -46,10 +64,10 @@ class Locale extends Service {
|
|
|
46
64
|
* @returns {Promise}
|
|
47
65
|
*/
|
|
48
66
|
async listContinents() {
|
|
49
|
-
|
|
67
|
+
const apiPath = '/locale/continents';
|
|
50
68
|
let payload = {};
|
|
51
69
|
|
|
52
|
-
return await this.client.call('get',
|
|
70
|
+
return await this.client.call('get', apiPath, {
|
|
53
71
|
'content-type': 'application/json',
|
|
54
72
|
}, payload);
|
|
55
73
|
}
|
|
@@ -64,10 +82,10 @@ class Locale extends Service {
|
|
|
64
82
|
* @returns {Promise}
|
|
65
83
|
*/
|
|
66
84
|
async listCountries() {
|
|
67
|
-
|
|
85
|
+
const apiPath = '/locale/countries';
|
|
68
86
|
let payload = {};
|
|
69
87
|
|
|
70
|
-
return await this.client.call('get',
|
|
88
|
+
return await this.client.call('get', apiPath, {
|
|
71
89
|
'content-type': 'application/json',
|
|
72
90
|
}, payload);
|
|
73
91
|
}
|
|
@@ -82,10 +100,10 @@ class Locale extends Service {
|
|
|
82
100
|
* @returns {Promise}
|
|
83
101
|
*/
|
|
84
102
|
async listCountriesEU() {
|
|
85
|
-
|
|
103
|
+
const apiPath = '/locale/countries/eu';
|
|
86
104
|
let payload = {};
|
|
87
105
|
|
|
88
|
-
return await this.client.call('get',
|
|
106
|
+
return await this.client.call('get', apiPath, {
|
|
89
107
|
'content-type': 'application/json',
|
|
90
108
|
}, payload);
|
|
91
109
|
}
|
|
@@ -100,10 +118,10 @@ class Locale extends Service {
|
|
|
100
118
|
* @returns {Promise}
|
|
101
119
|
*/
|
|
102
120
|
async listCountriesPhones() {
|
|
103
|
-
|
|
121
|
+
const apiPath = '/locale/countries/phones';
|
|
104
122
|
let payload = {};
|
|
105
123
|
|
|
106
|
-
return await this.client.call('get',
|
|
124
|
+
return await this.client.call('get', apiPath, {
|
|
107
125
|
'content-type': 'application/json',
|
|
108
126
|
}, payload);
|
|
109
127
|
}
|
|
@@ -119,10 +137,10 @@ class Locale extends Service {
|
|
|
119
137
|
* @returns {Promise}
|
|
120
138
|
*/
|
|
121
139
|
async listCurrencies() {
|
|
122
|
-
|
|
140
|
+
const apiPath = '/locale/currencies';
|
|
123
141
|
let payload = {};
|
|
124
142
|
|
|
125
|
-
return await this.client.call('get',
|
|
143
|
+
return await this.client.call('get', apiPath, {
|
|
126
144
|
'content-type': 'application/json',
|
|
127
145
|
}, payload);
|
|
128
146
|
}
|
|
@@ -137,10 +155,10 @@ class Locale extends Service {
|
|
|
137
155
|
* @returns {Promise}
|
|
138
156
|
*/
|
|
139
157
|
async listLanguages() {
|
|
140
|
-
|
|
158
|
+
const apiPath = '/locale/languages';
|
|
141
159
|
let payload = {};
|
|
142
160
|
|
|
143
|
-
return await this.client.call('get',
|
|
161
|
+
return await this.client.call('get', apiPath, {
|
|
144
162
|
'content-type': 'application/json',
|
|
145
163
|
}, payload);
|
|
146
164
|
}
|
package/lib/services/storage.js
CHANGED
|
@@ -26,7 +26,7 @@ class Storage extends Service {
|
|
|
26
26
|
* @returns {Promise}
|
|
27
27
|
*/
|
|
28
28
|
async listBuckets(queries, search) {
|
|
29
|
-
|
|
29
|
+
const apiPath = '/storage/buckets';
|
|
30
30
|
let payload = {};
|
|
31
31
|
|
|
32
32
|
if (typeof queries !== 'undefined') {
|
|
@@ -37,7 +37,7 @@ class Storage extends Service {
|
|
|
37
37
|
payload['search'] = search;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return await this.client.call('get',
|
|
40
|
+
return await this.client.call('get', apiPath, {
|
|
41
41
|
'content-type': 'application/json',
|
|
42
42
|
}, payload);
|
|
43
43
|
}
|
|
@@ -61,7 +61,7 @@ class Storage extends Service {
|
|
|
61
61
|
* @returns {Promise}
|
|
62
62
|
*/
|
|
63
63
|
async createBucket(bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus) {
|
|
64
|
-
|
|
64
|
+
const apiPath = '/storage/buckets';
|
|
65
65
|
let payload = {};
|
|
66
66
|
if (typeof bucketId === 'undefined') {
|
|
67
67
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -112,7 +112,7 @@ class Storage extends Service {
|
|
|
112
112
|
payload['antivirus'] = antivirus;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
return await this.client.call('post',
|
|
115
|
+
return await this.client.call('post', apiPath, {
|
|
116
116
|
'content-type': 'application/json',
|
|
117
117
|
}, payload);
|
|
118
118
|
}
|
|
@@ -128,14 +128,14 @@ class Storage extends Service {
|
|
|
128
128
|
* @returns {Promise}
|
|
129
129
|
*/
|
|
130
130
|
async getBucket(bucketId) {
|
|
131
|
-
|
|
131
|
+
const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
132
132
|
let payload = {};
|
|
133
133
|
if (typeof bucketId === 'undefined') {
|
|
134
134
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
return await this.client.call('get',
|
|
138
|
+
return await this.client.call('get', apiPath, {
|
|
139
139
|
'content-type': 'application/json',
|
|
140
140
|
}, payload);
|
|
141
141
|
}
|
|
@@ -159,7 +159,7 @@ class Storage extends Service {
|
|
|
159
159
|
* @returns {Promise}
|
|
160
160
|
*/
|
|
161
161
|
async updateBucket(bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus) {
|
|
162
|
-
|
|
162
|
+
const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
163
163
|
let payload = {};
|
|
164
164
|
if (typeof bucketId === 'undefined') {
|
|
165
165
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -206,7 +206,7 @@ class Storage extends Service {
|
|
|
206
206
|
payload['antivirus'] = antivirus;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
return await this.client.call('put',
|
|
209
|
+
return await this.client.call('put', apiPath, {
|
|
210
210
|
'content-type': 'application/json',
|
|
211
211
|
}, payload);
|
|
212
212
|
}
|
|
@@ -221,14 +221,14 @@ class Storage extends Service {
|
|
|
221
221
|
* @returns {Promise}
|
|
222
222
|
*/
|
|
223
223
|
async deleteBucket(bucketId) {
|
|
224
|
-
|
|
224
|
+
const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
225
225
|
let payload = {};
|
|
226
226
|
if (typeof bucketId === 'undefined') {
|
|
227
227
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
return await this.client.call('delete',
|
|
231
|
+
return await this.client.call('delete', apiPath, {
|
|
232
232
|
'content-type': 'application/json',
|
|
233
233
|
}, payload);
|
|
234
234
|
}
|
|
@@ -246,7 +246,7 @@ class Storage extends Service {
|
|
|
246
246
|
* @returns {Promise}
|
|
247
247
|
*/
|
|
248
248
|
async listFiles(bucketId, queries, search) {
|
|
249
|
-
|
|
249
|
+
const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
250
250
|
let payload = {};
|
|
251
251
|
if (typeof bucketId === 'undefined') {
|
|
252
252
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -261,7 +261,7 @@ class Storage extends Service {
|
|
|
261
261
|
payload['search'] = search;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
return await this.client.call('get',
|
|
264
|
+
return await this.client.call('get', apiPath, {
|
|
265
265
|
'content-type': 'application/json',
|
|
266
266
|
}, payload);
|
|
267
267
|
}
|
|
@@ -296,7 +296,7 @@ class Storage extends Service {
|
|
|
296
296
|
* @returns {Promise}
|
|
297
297
|
*/
|
|
298
298
|
async createFile(bucketId, fileId, file, permissions, onProgress = () => {}) {
|
|
299
|
-
|
|
299
|
+
const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
300
300
|
let payload = {};
|
|
301
301
|
if (typeof bucketId === 'undefined') {
|
|
302
302
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -336,7 +336,7 @@ class Storage extends Service {
|
|
|
336
336
|
|
|
337
337
|
if(fileId != 'unique()') {
|
|
338
338
|
try {
|
|
339
|
-
response = await this.client.call('get',
|
|
339
|
+
response = await this.client.call('get', apiPath + '/' + fileId, headers);
|
|
340
340
|
chunksUploaded = response.chunksUploaded;
|
|
341
341
|
} catch(e) {
|
|
342
342
|
}
|
|
@@ -367,7 +367,7 @@ class Storage extends Service {
|
|
|
367
367
|
const stream = Stream.Readable.from(currentChunk);
|
|
368
368
|
payload['file'] = { type: 'file', file: stream, filename: file.filename };
|
|
369
369
|
|
|
370
|
-
response = await selfClient.call('post',
|
|
370
|
+
response = await selfClient.call('post', apiPath, headers, payload);
|
|
371
371
|
|
|
372
372
|
if (!id) {
|
|
373
373
|
id = response['$id'];
|
|
@@ -388,48 +388,56 @@ class Storage extends Service {
|
|
|
388
388
|
|
|
389
389
|
return await new Promise((resolve, reject) => {
|
|
390
390
|
const writeStream = new Stream.Writable();
|
|
391
|
-
writeStream._write = async (mainChunk, encoding,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
391
|
+
writeStream._write = async (mainChunk, encoding, callback) => {
|
|
392
|
+
try {
|
|
393
|
+
// Segment incoming chunk into up to 5MB chunks
|
|
394
|
+
const mainChunkSize = Buffer.byteLength(mainChunk);
|
|
395
|
+
const chunksCount = Math.ceil(mainChunkSize / client.CHUNK_SIZE);
|
|
396
|
+
const chunks = [];
|
|
397
|
+
|
|
398
|
+
for(let i = 0; i < chunksCount; i++) {
|
|
399
|
+
const chunk = mainChunk.slice(i * client.CHUNK_SIZE, (i + 1) * client.CHUNK_SIZE);
|
|
400
|
+
chunks.push(chunk);
|
|
401
|
+
}
|
|
401
402
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
403
|
+
for (const chunk of chunks) {
|
|
404
|
+
const chunkSize = Buffer.byteLength(chunk);
|
|
405
|
+
|
|
406
|
+
if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
|
|
407
|
+
// Upload chunk
|
|
408
|
+
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
409
|
+
await uploadChunk();
|
|
410
|
+
currentChunk = Buffer.from('');
|
|
411
|
+
currentChunkSize = 0;
|
|
412
|
+
} else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
|
|
413
|
+
// Upload chunk, put rest into next chunk
|
|
414
|
+
const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
|
|
415
|
+
const newChunkSection = chunk.slice(0, bytesToUpload);
|
|
416
|
+
currentChunk = Buffer.concat([currentChunk, newChunkSection]);
|
|
417
|
+
currentChunkSize = Buffer.byteLength(currentChunk);
|
|
418
|
+
await uploadChunk();
|
|
419
|
+
currentChunk = chunk.slice(bytesToUpload, undefined);
|
|
420
|
+
currentChunkSize = chunkSize - bytesToUpload;
|
|
421
|
+
} else {
|
|
422
|
+
// Append into current chunk
|
|
423
|
+
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
424
|
+
currentChunkSize = chunkSize + currentChunkSize;
|
|
425
|
+
}
|
|
424
426
|
}
|
|
425
|
-
}
|
|
426
427
|
|
|
427
|
-
|
|
428
|
+
callback();
|
|
429
|
+
} catch (e) {
|
|
430
|
+
callback(e);
|
|
431
|
+
}
|
|
428
432
|
}
|
|
429
433
|
|
|
430
434
|
writeStream.on("finish", async () => {
|
|
431
435
|
if(currentChunkSize > 0) {
|
|
432
|
-
|
|
436
|
+
try {
|
|
437
|
+
await uploadChunk(true);
|
|
438
|
+
} catch (e) {
|
|
439
|
+
reject(e);
|
|
440
|
+
}
|
|
433
441
|
}
|
|
434
442
|
|
|
435
443
|
resolve(response);
|
|
@@ -456,7 +464,7 @@ class Storage extends Service {
|
|
|
456
464
|
* @returns {Promise}
|
|
457
465
|
*/
|
|
458
466
|
async getFile(bucketId, fileId) {
|
|
459
|
-
|
|
467
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
460
468
|
let payload = {};
|
|
461
469
|
if (typeof bucketId === 'undefined') {
|
|
462
470
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -467,7 +475,7 @@ class Storage extends Service {
|
|
|
467
475
|
}
|
|
468
476
|
|
|
469
477
|
|
|
470
|
-
return await this.client.call('get',
|
|
478
|
+
return await this.client.call('get', apiPath, {
|
|
471
479
|
'content-type': 'application/json',
|
|
472
480
|
}, payload);
|
|
473
481
|
}
|
|
@@ -480,12 +488,13 @@ class Storage extends Service {
|
|
|
480
488
|
*
|
|
481
489
|
* @param {string} bucketId
|
|
482
490
|
* @param {string} fileId
|
|
491
|
+
* @param {string} name
|
|
483
492
|
* @param {string[]} permissions
|
|
484
493
|
* @throws {AppwriteException}
|
|
485
494
|
* @returns {Promise}
|
|
486
495
|
*/
|
|
487
|
-
async updateFile(bucketId, fileId, permissions) {
|
|
488
|
-
|
|
496
|
+
async updateFile(bucketId, fileId, name, permissions) {
|
|
497
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
489
498
|
let payload = {};
|
|
490
499
|
if (typeof bucketId === 'undefined') {
|
|
491
500
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -496,11 +505,15 @@ class Storage extends Service {
|
|
|
496
505
|
}
|
|
497
506
|
|
|
498
507
|
|
|
508
|
+
if (typeof name !== 'undefined') {
|
|
509
|
+
payload['name'] = name;
|
|
510
|
+
}
|
|
511
|
+
|
|
499
512
|
if (typeof permissions !== 'undefined') {
|
|
500
513
|
payload['permissions'] = permissions;
|
|
501
514
|
}
|
|
502
515
|
|
|
503
|
-
return await this.client.call('put',
|
|
516
|
+
return await this.client.call('put', apiPath, {
|
|
504
517
|
'content-type': 'application/json',
|
|
505
518
|
}, payload);
|
|
506
519
|
}
|
|
@@ -517,7 +530,7 @@ class Storage extends Service {
|
|
|
517
530
|
* @returns {Promise}
|
|
518
531
|
*/
|
|
519
532
|
async deleteFile(bucketId, fileId) {
|
|
520
|
-
|
|
533
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
521
534
|
let payload = {};
|
|
522
535
|
if (typeof bucketId === 'undefined') {
|
|
523
536
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -528,7 +541,7 @@ class Storage extends Service {
|
|
|
528
541
|
}
|
|
529
542
|
|
|
530
543
|
|
|
531
|
-
return await this.client.call('delete',
|
|
544
|
+
return await this.client.call('delete', apiPath, {
|
|
532
545
|
'content-type': 'application/json',
|
|
533
546
|
}, payload);
|
|
534
547
|
}
|
|
@@ -546,7 +559,7 @@ class Storage extends Service {
|
|
|
546
559
|
* @returns {Promise}
|
|
547
560
|
*/
|
|
548
561
|
async getFileDownload(bucketId, fileId) {
|
|
549
|
-
|
|
562
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
550
563
|
let payload = {};
|
|
551
564
|
if (typeof bucketId === 'undefined') {
|
|
552
565
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -557,7 +570,7 @@ class Storage extends Service {
|
|
|
557
570
|
}
|
|
558
571
|
|
|
559
572
|
|
|
560
|
-
return await this.client.call('get',
|
|
573
|
+
return await this.client.call('get', apiPath, {
|
|
561
574
|
'content-type': 'application/json',
|
|
562
575
|
}, payload, 'arraybuffer');
|
|
563
576
|
}
|
|
@@ -588,7 +601,7 @@ class Storage extends Service {
|
|
|
588
601
|
* @returns {Promise}
|
|
589
602
|
*/
|
|
590
603
|
async getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) {
|
|
591
|
-
|
|
604
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
592
605
|
let payload = {};
|
|
593
606
|
if (typeof bucketId === 'undefined') {
|
|
594
607
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -643,7 +656,7 @@ class Storage extends Service {
|
|
|
643
656
|
payload['output'] = output;
|
|
644
657
|
}
|
|
645
658
|
|
|
646
|
-
return await this.client.call('get',
|
|
659
|
+
return await this.client.call('get', apiPath, {
|
|
647
660
|
'content-type': 'application/json',
|
|
648
661
|
}, payload, 'arraybuffer');
|
|
649
662
|
}
|
|
@@ -661,7 +674,7 @@ class Storage extends Service {
|
|
|
661
674
|
* @returns {Promise}
|
|
662
675
|
*/
|
|
663
676
|
async getFileView(bucketId, fileId) {
|
|
664
|
-
|
|
677
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
665
678
|
let payload = {};
|
|
666
679
|
if (typeof bucketId === 'undefined') {
|
|
667
680
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -672,7 +685,7 @@ class Storage extends Service {
|
|
|
672
685
|
}
|
|
673
686
|
|
|
674
687
|
|
|
675
|
-
return await this.client.call('get',
|
|
688
|
+
return await this.client.call('get', apiPath, {
|
|
676
689
|
'content-type': 'application/json',
|
|
677
690
|
}, payload, 'arraybuffer');
|
|
678
691
|
}
|