appwrite-cli 4.2.0 → 4.2.1

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