node-appwrite 7.0.2 → 8.0.0-RC1
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/databases/create-boolean-attribute.md +2 -2
- package/docs/examples/databases/create-collection.md +2 -2
- package/docs/examples/databases/create-datetime-attribute.md +20 -0
- package/docs/examples/databases/create-document.md +2 -2
- package/docs/examples/databases/create-email-attribute.md +2 -2
- package/docs/examples/databases/create-enum-attribute.md +2 -2
- package/docs/examples/databases/create-float-attribute.md +2 -2
- package/docs/examples/databases/create-index.md +2 -2
- package/docs/examples/databases/create-integer-attribute.md +2 -2
- package/docs/examples/databases/create-ip-attribute.md +2 -2
- package/docs/examples/databases/create-string-attribute.md +2 -2
- package/docs/examples/databases/create-url-attribute.md +2 -2
- package/docs/examples/databases/create.md +2 -2
- package/docs/examples/databases/delete-attribute.md +2 -2
- package/docs/examples/databases/delete-collection.md +2 -2
- package/docs/examples/databases/delete-document.md +2 -2
- package/docs/examples/databases/delete-index.md +2 -2
- package/docs/examples/databases/delete.md +2 -2
- package/docs/examples/databases/get-attribute.md +2 -2
- package/docs/examples/databases/get-collection.md +2 -2
- package/docs/examples/databases/get-document.md +2 -2
- package/docs/examples/databases/get-index.md +2 -2
- package/docs/examples/databases/get.md +2 -2
- package/docs/examples/databases/list-attributes.md +2 -2
- package/docs/examples/databases/list-collections.md +2 -2
- package/docs/examples/databases/list-documents.md +2 -2
- package/docs/examples/databases/list-indexes.md +2 -2
- package/docs/examples/databases/list.md +1 -1
- package/docs/examples/databases/update-collection.md +2 -2
- package/docs/examples/databases/update-document.md +2 -2
- package/docs/examples/databases/update.md +2 -2
- package/docs/examples/functions/create-deployment.md +1 -1
- package/docs/examples/functions/create-variable.md +20 -0
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/functions/delete-variable.md +20 -0
- package/docs/examples/functions/get-variable.md +20 -0
- package/docs/examples/functions/list-variables.md +20 -0
- package/docs/examples/functions/update-variable.md +20 -0
- package/docs/examples/functions/update.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/update-bucket.md +1 -1
- package/docs/examples/users/create-argon2user.md +20 -0
- package/docs/examples/users/create-bcrypt-user.md +20 -0
- package/docs/examples/users/create-m-d5user.md +20 -0
- package/docs/examples/users/create-p-h-pass-user.md +20 -0
- package/docs/examples/users/create-s-h-a-user.md +20 -0
- package/docs/examples/users/create-scrypt-modified-user.md +20 -0
- package/docs/examples/users/create-scrypt-user.md +20 -0
- package/docs/examples/users/create.md +1 -1
- package/index.d.ts +714 -262
- package/index.js +6 -0
- package/lib/client.js +5 -2
- package/lib/id.js +12 -0
- package/lib/permission.js +24 -0
- package/lib/query.js +30 -12
- package/lib/role.js +25 -0
- package/lib/services/account.js +43 -42
- package/lib/services/avatars.js +22 -20
- package/lib/services/databases.js +385 -243
- package/lib/services/functions.js +219 -109
- package/lib/services/health.js +7 -1
- package/lib/services/locale.js +7 -1
- package/lib/services/storage.js +78 -129
- package/lib/services/teams.js +39 -73
- package/lib/services/users.js +482 -63
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const Client = require('./lib/client.js');
|
|
2
2
|
const Query = require('./lib/query.js');
|
|
3
|
+
const Permission = require('./lib/permission.js');
|
|
4
|
+
const Role = require('./lib/role.js');
|
|
5
|
+
const ID = require('./lib/id.js');
|
|
3
6
|
const InputFile = require('./lib/inputFile.js');
|
|
4
7
|
const AppwriteException = require('./lib/exception.js');
|
|
5
8
|
const Account = require('./lib/services/account.js');
|
|
@@ -15,6 +18,9 @@ const Users = require('./lib/services/users.js');
|
|
|
15
18
|
module.exports = {
|
|
16
19
|
Client,
|
|
17
20
|
Query,
|
|
21
|
+
Permission,
|
|
22
|
+
Role,
|
|
23
|
+
ID,
|
|
18
24
|
InputFile,
|
|
19
25
|
AppwriteException,
|
|
20
26
|
Account,
|
package/lib/client.js
CHANGED
|
@@ -10,8 +10,11 @@ class Client {
|
|
|
10
10
|
this.endpoint = 'https://HOSTNAME/v1';
|
|
11
11
|
this.headers = {
|
|
12
12
|
'content-type': '',
|
|
13
|
-
'x-sdk-
|
|
14
|
-
'
|
|
13
|
+
'x-sdk-name': 'Node.js',
|
|
14
|
+
'x-sdk-platform': 'server',
|
|
15
|
+
'x-sdk-language': 'nodejs',
|
|
16
|
+
'x-sdk-version': '8.0.0-RC1',
|
|
17
|
+
'X-Appwrite-Response-Format' : '1.0.0-RC1',
|
|
15
18
|
};
|
|
16
19
|
this.selfSigned = false;
|
|
17
20
|
}
|
package/lib/id.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class Permission {
|
|
2
|
+
|
|
3
|
+
static read = (role) => {
|
|
4
|
+
return `read("${role}")`
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
static write = (role) => {
|
|
8
|
+
return `write("${role}")`
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static create = (role) => {
|
|
12
|
+
return `create("${role}")`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static update = (role) => {
|
|
16
|
+
return `update("${role}")`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static delete = (role) => {
|
|
20
|
+
return `delete("${role}")`
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = Permission;
|
package/lib/query.js
CHANGED
|
@@ -5,27 +5,45 @@ class Query {
|
|
|
5
5
|
static notEqual = (attribute, value) =>
|
|
6
6
|
Query.addQuery(attribute, "notEqual", value);
|
|
7
7
|
|
|
8
|
-
static
|
|
9
|
-
Query.addQuery(attribute, "
|
|
8
|
+
static lessThan = (attribute, value) =>
|
|
9
|
+
Query.addQuery(attribute, "lessThan", value);
|
|
10
10
|
|
|
11
|
-
static
|
|
12
|
-
Query.addQuery(attribute, "
|
|
11
|
+
static lessThanEqual = (attribute, value) =>
|
|
12
|
+
Query.addQuery(attribute, "lessThanEqual", value);
|
|
13
13
|
|
|
14
|
-
static
|
|
15
|
-
Query.addQuery(attribute, "
|
|
14
|
+
static greaterThan = (attribute, value) =>
|
|
15
|
+
Query.addQuery(attribute, "greaterThan", value);
|
|
16
16
|
|
|
17
|
-
static
|
|
18
|
-
Query.addQuery(attribute, "
|
|
17
|
+
static greaterThanEqual = (attribute, value) =>
|
|
18
|
+
Query.addQuery(attribute, "greaterThanEqual", value);
|
|
19
19
|
|
|
20
20
|
static search = (attribute, value) =>
|
|
21
21
|
Query.addQuery(attribute, "search", value);
|
|
22
22
|
|
|
23
|
-
static
|
|
23
|
+
static orderDesc = (attribute) =>
|
|
24
|
+
`orderDesc("${attribute}")`;
|
|
25
|
+
|
|
26
|
+
static orderAsc = (attribute) =>
|
|
27
|
+
`orderAsc("${attribute}")`;
|
|
28
|
+
|
|
29
|
+
static cursorAfter = (documentId) =>
|
|
30
|
+
`cursorAfter("${documentId}")`;
|
|
31
|
+
|
|
32
|
+
static cursorBefore = (documentId) =>
|
|
33
|
+
`cursorBefore("${documentId}")`;
|
|
34
|
+
|
|
35
|
+
static limit = (limit) =>
|
|
36
|
+
`limit(${limit})`;
|
|
37
|
+
|
|
38
|
+
static offset = (offset) =>
|
|
39
|
+
`offset(${offset})`;
|
|
40
|
+
|
|
41
|
+
static addQuery = (attribute, method, value) =>
|
|
24
42
|
value instanceof Array
|
|
25
|
-
? `${
|
|
43
|
+
? `${method}("${attribute}", [${value
|
|
26
44
|
.map((v) => Query.parseValues(v))
|
|
27
|
-
.join(",")})`
|
|
28
|
-
: `${
|
|
45
|
+
.join(",")}])`
|
|
46
|
+
: `${method}("${attribute}", [${Query.parseValues(value)}])`;
|
|
29
47
|
|
|
30
48
|
static parseValues = (value) =>
|
|
31
49
|
typeof value === "string" || value instanceof String
|
package/lib/role.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class Role {
|
|
2
|
+
static any = () => {
|
|
3
|
+
return 'any'
|
|
4
|
+
}
|
|
5
|
+
static user = (id) => {
|
|
6
|
+
return 'user:' + id
|
|
7
|
+
}
|
|
8
|
+
static users = () => {
|
|
9
|
+
return 'users'
|
|
10
|
+
}
|
|
11
|
+
static guests = () => {
|
|
12
|
+
return 'guests'
|
|
13
|
+
}
|
|
14
|
+
static team = (id, role = '') => {
|
|
15
|
+
if(role === '') {
|
|
16
|
+
return 'team:' + id
|
|
17
|
+
}
|
|
18
|
+
return 'team:' + id + '/' + role
|
|
19
|
+
}
|
|
20
|
+
static status = (status) => {
|
|
21
|
+
return 'status:' + status
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = Role;
|
package/lib/services/account.js
CHANGED
|
@@ -8,6 +8,12 @@ const fs = require('fs');
|
|
|
8
8
|
|
|
9
9
|
class Account extends Service {
|
|
10
10
|
|
|
11
|
+
constructor(client)
|
|
12
|
+
{
|
|
13
|
+
super(client);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
/**
|
|
12
18
|
* Get Account
|
|
13
19
|
*
|
|
@@ -43,6 +49,8 @@ class Account extends Service {
|
|
|
43
49
|
* @returns {Promise}
|
|
44
50
|
*/
|
|
45
51
|
async updateEmail(email, password) {
|
|
52
|
+
let path = '/account/email';
|
|
53
|
+
let payload = {};
|
|
46
54
|
if (typeof email === 'undefined') {
|
|
47
55
|
throw new AppwriteException('Missing required parameter: "email"');
|
|
48
56
|
}
|
|
@@ -51,8 +59,6 @@ class Account extends Service {
|
|
|
51
59
|
throw new AppwriteException('Missing required parameter: "password"');
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
let path = '/account/email';
|
|
55
|
-
let payload = {};
|
|
56
62
|
|
|
57
63
|
if (typeof email !== 'undefined') {
|
|
58
64
|
payload['email'] = email;
|
|
@@ -73,21 +79,16 @@ class Account extends Service {
|
|
|
73
79
|
* Get currently logged in user list of latest security activity logs. Each
|
|
74
80
|
* log returns user IP address, location and date and time of log.
|
|
75
81
|
*
|
|
76
|
-
* @param {
|
|
77
|
-
* @param {number} offset
|
|
82
|
+
* @param {string[]} queries
|
|
78
83
|
* @throws {AppwriteException}
|
|
79
84
|
* @returns {Promise}
|
|
80
85
|
*/
|
|
81
|
-
async getLogs(
|
|
86
|
+
async getLogs(queries) {
|
|
82
87
|
let path = '/account/logs';
|
|
83
88
|
let payload = {};
|
|
84
89
|
|
|
85
|
-
if (typeof
|
|
86
|
-
payload['
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (typeof offset !== 'undefined') {
|
|
90
|
-
payload['offset'] = offset;
|
|
90
|
+
if (typeof queries !== 'undefined') {
|
|
91
|
+
payload['queries'] = queries;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
return await this.client.call('get', path, {
|
|
@@ -105,12 +106,12 @@ class Account extends Service {
|
|
|
105
106
|
* @returns {Promise}
|
|
106
107
|
*/
|
|
107
108
|
async updateName(name) {
|
|
109
|
+
let path = '/account/name';
|
|
110
|
+
let payload = {};
|
|
108
111
|
if (typeof name === 'undefined') {
|
|
109
112
|
throw new AppwriteException('Missing required parameter: "name"');
|
|
110
113
|
}
|
|
111
114
|
|
|
112
|
-
let path = '/account/name';
|
|
113
|
-
let payload = {};
|
|
114
115
|
|
|
115
116
|
if (typeof name !== 'undefined') {
|
|
116
117
|
payload['name'] = name;
|
|
@@ -134,12 +135,12 @@ class Account extends Service {
|
|
|
134
135
|
* @returns {Promise}
|
|
135
136
|
*/
|
|
136
137
|
async updatePassword(password, oldPassword) {
|
|
138
|
+
let path = '/account/password';
|
|
139
|
+
let payload = {};
|
|
137
140
|
if (typeof password === 'undefined') {
|
|
138
141
|
throw new AppwriteException('Missing required parameter: "password"');
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
let path = '/account/password';
|
|
142
|
-
let payload = {};
|
|
143
144
|
|
|
144
145
|
if (typeof password !== 'undefined') {
|
|
145
146
|
payload['password'] = password;
|
|
@@ -163,25 +164,25 @@ class Account extends Service {
|
|
|
163
164
|
* /account/verification/phone](/docs/client/account#accountCreatePhoneVerification)
|
|
164
165
|
* endpoint to send a confirmation SMS.
|
|
165
166
|
*
|
|
166
|
-
* @param {string}
|
|
167
|
+
* @param {string} phone
|
|
167
168
|
* @param {string} password
|
|
168
169
|
* @throws {AppwriteException}
|
|
169
170
|
* @returns {Promise}
|
|
170
171
|
*/
|
|
171
|
-
async updatePhone(
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
async updatePhone(phone, password) {
|
|
173
|
+
let path = '/account/phone';
|
|
174
|
+
let payload = {};
|
|
175
|
+
if (typeof phone === 'undefined') {
|
|
176
|
+
throw new AppwriteException('Missing required parameter: "phone"');
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
if (typeof password === 'undefined') {
|
|
177
180
|
throw new AppwriteException('Missing required parameter: "password"');
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
let path = '/account/phone';
|
|
181
|
-
let payload = {};
|
|
182
183
|
|
|
183
|
-
if (typeof
|
|
184
|
-
payload['
|
|
184
|
+
if (typeof phone !== 'undefined') {
|
|
185
|
+
payload['phone'] = phone;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
if (typeof password !== 'undefined') {
|
|
@@ -222,12 +223,12 @@ class Account extends Service {
|
|
|
222
223
|
* @returns {Promise}
|
|
223
224
|
*/
|
|
224
225
|
async updatePrefs(prefs) {
|
|
226
|
+
let path = '/account/prefs';
|
|
227
|
+
let payload = {};
|
|
225
228
|
if (typeof prefs === 'undefined') {
|
|
226
229
|
throw new AppwriteException('Missing required parameter: "prefs"');
|
|
227
230
|
}
|
|
228
231
|
|
|
229
|
-
let path = '/account/prefs';
|
|
230
|
-
let payload = {};
|
|
231
232
|
|
|
232
233
|
if (typeof prefs !== 'undefined') {
|
|
233
234
|
payload['prefs'] = prefs;
|
|
@@ -256,6 +257,8 @@ class Account extends Service {
|
|
|
256
257
|
* @returns {Promise}
|
|
257
258
|
*/
|
|
258
259
|
async createRecovery(email, url) {
|
|
260
|
+
let path = '/account/recovery';
|
|
261
|
+
let payload = {};
|
|
259
262
|
if (typeof email === 'undefined') {
|
|
260
263
|
throw new AppwriteException('Missing required parameter: "email"');
|
|
261
264
|
}
|
|
@@ -264,8 +267,6 @@ class Account extends Service {
|
|
|
264
267
|
throw new AppwriteException('Missing required parameter: "url"');
|
|
265
268
|
}
|
|
266
269
|
|
|
267
|
-
let path = '/account/recovery';
|
|
268
|
-
let payload = {};
|
|
269
270
|
|
|
270
271
|
if (typeof email !== 'undefined') {
|
|
271
272
|
payload['email'] = email;
|
|
@@ -301,6 +302,8 @@ class Account extends Service {
|
|
|
301
302
|
* @returns {Promise}
|
|
302
303
|
*/
|
|
303
304
|
async updateRecovery(userId, secret, password, passwordAgain) {
|
|
305
|
+
let path = '/account/recovery';
|
|
306
|
+
let payload = {};
|
|
304
307
|
if (typeof userId === 'undefined') {
|
|
305
308
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
306
309
|
}
|
|
@@ -317,8 +320,6 @@ class Account extends Service {
|
|
|
317
320
|
throw new AppwriteException('Missing required parameter: "passwordAgain"');
|
|
318
321
|
}
|
|
319
322
|
|
|
320
|
-
let path = '/account/recovery';
|
|
321
|
-
let payload = {};
|
|
322
323
|
|
|
323
324
|
if (typeof userId !== 'undefined') {
|
|
324
325
|
payload['userId'] = userId;
|
|
@@ -388,12 +389,12 @@ class Account extends Service {
|
|
|
388
389
|
* @returns {Promise}
|
|
389
390
|
*/
|
|
390
391
|
async getSession(sessionId) {
|
|
392
|
+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
393
|
+
let payload = {};
|
|
391
394
|
if (typeof sessionId === 'undefined') {
|
|
392
395
|
throw new AppwriteException('Missing required parameter: "sessionId"');
|
|
393
396
|
}
|
|
394
397
|
|
|
395
|
-
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
396
|
-
let payload = {};
|
|
397
398
|
|
|
398
399
|
return await this.client.call('get', path, {
|
|
399
400
|
'content-type': 'application/json',
|
|
@@ -412,12 +413,12 @@ class Account extends Service {
|
|
|
412
413
|
* @returns {Promise}
|
|
413
414
|
*/
|
|
414
415
|
async updateSession(sessionId) {
|
|
416
|
+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
417
|
+
let payload = {};
|
|
415
418
|
if (typeof sessionId === 'undefined') {
|
|
416
419
|
throw new AppwriteException('Missing required parameter: "sessionId"');
|
|
417
420
|
}
|
|
418
421
|
|
|
419
|
-
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
420
|
-
let payload = {};
|
|
421
422
|
|
|
422
423
|
return await this.client.call('patch', path, {
|
|
423
424
|
'content-type': 'application/json',
|
|
@@ -437,12 +438,12 @@ class Account extends Service {
|
|
|
437
438
|
* @returns {Promise}
|
|
438
439
|
*/
|
|
439
440
|
async deleteSession(sessionId) {
|
|
441
|
+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
442
|
+
let payload = {};
|
|
440
443
|
if (typeof sessionId === 'undefined') {
|
|
441
444
|
throw new AppwriteException('Missing required parameter: "sessionId"');
|
|
442
445
|
}
|
|
443
446
|
|
|
444
|
-
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
445
|
-
let payload = {};
|
|
446
447
|
|
|
447
448
|
return await this.client.call('delete', path, {
|
|
448
449
|
'content-type': 'application/json',
|
|
@@ -492,12 +493,12 @@ class Account extends Service {
|
|
|
492
493
|
* @returns {Promise}
|
|
493
494
|
*/
|
|
494
495
|
async createVerification(url) {
|
|
496
|
+
let path = '/account/verification';
|
|
497
|
+
let payload = {};
|
|
495
498
|
if (typeof url === 'undefined') {
|
|
496
499
|
throw new AppwriteException('Missing required parameter: "url"');
|
|
497
500
|
}
|
|
498
501
|
|
|
499
|
-
let path = '/account/verification';
|
|
500
|
-
let payload = {};
|
|
501
502
|
|
|
502
503
|
if (typeof url !== 'undefined') {
|
|
503
504
|
payload['url'] = url;
|
|
@@ -522,6 +523,8 @@ class Account extends Service {
|
|
|
522
523
|
* @returns {Promise}
|
|
523
524
|
*/
|
|
524
525
|
async updateVerification(userId, secret) {
|
|
526
|
+
let path = '/account/verification';
|
|
527
|
+
let payload = {};
|
|
525
528
|
if (typeof userId === 'undefined') {
|
|
526
529
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
527
530
|
}
|
|
@@ -530,8 +533,6 @@ class Account extends Service {
|
|
|
530
533
|
throw new AppwriteException('Missing required parameter: "secret"');
|
|
531
534
|
}
|
|
532
535
|
|
|
533
|
-
let path = '/account/verification';
|
|
534
|
-
let payload = {};
|
|
535
536
|
|
|
536
537
|
if (typeof userId !== 'undefined') {
|
|
537
538
|
payload['userId'] = userId;
|
|
@@ -582,6 +583,8 @@ class Account extends Service {
|
|
|
582
583
|
* @returns {Promise}
|
|
583
584
|
*/
|
|
584
585
|
async updatePhoneVerification(userId, secret) {
|
|
586
|
+
let path = '/account/verification/phone';
|
|
587
|
+
let payload = {};
|
|
585
588
|
if (typeof userId === 'undefined') {
|
|
586
589
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
587
590
|
}
|
|
@@ -590,8 +593,6 @@ class Account extends Service {
|
|
|
590
593
|
throw new AppwriteException('Missing required parameter: "secret"');
|
|
591
594
|
}
|
|
592
595
|
|
|
593
|
-
let path = '/account/verification/phone';
|
|
594
|
-
let payload = {};
|
|
595
596
|
|
|
596
597
|
if (typeof userId !== 'undefined') {
|
|
597
598
|
payload['userId'] = userId;
|
|
@@ -607,4 +608,4 @@ class Account extends Service {
|
|
|
607
608
|
}
|
|
608
609
|
}
|
|
609
610
|
|
|
610
|
-
module.exports = Account;
|
|
611
|
+
module.exports = Account;
|
package/lib/services/avatars.js
CHANGED
|
@@ -8,6 +8,12 @@ const fs = require('fs');
|
|
|
8
8
|
|
|
9
9
|
class Avatars extends Service {
|
|
10
10
|
|
|
11
|
+
constructor(client)
|
|
12
|
+
{
|
|
13
|
+
super(client);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
/**
|
|
12
18
|
* Get Browser Icon
|
|
13
19
|
*
|
|
@@ -29,12 +35,12 @@ class Avatars extends Service {
|
|
|
29
35
|
* @returns {Promise}
|
|
30
36
|
*/
|
|
31
37
|
async getBrowser(code, width, height, quality) {
|
|
38
|
+
let path = '/avatars/browsers/{code}'.replace('{code}', code);
|
|
39
|
+
let payload = {};
|
|
32
40
|
if (typeof code === 'undefined') {
|
|
33
41
|
throw new AppwriteException('Missing required parameter: "code"');
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
let path = '/avatars/browsers/{code}'.replace('{code}', code);
|
|
37
|
-
let payload = {};
|
|
38
44
|
|
|
39
45
|
if (typeof width !== 'undefined') {
|
|
40
46
|
payload['width'] = width;
|
|
@@ -74,12 +80,12 @@ class Avatars extends Service {
|
|
|
74
80
|
* @returns {Promise}
|
|
75
81
|
*/
|
|
76
82
|
async getCreditCard(code, width, height, quality) {
|
|
83
|
+
let path = '/avatars/credit-cards/{code}'.replace('{code}', code);
|
|
84
|
+
let payload = {};
|
|
77
85
|
if (typeof code === 'undefined') {
|
|
78
86
|
throw new AppwriteException('Missing required parameter: "code"');
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
let path = '/avatars/credit-cards/{code}'.replace('{code}', code);
|
|
82
|
-
let payload = {};
|
|
83
89
|
|
|
84
90
|
if (typeof width !== 'undefined') {
|
|
85
91
|
payload['width'] = width;
|
|
@@ -110,12 +116,12 @@ class Avatars extends Service {
|
|
|
110
116
|
* @returns {Promise}
|
|
111
117
|
*/
|
|
112
118
|
async getFavicon(url) {
|
|
119
|
+
let path = '/avatars/favicon';
|
|
120
|
+
let payload = {};
|
|
113
121
|
if (typeof url === 'undefined') {
|
|
114
122
|
throw new AppwriteException('Missing required parameter: "url"');
|
|
115
123
|
}
|
|
116
124
|
|
|
117
|
-
let path = '/avatars/favicon';
|
|
118
|
-
let payload = {};
|
|
119
125
|
|
|
120
126
|
if (typeof url !== 'undefined') {
|
|
121
127
|
payload['url'] = url;
|
|
@@ -131,7 +137,8 @@ class Avatars extends Service {
|
|
|
131
137
|
*
|
|
132
138
|
* You can use this endpoint to show different country flags icons to your
|
|
133
139
|
* users. The code argument receives the 2 letter country code. Use width,
|
|
134
|
-
* height and quality arguments to change the output settings.
|
|
140
|
+
* height and quality arguments to change the output settings. Country codes
|
|
141
|
+
* follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard.
|
|
135
142
|
*
|
|
136
143
|
* When one dimension is specified and the other is 0, the image is scaled
|
|
137
144
|
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
@@ -147,12 +154,12 @@ class Avatars extends Service {
|
|
|
147
154
|
* @returns {Promise}
|
|
148
155
|
*/
|
|
149
156
|
async getFlag(code, width, height, quality) {
|
|
157
|
+
let path = '/avatars/flags/{code}'.replace('{code}', code);
|
|
158
|
+
let payload = {};
|
|
150
159
|
if (typeof code === 'undefined') {
|
|
151
160
|
throw new AppwriteException('Missing required parameter: "code"');
|
|
152
161
|
}
|
|
153
162
|
|
|
154
|
-
let path = '/avatars/flags/{code}'.replace('{code}', code);
|
|
155
|
-
let payload = {};
|
|
156
163
|
|
|
157
164
|
if (typeof width !== 'undefined') {
|
|
158
165
|
payload['width'] = width;
|
|
@@ -192,12 +199,12 @@ class Avatars extends Service {
|
|
|
192
199
|
* @returns {Promise}
|
|
193
200
|
*/
|
|
194
201
|
async getImage(url, width, height) {
|
|
202
|
+
let path = '/avatars/image';
|
|
203
|
+
let payload = {};
|
|
195
204
|
if (typeof url === 'undefined') {
|
|
196
205
|
throw new AppwriteException('Missing required parameter: "url"');
|
|
197
206
|
}
|
|
198
207
|
|
|
199
|
-
let path = '/avatars/image';
|
|
200
|
-
let payload = {};
|
|
201
208
|
|
|
202
209
|
if (typeof url !== 'undefined') {
|
|
203
210
|
payload['url'] = url;
|
|
@@ -239,12 +246,11 @@ class Avatars extends Service {
|
|
|
239
246
|
* @param {string} name
|
|
240
247
|
* @param {number} width
|
|
241
248
|
* @param {number} height
|
|
242
|
-
* @param {string} color
|
|
243
249
|
* @param {string} background
|
|
244
250
|
* @throws {AppwriteException}
|
|
245
251
|
* @returns {Promise}
|
|
246
252
|
*/
|
|
247
|
-
async getInitials(name, width, height,
|
|
253
|
+
async getInitials(name, width, height, background) {
|
|
248
254
|
let path = '/avatars/initials';
|
|
249
255
|
let payload = {};
|
|
250
256
|
|
|
@@ -260,10 +266,6 @@ class Avatars extends Service {
|
|
|
260
266
|
payload['height'] = height;
|
|
261
267
|
}
|
|
262
268
|
|
|
263
|
-
if (typeof color !== 'undefined') {
|
|
264
|
-
payload['color'] = color;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
269
|
if (typeof background !== 'undefined') {
|
|
268
270
|
payload['background'] = background;
|
|
269
271
|
}
|
|
@@ -288,12 +290,12 @@ class Avatars extends Service {
|
|
|
288
290
|
* @returns {Promise}
|
|
289
291
|
*/
|
|
290
292
|
async getQR(text, size, margin, download) {
|
|
293
|
+
let path = '/avatars/qr';
|
|
294
|
+
let payload = {};
|
|
291
295
|
if (typeof text === 'undefined') {
|
|
292
296
|
throw new AppwriteException('Missing required parameter: "text"');
|
|
293
297
|
}
|
|
294
298
|
|
|
295
|
-
let path = '/avatars/qr';
|
|
296
|
-
let payload = {};
|
|
297
299
|
|
|
298
300
|
if (typeof text !== 'undefined') {
|
|
299
301
|
payload['text'] = text;
|
|
@@ -317,4 +319,4 @@ class Avatars extends Service {
|
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
|
|
320
|
-
module.exports = Avatars;
|
|
322
|
+
module.exports = Avatars;
|