node-appwrite 9.0.0 → 10.0.1
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/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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/docs/examples/databases/update-collection.md +1 -1
- package/docs/examples/databases/update-datetime-attribute.md +1 -1
- package/docs/examples/databases/update-document.md +1 -1
- package/docs/examples/databases/update-email-attribute.md +1 -1
- package/docs/examples/databases/update-enum-attribute.md +1 -1
- package/docs/examples/databases/update-float-attribute.md +1 -1
- package/docs/examples/databases/update-integer-attribute.md +1 -1
- package/docs/examples/databases/update-ip-attribute.md +1 -1
- package/docs/examples/databases/update-relationship-attribute.md +1 -1
- package/docs/examples/databases/update-string-attribute.md +1 -1
- package/docs/examples/databases/update-url-attribute.md +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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-name.md +1 -1
- package/docs/examples/teams/update-prefs.md +1 -1
- 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 +1 -1
- 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 +435 -55
- package/lib/client.js +4 -2
- package/lib/role.js +74 -3
- package/lib/services/account.js +94 -50
- package/lib/services/avatars.js +14 -14
- package/lib/services/databases.js +120 -90
- package/lib/services/functions.js +223 -65
- 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 +44 -34
- package/lib/services/teams.js +29 -28
- package/lib/services/users.js +135 -50
- package/package.json +2 -2
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"');
|
|
@@ -325,7 +325,7 @@ class Storage extends Service {
|
|
|
325
325
|
|
|
326
326
|
const size = file.size;
|
|
327
327
|
|
|
328
|
-
const
|
|
328
|
+
const apiHeaders = {
|
|
329
329
|
'content-type': 'multipart/form-data',
|
|
330
330
|
};
|
|
331
331
|
|
|
@@ -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, apiHeaders);
|
|
340
340
|
chunksUploaded = response.chunksUploaded;
|
|
341
341
|
} catch(e) {
|
|
342
342
|
}
|
|
@@ -354,20 +354,24 @@ class Storage extends Service {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
const start = currentChunkStart;
|
|
357
|
-
const end =
|
|
357
|
+
const end = currentChunkStart + currentChunkSize - 1;
|
|
358
358
|
|
|
359
359
|
if(!lastUpload || currentChunkStart !== 0) {
|
|
360
|
-
|
|
360
|
+
apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
if (id) {
|
|
364
|
-
|
|
364
|
+
apiHeaders['x-appwrite-id'] = id;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
payload['file'] = {
|
|
368
|
+
type: 'file',
|
|
369
|
+
file: currentChunk,
|
|
370
|
+
filename: file.filename,
|
|
371
|
+
size: currentChunkSize
|
|
372
|
+
};
|
|
369
373
|
|
|
370
|
-
response = await selfClient.call('post',
|
|
374
|
+
response = await selfClient.call('post', apiPath, apiHeaders, payload);
|
|
371
375
|
|
|
372
376
|
if (!id) {
|
|
373
377
|
id = response['$id'];
|
|
@@ -406,6 +410,7 @@ class Storage extends Service {
|
|
|
406
410
|
if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
|
|
407
411
|
// Upload chunk
|
|
408
412
|
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
413
|
+
currentChunkSize = Buffer.byteLength(currentChunk);
|
|
409
414
|
await uploadChunk();
|
|
410
415
|
currentChunk = Buffer.from('');
|
|
411
416
|
currentChunkSize = 0;
|
|
@@ -464,7 +469,7 @@ class Storage extends Service {
|
|
|
464
469
|
* @returns {Promise}
|
|
465
470
|
*/
|
|
466
471
|
async getFile(bucketId, fileId) {
|
|
467
|
-
|
|
472
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
468
473
|
let payload = {};
|
|
469
474
|
if (typeof bucketId === 'undefined') {
|
|
470
475
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -475,7 +480,7 @@ class Storage extends Service {
|
|
|
475
480
|
}
|
|
476
481
|
|
|
477
482
|
|
|
478
|
-
return await this.client.call('get',
|
|
483
|
+
return await this.client.call('get', apiPath, {
|
|
479
484
|
'content-type': 'application/json',
|
|
480
485
|
}, payload);
|
|
481
486
|
}
|
|
@@ -488,12 +493,13 @@ class Storage extends Service {
|
|
|
488
493
|
*
|
|
489
494
|
* @param {string} bucketId
|
|
490
495
|
* @param {string} fileId
|
|
496
|
+
* @param {string} name
|
|
491
497
|
* @param {string[]} permissions
|
|
492
498
|
* @throws {AppwriteException}
|
|
493
499
|
* @returns {Promise}
|
|
494
500
|
*/
|
|
495
|
-
async updateFile(bucketId, fileId, permissions) {
|
|
496
|
-
|
|
501
|
+
async updateFile(bucketId, fileId, name, permissions) {
|
|
502
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
497
503
|
let payload = {};
|
|
498
504
|
if (typeof bucketId === 'undefined') {
|
|
499
505
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -504,11 +510,15 @@ class Storage extends Service {
|
|
|
504
510
|
}
|
|
505
511
|
|
|
506
512
|
|
|
513
|
+
if (typeof name !== 'undefined') {
|
|
514
|
+
payload['name'] = name;
|
|
515
|
+
}
|
|
516
|
+
|
|
507
517
|
if (typeof permissions !== 'undefined') {
|
|
508
518
|
payload['permissions'] = permissions;
|
|
509
519
|
}
|
|
510
520
|
|
|
511
|
-
return await this.client.call('put',
|
|
521
|
+
return await this.client.call('put', apiPath, {
|
|
512
522
|
'content-type': 'application/json',
|
|
513
523
|
}, payload);
|
|
514
524
|
}
|
|
@@ -525,7 +535,7 @@ class Storage extends Service {
|
|
|
525
535
|
* @returns {Promise}
|
|
526
536
|
*/
|
|
527
537
|
async deleteFile(bucketId, fileId) {
|
|
528
|
-
|
|
538
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
529
539
|
let payload = {};
|
|
530
540
|
if (typeof bucketId === 'undefined') {
|
|
531
541
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -536,7 +546,7 @@ class Storage extends Service {
|
|
|
536
546
|
}
|
|
537
547
|
|
|
538
548
|
|
|
539
|
-
return await this.client.call('delete',
|
|
549
|
+
return await this.client.call('delete', apiPath, {
|
|
540
550
|
'content-type': 'application/json',
|
|
541
551
|
}, payload);
|
|
542
552
|
}
|
|
@@ -554,7 +564,7 @@ class Storage extends Service {
|
|
|
554
564
|
* @returns {Promise}
|
|
555
565
|
*/
|
|
556
566
|
async getFileDownload(bucketId, fileId) {
|
|
557
|
-
|
|
567
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
558
568
|
let payload = {};
|
|
559
569
|
if (typeof bucketId === 'undefined') {
|
|
560
570
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -565,7 +575,7 @@ class Storage extends Service {
|
|
|
565
575
|
}
|
|
566
576
|
|
|
567
577
|
|
|
568
|
-
return await this.client.call('get',
|
|
578
|
+
return await this.client.call('get', apiPath, {
|
|
569
579
|
'content-type': 'application/json',
|
|
570
580
|
}, payload, 'arraybuffer');
|
|
571
581
|
}
|
|
@@ -596,7 +606,7 @@ class Storage extends Service {
|
|
|
596
606
|
* @returns {Promise}
|
|
597
607
|
*/
|
|
598
608
|
async getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) {
|
|
599
|
-
|
|
609
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
600
610
|
let payload = {};
|
|
601
611
|
if (typeof bucketId === 'undefined') {
|
|
602
612
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -651,7 +661,7 @@ class Storage extends Service {
|
|
|
651
661
|
payload['output'] = output;
|
|
652
662
|
}
|
|
653
663
|
|
|
654
|
-
return await this.client.call('get',
|
|
664
|
+
return await this.client.call('get', apiPath, {
|
|
655
665
|
'content-type': 'application/json',
|
|
656
666
|
}, payload, 'arraybuffer');
|
|
657
667
|
}
|
|
@@ -669,7 +679,7 @@ class Storage extends Service {
|
|
|
669
679
|
* @returns {Promise}
|
|
670
680
|
*/
|
|
671
681
|
async getFileView(bucketId, fileId) {
|
|
672
|
-
|
|
682
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
673
683
|
let payload = {};
|
|
674
684
|
if (typeof bucketId === 'undefined') {
|
|
675
685
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
@@ -680,7 +690,7 @@ class Storage extends Service {
|
|
|
680
690
|
}
|
|
681
691
|
|
|
682
692
|
|
|
683
|
-
return await this.client.call('get',
|
|
693
|
+
return await this.client.call('get', apiPath, {
|
|
684
694
|
'content-type': 'application/json',
|
|
685
695
|
}, payload, 'arraybuffer');
|
|
686
696
|
}
|