appwrite-cli 4.2.0 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,900 +9,1100 @@ const { Command } = require('commander');
9
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
+ const { File } = require('undici');
13
+ const { ReadableStream } = require('stream/web');
14
+
15
+ /**
16
+ * @param {fs.ReadStream} readStream
17
+ * @returns {ReadableStream}
18
+ */
19
+ function convertReadStreamToReadableStream(readStream) {
20
+ return new ReadableStream({
21
+ start(controller) {
22
+ readStream.on("data", (chunk) => {
23
+ controller.enqueue(chunk);
24
+ });
25
+ readStream.on("end", () => {
26
+ controller.close();
27
+ });
28
+ readStream.on("error", (err) => {
29
+ controller.error(err);
30
+ });
31
+ },
32
+ cancel() {
33
+ readStream.destroy();
34
+ },
35
+ });
36
+ }
12
37
 
13
38
  const users = new Command("users").description(commandDescriptions['users']).configureHelp({
14
39
  helpWidth: process.stdout.columns || 80
15
- })
16
-
40
+ })
41
+
42
+ /**
43
+ * @typedef {Object} UsersListRequestParams
44
+ * @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification
45
+ * @property {string} search Search term to filter your list results. Max length: 256 chars.
46
+ * @property {boolean} parseOutput
47
+ * @property {libClient | undefined} sdk
48
+ */
49
+
50
+ /**
51
+ * @param {UsersListRequestParams} params
52
+ */
17
53
  const usersList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
18
- /* @param {string[]} queries */
19
- /* @param {string} search */
20
-
21
54
  let client = !sdk ? await sdkForProject() : sdk;
22
55
  let apiPath = '/users';
23
56
  let payload = {};
24
-
25
- /** Query Params */
26
57
  if (typeof queries !== 'undefined') {
27
58
  payload['queries'] = queries;
28
59
  }
29
60
  if (typeof search !== 'undefined') {
30
61
  payload['search'] = search;
31
62
  }
63
+
32
64
  let response = undefined;
65
+
33
66
  response = await client.call('get', apiPath, {
34
67
  'content-type': 'application/json',
35
68
  }, payload);
36
-
69
+
37
70
  if (parseOutput) {
38
71
  parse(response)
39
72
  success()
40
73
  }
74
+
41
75
  return response;
42
76
  }
43
77
 
78
+ /**
79
+ * @typedef {Object} UsersCreateRequestParams
80
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
81
+ * @property {string} email User email.
82
+ * @property {string} phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
83
+ * @property {string} password Plain text user password. Must be at least 8 chars.
84
+ * @property {string} name User name. Max length: 128 chars.
85
+ * @property {boolean} parseOutput
86
+ * @property {libClient | undefined} sdk
87
+ */
88
+
89
+ /**
90
+ * @param {UsersCreateRequestParams} params
91
+ */
44
92
  const usersCreate = async ({ userId, email, phone, password, name, parseOutput = true, sdk = undefined}) => {
45
- /* @param {string} userId */
46
- /* @param {string} email */
47
- /* @param {string} phone */
48
- /* @param {string} password */
49
- /* @param {string} name */
50
-
51
93
  let client = !sdk ? await sdkForProject() : sdk;
52
94
  let apiPath = '/users';
53
95
  let payload = {};
54
-
55
- /** Body Params */
56
-
57
96
  if (typeof userId !== 'undefined') {
58
97
  payload['userId'] = userId;
59
98
  }
60
-
61
-
62
99
  if (typeof email !== 'undefined') {
63
100
  payload['email'] = email;
64
101
  }
65
-
66
-
67
102
  if (typeof phone !== 'undefined') {
68
103
  payload['phone'] = phone;
69
104
  }
70
-
71
-
72
105
  if (typeof password !== 'undefined') {
73
106
  payload['password'] = password;
74
107
  }
75
-
76
-
77
108
  if (typeof name !== 'undefined') {
78
109
  payload['name'] = name;
79
110
  }
80
111
 
81
112
  let response = undefined;
113
+
82
114
  response = await client.call('post', apiPath, {
83
115
  'content-type': 'application/json',
84
116
  }, payload);
85
-
117
+
86
118
  if (parseOutput) {
87
119
  parse(response)
88
120
  success()
89
121
  }
122
+
90
123
  return response;
91
124
  }
92
125
 
126
+ /**
127
+ * @typedef {Object} UsersCreateArgon2UserRequestParams
128
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
129
+ * @property {string} email User email.
130
+ * @property {string} password User password hashed using Argon2.
131
+ * @property {string} name User name. Max length: 128 chars.
132
+ * @property {boolean} parseOutput
133
+ * @property {libClient | undefined} sdk
134
+ */
135
+
136
+ /**
137
+ * @param {UsersCreateArgon2UserRequestParams} params
138
+ */
93
139
  const usersCreateArgon2User = async ({ userId, email, password, name, parseOutput = true, sdk = undefined}) => {
94
- /* @param {string} userId */
95
- /* @param {string} email */
96
- /* @param {string} password */
97
- /* @param {string} name */
98
-
99
140
  let client = !sdk ? await sdkForProject() : sdk;
100
141
  let apiPath = '/users/argon2';
101
142
  let payload = {};
102
-
103
- /** Body Params */
104
-
105
143
  if (typeof userId !== 'undefined') {
106
144
  payload['userId'] = userId;
107
145
  }
108
-
109
-
110
146
  if (typeof email !== 'undefined') {
111
147
  payload['email'] = email;
112
148
  }
113
-
114
-
115
149
  if (typeof password !== 'undefined') {
116
150
  payload['password'] = password;
117
151
  }
118
-
119
-
120
152
  if (typeof name !== 'undefined') {
121
153
  payload['name'] = name;
122
154
  }
123
155
 
124
156
  let response = undefined;
157
+
125
158
  response = await client.call('post', apiPath, {
126
159
  'content-type': 'application/json',
127
160
  }, payload);
128
-
161
+
129
162
  if (parseOutput) {
130
163
  parse(response)
131
164
  success()
132
165
  }
166
+
133
167
  return response;
134
168
  }
135
169
 
170
+ /**
171
+ * @typedef {Object} UsersCreateBcryptUserRequestParams
172
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
173
+ * @property {string} email User email.
174
+ * @property {string} password User password hashed using Bcrypt.
175
+ * @property {string} name User name. Max length: 128 chars.
176
+ * @property {boolean} parseOutput
177
+ * @property {libClient | undefined} sdk
178
+ */
179
+
180
+ /**
181
+ * @param {UsersCreateBcryptUserRequestParams} params
182
+ */
136
183
  const usersCreateBcryptUser = async ({ userId, email, password, name, parseOutput = true, sdk = undefined}) => {
137
- /* @param {string} userId */
138
- /* @param {string} email */
139
- /* @param {string} password */
140
- /* @param {string} name */
141
-
142
184
  let client = !sdk ? await sdkForProject() : sdk;
143
185
  let apiPath = '/users/bcrypt';
144
186
  let payload = {};
145
-
146
- /** Body Params */
147
-
148
187
  if (typeof userId !== 'undefined') {
149
188
  payload['userId'] = userId;
150
189
  }
151
-
152
-
153
190
  if (typeof email !== 'undefined') {
154
191
  payload['email'] = email;
155
192
  }
156
-
157
-
158
193
  if (typeof password !== 'undefined') {
159
194
  payload['password'] = password;
160
195
  }
161
-
162
-
163
196
  if (typeof name !== 'undefined') {
164
197
  payload['name'] = name;
165
198
  }
166
199
 
167
200
  let response = undefined;
201
+
168
202
  response = await client.call('post', apiPath, {
169
203
  'content-type': 'application/json',
170
204
  }, payload);
171
-
205
+
172
206
  if (parseOutput) {
173
207
  parse(response)
174
208
  success()
175
209
  }
210
+
176
211
  return response;
177
212
  }
178
213
 
214
+ /**
215
+ * @typedef {Object} UsersListIdentitiesRequestParams
216
+ * @property {string} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry
217
+ * @property {string} search Search term to filter your list results. Max length: 256 chars.
218
+ * @property {boolean} parseOutput
219
+ * @property {libClient | undefined} sdk
220
+ */
221
+
222
+ /**
223
+ * @param {UsersListIdentitiesRequestParams} params
224
+ */
179
225
  const usersListIdentities = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
180
- /* @param {string} queries */
181
- /* @param {string} search */
182
-
183
226
  let client = !sdk ? await sdkForProject() : sdk;
184
227
  let apiPath = '/users/identities';
185
228
  let payload = {};
186
-
187
- /** Query Params */
188
229
  if (typeof queries !== 'undefined') {
189
230
  payload['queries'] = queries;
190
231
  }
191
232
  if (typeof search !== 'undefined') {
192
233
  payload['search'] = search;
193
234
  }
235
+
194
236
  let response = undefined;
237
+
195
238
  response = await client.call('get', apiPath, {
196
239
  'content-type': 'application/json',
197
240
  }, payload);
198
-
241
+
199
242
  if (parseOutput) {
200
243
  parse(response)
201
244
  success()
202
245
  }
246
+
203
247
  return response;
204
248
  }
205
249
 
206
- const usersDeleteIdentity = async ({ identityId, parseOutput = true, sdk = undefined}) => {
207
- /* @param {string} identityId */
250
+ /**
251
+ * @typedef {Object} UsersDeleteIdentityRequestParams
252
+ * @property {string} identityId Identity ID.
253
+ * @property {boolean} parseOutput
254
+ * @property {libClient | undefined} sdk
255
+ */
208
256
 
257
+ /**
258
+ * @param {UsersDeleteIdentityRequestParams} params
259
+ */
260
+ const usersDeleteIdentity = async ({ identityId, parseOutput = true, sdk = undefined}) => {
209
261
  let client = !sdk ? await sdkForProject() : sdk;
210
262
  let apiPath = '/users/identities/{identityId}'.replace('{identityId}', identityId);
211
263
  let payload = {};
264
+
212
265
  let response = undefined;
266
+
213
267
  response = await client.call('delete', apiPath, {
214
268
  'content-type': 'application/json',
215
269
  }, payload);
216
-
270
+
217
271
  if (parseOutput) {
218
272
  parse(response)
219
273
  success()
220
274
  }
275
+
221
276
  return response;
222
277
  }
223
278
 
279
+ /**
280
+ * @typedef {Object} UsersCreateMD5UserRequestParams
281
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
282
+ * @property {string} email User email.
283
+ * @property {string} password User password hashed using MD5.
284
+ * @property {string} name User name. Max length: 128 chars.
285
+ * @property {boolean} parseOutput
286
+ * @property {libClient | undefined} sdk
287
+ */
288
+
289
+ /**
290
+ * @param {UsersCreateMD5UserRequestParams} params
291
+ */
224
292
  const usersCreateMD5User = async ({ userId, email, password, name, parseOutput = true, sdk = undefined}) => {
225
- /* @param {string} userId */
226
- /* @param {string} email */
227
- /* @param {string} password */
228
- /* @param {string} name */
229
-
230
293
  let client = !sdk ? await sdkForProject() : sdk;
231
294
  let apiPath = '/users/md5';
232
295
  let payload = {};
233
-
234
- /** Body Params */
235
-
236
296
  if (typeof userId !== 'undefined') {
237
297
  payload['userId'] = userId;
238
298
  }
239
-
240
-
241
299
  if (typeof email !== 'undefined') {
242
300
  payload['email'] = email;
243
301
  }
244
-
245
-
246
302
  if (typeof password !== 'undefined') {
247
303
  payload['password'] = password;
248
304
  }
249
-
250
-
251
305
  if (typeof name !== 'undefined') {
252
306
  payload['name'] = name;
253
307
  }
254
308
 
255
309
  let response = undefined;
310
+
256
311
  response = await client.call('post', apiPath, {
257
312
  'content-type': 'application/json',
258
313
  }, payload);
259
-
314
+
260
315
  if (parseOutput) {
261
316
  parse(response)
262
317
  success()
263
318
  }
319
+
264
320
  return response;
265
321
  }
266
322
 
323
+ /**
324
+ * @typedef {Object} UsersCreatePHPassUserRequestParams
325
+ * @property {string} userId User ID. Choose a custom ID or pass the string 'ID.unique()'to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
326
+ * @property {string} email User email.
327
+ * @property {string} password User password hashed using PHPass.
328
+ * @property {string} name User name. Max length: 128 chars.
329
+ * @property {boolean} parseOutput
330
+ * @property {libClient | undefined} sdk
331
+ */
332
+
333
+ /**
334
+ * @param {UsersCreatePHPassUserRequestParams} params
335
+ */
267
336
  const usersCreatePHPassUser = async ({ userId, email, password, name, parseOutput = true, sdk = undefined}) => {
268
- /* @param {string} userId */
269
- /* @param {string} email */
270
- /* @param {string} password */
271
- /* @param {string} name */
272
-
273
337
  let client = !sdk ? await sdkForProject() : sdk;
274
338
  let apiPath = '/users/phpass';
275
339
  let payload = {};
276
-
277
- /** Body Params */
278
-
279
340
  if (typeof userId !== 'undefined') {
280
341
  payload['userId'] = userId;
281
342
  }
282
-
283
-
284
343
  if (typeof email !== 'undefined') {
285
344
  payload['email'] = email;
286
345
  }
287
-
288
-
289
346
  if (typeof password !== 'undefined') {
290
347
  payload['password'] = password;
291
348
  }
292
-
293
-
294
349
  if (typeof name !== 'undefined') {
295
350
  payload['name'] = name;
296
351
  }
297
352
 
298
353
  let response = undefined;
354
+
299
355
  response = await client.call('post', apiPath, {
300
356
  'content-type': 'application/json',
301
357
  }, payload);
302
-
358
+
303
359
  if (parseOutput) {
304
360
  parse(response)
305
361
  success()
306
362
  }
363
+
307
364
  return response;
308
365
  }
309
366
 
367
+ /**
368
+ * @typedef {Object} UsersCreateScryptUserRequestParams
369
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
370
+ * @property {string} email User email.
371
+ * @property {string} password User password hashed using Scrypt.
372
+ * @property {string} passwordSalt Optional salt used to hash password.
373
+ * @property {number} passwordCpu Optional CPU cost used to hash password.
374
+ * @property {number} passwordMemory Optional memory cost used to hash password.
375
+ * @property {number} passwordParallel Optional parallelization cost used to hash password.
376
+ * @property {number} passwordLength Optional hash length used to hash password.
377
+ * @property {string} name User name. Max length: 128 chars.
378
+ * @property {boolean} parseOutput
379
+ * @property {libClient | undefined} sdk
380
+ */
381
+
382
+ /**
383
+ * @param {UsersCreateScryptUserRequestParams} params
384
+ */
310
385
  const usersCreateScryptUser = async ({ userId, email, password, passwordSalt, passwordCpu, passwordMemory, passwordParallel, passwordLength, name, parseOutput = true, sdk = undefined}) => {
311
- /* @param {string} userId */
312
- /* @param {string} email */
313
- /* @param {string} password */
314
- /* @param {string} passwordSalt */
315
- /* @param {number} passwordCpu */
316
- /* @param {number} passwordMemory */
317
- /* @param {number} passwordParallel */
318
- /* @param {number} passwordLength */
319
- /* @param {string} name */
320
-
321
386
  let client = !sdk ? await sdkForProject() : sdk;
322
387
  let apiPath = '/users/scrypt';
323
388
  let payload = {};
324
-
325
- /** Body Params */
326
-
327
389
  if (typeof userId !== 'undefined') {
328
390
  payload['userId'] = userId;
329
391
  }
330
-
331
-
332
392
  if (typeof email !== 'undefined') {
333
393
  payload['email'] = email;
334
394
  }
335
-
336
-
337
395
  if (typeof password !== 'undefined') {
338
396
  payload['password'] = password;
339
397
  }
340
-
341
-
342
398
  if (typeof passwordSalt !== 'undefined') {
343
399
  payload['passwordSalt'] = passwordSalt;
344
400
  }
345
-
346
-
347
401
  if (typeof passwordCpu !== 'undefined') {
348
402
  payload['passwordCpu'] = passwordCpu;
349
403
  }
350
-
351
-
352
404
  if (typeof passwordMemory !== 'undefined') {
353
405
  payload['passwordMemory'] = passwordMemory;
354
406
  }
355
-
356
-
357
407
  if (typeof passwordParallel !== 'undefined') {
358
408
  payload['passwordParallel'] = passwordParallel;
359
409
  }
360
-
361
-
362
410
  if (typeof passwordLength !== 'undefined') {
363
411
  payload['passwordLength'] = passwordLength;
364
412
  }
365
-
366
-
367
413
  if (typeof name !== 'undefined') {
368
414
  payload['name'] = name;
369
415
  }
370
416
 
371
417
  let response = undefined;
418
+
372
419
  response = await client.call('post', apiPath, {
373
420
  'content-type': 'application/json',
374
421
  }, payload);
375
-
422
+
376
423
  if (parseOutput) {
377
424
  parse(response)
378
425
  success()
379
426
  }
427
+
380
428
  return response;
381
429
  }
382
430
 
431
+ /**
432
+ * @typedef {Object} UsersCreateScryptModifiedUserRequestParams
433
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
434
+ * @property {string} email User email.
435
+ * @property {string} password User password hashed using Scrypt Modified.
436
+ * @property {string} passwordSalt Salt used to hash password.
437
+ * @property {string} passwordSaltSeparator Salt separator used to hash password.
438
+ * @property {string} passwordSignerKey Signer key used to hash password.
439
+ * @property {string} name User name. Max length: 128 chars.
440
+ * @property {boolean} parseOutput
441
+ * @property {libClient | undefined} sdk
442
+ */
443
+
444
+ /**
445
+ * @param {UsersCreateScryptModifiedUserRequestParams} params
446
+ */
383
447
  const usersCreateScryptModifiedUser = async ({ userId, email, password, passwordSalt, passwordSaltSeparator, passwordSignerKey, name, parseOutput = true, sdk = undefined}) => {
384
- /* @param {string} userId */
385
- /* @param {string} email */
386
- /* @param {string} password */
387
- /* @param {string} passwordSalt */
388
- /* @param {string} passwordSaltSeparator */
389
- /* @param {string} passwordSignerKey */
390
- /* @param {string} name */
391
-
392
448
  let client = !sdk ? await sdkForProject() : sdk;
393
449
  let apiPath = '/users/scrypt-modified';
394
450
  let payload = {};
395
-
396
- /** Body Params */
397
-
398
451
  if (typeof userId !== 'undefined') {
399
452
  payload['userId'] = userId;
400
453
  }
401
-
402
-
403
454
  if (typeof email !== 'undefined') {
404
455
  payload['email'] = email;
405
456
  }
406
-
407
-
408
457
  if (typeof password !== 'undefined') {
409
458
  payload['password'] = password;
410
459
  }
411
-
412
-
413
460
  if (typeof passwordSalt !== 'undefined') {
414
461
  payload['passwordSalt'] = passwordSalt;
415
462
  }
416
-
417
-
418
463
  if (typeof passwordSaltSeparator !== 'undefined') {
419
464
  payload['passwordSaltSeparator'] = passwordSaltSeparator;
420
465
  }
421
-
422
-
423
466
  if (typeof passwordSignerKey !== 'undefined') {
424
467
  payload['passwordSignerKey'] = passwordSignerKey;
425
468
  }
426
-
427
-
428
469
  if (typeof name !== 'undefined') {
429
470
  payload['name'] = name;
430
471
  }
431
472
 
432
473
  let response = undefined;
474
+
433
475
  response = await client.call('post', apiPath, {
434
476
  'content-type': 'application/json',
435
477
  }, payload);
436
-
478
+
437
479
  if (parseOutput) {
438
480
  parse(response)
439
481
  success()
440
482
  }
483
+
441
484
  return response;
442
485
  }
443
486
 
487
+ /**
488
+ * @typedef {Object} UsersCreateSHAUserRequestParams
489
+ * @property {string} userId User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
490
+ * @property {string} email User email.
491
+ * @property {string} password User password hashed using SHA.
492
+ * @property {string} passwordVersion Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'
493
+ * @property {string} name User name. Max length: 128 chars.
494
+ * @property {boolean} parseOutput
495
+ * @property {libClient | undefined} sdk
496
+ */
497
+
498
+ /**
499
+ * @param {UsersCreateSHAUserRequestParams} params
500
+ */
444
501
  const usersCreateSHAUser = async ({ userId, email, password, passwordVersion, name, parseOutput = true, sdk = undefined}) => {
445
- /* @param {string} userId */
446
- /* @param {string} email */
447
- /* @param {string} password */
448
- /* @param {string} passwordVersion */
449
- /* @param {string} name */
450
-
451
502
  let client = !sdk ? await sdkForProject() : sdk;
452
503
  let apiPath = '/users/sha';
453
504
  let payload = {};
454
-
455
- /** Body Params */
456
-
457
505
  if (typeof userId !== 'undefined') {
458
506
  payload['userId'] = userId;
459
507
  }
460
-
461
-
462
508
  if (typeof email !== 'undefined') {
463
509
  payload['email'] = email;
464
510
  }
465
-
466
-
467
511
  if (typeof password !== 'undefined') {
468
512
  payload['password'] = password;
469
513
  }
470
-
471
-
472
514
  if (typeof passwordVersion !== 'undefined') {
473
515
  payload['passwordVersion'] = passwordVersion;
474
516
  }
475
-
476
-
477
517
  if (typeof name !== 'undefined') {
478
518
  payload['name'] = name;
479
519
  }
480
520
 
481
521
  let response = undefined;
522
+
482
523
  response = await client.call('post', apiPath, {
483
524
  'content-type': 'application/json',
484
525
  }, payload);
485
-
526
+
486
527
  if (parseOutput) {
487
528
  parse(response)
488
529
  success()
489
530
  }
531
+
490
532
  return response;
491
533
  }
492
534
 
535
+ /**
536
+ * @typedef {Object} UsersGetUsageRequestParams
537
+ * @property {string} range Date range.
538
+ * @property {string} provider Provider Name.
539
+ * @property {boolean} parseOutput
540
+ * @property {libClient | undefined} sdk
541
+ */
542
+
543
+ /**
544
+ * @param {UsersGetUsageRequestParams} params
545
+ */
493
546
  const usersGetUsage = async ({ range, provider, parseOutput = true, sdk = undefined}) => {
494
- /* @param {string} range */
495
- /* @param {string} provider */
496
-
497
547
  let client = !sdk ? await sdkForProject() : sdk;
498
548
  let apiPath = '/users/usage';
499
549
  let payload = {};
500
-
501
- /** Query Params */
502
550
  if (typeof range !== 'undefined') {
503
551
  payload['range'] = range;
504
552
  }
505
553
  if (typeof provider !== 'undefined') {
506
554
  payload['provider'] = provider;
507
555
  }
556
+
508
557
  let response = undefined;
558
+
509
559
  response = await client.call('get', apiPath, {
510
560
  'content-type': 'application/json',
511
561
  }, payload);
512
-
562
+
513
563
  if (parseOutput) {
514
564
  parse(response)
515
565
  success()
516
566
  }
567
+
517
568
  return response;
518
569
  }
519
570
 
520
- const usersGet = async ({ userId, parseOutput = true, sdk = undefined}) => {
521
- /* @param {string} userId */
571
+ /**
572
+ * @typedef {Object} UsersGetRequestParams
573
+ * @property {string} userId User ID.
574
+ * @property {boolean} parseOutput
575
+ * @property {libClient | undefined} sdk
576
+ */
522
577
 
578
+ /**
579
+ * @param {UsersGetRequestParams} params
580
+ */
581
+ const usersGet = async ({ userId, parseOutput = true, sdk = undefined}) => {
523
582
  let client = !sdk ? await sdkForProject() : sdk;
524
583
  let apiPath = '/users/{userId}'.replace('{userId}', userId);
525
584
  let payload = {};
585
+
526
586
  let response = undefined;
587
+
527
588
  response = await client.call('get', apiPath, {
528
589
  'content-type': 'application/json',
529
590
  }, payload);
530
-
591
+
531
592
  if (parseOutput) {
532
593
  parse(response)
533
594
  success()
534
595
  }
596
+
535
597
  return response;
536
598
  }
537
599
 
538
- const usersDelete = async ({ userId, parseOutput = true, sdk = undefined}) => {
539
- /* @param {string} userId */
600
+ /**
601
+ * @typedef {Object} UsersDeleteRequestParams
602
+ * @property {string} userId User ID.
603
+ * @property {boolean} parseOutput
604
+ * @property {libClient | undefined} sdk
605
+ */
540
606
 
607
+ /**
608
+ * @param {UsersDeleteRequestParams} params
609
+ */
610
+ const usersDelete = async ({ userId, parseOutput = true, sdk = undefined}) => {
541
611
  let client = !sdk ? await sdkForProject() : sdk;
542
612
  let apiPath = '/users/{userId}'.replace('{userId}', userId);
543
613
  let payload = {};
614
+
544
615
  let response = undefined;
616
+
545
617
  response = await client.call('delete', apiPath, {
546
618
  'content-type': 'application/json',
547
619
  }, payload);
548
-
620
+
549
621
  if (parseOutput) {
550
622
  parse(response)
551
623
  success()
552
624
  }
625
+
553
626
  return response;
554
627
  }
555
628
 
629
+ /**
630
+ * @typedef {Object} UsersUpdateEmailRequestParams
631
+ * @property {string} userId User ID.
632
+ * @property {string} email User email.
633
+ * @property {boolean} parseOutput
634
+ * @property {libClient | undefined} sdk
635
+ */
636
+
637
+ /**
638
+ * @param {UsersUpdateEmailRequestParams} params
639
+ */
556
640
  const usersUpdateEmail = async ({ userId, email, parseOutput = true, sdk = undefined}) => {
557
- /* @param {string} userId */
558
- /* @param {string} email */
559
-
560
641
  let client = !sdk ? await sdkForProject() : sdk;
561
642
  let apiPath = '/users/{userId}/email'.replace('{userId}', userId);
562
643
  let payload = {};
563
-
564
- /** Body Params */
565
-
566
644
  if (typeof email !== 'undefined') {
567
645
  payload['email'] = email;
568
646
  }
569
647
 
570
648
  let response = undefined;
649
+
571
650
  response = await client.call('patch', apiPath, {
572
651
  'content-type': 'application/json',
573
652
  }, payload);
574
-
653
+
575
654
  if (parseOutput) {
576
655
  parse(response)
577
656
  success()
578
657
  }
658
+
579
659
  return response;
580
660
  }
581
661
 
662
+ /**
663
+ * @typedef {Object} UsersUpdateLabelsRequestParams
664
+ * @property {string} userId User ID.
665
+ * @property {string[]} labels Array of user labels. Replaces the previous labels. Maximum of 100 labels are allowed, each up to 36 alphanumeric characters long.
666
+ * @property {boolean} parseOutput
667
+ * @property {libClient | undefined} sdk
668
+ */
669
+
670
+ /**
671
+ * @param {UsersUpdateLabelsRequestParams} params
672
+ */
582
673
  const usersUpdateLabels = async ({ userId, labels, parseOutput = true, sdk = undefined}) => {
583
- /* @param {string} userId */
584
- /* @param {string[]} labels */
585
-
586
674
  let client = !sdk ? await sdkForProject() : sdk;
587
675
  let apiPath = '/users/{userId}/labels'.replace('{userId}', userId);
588
676
  let payload = {};
589
-
590
- /** Body Params */
591
677
  labels = labels === true ? [] : labels;
592
-
593
678
  if (typeof labels !== 'undefined') {
594
679
  payload['labels'] = labels;
595
680
  }
596
681
 
597
682
  let response = undefined;
683
+
598
684
  response = await client.call('put', apiPath, {
599
685
  'content-type': 'application/json',
600
686
  }, payload);
601
-
687
+
602
688
  if (parseOutput) {
603
689
  parse(response)
604
690
  success()
605
691
  }
692
+
606
693
  return response;
607
694
  }
608
695
 
696
+ /**
697
+ * @typedef {Object} UsersListLogsRequestParams
698
+ * @property {string} userId User ID.
699
+ * @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset
700
+ * @property {boolean} parseOutput
701
+ * @property {libClient | undefined} sdk
702
+ */
703
+
704
+ /**
705
+ * @param {UsersListLogsRequestParams} params
706
+ */
609
707
  const usersListLogs = async ({ userId, queries, parseOutput = true, sdk = undefined}) => {
610
- /* @param {string} userId */
611
- /* @param {string[]} queries */
612
-
613
708
  let client = !sdk ? await sdkForProject() : sdk;
614
709
  let apiPath = '/users/{userId}/logs'.replace('{userId}', userId);
615
710
  let payload = {};
616
-
617
- /** Query Params */
618
711
  if (typeof queries !== 'undefined') {
619
712
  payload['queries'] = queries;
620
713
  }
714
+
621
715
  let response = undefined;
716
+
622
717
  response = await client.call('get', apiPath, {
623
718
  'content-type': 'application/json',
624
719
  }, payload);
625
-
720
+
626
721
  if (parseOutput) {
627
722
  parse(response)
628
723
  success()
629
724
  }
725
+
630
726
  return response;
631
727
  }
632
728
 
633
- const usersListMemberships = async ({ userId, parseOutput = true, sdk = undefined}) => {
634
- /* @param {string} userId */
729
+ /**
730
+ * @typedef {Object} UsersListMembershipsRequestParams
731
+ * @property {string} userId User ID.
732
+ * @property {boolean} parseOutput
733
+ * @property {libClient | undefined} sdk
734
+ */
635
735
 
736
+ /**
737
+ * @param {UsersListMembershipsRequestParams} params
738
+ */
739
+ const usersListMemberships = async ({ userId, parseOutput = true, sdk = undefined}) => {
636
740
  let client = !sdk ? await sdkForProject() : sdk;
637
741
  let apiPath = '/users/{userId}/memberships'.replace('{userId}', userId);
638
742
  let payload = {};
743
+
639
744
  let response = undefined;
745
+
640
746
  response = await client.call('get', apiPath, {
641
747
  'content-type': 'application/json',
642
748
  }, payload);
643
-
749
+
644
750
  if (parseOutput) {
645
751
  parse(response)
646
752
  success()
647
753
  }
754
+
648
755
  return response;
649
756
  }
650
757
 
758
+ /**
759
+ * @typedef {Object} UsersUpdateNameRequestParams
760
+ * @property {string} userId User ID.
761
+ * @property {string} name User name. Max length: 128 chars.
762
+ * @property {boolean} parseOutput
763
+ * @property {libClient | undefined} sdk
764
+ */
765
+
766
+ /**
767
+ * @param {UsersUpdateNameRequestParams} params
768
+ */
651
769
  const usersUpdateName = async ({ userId, name, parseOutput = true, sdk = undefined}) => {
652
- /* @param {string} userId */
653
- /* @param {string} name */
654
-
655
770
  let client = !sdk ? await sdkForProject() : sdk;
656
771
  let apiPath = '/users/{userId}/name'.replace('{userId}', userId);
657
772
  let payload = {};
658
-
659
- /** Body Params */
660
-
661
773
  if (typeof name !== 'undefined') {
662
774
  payload['name'] = name;
663
775
  }
664
776
 
665
777
  let response = undefined;
778
+
666
779
  response = await client.call('patch', apiPath, {
667
780
  'content-type': 'application/json',
668
781
  }, payload);
669
-
782
+
670
783
  if (parseOutput) {
671
784
  parse(response)
672
785
  success()
673
786
  }
787
+
674
788
  return response;
675
789
  }
676
790
 
791
+ /**
792
+ * @typedef {Object} UsersUpdatePasswordRequestParams
793
+ * @property {string} userId User ID.
794
+ * @property {string} password New user password. Must be at least 8 chars.
795
+ * @property {boolean} parseOutput
796
+ * @property {libClient | undefined} sdk
797
+ */
798
+
799
+ /**
800
+ * @param {UsersUpdatePasswordRequestParams} params
801
+ */
677
802
  const usersUpdatePassword = async ({ userId, password, parseOutput = true, sdk = undefined}) => {
678
- /* @param {string} userId */
679
- /* @param {string} password */
680
-
681
803
  let client = !sdk ? await sdkForProject() : sdk;
682
804
  let apiPath = '/users/{userId}/password'.replace('{userId}', userId);
683
805
  let payload = {};
684
-
685
- /** Body Params */
686
-
687
806
  if (typeof password !== 'undefined') {
688
807
  payload['password'] = password;
689
808
  }
690
809
 
691
810
  let response = undefined;
811
+
692
812
  response = await client.call('patch', apiPath, {
693
813
  'content-type': 'application/json',
694
814
  }, payload);
695
-
815
+
696
816
  if (parseOutput) {
697
817
  parse(response)
698
818
  success()
699
819
  }
820
+
700
821
  return response;
701
822
  }
702
823
 
824
+ /**
825
+ * @typedef {Object} UsersUpdatePhoneRequestParams
826
+ * @property {string} userId User ID.
827
+ * @property {string} number User phone number.
828
+ * @property {boolean} parseOutput
829
+ * @property {libClient | undefined} sdk
830
+ */
831
+
832
+ /**
833
+ * @param {UsersUpdatePhoneRequestParams} params
834
+ */
703
835
  const usersUpdatePhone = async ({ userId, number, parseOutput = true, sdk = undefined}) => {
704
- /* @param {string} userId */
705
- /* @param {string} number */
706
-
707
836
  let client = !sdk ? await sdkForProject() : sdk;
708
837
  let apiPath = '/users/{userId}/phone'.replace('{userId}', userId);
709
838
  let payload = {};
710
-
711
- /** Body Params */
712
-
713
839
  if (typeof number !== 'undefined') {
714
840
  payload['number'] = number;
715
841
  }
716
842
 
717
843
  let response = undefined;
844
+
718
845
  response = await client.call('patch', apiPath, {
719
846
  'content-type': 'application/json',
720
847
  }, payload);
721
-
848
+
722
849
  if (parseOutput) {
723
850
  parse(response)
724
851
  success()
725
852
  }
853
+
726
854
  return response;
727
855
  }
728
856
 
729
- const usersGetPrefs = async ({ userId, parseOutput = true, sdk = undefined}) => {
730
- /* @param {string} userId */
857
+ /**
858
+ * @typedef {Object} UsersGetPrefsRequestParams
859
+ * @property {string} userId User ID.
860
+ * @property {boolean} parseOutput
861
+ * @property {libClient | undefined} sdk
862
+ */
731
863
 
864
+ /**
865
+ * @param {UsersGetPrefsRequestParams} params
866
+ */
867
+ const usersGetPrefs = async ({ userId, parseOutput = true, sdk = undefined}) => {
732
868
  let client = !sdk ? await sdkForProject() : sdk;
733
869
  let apiPath = '/users/{userId}/prefs'.replace('{userId}', userId);
734
870
  let payload = {};
871
+
735
872
  let response = undefined;
873
+
736
874
  response = await client.call('get', apiPath, {
737
875
  'content-type': 'application/json',
738
876
  }, payload);
739
-
877
+
740
878
  if (parseOutput) {
741
879
  parse(response)
742
880
  success()
743
881
  }
882
+
744
883
  return response;
745
884
  }
746
885
 
886
+ /**
887
+ * @typedef {Object} UsersUpdatePrefsRequestParams
888
+ * @property {string} userId User ID.
889
+ * @property {object} prefs Prefs key-value JSON object.
890
+ * @property {boolean} parseOutput
891
+ * @property {libClient | undefined} sdk
892
+ */
893
+
894
+ /**
895
+ * @param {UsersUpdatePrefsRequestParams} params
896
+ */
747
897
  const usersUpdatePrefs = async ({ userId, prefs, parseOutput = true, sdk = undefined}) => {
748
- /* @param {string} userId */
749
- /* @param {object} prefs */
750
-
751
898
  let client = !sdk ? await sdkForProject() : sdk;
752
899
  let apiPath = '/users/{userId}/prefs'.replace('{userId}', userId);
753
900
  let payload = {};
754
-
755
- /** Body Params */
756
901
  if (typeof prefs !== 'undefined') {
757
902
  payload['prefs'] = JSON.parse(prefs);
758
903
  }
759
904
 
760
905
  let response = undefined;
906
+
761
907
  response = await client.call('patch', apiPath, {
762
908
  'content-type': 'application/json',
763
909
  }, payload);
764
-
910
+
765
911
  if (parseOutput) {
766
912
  parse(response)
767
913
  success()
768
914
  }
915
+
769
916
  return response;
770
917
  }
771
918
 
772
- const usersListSessions = async ({ userId, parseOutput = true, sdk = undefined}) => {
773
- /* @param {string} userId */
919
+ /**
920
+ * @typedef {Object} UsersListSessionsRequestParams
921
+ * @property {string} userId User ID.
922
+ * @property {boolean} parseOutput
923
+ * @property {libClient | undefined} sdk
924
+ */
774
925
 
926
+ /**
927
+ * @param {UsersListSessionsRequestParams} params
928
+ */
929
+ const usersListSessions = async ({ userId, parseOutput = true, sdk = undefined}) => {
775
930
  let client = !sdk ? await sdkForProject() : sdk;
776
931
  let apiPath = '/users/{userId}/sessions'.replace('{userId}', userId);
777
932
  let payload = {};
933
+
778
934
  let response = undefined;
935
+
779
936
  response = await client.call('get', apiPath, {
780
937
  'content-type': 'application/json',
781
938
  }, payload);
782
-
939
+
783
940
  if (parseOutput) {
784
941
  parse(response)
785
942
  success()
786
943
  }
944
+
787
945
  return response;
788
946
  }
789
947
 
790
- const usersDeleteSessions = async ({ userId, parseOutput = true, sdk = undefined}) => {
791
- /* @param {string} userId */
948
+ /**
949
+ * @typedef {Object} UsersDeleteSessionsRequestParams
950
+ * @property {string} userId User ID.
951
+ * @property {boolean} parseOutput
952
+ * @property {libClient | undefined} sdk
953
+ */
792
954
 
955
+ /**
956
+ * @param {UsersDeleteSessionsRequestParams} params
957
+ */
958
+ const usersDeleteSessions = async ({ userId, parseOutput = true, sdk = undefined}) => {
793
959
  let client = !sdk ? await sdkForProject() : sdk;
794
960
  let apiPath = '/users/{userId}/sessions'.replace('{userId}', userId);
795
961
  let payload = {};
962
+
796
963
  let response = undefined;
964
+
797
965
  response = await client.call('delete', apiPath, {
798
966
  'content-type': 'application/json',
799
967
  }, payload);
800
-
968
+
801
969
  if (parseOutput) {
802
970
  parse(response)
803
971
  success()
804
972
  }
973
+
805
974
  return response;
806
975
  }
807
976
 
977
+ /**
978
+ * @typedef {Object} UsersDeleteSessionRequestParams
979
+ * @property {string} userId User ID.
980
+ * @property {string} sessionId Session ID.
981
+ * @property {boolean} parseOutput
982
+ * @property {libClient | undefined} sdk
983
+ */
984
+
985
+ /**
986
+ * @param {UsersDeleteSessionRequestParams} params
987
+ */
808
988
  const usersDeleteSession = async ({ userId, sessionId, parseOutput = true, sdk = undefined}) => {
809
- /* @param {string} userId */
810
- /* @param {string} sessionId */
811
-
812
989
  let client = !sdk ? await sdkForProject() : sdk;
813
990
  let apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId);
814
991
  let payload = {};
992
+
815
993
  let response = undefined;
994
+
816
995
  response = await client.call('delete', apiPath, {
817
996
  'content-type': 'application/json',
818
997
  }, payload);
819
-
998
+
820
999
  if (parseOutput) {
821
1000
  parse(response)
822
1001
  success()
823
1002
  }
1003
+
824
1004
  return response;
825
1005
  }
826
1006
 
1007
+ /**
1008
+ * @typedef {Object} UsersUpdateStatusRequestParams
1009
+ * @property {string} userId User ID.
1010
+ * @property {boolean} status User Status. To activate the user pass 'true' and to block the user pass 'false'.
1011
+ * @property {boolean} parseOutput
1012
+ * @property {libClient | undefined} sdk
1013
+ */
1014
+
1015
+ /**
1016
+ * @param {UsersUpdateStatusRequestParams} params
1017
+ */
827
1018
  const usersUpdateStatus = async ({ userId, status, parseOutput = true, sdk = undefined}) => {
828
- /* @param {string} userId */
829
- /* @param {boolean} status */
830
-
831
1019
  let client = !sdk ? await sdkForProject() : sdk;
832
1020
  let apiPath = '/users/{userId}/status'.replace('{userId}', userId);
833
1021
  let payload = {};
834
-
835
- /** Body Params */
836
-
837
1022
  if (typeof status !== 'undefined') {
838
1023
  payload['status'] = status;
839
1024
  }
840
1025
 
841
1026
  let response = undefined;
1027
+
842
1028
  response = await client.call('patch', apiPath, {
843
1029
  'content-type': 'application/json',
844
1030
  }, payload);
845
-
1031
+
846
1032
  if (parseOutput) {
847
1033
  parse(response)
848
1034
  success()
849
1035
  }
1036
+
850
1037
  return response;
851
1038
  }
852
1039
 
1040
+ /**
1041
+ * @typedef {Object} UsersUpdateEmailVerificationRequestParams
1042
+ * @property {string} userId User ID.
1043
+ * @property {boolean} emailVerification User email verification status.
1044
+ * @property {boolean} parseOutput
1045
+ * @property {libClient | undefined} sdk
1046
+ */
1047
+
1048
+ /**
1049
+ * @param {UsersUpdateEmailVerificationRequestParams} params
1050
+ */
853
1051
  const usersUpdateEmailVerification = async ({ userId, emailVerification, parseOutput = true, sdk = undefined}) => {
854
- /* @param {string} userId */
855
- /* @param {boolean} emailVerification */
856
-
857
1052
  let client = !sdk ? await sdkForProject() : sdk;
858
1053
  let apiPath = '/users/{userId}/verification'.replace('{userId}', userId);
859
1054
  let payload = {};
860
-
861
- /** Body Params */
862
-
863
1055
  if (typeof emailVerification !== 'undefined') {
864
1056
  payload['emailVerification'] = emailVerification;
865
1057
  }
866
1058
 
867
1059
  let response = undefined;
1060
+
868
1061
  response = await client.call('patch', apiPath, {
869
1062
  'content-type': 'application/json',
870
1063
  }, payload);
871
-
1064
+
872
1065
  if (parseOutput) {
873
1066
  parse(response)
874
1067
  success()
875
1068
  }
1069
+
876
1070
  return response;
877
1071
  }
878
1072
 
1073
+ /**
1074
+ * @typedef {Object} UsersUpdatePhoneVerificationRequestParams
1075
+ * @property {string} userId User ID.
1076
+ * @property {boolean} phoneVerification User phone verification status.
1077
+ * @property {boolean} parseOutput
1078
+ * @property {libClient | undefined} sdk
1079
+ */
1080
+
1081
+ /**
1082
+ * @param {UsersUpdatePhoneVerificationRequestParams} params
1083
+ */
879
1084
  const usersUpdatePhoneVerification = async ({ userId, phoneVerification, parseOutput = true, sdk = undefined}) => {
880
- /* @param {string} userId */
881
- /* @param {boolean} phoneVerification */
882
-
883
1085
  let client = !sdk ? await sdkForProject() : sdk;
884
1086
  let apiPath = '/users/{userId}/verification/phone'.replace('{userId}', userId);
885
1087
  let payload = {};
886
-
887
- /** Body Params */
888
-
889
1088
  if (typeof phoneVerification !== 'undefined') {
890
1089
  payload['phoneVerification'] = phoneVerification;
891
1090
  }
892
1091
 
893
1092
  let response = undefined;
1093
+
894
1094
  response = await client.call('patch', apiPath, {
895
1095
  'content-type': 'application/json',
896
1096
  }, payload);
897
-
1097
+
898
1098
  if (parseOutput) {
899
1099
  parse(response)
900
1100
  success()
901
1101
  }
1102
+
902
1103
  return response;
903
1104
  }
904
1105
 
905
-
906
1106
  users
907
1107
  .command(`list`)
908
1108
  .description(`Get a list of all the project's users. You can use the query params to filter your results.`)
@@ -1125,7 +1325,6 @@ users
1125
1325
  .requiredOption(`--phoneVerification <phoneVerification>`, `User phone verification status.`, parseBool)
1126
1326
  .action(actionRunner(usersUpdatePhoneVerification))
1127
1327
 
1128
-
1129
1328
  module.exports = {
1130
1329
  users,
1131
1330
  usersList,
@@ -1157,4 +1356,4 @@ module.exports = {
1157
1356
  usersUpdateStatus,
1158
1357
  usersUpdateEmailVerification,
1159
1358
  usersUpdatePhoneVerification
1160
- };
1359
+ };