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,546 +9,722 @@ 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 account = new Command("account").description(commandDescriptions['account']).configureHelp({
14
39
  helpWidth: process.stdout.columns || 80
15
- })
40
+ })
16
41
 
17
- const accountGet = async ({ parseOutput = true, sdk = undefined}) => {
42
+ /**
43
+ * @typedef {Object} AccountGetRequestParams
44
+ * @property {boolean} parseOutput
45
+ * @property {libClient | undefined} sdk
46
+ */
18
47
 
48
+ /**
49
+ * @param {AccountGetRequestParams} params
50
+ */
51
+ const accountGet = async ({ parseOutput = true, sdk = undefined}) => {
19
52
  let client = !sdk ? await sdkForProject() : sdk;
20
53
  let apiPath = '/account';
21
54
  let payload = {};
55
+
22
56
  let response = undefined;
57
+
23
58
  response = await client.call('get', apiPath, {
24
59
  'content-type': 'application/json',
25
60
  }, payload);
26
-
61
+
27
62
  if (parseOutput) {
28
63
  parse(response)
29
64
  success()
30
65
  }
66
+
31
67
  return response;
32
68
  }
33
69
 
70
+ /**
71
+ * @typedef {Object} AccountCreateRequestParams
72
+ * @property {string} userId Unique 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.
73
+ * @property {string} email User email.
74
+ * @property {string} password New user password. Must be at least 8 chars.
75
+ * @property {string} name User name. Max length: 128 chars.
76
+ * @property {boolean} parseOutput
77
+ * @property {libClient | undefined} sdk
78
+ */
79
+
80
+ /**
81
+ * @param {AccountCreateRequestParams} params
82
+ */
34
83
  const accountCreate = async ({ userId, email, password, name, parseOutput = true, sdk = undefined}) => {
35
- /* @param {string} userId */
36
- /* @param {string} email */
37
- /* @param {string} password */
38
- /* @param {string} name */
39
-
40
84
  let client = !sdk ? await sdkForProject() : sdk;
41
85
  let apiPath = '/account';
42
86
  let payload = {};
43
-
44
- /** Body Params */
45
-
46
87
  if (typeof userId !== 'undefined') {
47
88
  payload['userId'] = userId;
48
89
  }
49
-
50
-
51
90
  if (typeof email !== 'undefined') {
52
91
  payload['email'] = email;
53
92
  }
54
-
55
-
56
93
  if (typeof password !== 'undefined') {
57
94
  payload['password'] = password;
58
95
  }
59
-
60
-
61
96
  if (typeof name !== 'undefined') {
62
97
  payload['name'] = name;
63
98
  }
64
99
 
65
100
  let response = undefined;
101
+
66
102
  response = await client.call('post', apiPath, {
67
103
  'content-type': 'application/json',
68
104
  }, payload);
69
-
105
+
70
106
  if (parseOutput) {
71
107
  parse(response)
72
108
  success()
73
109
  }
110
+
74
111
  return response;
75
112
  }
76
113
 
114
+ /**
115
+ * @typedef {Object} AccountUpdateEmailRequestParams
116
+ * @property {string} email User email.
117
+ * @property {string} password User password. Must be at least 8 chars.
118
+ * @property {boolean} parseOutput
119
+ * @property {libClient | undefined} sdk
120
+ */
121
+
122
+ /**
123
+ * @param {AccountUpdateEmailRequestParams} params
124
+ */
77
125
  const accountUpdateEmail = async ({ email, password, parseOutput = true, sdk = undefined}) => {
78
- /* @param {string} email */
79
- /* @param {string} password */
80
-
81
126
  let client = !sdk ? await sdkForProject() : sdk;
82
127
  let apiPath = '/account/email';
83
128
  let payload = {};
84
-
85
- /** Body Params */
86
-
87
129
  if (typeof email !== 'undefined') {
88
130
  payload['email'] = email;
89
131
  }
90
-
91
-
92
132
  if (typeof password !== 'undefined') {
93
133
  payload['password'] = password;
94
134
  }
95
135
 
96
136
  let response = undefined;
137
+
97
138
  response = await client.call('patch', apiPath, {
98
139
  'content-type': 'application/json',
99
140
  }, payload);
100
-
141
+
101
142
  if (parseOutput) {
102
143
  parse(response)
103
144
  success()
104
145
  }
146
+
105
147
  return response;
106
148
  }
107
149
 
108
- const accountListIdentities = async ({ queries, parseOutput = true, sdk = undefined}) => {
109
- /* @param {string} queries */
150
+ /**
151
+ * @typedef {Object} AccountListIdentitiesRequestParams
152
+ * @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
153
+ * @property {boolean} parseOutput
154
+ * @property {libClient | undefined} sdk
155
+ */
110
156
 
157
+ /**
158
+ * @param {AccountListIdentitiesRequestParams} params
159
+ */
160
+ const accountListIdentities = async ({ queries, parseOutput = true, sdk = undefined}) => {
111
161
  let client = !sdk ? await sdkForProject() : sdk;
112
162
  let apiPath = '/account/identities';
113
163
  let payload = {};
114
-
115
- /** Query Params */
116
164
  if (typeof queries !== 'undefined') {
117
165
  payload['queries'] = queries;
118
166
  }
167
+
119
168
  let response = undefined;
169
+
120
170
  response = await client.call('get', apiPath, {
121
171
  'content-type': 'application/json',
122
172
  }, payload);
123
-
173
+
124
174
  if (parseOutput) {
125
175
  parse(response)
126
176
  success()
127
177
  }
178
+
128
179
  return response;
129
180
  }
130
181
 
131
- const accountDeleteIdentity = async ({ identityId, parseOutput = true, sdk = undefined}) => {
132
- /* @param {string} identityId */
182
+ /**
183
+ * @typedef {Object} AccountDeleteIdentityRequestParams
184
+ * @property {string} identityId Identity ID.
185
+ * @property {boolean} parseOutput
186
+ * @property {libClient | undefined} sdk
187
+ */
133
188
 
189
+ /**
190
+ * @param {AccountDeleteIdentityRequestParams} params
191
+ */
192
+ const accountDeleteIdentity = async ({ identityId, parseOutput = true, sdk = undefined}) => {
134
193
  let client = !sdk ? await sdkForProject() : sdk;
135
194
  let apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId);
136
195
  let payload = {};
196
+
137
197
  let response = undefined;
198
+
138
199
  response = await client.call('delete', apiPath, {
139
200
  'content-type': 'application/json',
140
201
  }, payload);
141
-
202
+
142
203
  if (parseOutput) {
143
204
  parse(response)
144
205
  success()
145
206
  }
207
+
146
208
  return response;
147
209
  }
148
210
 
149
- const accountCreateJWT = async ({ parseOutput = true, sdk = undefined}) => {
211
+ /**
212
+ * @typedef {Object} AccountCreateJWTRequestParams
213
+ * @property {boolean} parseOutput
214
+ * @property {libClient | undefined} sdk
215
+ */
150
216
 
217
+ /**
218
+ * @param {AccountCreateJWTRequestParams} params
219
+ */
220
+ const accountCreateJWT = async ({ parseOutput = true, sdk = undefined}) => {
151
221
  let client = !sdk ? await sdkForProject() : sdk;
152
222
  let apiPath = '/account/jwt';
153
223
  let payload = {};
224
+
154
225
  let response = undefined;
226
+
155
227
  response = await client.call('post', apiPath, {
156
228
  'content-type': 'application/json',
157
229
  }, payload);
158
-
230
+
159
231
  if (parseOutput) {
160
232
  parse(response)
161
233
  success()
162
234
  }
235
+
163
236
  return response;
164
237
  }
165
238
 
166
- const accountListLogs = async ({ queries, parseOutput = true, sdk = undefined}) => {
167
- /* @param {string[]} queries */
239
+ /**
240
+ * @typedef {Object} AccountListLogsRequestParams
241
+ * @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
242
+ * @property {boolean} parseOutput
243
+ * @property {libClient | undefined} sdk
244
+ */
168
245
 
246
+ /**
247
+ * @param {AccountListLogsRequestParams} params
248
+ */
249
+ const accountListLogs = async ({ queries, parseOutput = true, sdk = undefined}) => {
169
250
  let client = !sdk ? await sdkForProject() : sdk;
170
251
  let apiPath = '/account/logs';
171
252
  let payload = {};
172
-
173
- /** Query Params */
174
253
  if (typeof queries !== 'undefined') {
175
254
  payload['queries'] = queries;
176
255
  }
256
+
177
257
  let response = undefined;
258
+
178
259
  response = await client.call('get', apiPath, {
179
260
  'content-type': 'application/json',
180
261
  }, payload);
181
-
262
+
182
263
  if (parseOutput) {
183
264
  parse(response)
184
265
  success()
185
266
  }
267
+
186
268
  return response;
187
269
  }
188
270
 
189
- const accountUpdateName = async ({ name, parseOutput = true, sdk = undefined}) => {
190
- /* @param {string} name */
271
+ /**
272
+ * @typedef {Object} AccountUpdateNameRequestParams
273
+ * @property {string} name User name. Max length: 128 chars.
274
+ * @property {boolean} parseOutput
275
+ * @property {libClient | undefined} sdk
276
+ */
191
277
 
278
+ /**
279
+ * @param {AccountUpdateNameRequestParams} params
280
+ */
281
+ const accountUpdateName = async ({ name, parseOutput = true, sdk = undefined}) => {
192
282
  let client = !sdk ? await sdkForProject() : sdk;
193
283
  let apiPath = '/account/name';
194
284
  let payload = {};
195
-
196
- /** Body Params */
197
-
198
285
  if (typeof name !== 'undefined') {
199
286
  payload['name'] = name;
200
287
  }
201
288
 
202
289
  let response = undefined;
290
+
203
291
  response = await client.call('patch', apiPath, {
204
292
  'content-type': 'application/json',
205
293
  }, payload);
206
-
294
+
207
295
  if (parseOutput) {
208
296
  parse(response)
209
297
  success()
210
298
  }
299
+
211
300
  return response;
212
301
  }
213
302
 
303
+ /**
304
+ * @typedef {Object} AccountUpdatePasswordRequestParams
305
+ * @property {string} password New user password. Must be at least 8 chars.
306
+ * @property {string} oldPassword Current user password. Must be at least 8 chars.
307
+ * @property {boolean} parseOutput
308
+ * @property {libClient | undefined} sdk
309
+ */
310
+
311
+ /**
312
+ * @param {AccountUpdatePasswordRequestParams} params
313
+ */
214
314
  const accountUpdatePassword = async ({ password, oldPassword, parseOutput = true, sdk = undefined}) => {
215
- /* @param {string} password */
216
- /* @param {string} oldPassword */
217
-
218
315
  let client = !sdk ? await sdkForProject() : sdk;
219
316
  let apiPath = '/account/password';
220
317
  let payload = {};
221
-
222
- /** Body Params */
223
-
224
318
  if (typeof password !== 'undefined') {
225
319
  payload['password'] = password;
226
320
  }
227
-
228
-
229
321
  if (typeof oldPassword !== 'undefined') {
230
322
  payload['oldPassword'] = oldPassword;
231
323
  }
232
324
 
233
325
  let response = undefined;
326
+
234
327
  response = await client.call('patch', apiPath, {
235
328
  'content-type': 'application/json',
236
329
  }, payload);
237
-
330
+
238
331
  if (parseOutput) {
239
332
  parse(response)
240
333
  success()
241
334
  }
335
+
242
336
  return response;
243
337
  }
244
338
 
339
+ /**
340
+ * @typedef {Object} AccountUpdatePhoneRequestParams
341
+ * @property {string} phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
342
+ * @property {string} password User password. Must be at least 8 chars.
343
+ * @property {boolean} parseOutput
344
+ * @property {libClient | undefined} sdk
345
+ */
346
+
347
+ /**
348
+ * @param {AccountUpdatePhoneRequestParams} params
349
+ */
245
350
  const accountUpdatePhone = async ({ phone, password, parseOutput = true, sdk = undefined}) => {
246
- /* @param {string} phone */
247
- /* @param {string} password */
248
-
249
351
  let client = !sdk ? await sdkForProject() : sdk;
250
352
  let apiPath = '/account/phone';
251
353
  let payload = {};
252
-
253
- /** Body Params */
254
-
255
354
  if (typeof phone !== 'undefined') {
256
355
  payload['phone'] = phone;
257
356
  }
258
-
259
-
260
357
  if (typeof password !== 'undefined') {
261
358
  payload['password'] = password;
262
359
  }
263
360
 
264
361
  let response = undefined;
362
+
265
363
  response = await client.call('patch', apiPath, {
266
364
  'content-type': 'application/json',
267
365
  }, payload);
268
-
366
+
269
367
  if (parseOutput) {
270
368
  parse(response)
271
369
  success()
272
370
  }
371
+
273
372
  return response;
274
373
  }
275
374
 
276
- const accountGetPrefs = async ({ parseOutput = true, sdk = undefined}) => {
375
+ /**
376
+ * @typedef {Object} AccountGetPrefsRequestParams
377
+ * @property {boolean} parseOutput
378
+ * @property {libClient | undefined} sdk
379
+ */
277
380
 
381
+ /**
382
+ * @param {AccountGetPrefsRequestParams} params
383
+ */
384
+ const accountGetPrefs = async ({ parseOutput = true, sdk = undefined}) => {
278
385
  let client = !sdk ? await sdkForProject() : sdk;
279
386
  let apiPath = '/account/prefs';
280
387
  let payload = {};
388
+
281
389
  let response = undefined;
390
+
282
391
  response = await client.call('get', apiPath, {
283
392
  'content-type': 'application/json',
284
393
  }, payload);
285
-
394
+
286
395
  if (parseOutput) {
287
396
  parse(response)
288
397
  success()
289
398
  }
399
+
290
400
  return response;
291
401
  }
292
402
 
293
- const accountUpdatePrefs = async ({ prefs, parseOutput = true, sdk = undefined}) => {
294
- /* @param {object} prefs */
403
+ /**
404
+ * @typedef {Object} AccountUpdatePrefsRequestParams
405
+ * @property {object} prefs Prefs key-value JSON object.
406
+ * @property {boolean} parseOutput
407
+ * @property {libClient | undefined} sdk
408
+ */
295
409
 
410
+ /**
411
+ * @param {AccountUpdatePrefsRequestParams} params
412
+ */
413
+ const accountUpdatePrefs = async ({ prefs, parseOutput = true, sdk = undefined}) => {
296
414
  let client = !sdk ? await sdkForProject() : sdk;
297
415
  let apiPath = '/account/prefs';
298
416
  let payload = {};
299
-
300
- /** Body Params */
301
417
  if (typeof prefs !== 'undefined') {
302
418
  payload['prefs'] = JSON.parse(prefs);
303
419
  }
304
420
 
305
421
  let response = undefined;
422
+
306
423
  response = await client.call('patch', apiPath, {
307
424
  'content-type': 'application/json',
308
425
  }, payload);
309
-
426
+
310
427
  if (parseOutput) {
311
428
  parse(response)
312
429
  success()
313
430
  }
431
+
314
432
  return response;
315
433
  }
316
434
 
435
+ /**
436
+ * @typedef {Object} AccountCreateRecoveryRequestParams
437
+ * @property {string} email User email.
438
+ * @property {string} url URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
439
+ * @property {boolean} parseOutput
440
+ * @property {libClient | undefined} sdk
441
+ */
442
+
443
+ /**
444
+ * @param {AccountCreateRecoveryRequestParams} params
445
+ */
317
446
  const accountCreateRecovery = async ({ email, url, parseOutput = true, sdk = undefined}) => {
318
- /* @param {string} email */
319
- /* @param {string} url */
320
-
321
447
  let client = !sdk ? await sdkForProject() : sdk;
322
448
  let apiPath = '/account/recovery';
323
449
  let payload = {};
324
-
325
- /** Body Params */
326
-
327
450
  if (typeof email !== 'undefined') {
328
451
  payload['email'] = email;
329
452
  }
330
-
331
-
332
453
  if (typeof url !== 'undefined') {
333
454
  payload['url'] = url;
334
455
  }
335
456
 
336
457
  let response = undefined;
458
+
337
459
  response = await client.call('post', apiPath, {
338
460
  'content-type': 'application/json',
339
461
  }, payload);
340
-
462
+
341
463
  if (parseOutput) {
342
464
  parse(response)
343
465
  success()
344
466
  }
467
+
345
468
  return response;
346
469
  }
347
470
 
471
+ /**
472
+ * @typedef {Object} AccountUpdateRecoveryRequestParams
473
+ * @property {string} userId User ID.
474
+ * @property {string} secret Valid reset token.
475
+ * @property {string} password New user password. Must be at least 8 chars.
476
+ * @property {string} passwordAgain Repeat new user password. Must be at least 8 chars.
477
+ * @property {boolean} parseOutput
478
+ * @property {libClient | undefined} sdk
479
+ */
480
+
481
+ /**
482
+ * @param {AccountUpdateRecoveryRequestParams} params
483
+ */
348
484
  const accountUpdateRecovery = async ({ userId, secret, password, passwordAgain, parseOutput = true, sdk = undefined}) => {
349
- /* @param {string} userId */
350
- /* @param {string} secret */
351
- /* @param {string} password */
352
- /* @param {string} passwordAgain */
353
-
354
485
  let client = !sdk ? await sdkForProject() : sdk;
355
486
  let apiPath = '/account/recovery';
356
487
  let payload = {};
357
-
358
- /** Body Params */
359
-
360
488
  if (typeof userId !== 'undefined') {
361
489
  payload['userId'] = userId;
362
490
  }
363
-
364
-
365
491
  if (typeof secret !== 'undefined') {
366
492
  payload['secret'] = secret;
367
493
  }
368
-
369
-
370
494
  if (typeof password !== 'undefined') {
371
495
  payload['password'] = password;
372
496
  }
373
-
374
-
375
497
  if (typeof passwordAgain !== 'undefined') {
376
498
  payload['passwordAgain'] = passwordAgain;
377
499
  }
378
500
 
379
501
  let response = undefined;
502
+
380
503
  response = await client.call('put', apiPath, {
381
504
  'content-type': 'application/json',
382
505
  }, payload);
383
-
506
+
384
507
  if (parseOutput) {
385
508
  parse(response)
386
509
  success()
387
510
  }
511
+
388
512
  return response;
389
513
  }
390
514
 
391
- const accountListSessions = async ({ parseOutput = true, sdk = undefined}) => {
515
+ /**
516
+ * @typedef {Object} AccountListSessionsRequestParams
517
+ * @property {boolean} parseOutput
518
+ * @property {libClient | undefined} sdk
519
+ */
392
520
 
521
+ /**
522
+ * @param {AccountListSessionsRequestParams} params
523
+ */
524
+ const accountListSessions = async ({ parseOutput = true, sdk = undefined}) => {
393
525
  let client = !sdk ? await sdkForProject() : sdk;
394
526
  let apiPath = '/account/sessions';
395
527
  let payload = {};
528
+
396
529
  let response = undefined;
530
+
397
531
  response = await client.call('get', apiPath, {
398
532
  'content-type': 'application/json',
399
533
  }, payload);
400
-
534
+
401
535
  if (parseOutput) {
402
536
  parse(response)
403
537
  success()
404
538
  }
539
+
405
540
  return response;
406
541
  }
407
542
 
408
- const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) => {
543
+ /**
544
+ * @typedef {Object} AccountDeleteSessionsRequestParams
545
+ * @property {boolean} parseOutput
546
+ * @property {libClient | undefined} sdk
547
+ */
409
548
 
549
+ /**
550
+ * @param {AccountDeleteSessionsRequestParams} params
551
+ */
552
+ const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) => {
410
553
  let client = !sdk ? await sdkForProject() : sdk;
411
554
  let apiPath = '/account/sessions';
412
555
  let payload = {};
556
+
413
557
  let response = undefined;
558
+
414
559
  response = await client.call('delete', apiPath, {
415
560
  'content-type': 'application/json',
416
561
  }, payload);
417
-
562
+
418
563
  if (parseOutput) {
419
564
  parse(response)
420
565
  success()
421
566
  }
567
+
422
568
  return response;
423
569
  }
424
570
 
425
- const accountCreateAnonymousSession = async ({ parseOutput = true, sdk = undefined}) => {
571
+ /**
572
+ * @typedef {Object} AccountCreateAnonymousSessionRequestParams
573
+ * @property {boolean} parseOutput
574
+ * @property {libClient | undefined} sdk
575
+ */
426
576
 
577
+ /**
578
+ * @param {AccountCreateAnonymousSessionRequestParams} params
579
+ */
580
+ const accountCreateAnonymousSession = async ({ parseOutput = true, sdk = undefined}) => {
427
581
  let client = !sdk ? await sdkForProject() : sdk;
428
582
  let apiPath = '/account/sessions/anonymous';
429
583
  let payload = {};
584
+
430
585
  let response = undefined;
586
+
431
587
  response = await client.call('post', apiPath, {
432
588
  'content-type': 'application/json',
433
589
  }, payload);
434
-
590
+
435
591
  if (parseOutput) {
436
592
  parse(response)
437
593
  success()
438
594
  }
595
+
439
596
  return response;
440
597
  }
441
598
 
599
+ /**
600
+ * @typedef {Object} AccountCreateEmailSessionRequestParams
601
+ * @property {string} email User email.
602
+ * @property {string} password User password. Must be at least 8 chars.
603
+ * @property {boolean} parseOutput
604
+ * @property {libClient | undefined} sdk
605
+ */
606
+
607
+ /**
608
+ * @param {AccountCreateEmailSessionRequestParams} params
609
+ */
442
610
  const accountCreateEmailSession = async ({ email, password, parseOutput = true, sdk = undefined}) => {
443
- /* @param {string} email */
444
- /* @param {string} password */
445
-
446
611
  let client = !sdk ? await sdkForProject() : sdk;
447
612
  let apiPath = '/account/sessions/email';
448
613
  let payload = {};
449
-
450
- /** Body Params */
451
-
452
614
  if (typeof email !== 'undefined') {
453
615
  payload['email'] = email;
454
616
  }
455
-
456
-
457
617
  if (typeof password !== 'undefined') {
458
618
  payload['password'] = password;
459
619
  }
460
620
 
461
621
  let response = undefined;
622
+
462
623
  response = await client.call('post', apiPath, {
463
624
  'content-type': 'application/json',
464
625
  }, payload);
465
-
626
+
466
627
  if (parseOutput) {
467
628
  parse(response)
468
629
  success()
469
630
  }
631
+
470
632
  return response;
471
633
  }
472
634
 
635
+ /**
636
+ * @typedef {Object} AccountCreateMagicURLSessionRequestParams
637
+ * @property {string} userId Unique 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.
638
+ * @property {string} email User email.
639
+ * @property {string} url URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
640
+ * @property {boolean} parseOutput
641
+ * @property {libClient | undefined} sdk
642
+ */
643
+
644
+ /**
645
+ * @param {AccountCreateMagicURLSessionRequestParams} params
646
+ */
473
647
  const accountCreateMagicURLSession = async ({ userId, email, url, parseOutput = true, sdk = undefined}) => {
474
- /* @param {string} userId */
475
- /* @param {string} email */
476
- /* @param {string} url */
477
-
478
648
  let client = !sdk ? await sdkForProject() : sdk;
479
649
  let apiPath = '/account/sessions/magic-url';
480
650
  let payload = {};
481
-
482
- /** Body Params */
483
-
484
651
  if (typeof userId !== 'undefined') {
485
652
  payload['userId'] = userId;
486
653
  }
487
-
488
-
489
654
  if (typeof email !== 'undefined') {
490
655
  payload['email'] = email;
491
656
  }
492
-
493
-
494
657
  if (typeof url !== 'undefined') {
495
658
  payload['url'] = url;
496
659
  }
497
660
 
498
661
  let response = undefined;
662
+
499
663
  response = await client.call('post', apiPath, {
500
664
  'content-type': 'application/json',
501
665
  }, payload);
502
-
666
+
503
667
  if (parseOutput) {
504
668
  parse(response)
505
669
  success()
506
670
  }
671
+
507
672
  return response;
508
673
  }
509
674
 
675
+ /**
676
+ * @typedef {Object} AccountUpdateMagicURLSessionRequestParams
677
+ * @property {string} userId User ID.
678
+ * @property {string} secret Valid verification token.
679
+ * @property {boolean} parseOutput
680
+ * @property {libClient | undefined} sdk
681
+ */
682
+
683
+ /**
684
+ * @param {AccountUpdateMagicURLSessionRequestParams} params
685
+ */
510
686
  const accountUpdateMagicURLSession = async ({ userId, secret, parseOutput = true, sdk = undefined}) => {
511
- /* @param {string} userId */
512
- /* @param {string} secret */
513
-
514
687
  let client = !sdk ? await sdkForProject() : sdk;
515
688
  let apiPath = '/account/sessions/magic-url';
516
689
  let payload = {};
517
-
518
- /** Body Params */
519
-
520
690
  if (typeof userId !== 'undefined') {
521
691
  payload['userId'] = userId;
522
692
  }
523
-
524
-
525
693
  if (typeof secret !== 'undefined') {
526
694
  payload['secret'] = secret;
527
695
  }
528
696
 
529
697
  let response = undefined;
698
+
530
699
  response = await client.call('put', apiPath, {
531
700
  'content-type': 'application/json',
532
701
  }, payload);
533
-
702
+
534
703
  if (parseOutput) {
535
704
  parse(response)
536
705
  success()
537
706
  }
707
+
538
708
  return response;
539
709
  }
540
710
 
711
+ /**
712
+ * @typedef {Object} AccountCreateOAuth2SessionRequestParams
713
+ * @property {string} provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.
714
+ * @property {string} success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
715
+ * @property {string} failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
716
+ * @property {string[]} scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
717
+ * @property {boolean} parseOutput
718
+ * @property {libClient | undefined} sdk
719
+ */
720
+
721
+ /**
722
+ * @param {AccountCreateOAuth2SessionRequestParams} params
723
+ */
541
724
  const accountCreateOAuth2Session = async ({ provider, success, failure, scopes, parseOutput = true, sdk = undefined}) => {
542
- /* @param {string} provider */
543
- /* @param {string} success */
544
- /* @param {string} failure */
545
- /* @param {string[]} scopes */
546
-
547
725
  let client = !sdk ? await sdkForProject() : sdk;
548
726
  let apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
549
727
  let payload = {};
550
-
551
- /** Query Params */
552
728
  if (typeof success !== 'undefined') {
553
729
  payload['success'] = success;
554
730
  }
@@ -558,256 +734,340 @@ const accountCreateOAuth2Session = async ({ provider, success, failure, scopes,
558
734
  if (typeof scopes !== 'undefined') {
559
735
  payload['scopes'] = scopes;
560
736
  }
737
+
561
738
  let response = undefined;
739
+
562
740
  response = await client.call('get', apiPath, {
563
741
  'content-type': 'application/json',
564
742
  }, payload);
565
-
743
+
566
744
  if (parseOutput) {
567
745
  parse(response)
568
746
  success()
569
747
  }
748
+
570
749
  return response;
571
750
  }
572
751
 
752
+ /**
753
+ * @typedef {Object} AccountCreatePhoneSessionRequestParams
754
+ * @property {string} userId Unique 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.
755
+ * @property {string} phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
756
+ * @property {boolean} parseOutput
757
+ * @property {libClient | undefined} sdk
758
+ */
759
+
760
+ /**
761
+ * @param {AccountCreatePhoneSessionRequestParams} params
762
+ */
573
763
  const accountCreatePhoneSession = async ({ userId, phone, parseOutput = true, sdk = undefined}) => {
574
- /* @param {string} userId */
575
- /* @param {string} phone */
576
-
577
764
  let client = !sdk ? await sdkForProject() : sdk;
578
765
  let apiPath = '/account/sessions/phone';
579
766
  let payload = {};
580
-
581
- /** Body Params */
582
-
583
767
  if (typeof userId !== 'undefined') {
584
768
  payload['userId'] = userId;
585
769
  }
586
-
587
-
588
770
  if (typeof phone !== 'undefined') {
589
771
  payload['phone'] = phone;
590
772
  }
591
773
 
592
774
  let response = undefined;
775
+
593
776
  response = await client.call('post', apiPath, {
594
777
  'content-type': 'application/json',
595
778
  }, payload);
596
-
779
+
597
780
  if (parseOutput) {
598
781
  parse(response)
599
782
  success()
600
783
  }
784
+
601
785
  return response;
602
786
  }
603
787
 
788
+ /**
789
+ * @typedef {Object} AccountUpdatePhoneSessionRequestParams
790
+ * @property {string} userId User ID.
791
+ * @property {string} secret Valid verification token.
792
+ * @property {boolean} parseOutput
793
+ * @property {libClient | undefined} sdk
794
+ */
795
+
796
+ /**
797
+ * @param {AccountUpdatePhoneSessionRequestParams} params
798
+ */
604
799
  const accountUpdatePhoneSession = async ({ userId, secret, parseOutput = true, sdk = undefined}) => {
605
- /* @param {string} userId */
606
- /* @param {string} secret */
607
-
608
800
  let client = !sdk ? await sdkForProject() : sdk;
609
801
  let apiPath = '/account/sessions/phone';
610
802
  let payload = {};
611
-
612
- /** Body Params */
613
-
614
803
  if (typeof userId !== 'undefined') {
615
804
  payload['userId'] = userId;
616
805
  }
617
-
618
-
619
806
  if (typeof secret !== 'undefined') {
620
807
  payload['secret'] = secret;
621
808
  }
622
809
 
623
810
  let response = undefined;
811
+
624
812
  response = await client.call('put', apiPath, {
625
813
  'content-type': 'application/json',
626
814
  }, payload);
627
-
815
+
628
816
  if (parseOutput) {
629
817
  parse(response)
630
818
  success()
631
819
  }
820
+
632
821
  return response;
633
822
  }
634
823
 
635
- const accountGetSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
636
- /* @param {string} sessionId */
824
+ /**
825
+ * @typedef {Object} AccountGetSessionRequestParams
826
+ * @property {string} sessionId Session ID. Use the string 'current' to get the current device session.
827
+ * @property {boolean} parseOutput
828
+ * @property {libClient | undefined} sdk
829
+ */
637
830
 
831
+ /**
832
+ * @param {AccountGetSessionRequestParams} params
833
+ */
834
+ const accountGetSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
638
835
  let client = !sdk ? await sdkForProject() : sdk;
639
836
  let apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
640
837
  let payload = {};
838
+
641
839
  let response = undefined;
840
+
642
841
  response = await client.call('get', apiPath, {
643
842
  'content-type': 'application/json',
644
843
  }, payload);
645
-
844
+
646
845
  if (parseOutput) {
647
846
  parse(response)
648
847
  success()
649
848
  }
849
+
650
850
  return response;
651
851
  }
652
852
 
653
- const accountUpdateSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
654
- /* @param {string} sessionId */
853
+ /**
854
+ * @typedef {Object} AccountUpdateSessionRequestParams
855
+ * @property {string} sessionId Session ID. Use the string 'current' to update the current device session.
856
+ * @property {boolean} parseOutput
857
+ * @property {libClient | undefined} sdk
858
+ */
655
859
 
860
+ /**
861
+ * @param {AccountUpdateSessionRequestParams} params
862
+ */
863
+ const accountUpdateSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
656
864
  let client = !sdk ? await sdkForProject() : sdk;
657
865
  let apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
658
866
  let payload = {};
867
+
659
868
  let response = undefined;
869
+
660
870
  response = await client.call('patch', apiPath, {
661
871
  'content-type': 'application/json',
662
872
  }, payload);
663
-
873
+
664
874
  if (parseOutput) {
665
875
  parse(response)
666
876
  success()
667
877
  }
878
+
668
879
  return response;
669
880
  }
670
881
 
671
- const accountDeleteSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
672
- /* @param {string} sessionId */
882
+ /**
883
+ * @typedef {Object} AccountDeleteSessionRequestParams
884
+ * @property {string} sessionId Session ID. Use the string 'current' to delete the current device session.
885
+ * @property {boolean} parseOutput
886
+ * @property {libClient | undefined} sdk
887
+ */
673
888
 
889
+ /**
890
+ * @param {AccountDeleteSessionRequestParams} params
891
+ */
892
+ const accountDeleteSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
674
893
  let client = !sdk ? await sdkForProject() : sdk;
675
894
  let apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
676
895
  let payload = {};
896
+
677
897
  let response = undefined;
898
+
678
899
  response = await client.call('delete', apiPath, {
679
900
  'content-type': 'application/json',
680
901
  }, payload);
681
-
902
+
682
903
  if (parseOutput) {
683
904
  parse(response)
684
905
  success()
685
906
  }
907
+
686
908
  return response;
687
909
  }
688
910
 
689
- const accountUpdateStatus = async ({ parseOutput = true, sdk = undefined}) => {
911
+ /**
912
+ * @typedef {Object} AccountUpdateStatusRequestParams
913
+ * @property {boolean} parseOutput
914
+ * @property {libClient | undefined} sdk
915
+ */
690
916
 
917
+ /**
918
+ * @param {AccountUpdateStatusRequestParams} params
919
+ */
920
+ const accountUpdateStatus = async ({ parseOutput = true, sdk = undefined}) => {
691
921
  let client = !sdk ? await sdkForProject() : sdk;
692
922
  let apiPath = '/account/status';
693
923
  let payload = {};
924
+
694
925
  let response = undefined;
926
+
695
927
  response = await client.call('patch', apiPath, {
696
928
  'content-type': 'application/json',
697
929
  }, payload);
698
-
930
+
699
931
  if (parseOutput) {
700
932
  parse(response)
701
933
  success()
702
934
  }
935
+
703
936
  return response;
704
937
  }
705
938
 
706
- const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefined}) => {
707
- /* @param {string} url */
939
+ /**
940
+ * @typedef {Object} AccountCreateVerificationRequestParams
941
+ * @property {string} url URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
942
+ * @property {boolean} parseOutput
943
+ * @property {libClient | undefined} sdk
944
+ */
708
945
 
946
+ /**
947
+ * @param {AccountCreateVerificationRequestParams} params
948
+ */
949
+ const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefined}) => {
709
950
  let client = !sdk ? await sdkForProject() : sdk;
710
951
  let apiPath = '/account/verification';
711
952
  let payload = {};
712
-
713
- /** Body Params */
714
-
715
953
  if (typeof url !== 'undefined') {
716
954
  payload['url'] = url;
717
955
  }
718
956
 
719
957
  let response = undefined;
958
+
720
959
  response = await client.call('post', apiPath, {
721
960
  'content-type': 'application/json',
722
961
  }, payload);
723
-
962
+
724
963
  if (parseOutput) {
725
964
  parse(response)
726
965
  success()
727
966
  }
967
+
728
968
  return response;
729
969
  }
730
970
 
971
+ /**
972
+ * @typedef {Object} AccountUpdateVerificationRequestParams
973
+ * @property {string} userId User ID.
974
+ * @property {string} secret Valid verification token.
975
+ * @property {boolean} parseOutput
976
+ * @property {libClient | undefined} sdk
977
+ */
978
+
979
+ /**
980
+ * @param {AccountUpdateVerificationRequestParams} params
981
+ */
731
982
  const accountUpdateVerification = async ({ userId, secret, parseOutput = true, sdk = undefined}) => {
732
- /* @param {string} userId */
733
- /* @param {string} secret */
734
-
735
983
  let client = !sdk ? await sdkForProject() : sdk;
736
984
  let apiPath = '/account/verification';
737
985
  let payload = {};
738
-
739
- /** Body Params */
740
-
741
986
  if (typeof userId !== 'undefined') {
742
987
  payload['userId'] = userId;
743
988
  }
744
-
745
-
746
989
  if (typeof secret !== 'undefined') {
747
990
  payload['secret'] = secret;
748
991
  }
749
992
 
750
993
  let response = undefined;
994
+
751
995
  response = await client.call('put', apiPath, {
752
996
  'content-type': 'application/json',
753
997
  }, payload);
754
-
998
+
755
999
  if (parseOutput) {
756
1000
  parse(response)
757
1001
  success()
758
1002
  }
1003
+
759
1004
  return response;
760
1005
  }
761
1006
 
762
- const accountCreatePhoneVerification = async ({ parseOutput = true, sdk = undefined}) => {
1007
+ /**
1008
+ * @typedef {Object} AccountCreatePhoneVerificationRequestParams
1009
+ * @property {boolean} parseOutput
1010
+ * @property {libClient | undefined} sdk
1011
+ */
763
1012
 
1013
+ /**
1014
+ * @param {AccountCreatePhoneVerificationRequestParams} params
1015
+ */
1016
+ const accountCreatePhoneVerification = async ({ parseOutput = true, sdk = undefined}) => {
764
1017
  let client = !sdk ? await sdkForProject() : sdk;
765
1018
  let apiPath = '/account/verification/phone';
766
1019
  let payload = {};
1020
+
767
1021
  let response = undefined;
1022
+
768
1023
  response = await client.call('post', apiPath, {
769
1024
  'content-type': 'application/json',
770
1025
  }, payload);
771
-
1026
+
772
1027
  if (parseOutput) {
773
1028
  parse(response)
774
1029
  success()
775
1030
  }
1031
+
776
1032
  return response;
777
1033
  }
778
1034
 
1035
+ /**
1036
+ * @typedef {Object} AccountUpdatePhoneVerificationRequestParams
1037
+ * @property {string} userId User ID.
1038
+ * @property {string} secret Valid verification token.
1039
+ * @property {boolean} parseOutput
1040
+ * @property {libClient | undefined} sdk
1041
+ */
1042
+
1043
+ /**
1044
+ * @param {AccountUpdatePhoneVerificationRequestParams} params
1045
+ */
779
1046
  const accountUpdatePhoneVerification = async ({ userId, secret, parseOutput = true, sdk = undefined}) => {
780
- /* @param {string} userId */
781
- /* @param {string} secret */
782
-
783
1047
  let client = !sdk ? await sdkForProject() : sdk;
784
1048
  let apiPath = '/account/verification/phone';
785
1049
  let payload = {};
786
-
787
- /** Body Params */
788
-
789
1050
  if (typeof userId !== 'undefined') {
790
1051
  payload['userId'] = userId;
791
1052
  }
792
-
793
-
794
1053
  if (typeof secret !== 'undefined') {
795
1054
  payload['secret'] = secret;
796
1055
  }
797
1056
 
798
1057
  let response = undefined;
1058
+
799
1059
  response = await client.call('put', apiPath, {
800
1060
  'content-type': 'application/json',
801
1061
  }, payload);
802
-
1062
+
803
1063
  if (parseOutput) {
804
1064
  parse(response)
805
1065
  success()
806
1066
  }
1067
+
807
1068
  return response;
808
1069
  }
809
1070
 
810
-
811
1071
  account
812
1072
  .command(`get`)
813
1073
  .description(`Get the currently logged in user.`)
@@ -1007,7 +1267,6 @@ account
1007
1267
  .requiredOption(`--secret <secret>`, `Valid verification token.`)
1008
1268
  .action(actionRunner(accountUpdatePhoneVerification))
1009
1269
 
1010
-
1011
1270
  module.exports = {
1012
1271
  account,
1013
1272
  accountGet,
@@ -1041,4 +1300,4 @@ module.exports = {
1041
1300
  accountUpdateVerification,
1042
1301
  accountCreatePhoneVerification,
1043
1302
  accountUpdatePhoneVerification
1044
- };
1303
+ };