@tailor-platform/sdk 0.12.3 → 0.13.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,83 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#121](https://github.com/tailor-platform/sdk/pull/121) [`bc7a3e9`](https://github.com/tailor-platform/sdk/commit/bc7a3e96b4805e75fcb153220d286abaced26368) Thanks [@toiroakr](https://github.com/toiroakr)! - Streamline workflow job function registration and trigger handling
8
+
9
+ **Breaking Changes:**
10
+ - Removed `deps` property from `createWorkflowJob()` - jobs no longer declare dependencies explicitly
11
+ - Removed `jobs` object from `WorkflowJobContext` - use `.trigger()` method instead
12
+ - Changed the way workflow jobs call other jobs: from `jobs.job_name()` to `otherJob.trigger()`
13
+
14
+ **Migration Guide:**
15
+
16
+ Before:
17
+
18
+ ```typescript
19
+ export const fetchCustomer = createWorkflowJob({
20
+ name: "fetch-customer",
21
+ body: async (input: { customerId: string }) => {
22
+ // fetch logic
23
+ },
24
+ });
25
+
26
+ export const processOrder = createWorkflowJob({
27
+ name: "process-order",
28
+ deps: [fetchCustomer],
29
+ body: async (input, { jobs }) => {
30
+ const customer = await jobs.fetch_customer({
31
+ customerId: input.customerId,
32
+ });
33
+ return { customer };
34
+ },
35
+ });
36
+ ```
37
+
38
+ After:
39
+
40
+ ```typescript
41
+ export const fetchCustomer = createWorkflowJob({
42
+ name: "fetch-customer",
43
+ body: async (input: { customerId: string }) => {
44
+ // fetch logic
45
+ },
46
+ });
47
+
48
+ export const processOrder = createWorkflowJob({
49
+ name: "process-order",
50
+ body: async (input, { env }) => {
51
+ const customer = await fetchCustomer.trigger({
52
+ customerId: input.customerId,
53
+ });
54
+ return { customer };
55
+ },
56
+ });
57
+ ```
58
+
59
+ **Key Changes:**
60
+ - Dependencies are now automatically detected via AST analysis of `.trigger()` calls at bundle time
61
+ - The `.trigger()` method is transformed to `tailor.workflow.triggerJobFunction()` during bundling
62
+ - Job function registration is optimized - all job functions are registered once and shared across workflows
63
+ - Unused jobs (not reachable from any mainJob via trigger calls) are automatically excluded from bundles
64
+
65
+ ### Patch Changes
66
+
67
+ - [#102](https://github.com/tailor-platform/sdk/pull/102) [`ac99d85`](https://github.com/tailor-platform/sdk/commit/ac99d8506693e27512a3ff59c5c8e4fda63b4695) Thanks [@riku99](https://github.com/riku99)! - Add CLI commands for managing Secret Manager vaults and secrets
68
+
69
+ ## 0.12.4
70
+
71
+ ### Patch Changes
72
+
73
+ - [#107](https://github.com/tailor-platform/sdk/pull/107) [`66fd5b5`](https://github.com/tailor-platform/sdk/commit/66fd5b5e507c6fd7f802e25819ec1e9896b43d80) Thanks [@remiposo](https://github.com/remiposo)! - Manage workflow resources with labels
74
+
75
+ Added labels to workflow resources just like other resources. This is a small breaking change for users already using workflows (a confirmation will occur), but since workflow itself is still a preview feature, we believe this is acceptable.
76
+
77
+ - [#109](https://github.com/tailor-platform/sdk/pull/109) [`2223025`](https://github.com/tailor-platform/sdk/commit/22230255d463ce76c709f8c441c9ca16e581b6e3) Thanks [@k1LoW](https://github.com/k1LoW)! - feat: support `lang` for idp
78
+
79
+ - [#110](https://github.com/tailor-platform/sdk/pull/110) [`5de725c`](https://github.com/tailor-platform/sdk/commit/5de725ce459788ead266930338c922ebd59123ed) Thanks [@remiposo](https://github.com/remiposo)! - Removed unused referenced field
80
+
3
81
  ## 0.12.3
4
82
 
5
83
  ## 0.12.2
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./../user-defined.d.ts" />
2
2
 
3
- import { AppConfig, CodeGeneratorBase, Executor, Generator, IdProviderConfig, OAuth2Client, Resolver, TailorDBTypeConfig } from "../types-BdwXWhOF.mjs";
3
+ import { AppConfig, CodeGeneratorBase, Executor, Generator, IdProviderConfig, OAuth2Client, Resolver, TailorDBTypeConfig } from "../types-JFLKYNHP.mjs";
4
4
  import "citty";
5
5
  import "zod";
6
6
  import "@bufbuild/protobuf/wkt";
@@ -136,9 +136,10 @@ type GenerateOptions = {
136
136
  declare function generate(options?: GenerateOptions): Promise<void>;
137
137
  //#endregion
138
138
  //#region src/cli/config-loader.d.ts
139
- declare function loadConfig(configPath: string): Promise<{
139
+ declare function loadConfig(configPath?: string): Promise<{
140
140
  config: AppConfig;
141
141
  generators: Generator[];
142
+ configPath: string;
142
143
  }>;
143
144
  //#endregion
144
145
  //#region src/cli/type-generator.d.ts
package/dist/cli/api.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, remove, show, workspaceCreate, workspaceDelete, workspaceList } from "../list-DeXjmUU0.mjs";
2
- import "../job-B8jI-poE.mjs";
1
+ import { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, remove, show, workspaceCreate, workspaceDelete, workspaceList } from "../list-D-R1mEOM.mjs";
2
+ import "../job-vYIg6hFf.mjs";
3
3
  import { register } from "node:module";
4
4
 
5
5
  //#region src/cli/api.ts
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generateCommand, getCommand, initOAuth2Client, initOperatorClient, listCommand as listCommand$4, listCommand$1 as listCommand$5, listCommand$2 as listCommand, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, removeCommand, showCommand, tokenCommand, withCommonArgs, writePlatformConfig } from "../list-DeXjmUU0.mjs";
3
- import "../job-B8jI-poE.mjs";
2
+ import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generateCommand, getCommand, initOAuth2Client, initOperatorClient, listCommand as listCommand$5, listCommand$1 as listCommand$6, listCommand$2 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, removeCommand, showCommand, tokenCommand, withCommonArgs, writePlatformConfig } from "../list-D-R1mEOM.mjs";
3
+ import "../job-vYIg6hFf.mjs";
4
4
  import { register } from "node:module";
5
5
  import { defineCommand, runCommand, runMain } from "citty";
6
6
  import { z } from "zod";
7
7
  import ml from "multiline-ts";
8
8
  import { consola } from "consola";
9
9
  import { generateCodeVerifier } from "@badgateway/oauth2-client";
10
+ import { timestampDate } from "@bufbuild/protobuf/wkt";
11
+ import { Code, ConnectError } from "@connectrpc/connect";
10
12
  import chalk from "chalk";
11
13
  import { spawnSync } from "node:child_process";
12
14
  import * as crypto from "node:crypto";
@@ -183,11 +185,11 @@ const machineuserCommand = defineCommand({
183
185
  description: "Manage machine users"
184
186
  },
185
187
  subCommands: {
186
- list: listCommand$5,
188
+ list: listCommand$6,
187
189
  token: tokenCommand
188
190
  },
189
191
  async run() {
190
- await runCommand(listCommand$5, { rawArgs: [] });
192
+ await runCommand(listCommand$6, { rawArgs: [] });
191
193
  }
192
194
  });
193
195
 
@@ -200,16 +202,16 @@ const oauth2clientCommand = defineCommand({
200
202
  },
201
203
  subCommands: {
202
204
  get: getCommand,
203
- list: listCommand$4
205
+ list: listCommand$5
204
206
  },
205
207
  async run() {
206
- await runCommand(listCommand$4, { rawArgs: [] });
208
+ await runCommand(listCommand$5, { rawArgs: [] });
207
209
  }
208
210
  });
209
211
 
210
212
  //#endregion
211
213
  //#region src/cli/profile/create.ts
212
- const createCommand$2 = defineCommand({
214
+ const createCommand$3 = defineCommand({
213
215
  meta: {
214
216
  name: "create",
215
217
  description: "Create new profile"
@@ -262,7 +264,7 @@ const createCommand$2 = defineCommand({
262
264
 
263
265
  //#endregion
264
266
  //#region src/cli/profile/delete.ts
265
- const deleteCommand$2 = defineCommand({
267
+ const deleteCommand$3 = defineCommand({
266
268
  meta: {
267
269
  name: "delete",
268
270
  description: "Delete profile"
@@ -286,7 +288,7 @@ const deleteCommand$2 = defineCommand({
286
288
 
287
289
  //#endregion
288
290
  //#region src/cli/profile/list.ts
289
- const listCommand$3 = defineCommand({
291
+ const listCommand$4 = defineCommand({
290
292
  meta: {
291
293
  name: "list",
292
294
  description: "List all profiles"
@@ -377,17 +379,474 @@ const profileCommand = defineCommand({
377
379
  name: "profile",
378
380
  description: "Manage workspace profiles (user + workspace combinations)"
379
381
  },
382
+ subCommands: {
383
+ create: createCommand$3,
384
+ delete: deleteCommand$3,
385
+ list: listCommand$4,
386
+ update: updateCommand$1
387
+ },
388
+ async run() {
389
+ await runCommand(listCommand$4, { rawArgs: [] });
390
+ }
391
+ });
392
+
393
+ //#endregion
394
+ //#region src/cli/secret/create.ts
395
+ const createSecretCommand = defineCommand({
396
+ meta: {
397
+ name: "create",
398
+ description: "Create a secret in a vault"
399
+ },
400
+ args: {
401
+ ...commonArgs,
402
+ "workspace-id": {
403
+ type: "string",
404
+ description: "Workspace ID",
405
+ alias: "w"
406
+ },
407
+ profile: {
408
+ type: "string",
409
+ description: "Workspace profile",
410
+ alias: "p"
411
+ },
412
+ "vault-name": {
413
+ type: "string",
414
+ description: "Vault name",
415
+ required: true
416
+ },
417
+ name: {
418
+ type: "string",
419
+ description: "Secret name",
420
+ required: true
421
+ },
422
+ value: {
423
+ type: "string",
424
+ description: "Secret value",
425
+ required: true
426
+ }
427
+ },
428
+ run: withCommonArgs(async (args) => {
429
+ const accessToken = await loadAccessToken({
430
+ useProfile: true,
431
+ profile: args.profile
432
+ });
433
+ const client = await initOperatorClient(accessToken);
434
+ const workspaceId = loadWorkspaceId({
435
+ workspaceId: args["workspace-id"],
436
+ profile: args.profile
437
+ });
438
+ try {
439
+ await client.createSecretManagerSecret({
440
+ workspaceId,
441
+ secretmanagerVaultName: args["vault-name"],
442
+ secretmanagerSecretName: args.name,
443
+ secretmanagerSecretValue: args.value
444
+ });
445
+ } catch (error) {
446
+ if (error instanceof ConnectError) {
447
+ if (error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
448
+ if (error.code === Code.AlreadyExists) throw new Error(`Secret "${args.name}" already exists.`);
449
+ }
450
+ throw error;
451
+ }
452
+ consola.success(`Secret: ${args.name} created in vault: ${args["vault-name"]}`);
453
+ })
454
+ });
455
+
456
+ //#endregion
457
+ //#region src/cli/secret/delete.ts
458
+ const deleteSecretCommand = defineCommand({
459
+ meta: {
460
+ name: "delete",
461
+ description: "Delete a secret in a vault"
462
+ },
463
+ args: {
464
+ ...commonArgs,
465
+ "workspace-id": {
466
+ type: "string",
467
+ description: "Workspace ID",
468
+ alias: "w"
469
+ },
470
+ profile: {
471
+ type: "string",
472
+ description: "Workspace profile",
473
+ alias: "p"
474
+ },
475
+ "vault-name": {
476
+ type: "string",
477
+ description: "Vault name",
478
+ required: true
479
+ },
480
+ name: {
481
+ type: "string",
482
+ description: "Secret name",
483
+ required: true
484
+ },
485
+ yes: {
486
+ type: "boolean",
487
+ description: "Skip confirmation prompt",
488
+ alias: "y",
489
+ default: false
490
+ }
491
+ },
492
+ run: withCommonArgs(async (args) => {
493
+ const accessToken = await loadAccessToken({
494
+ useProfile: true,
495
+ profile: args.profile
496
+ });
497
+ const client = await initOperatorClient(accessToken);
498
+ const workspaceId = loadWorkspaceId({
499
+ workspaceId: args["workspace-id"],
500
+ profile: args.profile
501
+ });
502
+ if (!args.yes) {
503
+ if (await consola.prompt(`Enter the secret name to confirm deletion ("${args.name}"): `, { type: "text" }) !== args.name) {
504
+ consola.info("Secret deletion cancelled.");
505
+ return;
506
+ }
507
+ }
508
+ try {
509
+ await client.deleteSecretManagerSecret({
510
+ workspaceId,
511
+ secretmanagerVaultName: args["vault-name"],
512
+ secretmanagerSecretName: args.name
513
+ });
514
+ } catch (error) {
515
+ if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Secret "${args.name}" not found in vault "${args["vault-name"]}".`);
516
+ throw error;
517
+ }
518
+ consola.success(`Secret: ${args.name} deleted from vault: ${args["vault-name"]}`);
519
+ })
520
+ });
521
+
522
+ //#endregion
523
+ //#region src/cli/secret/list.ts
524
+ function secretInfo(secret) {
525
+ return {
526
+ name: secret.name,
527
+ createdAt: secret.createTime ? timestampDate(secret.createTime).toISOString() : "N/A",
528
+ updatedAt: secret.updateTime ? timestampDate(secret.updateTime).toISOString() : "N/A"
529
+ };
530
+ }
531
+ async function secretList(options) {
532
+ const accessToken = await loadAccessToken({
533
+ useProfile: true,
534
+ profile: options.profile
535
+ });
536
+ const client = await initOperatorClient(accessToken);
537
+ const workspaceId = loadWorkspaceId({
538
+ workspaceId: options.workspaceId,
539
+ profile: options.profile
540
+ });
541
+ return (await fetchAll(async (pageToken) => {
542
+ const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
543
+ workspaceId,
544
+ secretmanagerVaultName: options.vaultName,
545
+ pageToken
546
+ });
547
+ return [secrets, nextPageToken];
548
+ })).map(secretInfo);
549
+ }
550
+ const listSecretCommand = defineCommand({
551
+ meta: {
552
+ name: "list",
553
+ description: "List secrets in a vault"
554
+ },
555
+ args: {
556
+ ...commonArgs,
557
+ ...formatArgs,
558
+ "workspace-id": {
559
+ type: "string",
560
+ description: "Workspace ID",
561
+ alias: "w"
562
+ },
563
+ profile: {
564
+ type: "string",
565
+ description: "Workspace profile",
566
+ alias: "p"
567
+ },
568
+ "vault-name": {
569
+ type: "string",
570
+ description: "Vault name",
571
+ required: true
572
+ }
573
+ },
574
+ run: withCommonArgs(async (args) => {
575
+ const format = parseFormat(args.format);
576
+ try {
577
+ const secrets = await secretList({
578
+ workspaceId: args["workspace-id"],
579
+ profile: args.profile,
580
+ vaultName: args["vault-name"]
581
+ });
582
+ printWithFormat(secrets, format);
583
+ } catch (error) {
584
+ if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
585
+ throw error;
586
+ }
587
+ })
588
+ });
589
+
590
+ //#endregion
591
+ //#region src/cli/secret/update.ts
592
+ const updateSecretCommand = defineCommand({
593
+ meta: {
594
+ name: "update",
595
+ description: "Update a secret in a vault"
596
+ },
597
+ args: {
598
+ ...commonArgs,
599
+ "workspace-id": {
600
+ type: "string",
601
+ description: "Workspace ID",
602
+ alias: "w"
603
+ },
604
+ profile: {
605
+ type: "string",
606
+ description: "Workspace profile",
607
+ alias: "p"
608
+ },
609
+ "vault-name": {
610
+ type: "string",
611
+ description: "Vault name",
612
+ required: true
613
+ },
614
+ name: {
615
+ type: "string",
616
+ description: "Secret name",
617
+ required: true
618
+ },
619
+ value: {
620
+ type: "string",
621
+ description: "Secret value",
622
+ required: true
623
+ }
624
+ },
625
+ run: withCommonArgs(async (args) => {
626
+ const accessToken = await loadAccessToken({
627
+ useProfile: true,
628
+ profile: args.profile
629
+ });
630
+ const client = await initOperatorClient(accessToken);
631
+ const workspaceId = loadWorkspaceId({
632
+ workspaceId: args["workspace-id"],
633
+ profile: args.profile
634
+ });
635
+ try {
636
+ await client.updateSecretManagerSecret({
637
+ workspaceId,
638
+ secretmanagerVaultName: args["vault-name"],
639
+ secretmanagerSecretName: args.name,
640
+ secretmanagerSecretValue: args.value
641
+ });
642
+ } catch (error) {
643
+ if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Secret "${args.name}" not found in vault "${args["vault-name"]}".`);
644
+ throw error;
645
+ }
646
+ consola.success(`Secret: ${args.name} updated in vault: ${args["vault-name"]}`);
647
+ })
648
+ });
649
+
650
+ //#endregion
651
+ //#region src/cli/secret/vault/create.ts
652
+ const createCommand$2 = defineCommand({
653
+ meta: {
654
+ name: "create",
655
+ description: "Create a Secret Manager vault"
656
+ },
657
+ args: {
658
+ ...commonArgs,
659
+ "workspace-id": {
660
+ type: "string",
661
+ description: "Workspace ID",
662
+ alias: "w"
663
+ },
664
+ profile: {
665
+ type: "string",
666
+ description: "Workspace profile",
667
+ alias: "p"
668
+ },
669
+ name: {
670
+ type: "string",
671
+ description: "Vault name",
672
+ required: true
673
+ }
674
+ },
675
+ run: withCommonArgs(async (args) => {
676
+ const accessToken = await loadAccessToken({
677
+ useProfile: true,
678
+ profile: args.profile
679
+ });
680
+ const client = await initOperatorClient(accessToken);
681
+ const workspaceId = loadWorkspaceId({
682
+ workspaceId: args["workspace-id"],
683
+ profile: args.profile
684
+ });
685
+ try {
686
+ await client.createSecretManagerVault({
687
+ workspaceId,
688
+ secretmanagerVaultName: args.name
689
+ });
690
+ } catch (error) {
691
+ if (error instanceof ConnectError && error.code === Code.AlreadyExists) throw new Error(`Vault "${args.name}" already exists.`);
692
+ throw error;
693
+ }
694
+ consola.success(`Vault: ${args.name} created`);
695
+ })
696
+ });
697
+
698
+ //#endregion
699
+ //#region src/cli/secret/vault/delete.ts
700
+ const deleteCommand$2 = defineCommand({
701
+ meta: {
702
+ name: "delete",
703
+ description: "Delete a Secret Manager vault"
704
+ },
705
+ args: {
706
+ ...commonArgs,
707
+ "workspace-id": {
708
+ type: "string",
709
+ description: "Workspace ID",
710
+ alias: "w"
711
+ },
712
+ profile: {
713
+ type: "string",
714
+ description: "Workspace profile",
715
+ alias: "p"
716
+ },
717
+ name: {
718
+ type: "string",
719
+ description: "Vault name",
720
+ required: true
721
+ },
722
+ yes: {
723
+ type: "boolean",
724
+ description: "Skip confirmation prompt",
725
+ alias: "y",
726
+ default: false
727
+ }
728
+ },
729
+ run: withCommonArgs(async (args) => {
730
+ const accessToken = await loadAccessToken({
731
+ useProfile: true,
732
+ profile: args.profile
733
+ });
734
+ const client = await initOperatorClient(accessToken);
735
+ const workspaceId = loadWorkspaceId({
736
+ workspaceId: args["workspace-id"],
737
+ profile: args.profile
738
+ });
739
+ if (!args.yes) {
740
+ if (await consola.prompt(`Enter the vault name to confirm deletion ("${args.name}"): `, { type: "text" }) !== args.name) {
741
+ consola.info("Vault deletion cancelled.");
742
+ return;
743
+ }
744
+ }
745
+ try {
746
+ await client.deleteSecretManagerVault({
747
+ workspaceId,
748
+ secretmanagerVaultName: args.name
749
+ });
750
+ } catch (error) {
751
+ if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args.name}" not found.`);
752
+ throw error;
753
+ }
754
+ consola.success(`Vault: ${args.name} deleted`);
755
+ })
756
+ });
757
+
758
+ //#endregion
759
+ //#region src/cli/secret/vault/list.ts
760
+ function vaultInfo(vault) {
761
+ return {
762
+ name: vault.name,
763
+ createdAt: vault.createTime ? timestampDate(vault.createTime).toISOString() : "N/A",
764
+ updatedAt: vault.updateTime ? timestampDate(vault.updateTime).toISOString() : "N/A"
765
+ };
766
+ }
767
+ async function vaultList(options) {
768
+ const accessToken = await loadAccessToken({
769
+ useProfile: true,
770
+ profile: options?.profile
771
+ });
772
+ const client = await initOperatorClient(accessToken);
773
+ const workspaceId = loadWorkspaceId({
774
+ workspaceId: options?.workspaceId,
775
+ profile: options?.profile
776
+ });
777
+ return (await fetchAll(async (pageToken) => {
778
+ const { vaults, nextPageToken } = await client.listSecretManagerVaults({
779
+ workspaceId,
780
+ pageToken
781
+ });
782
+ return [vaults, nextPageToken];
783
+ })).map(vaultInfo);
784
+ }
785
+ const listCommand$3 = defineCommand({
786
+ meta: {
787
+ name: "list",
788
+ description: "List Secret Manager vaults"
789
+ },
790
+ args: {
791
+ ...commonArgs,
792
+ ...formatArgs,
793
+ "workspace-id": {
794
+ type: "string",
795
+ description: "Workspace ID",
796
+ alias: "w"
797
+ },
798
+ profile: {
799
+ type: "string",
800
+ description: "Workspace profile",
801
+ alias: "p"
802
+ }
803
+ },
804
+ run: withCommonArgs(async (args) => {
805
+ const format = parseFormat(args.format);
806
+ const vaults = await vaultList({
807
+ workspaceId: args["workspace-id"],
808
+ profile: args.profile
809
+ });
810
+ printWithFormat(vaults, format);
811
+ })
812
+ });
813
+
814
+ //#endregion
815
+ //#region src/cli/secret/vault/index.ts
816
+ const vaultCommand = defineCommand({
817
+ meta: {
818
+ name: "vault",
819
+ description: "Manage Secret Manager vaults"
820
+ },
380
821
  subCommands: {
381
822
  create: createCommand$2,
382
823
  delete: deleteCommand$2,
383
- list: listCommand$3,
384
- update: updateCommand$1
824
+ list: listCommand$3
385
825
  },
386
826
  async run() {
387
827
  await runCommand(listCommand$3, { rawArgs: [] });
388
828
  }
389
829
  });
390
830
 
831
+ //#endregion
832
+ //#region src/cli/secret/index.ts
833
+ const secretCommand = defineCommand({
834
+ meta: {
835
+ name: "secret",
836
+ description: "Manage secrets and vaults"
837
+ },
838
+ subCommands: {
839
+ create: createSecretCommand,
840
+ delete: deleteSecretCommand,
841
+ list: listSecretCommand,
842
+ update: updateSecretCommand,
843
+ vault: vaultCommand
844
+ },
845
+ async run() {
846
+ await runCommand(vaultCommand, { rawArgs: [] });
847
+ }
848
+ });
849
+
391
850
  //#endregion
392
851
  //#region src/cli/tailordb/truncate.ts
393
852
  async function truncateSingleType(options, client) {
@@ -405,14 +864,14 @@ async function truncateNamespace(workspaceId, namespaceName, client) {
405
864
  });
406
865
  consola.success(`Truncated all types in namespace "${namespaceName}"`);
407
866
  }
408
- async function getAllNamespaces(workspaceId, configPath) {
867
+ async function getAllNamespaces(configPath) {
409
868
  const { config } = await loadConfig(configPath);
410
869
  const namespaces = /* @__PURE__ */ new Set();
411
870
  if (config.db) for (const [namespaceName] of Object.entries(config.db)) namespaces.add(namespaceName);
412
871
  return Array.from(namespaces);
413
872
  }
414
873
  async function getTypeNamespace(workspaceId, typeName, client, configPath) {
415
- const namespaces = await getAllNamespaces(workspaceId, configPath);
874
+ const namespaces = await getAllNamespaces(configPath);
416
875
  for (const namespace of namespaces) try {
417
876
  const { tailordbTypes } = await client.listTailorDBTypes({
418
877
  workspaceId,
@@ -443,8 +902,7 @@ async function truncate(options) {
443
902
  hasAll
444
903
  ].filter(Boolean).length > 1) throw new Error("Cannot specify multiple options: choose one of --all, --namespace, or type names");
445
904
  if (!hasTypes && !hasNamespace && !hasAll) throw new Error("Please specify one of: --all, --namespace <name>, or type names");
446
- const configPath = loadConfigPath(options?.configPath);
447
- const namespaces = await getAllNamespaces(workspaceId, configPath);
905
+ const namespaces = await getAllNamespaces(options?.configPath);
448
906
  if (hasAll) {
449
907
  if (namespaces.length === 0) {
450
908
  consola.warn("No namespaces found in config file.");
@@ -484,7 +942,7 @@ async function truncate(options) {
484
942
  const typeNamespaceMap = /* @__PURE__ */ new Map();
485
943
  const notFoundTypes = [];
486
944
  for (const typeName of typeNames) {
487
- const namespace = await getTypeNamespace(workspaceId, typeName, client, configPath);
945
+ const namespace = await getTypeNamespace(workspaceId, typeName, client, options.configPath);
488
946
  if (namespace) typeNamespaceMap.set(typeName, namespace);
489
947
  else notFoundTypes.push(typeName);
490
948
  }
@@ -949,6 +1407,7 @@ const mainCommand = defineCommand({
949
1407
  remove: removeCommand,
950
1408
  show: showCommand,
951
1409
  tailordb: tailordbCommand,
1410
+ secret: secretCommand,
952
1411
  user: userCommand,
953
1412
  workspace: workspaceCommand
954
1413
  }