@tailor-platform/sdk 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 0.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#228](https://github.com/tailor-platform/sdk/pull/228) [`5b7749e`](https://github.com/tailor-platform/sdk/commit/5b7749e996f849bac158678cec0d63c710bfef2e) Thanks [@toiroakr](https://github.com/toiroakr)! - feat(cli)!: enhance command arguments and improve documentation for secret and workflow commands
8
+
9
+ ### Patch Changes
10
+
11
+ - [#225](https://github.com/tailor-platform/sdk/pull/225) [`21f689d`](https://github.com/tailor-platform/sdk/commit/21f689df8f53e2731a36b50e14faa43f09d5a4e2) Thanks [@riku99](https://github.com/riku99)! - Refactor example resolvers to call getDB() inside handlers instead of importing a shared DB instance
12
+
13
+ - [#229](https://github.com/tailor-platform/sdk/pull/229) [`70527bb`](https://github.com/tailor-platform/sdk/commit/70527bb1c2bb1e0d2f03d94a539c771f6e3f54d3) Thanks [@toiroakr](https://github.com/toiroakr)! - feat: load organization/folder from env
14
+
15
+ ## 0.20.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#220](https://github.com/tailor-platform/sdk/pull/220) [`f4b3d4e`](https://github.com/tailor-platform/sdk/commit/f4b3d4e237e08982e185db980a6b5666fb89cb5a) Thanks [@toiroakr](https://github.com/toiroakr)! - refactor(cli)!: rename "user use" to "user switch"
20
+
3
21
  ## 0.19.0
4
22
 
5
23
  ### Minor Changes
@@ -1,9 +1,11 @@
1
1
  /// <reference path="./../user-defined.d.ts" />
2
2
 
3
- import { AppConfig, CodeGeneratorBase, Executor, Generator, IdProviderConfig, OAuth2ClientInput, Resolver, TailorDBTypeConfig } from "../types-BBF5LRC0.mjs";
3
+ import { Ct as Resolver, J as OAuth2ClientInput, K as IdProviderConfig, M as TailorDBTypeConfig, d as AppConfig, h as Generator, m as CodeGeneratorBase, t as Executor } from "../types-EKga-JDM.mjs";
4
4
  import "citty";
5
5
  import { z } from "zod";
6
+ import { OAuth2Client } from "@badgateway/oauth2-client";
6
7
  import "@bufbuild/protobuf/wkt";
8
+ import "@connectrpc/connect";
7
9
  import "@bufbuild/protobuf/codegenv2";
8
10
  import "@bufbuild/protobuf";
9
11
  import { Jsonifiable } from "type-fest";
@@ -318,7 +320,7 @@ declare function listWorkflows(options?: ListWorkflowsOptions): Promise<Workflow
318
320
  //#endregion
319
321
  //#region src/cli/workflow/get.d.ts
320
322
  interface GetWorkflowOptions {
321
- nameOrId: string;
323
+ name: string;
322
324
  workspaceId?: string;
323
325
  profile?: string;
324
326
  }
@@ -326,7 +328,7 @@ declare function getWorkflow(options: GetWorkflowOptions): Promise<WorkflowInfo>
326
328
  //#endregion
327
329
  //#region src/cli/workflow/start.d.ts
328
330
  interface StartWorkflowOptions {
329
- nameOrId: string;
331
+ name: string;
330
332
  machineUser: string;
331
333
  arg?: Jsonifiable;
332
334
  workspaceId?: string;
package/dist/cli/api.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { apply, createWorkspace, deleteWorkspace, generate, generateUserTypes, getMachineUserToken, getOAuth2Client, getWorkflow, getWorkflowExecution, listMachineUsers, listOAuth2Clients, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, remove, resumeWorkflow, show, startWorkflow } from "../resume-DSfYKl2w.mjs";
2
- import "../job-CL8myeqs.mjs";
1
+ import { C as listOAuth2Clients, E as getMachineUserToken, G as loadWorkspaceId, H as loadConfig, N as apply, T as getOAuth2Client, V as generateUserTypes, W as loadAccessToken, _ as listWorkflowExecutions, b as remove, c as resumeWorkflow, f as listWorkflows, g as getWorkflowExecution, i as deleteWorkspace, j as generate, k as listMachineUsers, m as getWorkflow, n as listWorkspaces, o as createWorkspace, u as startWorkflow, v as show } from "../list-D_TfcRMd.mjs";
2
+ import "../config-BGY8v5d7.mjs";
3
3
  import { register } from "node:module";
4
4
 
5
5
  //#region src/cli/api.ts
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, deploymentArgs, executionsCommand, fetchAll, fetchLatestToken, fetchUserInfo, generateCommand, getCommand, getCommand$1 as getCommand$2, initOAuth2Client, initOperatorClient, jsonArgs, listCommand as listCommand$1, listCommand$1 as listCommand$7, listCommand$2 as listCommand$8, listCommand$3 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, logger, printData, readPackageJson, readPlatformConfig, removeCommand, resumeCommand, showCommand, startCommand, tokenCommand, withCommonArgs, workspaceArgs, writePlatformConfig } from "../resume-DSfYKl2w.mjs";
3
- import "../job-CL8myeqs.mjs";
2
+ import { $ as PATScope, A as printData, B as workspaceArgs, D as tokenCommand, F as commonArgs, G as loadWorkspaceId, H as loadConfig, I as confirmationArgs, J as fetchAll, K as readPlatformConfig, L as deploymentArgs, M as generateCommand, O as listCommand$8, P as applyCommand, Q as readPackageJson, R as jsonArgs, S as listCommand$7, U as fetchLatestToken, W as loadAccessToken, X as initOAuth2Client, Y as fetchUserInfo, Z as initOperatorClient, a as createCommand, d as listCommand$1, et as logger, h as executionsCommand, l as startCommand, p as getCommand, q as writePlatformConfig, r as deleteCommand, s as resumeCommand, t as listCommand, w as getCommand$2, x as removeCommand, y as showCommand, z as withCommonArgs } from "../list-D_TfcRMd.mjs";
3
+ import "../config-BGY8v5d7.mjs";
4
4
  import { register } from "node:module";
5
5
  import { defineCommand, runCommand, runMain } from "citty";
6
6
  import * as path from "path";
@@ -242,8 +242,7 @@ const createCommand$3 = defineCommand({
242
242
  run: withCommonArgs(async (args) => {
243
243
  const config = readPlatformConfig();
244
244
  if (config.profiles[args.name]) throw new Error(`Profile "${args.name}" already exists.`);
245
- const token = await fetchLatestToken(config, args.user);
246
- const client = await initOperatorClient(token);
245
+ const client = await initOperatorClient(await fetchLatestToken(config, args.user));
247
246
  if (!(await fetchAll(async (pageToken) => {
248
247
  const { workspaces, nextPageToken } = await client.listWorkspaces({ pageToken });
249
248
  return [workspaces, nextPageToken];
@@ -254,12 +253,11 @@ const createCommand$3 = defineCommand({
254
253
  };
255
254
  writePlatformConfig(config);
256
255
  if (!args.json) logger.success(`Profile "${args.name}" created successfully.`);
257
- const profileInfo = {
256
+ printData({
258
257
  name: args.name,
259
258
  user: args.user,
260
259
  workspaceId: args["workspace-id"]
261
- };
262
- printData(profileInfo, args.json);
260
+ }, args.json);
263
261
  })
264
262
  });
265
263
 
@@ -308,12 +306,11 @@ const listCommand$6 = defineCommand({
308
306
  `);
309
307
  return;
310
308
  }
311
- const profileInfos = profiles.map(([name, profile]) => ({
309
+ printData(profiles.map(([name, profile]) => ({
312
310
  name,
313
311
  user: profile.user,
314
312
  workspaceId: profile.workspace_id
315
- }));
316
- printData(profileInfos, args.json);
313
+ })), args.json);
317
314
  })
318
315
  });
319
316
 
@@ -352,8 +349,7 @@ const updateCommand$1 = defineCommand({
352
349
  const newUser = args.user || oldUser;
353
350
  const oldWorkspaceId = profile.workspace_id;
354
351
  const newWorkspaceId = args["workspace-id"] || oldWorkspaceId;
355
- const token = await fetchLatestToken(config, newUser);
356
- const client = await initOperatorClient(token);
352
+ const client = await initOperatorClient(await fetchLatestToken(config, newUser));
357
353
  if (!(await fetchAll(async (pageToken) => {
358
354
  const { workspaces, nextPageToken } = await client.listWorkspaces({ pageToken });
359
355
  return [workspaces, nextPageToken];
@@ -362,12 +358,11 @@ const updateCommand$1 = defineCommand({
362
358
  profile.workspace_id = newWorkspaceId;
363
359
  writePlatformConfig(config);
364
360
  if (!args.json) logger.success(`Profile "${args.name}" updated successfully`);
365
- const profileInfo = {
361
+ printData({
366
362
  name: args.name,
367
363
  user: newUser,
368
364
  workspaceId: newWorkspaceId
369
- };
370
- printData(profileInfo, args.json);
365
+ }, args.json);
371
366
  })
372
367
  });
373
368
 
@@ -389,6 +384,42 @@ const profileCommand = defineCommand({
389
384
  }
390
385
  });
391
386
 
387
+ //#endregion
388
+ //#region src/cli/secret/args.ts
389
+ /**
390
+ * Arguments for specify secret key
391
+ */
392
+ const vaultArgs = { "vault-name": {
393
+ type: "string",
394
+ description: "Vault name",
395
+ alias: "V",
396
+ required: true
397
+ } };
398
+ /**
399
+ * Arguments for specify secret key
400
+ */
401
+ const secretIdentifyArgs = {
402
+ ...vaultArgs,
403
+ name: {
404
+ type: "string",
405
+ description: "Secret name",
406
+ alias: "N",
407
+ required: true
408
+ }
409
+ };
410
+ /**
411
+ * Arguments for specify secret key
412
+ */
413
+ const secretValueArgs = {
414
+ ...secretIdentifyArgs,
415
+ value: {
416
+ type: "string",
417
+ description: "Secret value",
418
+ alias: "v",
419
+ required: true
420
+ }
421
+ };
422
+
392
423
  //#endregion
393
424
  //#region src/cli/secret/create.ts
394
425
  const createSecretCommand = defineCommand({
@@ -399,28 +430,13 @@ const createSecretCommand = defineCommand({
399
430
  args: {
400
431
  ...commonArgs,
401
432
  ...workspaceArgs,
402
- "vault-name": {
403
- type: "string",
404
- description: "Vault name",
405
- required: true
406
- },
407
- name: {
408
- type: "string",
409
- description: "Secret name",
410
- required: true
411
- },
412
- value: {
413
- type: "string",
414
- description: "Secret value",
415
- required: true
416
- }
433
+ ...secretValueArgs
417
434
  },
418
435
  run: withCommonArgs(async (args) => {
419
- const accessToken = await loadAccessToken({
436
+ const client = await initOperatorClient(await loadAccessToken({
420
437
  useProfile: true,
421
438
  profile: args.profile
422
- });
423
- const client = await initOperatorClient(accessToken);
439
+ }));
424
440
  const workspaceId = loadWorkspaceId({
425
441
  workspaceId: args["workspace-id"],
426
442
  profile: args.profile
@@ -453,29 +469,14 @@ const deleteSecretCommand = defineCommand({
453
469
  args: {
454
470
  ...commonArgs,
455
471
  ...workspaceArgs,
456
- "vault-name": {
457
- type: "string",
458
- description: "Vault name",
459
- required: true
460
- },
461
- name: {
462
- type: "string",
463
- description: "Secret name",
464
- required: true
465
- },
466
- yes: {
467
- type: "boolean",
468
- description: "Skip confirmation prompt",
469
- alias: "y",
470
- default: false
471
- }
472
+ ...secretIdentifyArgs,
473
+ ...confirmationArgs
472
474
  },
473
475
  run: withCommonArgs(async (args) => {
474
- const accessToken = await loadAccessToken({
476
+ const client = await initOperatorClient(await loadAccessToken({
475
477
  useProfile: true,
476
478
  profile: args.profile
477
- });
478
- const client = await initOperatorClient(accessToken);
479
+ }));
479
480
  const workspaceId = loadWorkspaceId({
480
481
  workspaceId: args["workspace-id"],
481
482
  profile: args.profile
@@ -510,11 +511,10 @@ function secretInfo(secret) {
510
511
  };
511
512
  }
512
513
  async function secretList(options) {
513
- const accessToken = await loadAccessToken({
514
+ const client = await initOperatorClient(await loadAccessToken({
514
515
  useProfile: true,
515
516
  profile: options.profile
516
- });
517
- const client = await initOperatorClient(accessToken);
517
+ }));
518
518
  const workspaceId = loadWorkspaceId({
519
519
  workspaceId: options.workspaceId,
520
520
  profile: options.profile
@@ -537,20 +537,15 @@ const listSecretCommand = defineCommand({
537
537
  ...commonArgs,
538
538
  ...jsonArgs,
539
539
  ...workspaceArgs,
540
- "vault-name": {
541
- type: "string",
542
- description: "Vault name",
543
- required: true
544
- }
540
+ ...vaultArgs
545
541
  },
546
542
  run: withCommonArgs(async (args) => {
547
543
  try {
548
- const secrets = await secretList({
544
+ printData(await secretList({
549
545
  workspaceId: args["workspace-id"],
550
546
  profile: args.profile,
551
547
  vaultName: args["vault-name"]
552
- });
553
- printData(secrets, args.json);
548
+ }), args.json);
554
549
  } catch (error) {
555
550
  if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
556
551
  throw error;
@@ -568,28 +563,13 @@ const updateSecretCommand = defineCommand({
568
563
  args: {
569
564
  ...commonArgs,
570
565
  ...workspaceArgs,
571
- "vault-name": {
572
- type: "string",
573
- description: "Vault name",
574
- required: true
575
- },
576
- name: {
577
- type: "string",
578
- description: "Secret name",
579
- required: true
580
- },
581
- value: {
582
- type: "string",
583
- description: "Secret value",
584
- required: true
585
- }
566
+ ...secretValueArgs
586
567
  },
587
568
  run: withCommonArgs(async (args) => {
588
- const accessToken = await loadAccessToken({
569
+ const client = await initOperatorClient(await loadAccessToken({
589
570
  useProfile: true,
590
571
  profile: args.profile
591
- });
592
- const client = await initOperatorClient(accessToken);
572
+ }));
593
573
  const workspaceId = loadWorkspaceId({
594
574
  workspaceId: args["workspace-id"],
595
575
  profile: args.profile
@@ -609,6 +589,14 @@ const updateSecretCommand = defineCommand({
609
589
  })
610
590
  });
611
591
 
592
+ //#endregion
593
+ //#region src/cli/secret/vault/args.ts
594
+ const nameArgs = { name: {
595
+ type: "positional",
596
+ description: "Vault name",
597
+ required: true
598
+ } };
599
+
612
600
  //#endregion
613
601
  //#region src/cli/secret/vault/create.ts
614
602
  const createCommand$2 = defineCommand({
@@ -619,18 +607,13 @@ const createCommand$2 = defineCommand({
619
607
  args: {
620
608
  ...commonArgs,
621
609
  ...workspaceArgs,
622
- name: {
623
- type: "string",
624
- description: "Vault name",
625
- required: true
626
- }
610
+ ...nameArgs
627
611
  },
628
612
  run: withCommonArgs(async (args) => {
629
- const accessToken = await loadAccessToken({
613
+ const client = await initOperatorClient(await loadAccessToken({
630
614
  useProfile: true,
631
615
  profile: args.profile
632
- });
633
- const client = await initOperatorClient(accessToken);
616
+ }));
634
617
  const workspaceId = loadWorkspaceId({
635
618
  workspaceId: args["workspace-id"],
636
619
  profile: args.profile
@@ -658,24 +641,14 @@ const deleteCommand$2 = defineCommand({
658
641
  args: {
659
642
  ...commonArgs,
660
643
  ...workspaceArgs,
661
- name: {
662
- type: "string",
663
- description: "Vault name",
664
- required: true
665
- },
666
- yes: {
667
- type: "boolean",
668
- description: "Skip confirmation prompt",
669
- alias: "y",
670
- default: false
671
- }
644
+ ...nameArgs,
645
+ ...confirmationArgs
672
646
  },
673
647
  run: withCommonArgs(async (args) => {
674
- const accessToken = await loadAccessToken({
648
+ const client = await initOperatorClient(await loadAccessToken({
675
649
  useProfile: true,
676
650
  profile: args.profile
677
- });
678
- const client = await initOperatorClient(accessToken);
651
+ }));
679
652
  const workspaceId = loadWorkspaceId({
680
653
  workspaceId: args["workspace-id"],
681
654
  profile: args.profile
@@ -709,11 +682,10 @@ function vaultInfo(vault) {
709
682
  };
710
683
  }
711
684
  async function vaultList(options) {
712
- const accessToken = await loadAccessToken({
685
+ const client = await initOperatorClient(await loadAccessToken({
713
686
  useProfile: true,
714
687
  profile: options?.profile
715
- });
716
- const client = await initOperatorClient(accessToken);
688
+ }));
717
689
  const workspaceId = loadWorkspaceId({
718
690
  workspaceId: options?.workspaceId,
719
691
  profile: options?.profile
@@ -737,11 +709,10 @@ const listCommand$5 = defineCommand({
737
709
  ...workspaceArgs
738
710
  },
739
711
  run: withCommonArgs(async (args) => {
740
- const vaults = await vaultList({
712
+ printData(await vaultList({
741
713
  workspaceId: args["workspace-id"],
742
714
  profile: args.profile
743
- });
744
- printData(vaults, args.json);
715
+ }), args.json);
745
716
  })
746
717
  });
747
718
 
@@ -930,11 +901,10 @@ const deployCommand = defineCommand({
930
901
  },
931
902
  run: withCommonArgs(async (args) => {
932
903
  logger.info(`Deploying static website "${args.name}" from directory: ${args.dir}`);
933
- const accessToken = await loadAccessToken({
904
+ const client = await initOperatorClient(await loadAccessToken({
934
905
  useProfile: true,
935
906
  profile: args.profile
936
- });
937
- const client = await initOperatorClient(accessToken);
907
+ }));
938
908
  const name = args.name;
939
909
  const dir = path.resolve(process.cwd(), args.dir);
940
910
  const workspaceId = loadWorkspaceId({
@@ -974,11 +944,10 @@ const getCommand$1 = defineCommand({
974
944
  }
975
945
  },
976
946
  run: withCommonArgs(async (args) => {
977
- const accessToken = await loadAccessToken({
947
+ const client = await initOperatorClient(await loadAccessToken({
978
948
  useProfile: true,
979
949
  profile: args.profile
980
- });
981
- const client = await initOperatorClient(accessToken);
950
+ }));
982
951
  const workspaceId = loadWorkspaceId({
983
952
  workspaceId: args["workspace-id"],
984
953
  profile: args.profile
@@ -990,14 +959,13 @@ const getCommand$1 = defineCommand({
990
959
  name: args.name
991
960
  });
992
961
  if (!staticwebsite) throw new Error(notFoundErrorMessage);
993
- const info = {
962
+ printData({
994
963
  workspaceId,
995
964
  name: staticwebsite.name,
996
965
  description: staticwebsite.description,
997
966
  url: staticwebsite.url,
998
967
  allowedIpAddresses: args.json ? staticwebsite.allowedIpAddresses : staticwebsite.allowedIpAddresses.join("\n")
999
- };
1000
- printData(info, args.json);
968
+ }, args.json);
1001
969
  } catch (error) {
1002
970
  if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(notFoundErrorMessage);
1003
971
  throw error;
@@ -1008,11 +976,10 @@ const getCommand$1 = defineCommand({
1008
976
  //#endregion
1009
977
  //#region src/cli/staticwebsite/list.ts
1010
978
  async function listStaticWebsites(options) {
1011
- const accessToken = await loadAccessToken({
979
+ const client = await initOperatorClient(await loadAccessToken({
1012
980
  useProfile: true,
1013
981
  profile: options?.profile
1014
- });
1015
- const client = await initOperatorClient(accessToken);
982
+ }));
1016
983
  const workspaceId = loadWorkspaceId({
1017
984
  workspaceId: options?.workspaceId,
1018
985
  profile: options?.profile
@@ -1046,7 +1013,7 @@ const listCommand$4 = defineCommand({
1046
1013
  workspaceId: args["workspace-id"],
1047
1014
  profile: args.profile
1048
1015
  });
1049
- const formatted = args.json ? websites : websites.map(({ allowedIpAddresses,...rest }) => {
1016
+ printData(args.json ? websites : websites.map(({ allowedIpAddresses, ...rest }) => {
1050
1017
  if (allowedIpAddresses.length === 0) return {
1051
1018
  ...rest,
1052
1019
  allowedIpAddresses: "No allowed IP addresses"
@@ -1057,8 +1024,7 @@ const listCommand$4 = defineCommand({
1057
1024
  ...rest,
1058
1025
  allowedIpAddresses: label
1059
1026
  };
1060
- });
1061
- printData(formatted, args.json);
1027
+ }), args.json);
1062
1028
  })
1063
1029
  });
1064
1030
 
@@ -1116,11 +1082,10 @@ async function getTypeNamespace(workspaceId, typeName, client, configPath) {
1116
1082
  return null;
1117
1083
  }
1118
1084
  async function truncate(options) {
1119
- const accessToken = await loadAccessToken({
1085
+ const client = await initOperatorClient(await loadAccessToken({
1120
1086
  useProfile: true,
1121
1087
  profile: options?.profile
1122
- });
1123
- const client = await initOperatorClient(accessToken);
1088
+ }));
1124
1089
  const workspaceId = loadWorkspaceId({
1125
1090
  workspaceId: options?.workspaceId,
1126
1091
  profile: options?.profile
@@ -1380,8 +1345,7 @@ const createCommand$1 = defineCommand({
1380
1345
  No user logged in.
1381
1346
  Please login first using 'tailor-sdk login' command.
1382
1347
  `);
1383
- const token = await fetchLatestToken(config, config.current_user);
1384
- const client = await initOperatorClient(token);
1348
+ const client = await initOperatorClient(await fetchLatestToken(config, config.current_user));
1385
1349
  const scopes = getScopesFromWriteFlag(args.write);
1386
1350
  const result = await client.createPersonalAccessToken({
1387
1351
  name: args.name,
@@ -1413,8 +1377,7 @@ const deleteCommand$1 = defineCommand({
1413
1377
  No user logged in.
1414
1378
  Please login first using 'tailor-sdk login' command.
1415
1379
  `);
1416
- const token = await fetchLatestToken(config, config.current_user);
1417
- await (await initOperatorClient(token)).deletePersonalAccessToken({ name: args.name });
1380
+ await (await initOperatorClient(await fetchLatestToken(config, config.current_user))).deletePersonalAccessToken({ name: args.name });
1418
1381
  logger.success(`Personal access token "${args.name}" deleted successfully.`);
1419
1382
  })
1420
1383
  });
@@ -1436,8 +1399,7 @@ const listCommand$3 = defineCommand({
1436
1399
  No user logged in.
1437
1400
  Please login first using 'tailor-sdk login' command.
1438
1401
  `);
1439
- const token = await fetchLatestToken(config, config.current_user);
1440
- const client = await initOperatorClient(token);
1402
+ const client = await initOperatorClient(await fetchLatestToken(config, config.current_user));
1441
1403
  const pats = await fetchAll(async (pageToken) => {
1442
1404
  const { personalAccessTokens, nextPageToken } = await client.listPersonalAccessTokens({ pageToken });
1443
1405
  return [personalAccessTokens, nextPageToken];
@@ -1450,8 +1412,7 @@ const listCommand$3 = defineCommand({
1450
1412
  return;
1451
1413
  }
1452
1414
  if (args.json) {
1453
- const patInfos = pats.map(transformPersonalAccessToken);
1454
- printData(patInfos, args.json);
1415
+ printData(pats.map(transformPersonalAccessToken), args.json);
1455
1416
  return;
1456
1417
  }
1457
1418
  const maxNameLength = Math.max(...pats.map((pat) => pat.name.length));
@@ -1491,8 +1452,7 @@ const updateCommand = defineCommand({
1491
1452
  No user logged in.
1492
1453
  Please login first using 'tailor-sdk login' command.
1493
1454
  `);
1494
- const token = await fetchLatestToken(config, config.current_user);
1495
- const client = await initOperatorClient(token);
1455
+ const client = await initOperatorClient(await fetchLatestToken(config, config.current_user));
1496
1456
  await client.deletePersonalAccessToken({ name: args.name });
1497
1457
  const scopes = getScopesFromWriteFlag(args.write);
1498
1458
  const result = await client.createPersonalAccessToken({
@@ -1523,10 +1483,10 @@ const patCommand = defineCommand({
1523
1483
  });
1524
1484
 
1525
1485
  //#endregion
1526
- //#region src/cli/user/use.ts
1527
- const useCommand = defineCommand({
1486
+ //#region src/cli/user/switch.ts
1487
+ const switchCommand = defineCommand({
1528
1488
  meta: {
1529
- name: "use",
1489
+ name: "switch",
1530
1490
  description: "Set current user"
1531
1491
  },
1532
1492
  args: {
@@ -1560,7 +1520,7 @@ const userCommand = defineCommand({
1560
1520
  current: currentCommand,
1561
1521
  list: listCommand$2,
1562
1522
  pat: patCommand,
1563
- use: useCommand
1523
+ switch: switchCommand
1564
1524
  },
1565
1525
  async run() {
1566
1526
  await runCommand(listCommand$2, { rawArgs: [] });