@tailor-platform/sdk 1.25.1 → 1.25.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.
- package/CHANGELOG.md +30 -0
- package/dist/{application-iRp2OYMz.mjs → application-BGO3TtXi.mjs} +105 -63
- package/dist/application-BGO3TtXi.mjs.map +1 -0
- package/dist/application-C0lXqKBr.mjs +9 -0
- package/dist/{brand-BOaOlsiP.mjs → brand-GZnI4eYb.mjs} +1 -1
- package/dist/{brand-BOaOlsiP.mjs.map → brand-GZnI4eYb.mjs.map} +1 -1
- package/dist/chunk-Cz-A8uMR.mjs +3 -0
- package/dist/cli/index.d.mts +2 -3
- package/dist/cli/index.mjs +167 -211
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +706 -1108
- package/dist/cli/lib.mjs +28 -16
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/skills.mjs +2 -1
- package/dist/cli/skills.mjs.map +1 -1
- package/dist/configure/index.d.mts +5 -5
- package/dist/configure/index.mjs +4 -3
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{enum-constants-BxdLbhsW.mjs → enum-constants-6uK0VI_s.mjs} +1 -1
- package/dist/{enum-constants-BxdLbhsW.mjs.map → enum-constants-6uK0VI_s.mjs.map} +1 -1
- package/dist/{env-jndw86T4.d.mts → env-uBeVwE9B.d.mts} +4 -7
- package/dist/{file-utils-C2r3AVbI.mjs → file-utils-2T9w20FP.mjs} +1 -1
- package/dist/{file-utils-C2r3AVbI.mjs.map → file-utils-2T9w20FP.mjs.map} +1 -1
- package/dist/{index-Do7zo7z-.d.mts → index-BD-K97-C.d.mts} +2 -2
- package/dist/{index-VZq4IAEK.d.mts → index-CT53egux.d.mts} +2 -2
- package/dist/{index-DZRZdh71.d.mts → index-D1J5SfyK.d.mts} +2 -2
- package/dist/{index-BuWllBxZ.d.mts → index-DuZRAsc3.d.mts} +14 -11
- package/dist/{index-DoxGF8-i.d.mts → index-cZilKprY.d.mts} +2 -2
- package/dist/{interceptor-DVy32eIG.mjs → interceptor-BPiIBTk_.mjs} +2 -1
- package/dist/{interceptor-DVy32eIG.mjs.map → interceptor-BPiIBTk_.mjs.map} +1 -1
- package/dist/{job-BQDunsd7.mjs → job-DdfW7vH3.mjs} +3 -3
- package/dist/{job-BQDunsd7.mjs.map → job-DdfW7vH3.mjs.map} +1 -1
- package/dist/kysely/index.d.mts +3 -4
- package/dist/kysely/index.mjs +1 -0
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{kysely-type-DzLBuVp6.mjs → kysely-type-cMNbsQ6k.mjs} +1 -1
- package/dist/{kysely-type-DzLBuVp6.mjs.map → kysely-type-cMNbsQ6k.mjs.map} +1 -1
- package/dist/package-json-Bj76LPsV.mjs +4 -0
- package/dist/{package-json-DnbGCOkg.mjs → package-json-CVUv8Y9T.mjs} +1 -1
- package/dist/{package-json-DnbGCOkg.mjs.map → package-json-CVUv8Y9T.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -2
- package/dist/plugin/builtin/enum-constants/index.mjs +2 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -2
- package/dist/plugin/builtin/file-utils/index.mjs +2 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +2 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -2
- package/dist/plugin/builtin/seed/index.mjs +2 -1
- package/dist/plugin/index.d.mts +2 -3
- package/dist/plugin/index.mjs +5 -4
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/{plugin-3sT6Tcq0.d.mts → plugin-zY5wvV82.d.mts} +117 -225
- package/dist/{query-D3UyoG68.mjs → query-CRSZGUmD.mjs} +445 -509
- package/dist/query-CRSZGUmD.mjs.map +1 -0
- package/dist/{schema-Fbfeq9gi.mjs → schema-BePzTFBV.mjs} +9 -9
- package/dist/schema-BePzTFBV.mjs.map +1 -0
- package/dist/seed/index.d.mts +1 -4
- package/dist/seed/index.mjs +1 -0
- package/dist/seed/index.mjs.map +1 -1
- package/dist/{seed-DkKAheSe.mjs → seed-CCVRLibh.mjs} +24 -10
- package/dist/seed-CCVRLibh.mjs.map +1 -0
- package/dist/{telemetry-d_lgTL33.mjs → telemetry-0w8OupuQ.mjs} +2 -2
- package/dist/{telemetry-d_lgTL33.mjs.map → telemetry-0w8OupuQ.mjs.map} +1 -1
- package/dist/telemetry-DDQZRqHK.mjs +4 -0
- package/dist/utils/test/index.d.mts +2 -3
- package/dist/utils/test/index.mjs +3 -2
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/{app-config-QzNOFnEy.d.mts → workflow.generated-v1LXRuB6.d.mts} +19 -22
- package/docs/cli/application.md +73 -33
- package/docs/cli/auth.md +56 -24
- package/docs/cli/completion.md +6 -0
- package/docs/cli/executor.md +73 -36
- package/docs/cli/function.md +30 -14
- package/docs/cli/secret.md +93 -41
- package/docs/cli/staticwebsite.md +38 -17
- package/docs/cli/tailordb.md +106 -48
- package/docs/cli/user.md +74 -10
- package/docs/cli/workflow.md +70 -39
- package/docs/cli/workspace.md +166 -60
- package/docs/cli-reference.md +22 -12
- package/docs/services/workflow.md +26 -0
- package/package.json +5 -5
- package/dist/application-B4ORumjE.mjs +0 -8
- package/dist/application-iRp2OYMz.mjs.map +0 -1
- package/dist/package-json-BKA36WTo.mjs +0 -3
- package/dist/query-D3UyoG68.mjs.map +0 -1
- package/dist/schema-Fbfeq9gi.mjs.map +0 -1
- package/dist/seed-DkKAheSe.mjs.map +0 -1
- package/dist/telemetry-J6dpByo2.mjs +0 -3
package/dist/cli/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import
|
|
5
|
-
import { C as
|
|
6
|
-
import {
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import "../
|
|
10
|
-
import "../
|
|
2
|
+
import "../chunk-Cz-A8uMR.mjs";
|
|
3
|
+
import "../schema-BePzTFBV.mjs";
|
|
4
|
+
import "../brand-GZnI4eYb.mjs";
|
|
5
|
+
import { C as fetchAll, D as initOperatorClient, E as initOAuth2Client, J as AuthInvokerSchema, S as writePlatformConfig, T as fetchUserInfo, U as FunctionExecution_Type, a as loadConfig, b as loadWorkspaceId, c as ExecutorSchema, dt as logger, ft as styles, g as getDistDir, i as resolveInlineSourcemap, o as WorkflowJobSchema, tt as PATScope, u as ResolverSchema, v as fetchLatestToken, x as readPlatformConfig, y as loadAccessToken } from "../application-BGO3TtXi.mjs";
|
|
6
|
+
import { C as listCommand$9, E as resumeCommand, Ft as isValidMigrationNumber, G as listCommand$6, Gt as apiCommand, Ht as trnPrefix, I as showCommand, It as loadDiff, Jt as confirmationArgs, Kt as defineAppCommand, Mt as getMigrationFilePath, N as generateCommand$1, Nt as getMigrationFiles, O as listCommand$8, P as logBetaWarning, Q as listCommand$5, R as removeCommand$1, T as healthCommand, V as getCommand$2, Vt as getNamespacesWithMigrations, W as tokenCommand, X as triggerCommand, Xt as isVerbose, Y as webhookCommand, Yt as deploymentArgs, Zt as workspaceArgs, b as createCommand$3, c as listCommand$10, ct as executionsCommand, dt as functionExecutionStatusToString, f as restoreCommand, ft as formatKeyValueTable, g as getCommand$4, gt as executeScript, ht as apply, i as updateCommand$2, it as startCommand, j as truncateCommand, kt as formatMigrationNumber, m as listCommand$11, n as queryCommand, o as removeCommand, ot as getCommand$3, pt as getCommand$1, q as generate, qt as commonArgs, r as isCLIError, tt as jobsCommand, u as inviteCommand, v as deleteCommand$3, yt as parseMigrationLabelNumber, z as listCommand$7 } from "../query-CRSZGUmD.mjs";
|
|
7
|
+
import { t as readPackageJson } from "../package-json-CVUv8Y9T.mjs";
|
|
8
|
+
import "../seed-CCVRLibh.mjs";
|
|
9
|
+
import "../file-utils-2T9w20FP.mjs";
|
|
10
|
+
import "../kysely-type-cMNbsQ6k.mjs";
|
|
11
|
+
import "../telemetry-0w8OupuQ.mjs";
|
|
11
12
|
import { createRequire, register } from "node:module";
|
|
12
13
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
13
14
|
import { withCompletionCommand } from "politty/completion";
|
|
@@ -32,11 +33,10 @@ import pLimit from "p-limit";
|
|
|
32
33
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
33
34
|
|
|
34
35
|
//#region src/cli/commands/apply/index.ts
|
|
35
|
-
const applyCommand =
|
|
36
|
+
const applyCommand = defineAppCommand({
|
|
36
37
|
name: "apply",
|
|
37
38
|
description: "Apply Tailor configuration to deploy your application.",
|
|
38
39
|
args: z.object({
|
|
39
|
-
...commonArgs,
|
|
40
40
|
...deploymentArgs,
|
|
41
41
|
...confirmationArgs,
|
|
42
42
|
"dry-run": arg(z.boolean().optional(), {
|
|
@@ -47,7 +47,9 @@ const applyCommand = defineCommand({
|
|
|
47
47
|
"no-cache": arg(z.boolean().optional(), { description: "Disable bundle caching for this run" }),
|
|
48
48
|
"clean-cache": arg(z.boolean().optional(), { description: "Clean the bundle cache before building" })
|
|
49
49
|
}).strict(),
|
|
50
|
-
run:
|
|
50
|
+
run: async (args) => {
|
|
51
|
+
const { initTelemetry } = await import("../telemetry-DDQZRqHK.mjs");
|
|
52
|
+
await initTelemetry();
|
|
51
53
|
await apply({
|
|
52
54
|
workspaceId: args["workspace-id"],
|
|
53
55
|
profile: args.profile,
|
|
@@ -58,7 +60,7 @@ const applyCommand = defineCommand({
|
|
|
58
60
|
noCache: args["no-cache"],
|
|
59
61
|
cleanCache: args["clean-cache"]
|
|
60
62
|
});
|
|
61
|
-
}
|
|
63
|
+
}
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
//#endregion
|
|
@@ -153,19 +155,17 @@ function printFunctionExecutionDetail(detail) {
|
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
|
-
const logsCommand =
|
|
158
|
+
const logsCommand = defineAppCommand({
|
|
157
159
|
name: "logs",
|
|
158
160
|
description: "List or get function execution logs.",
|
|
159
161
|
args: z.object({
|
|
160
|
-
...commonArgs,
|
|
161
|
-
...jsonArgs,
|
|
162
162
|
...workspaceArgs,
|
|
163
163
|
executionId: arg(z.string().optional(), {
|
|
164
164
|
positional: true,
|
|
165
165
|
description: "Execution ID (if provided, shows details with logs)"
|
|
166
166
|
})
|
|
167
167
|
}).strict(),
|
|
168
|
-
run:
|
|
168
|
+
run: async (args) => {
|
|
169
169
|
const client = await initOperatorClient(await loadAccessToken({
|
|
170
170
|
useProfile: true,
|
|
171
171
|
profile: args.profile
|
|
@@ -198,7 +198,7 @@ const logsCommand = defineCommand({
|
|
|
198
198
|
}
|
|
199
199
|
logger.out(logs);
|
|
200
200
|
}
|
|
201
|
-
}
|
|
201
|
+
}
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
//#endregion
|
|
@@ -239,7 +239,7 @@ async function bundleForTestRun(options) {
|
|
|
239
239
|
format: "esm",
|
|
240
240
|
sourcemap: inlineSourcemap ? "inline" : true,
|
|
241
241
|
minify: inlineSourcemap ? { mangle: { keepNames: true } } : true,
|
|
242
|
-
|
|
242
|
+
codeSplitting: false
|
|
243
243
|
},
|
|
244
244
|
tsconfig,
|
|
245
245
|
treeshake: {
|
|
@@ -440,8 +440,8 @@ function detectWorkflowJob(module, jobName) {
|
|
|
440
440
|
if (jobName) {
|
|
441
441
|
const match = jobs.find((j) => j.name === jobName);
|
|
442
442
|
if (!match) {
|
|
443
|
-
const available
|
|
444
|
-
throw new Error(`Workflow job "${jobName}" not found. Available jobs:\n${available
|
|
443
|
+
const available = jobs.map((j) => ` - "${j.name}" (export: ${j.exportName})`).join("\n");
|
|
444
|
+
throw new Error(`Workflow job "${jobName}" not found. Available jobs:\n${available}`);
|
|
445
445
|
}
|
|
446
446
|
return {
|
|
447
447
|
type: "workflow-job",
|
|
@@ -474,12 +474,10 @@ function deriveNameFromPath(filePath) {
|
|
|
474
474
|
* Bundles and executes a function on the Tailor Platform server
|
|
475
475
|
* without deploying (applying) the application.
|
|
476
476
|
*/
|
|
477
|
-
const testRunCommand =
|
|
477
|
+
const testRunCommand = defineAppCommand({
|
|
478
478
|
name: "test-run",
|
|
479
479
|
description: "Run a function on the Tailor Platform server without deploying.",
|
|
480
480
|
args: z.object({
|
|
481
|
-
...commonArgs,
|
|
482
|
-
...jsonArgs,
|
|
483
481
|
...workspaceArgs,
|
|
484
482
|
file: arg(z.string(), {
|
|
485
483
|
positional: true,
|
|
@@ -522,7 +520,7 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
|
|
|
522
520
|
desc: "Run a pre-bundled .js file directly"
|
|
523
521
|
}
|
|
524
522
|
],
|
|
525
|
-
run:
|
|
523
|
+
run: async (args) => {
|
|
526
524
|
const filePath = path.resolve(args.file);
|
|
527
525
|
if (!fs$1.existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
|
528
526
|
const { config } = await loadConfig(args.config);
|
|
@@ -617,7 +615,7 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
|
|
|
617
615
|
}
|
|
618
616
|
}
|
|
619
617
|
if (!result.success) process.exit(1);
|
|
620
|
-
}
|
|
618
|
+
}
|
|
621
619
|
});
|
|
622
620
|
/**
|
|
623
621
|
* Resolve auth namespace from config.
|
|
@@ -695,11 +693,10 @@ const functionCommand = defineCommand({
|
|
|
695
693
|
|
|
696
694
|
//#endregion
|
|
697
695
|
//#region src/cli/commands/generate/index.ts
|
|
698
|
-
const generateCommand =
|
|
696
|
+
const generateCommand = defineAppCommand({
|
|
699
697
|
name: "generate",
|
|
700
698
|
description: "Generate files using Tailor configuration.",
|
|
701
699
|
args: z.object({
|
|
702
|
-
...commonArgs,
|
|
703
700
|
config: arg(z.string().default("tailor.config.ts"), {
|
|
704
701
|
alias: "c",
|
|
705
702
|
description: "Path to SDK config file"
|
|
@@ -709,12 +706,14 @@ const generateCommand = defineCommand({
|
|
|
709
706
|
description: "Watch for type/resolver changes and regenerate"
|
|
710
707
|
})
|
|
711
708
|
}).strict(),
|
|
712
|
-
run:
|
|
709
|
+
run: async (args) => {
|
|
710
|
+
const { initTelemetry } = await import("../telemetry-DDQZRqHK.mjs");
|
|
711
|
+
await initTelemetry();
|
|
713
712
|
await generate({
|
|
714
713
|
configPath: args.config,
|
|
715
714
|
watch: args.watch
|
|
716
715
|
});
|
|
717
|
-
}
|
|
716
|
+
}
|
|
718
717
|
});
|
|
719
718
|
|
|
720
719
|
//#endregion
|
|
@@ -731,11 +730,10 @@ const detectPackageManager = () => {
|
|
|
731
730
|
if (!availablePMs.includes(name)) return;
|
|
732
731
|
return name;
|
|
733
732
|
};
|
|
734
|
-
const initCommand =
|
|
733
|
+
const initCommand = defineAppCommand({
|
|
735
734
|
name: "init",
|
|
736
735
|
description: "Initialize a new project using create-sdk.",
|
|
737
736
|
args: z.object({
|
|
738
|
-
...commonArgs,
|
|
739
737
|
name: arg(z.string().optional(), {
|
|
740
738
|
positional: true,
|
|
741
739
|
description: "Project name"
|
|
@@ -745,9 +743,9 @@ const initCommand = defineCommand({
|
|
|
745
743
|
description: "Template name"
|
|
746
744
|
})
|
|
747
745
|
}).strict(),
|
|
748
|
-
run:
|
|
749
|
-
const packageJson
|
|
750
|
-
const version = packageJson
|
|
746
|
+
run: async (args) => {
|
|
747
|
+
const packageJson = await readPackageJson();
|
|
748
|
+
const version = packageJson.version && packageJson.version !== "0.0.0" ? packageJson.version : "latest";
|
|
751
749
|
let packageManager = detectPackageManager();
|
|
752
750
|
if (!packageManager) {
|
|
753
751
|
logger.warn("Could not detect package manager, defaulting to npm");
|
|
@@ -762,7 +760,7 @@ const initCommand = defineCommand({
|
|
|
762
760
|
];
|
|
763
761
|
logger.log(`Running: ${packageManager} ${initArgs.join(" ")}`);
|
|
764
762
|
spawnSync(packageManager, initArgs, { stdio: "inherit" });
|
|
765
|
-
}
|
|
763
|
+
}
|
|
766
764
|
});
|
|
767
765
|
|
|
768
766
|
//#endregion
|
|
@@ -776,7 +774,7 @@ const startAuthServer = async () => {
|
|
|
776
774
|
const client = initOAuth2Client();
|
|
777
775
|
const state = randomState();
|
|
778
776
|
const codeVerifier = await generateCodeVerifier();
|
|
779
|
-
return new Promise((resolve
|
|
777
|
+
return new Promise((resolve, reject) => {
|
|
780
778
|
const server = http.createServer(async (req, res) => {
|
|
781
779
|
try {
|
|
782
780
|
if (!req.url?.startsWith("/callback")) throw new Error("Invalid callback URL");
|
|
@@ -802,7 +800,7 @@ const startAuthServer = async () => {
|
|
|
802
800
|
status: "ok",
|
|
803
801
|
message: "Successfully authenticated. Please close this window."
|
|
804
802
|
}));
|
|
805
|
-
resolve
|
|
803
|
+
resolve();
|
|
806
804
|
} catch (error) {
|
|
807
805
|
res.writeHead(401);
|
|
808
806
|
res.end("Authentication failed");
|
|
@@ -836,23 +834,23 @@ const startAuthServer = async () => {
|
|
|
836
834
|
});
|
|
837
835
|
});
|
|
838
836
|
};
|
|
839
|
-
const loginCommand =
|
|
837
|
+
const loginCommand = defineAppCommand({
|
|
840
838
|
name: "login",
|
|
841
839
|
description: "Login to Tailor Platform.",
|
|
842
|
-
args: z.object({
|
|
843
|
-
run:
|
|
840
|
+
args: z.object({}).strict(),
|
|
841
|
+
run: async () => {
|
|
844
842
|
await startAuthServer();
|
|
845
843
|
logger.success("Successfully logged in to Tailor Platform.");
|
|
846
|
-
}
|
|
844
|
+
}
|
|
847
845
|
});
|
|
848
846
|
|
|
849
847
|
//#endregion
|
|
850
848
|
//#region src/cli/commands/logout.ts
|
|
851
|
-
const logoutCommand =
|
|
849
|
+
const logoutCommand = defineAppCommand({
|
|
852
850
|
name: "logout",
|
|
853
851
|
description: "Logout from Tailor Platform.",
|
|
854
|
-
args: z.object({
|
|
855
|
-
run:
|
|
852
|
+
args: z.object({}).strict(),
|
|
853
|
+
run: async () => {
|
|
856
854
|
const pfConfig = readPlatformConfig();
|
|
857
855
|
const tokens = pfConfig.current_user ? pfConfig.users[pfConfig.current_user] : void 0;
|
|
858
856
|
if (!tokens) {
|
|
@@ -868,7 +866,7 @@ const logoutCommand = defineCommand({
|
|
|
868
866
|
pfConfig.current_user = null;
|
|
869
867
|
writePlatformConfig(pfConfig);
|
|
870
868
|
logger.success("Successfully logged out from Tailor Platform.");
|
|
871
|
-
}
|
|
869
|
+
}
|
|
872
870
|
});
|
|
873
871
|
|
|
874
872
|
//#endregion
|
|
@@ -902,14 +900,11 @@ const oauth2clientCommand = defineCommand({
|
|
|
902
900
|
//#endregion
|
|
903
901
|
//#region src/cli/commands/open.ts
|
|
904
902
|
const consoleBaseUrl = "https://console.tailor.tech";
|
|
905
|
-
const openCommand =
|
|
903
|
+
const openCommand = defineAppCommand({
|
|
906
904
|
name: "open",
|
|
907
905
|
description: "Open Tailor Platform Console.",
|
|
908
|
-
args: z.object({
|
|
909
|
-
|
|
910
|
-
...deploymentArgs
|
|
911
|
-
}).strict(),
|
|
912
|
-
run: withCommonArgs(async (args) => {
|
|
906
|
+
args: z.object({ ...deploymentArgs }).strict(),
|
|
907
|
+
run: async (args) => {
|
|
913
908
|
const workspaceId = loadWorkspaceId({
|
|
914
909
|
workspaceId: args["workspace-id"],
|
|
915
910
|
profile: args.profile
|
|
@@ -927,17 +922,15 @@ const openCommand = defineCommand({
|
|
|
927
922
|
} catch {
|
|
928
923
|
logger.warn(`Failed to open browser automatically. Please open this URL manually:\n${consoleUrl}`);
|
|
929
924
|
}
|
|
930
|
-
}
|
|
925
|
+
}
|
|
931
926
|
});
|
|
932
927
|
|
|
933
928
|
//#endregion
|
|
934
929
|
//#region src/cli/commands/profile/create.ts
|
|
935
|
-
const createCommand$2 =
|
|
930
|
+
const createCommand$2 = defineAppCommand({
|
|
936
931
|
name: "create",
|
|
937
932
|
description: "Create a new profile.",
|
|
938
933
|
args: z.object({
|
|
939
|
-
...commonArgs,
|
|
940
|
-
...jsonArgs,
|
|
941
934
|
name: arg(z.string(), {
|
|
942
935
|
positional: true,
|
|
943
936
|
description: "Profile name"
|
|
@@ -951,7 +944,7 @@ const createCommand$2 = defineCommand({
|
|
|
951
944
|
description: "Workspace ID"
|
|
952
945
|
})
|
|
953
946
|
}).strict(),
|
|
954
|
-
run:
|
|
947
|
+
run: async (args) => {
|
|
955
948
|
const config = readPlatformConfig();
|
|
956
949
|
if (config.profiles[args.name]) throw new Error(`Profile "${args.name}" already exists.`);
|
|
957
950
|
const client = await initOperatorClient(await fetchLatestToken(config, args.user));
|
|
@@ -974,40 +967,34 @@ const createCommand$2 = defineCommand({
|
|
|
974
967
|
workspaceId: args["workspace-id"]
|
|
975
968
|
};
|
|
976
969
|
logger.out(profileInfo);
|
|
977
|
-
}
|
|
970
|
+
}
|
|
978
971
|
});
|
|
979
972
|
|
|
980
973
|
//#endregion
|
|
981
974
|
//#region src/cli/commands/profile/delete.ts
|
|
982
|
-
const deleteCommand$2 =
|
|
975
|
+
const deleteCommand$2 = defineAppCommand({
|
|
983
976
|
name: "delete",
|
|
984
977
|
description: "Delete a profile.",
|
|
985
|
-
args: z.object({
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
})
|
|
991
|
-
}).strict(),
|
|
992
|
-
run: withCommonArgs(async (args) => {
|
|
978
|
+
args: z.object({ name: arg(z.string(), {
|
|
979
|
+
positional: true,
|
|
980
|
+
description: "Profile name"
|
|
981
|
+
}) }).strict(),
|
|
982
|
+
run: async (args) => {
|
|
993
983
|
const config = readPlatformConfig();
|
|
994
984
|
if (!config.profiles[args.name]) throw new Error(`Profile "${args.name}" not found.`);
|
|
995
985
|
delete config.profiles[args.name];
|
|
996
986
|
writePlatformConfig(config);
|
|
997
987
|
logger.success(`Profile "${args.name}" deleted successfully.`);
|
|
998
|
-
}
|
|
988
|
+
}
|
|
999
989
|
});
|
|
1000
990
|
|
|
1001
991
|
//#endregion
|
|
1002
992
|
//#region src/cli/commands/profile/list.ts
|
|
1003
|
-
const listCommand$4 =
|
|
993
|
+
const listCommand$4 = defineAppCommand({
|
|
1004
994
|
name: "list",
|
|
1005
995
|
description: "List all profiles.",
|
|
1006
|
-
args: z.object({
|
|
1007
|
-
|
|
1008
|
-
...jsonArgs
|
|
1009
|
-
}).strict(),
|
|
1010
|
-
run: withCommonArgs(async () => {
|
|
996
|
+
args: z.object({}).strict(),
|
|
997
|
+
run: async () => {
|
|
1011
998
|
const config = readPlatformConfig();
|
|
1012
999
|
const profiles = Object.entries(config.profiles);
|
|
1013
1000
|
if (profiles.length === 0) {
|
|
@@ -1023,17 +1010,15 @@ const listCommand$4 = defineCommand({
|
|
|
1023
1010
|
workspaceId: profile.workspace_id
|
|
1024
1011
|
}));
|
|
1025
1012
|
logger.out(profileInfos);
|
|
1026
|
-
}
|
|
1013
|
+
}
|
|
1027
1014
|
});
|
|
1028
1015
|
|
|
1029
1016
|
//#endregion
|
|
1030
1017
|
//#region src/cli/commands/profile/update.ts
|
|
1031
|
-
const updateCommand$1 =
|
|
1018
|
+
const updateCommand$1 = defineAppCommand({
|
|
1032
1019
|
name: "update",
|
|
1033
1020
|
description: "Update profile properties.",
|
|
1034
1021
|
args: z.object({
|
|
1035
|
-
...commonArgs,
|
|
1036
|
-
...jsonArgs,
|
|
1037
1022
|
name: arg(z.string(), {
|
|
1038
1023
|
positional: true,
|
|
1039
1024
|
description: "Profile name"
|
|
@@ -1047,7 +1032,7 @@ const updateCommand$1 = defineCommand({
|
|
|
1047
1032
|
description: "New workspace ID"
|
|
1048
1033
|
})
|
|
1049
1034
|
}).strict(),
|
|
1050
|
-
run:
|
|
1035
|
+
run: async (args) => {
|
|
1051
1036
|
const config = readPlatformConfig();
|
|
1052
1037
|
if (!config.profiles[args.name]) throw new Error(`Profile "${args.name}" not found.`);
|
|
1053
1038
|
if (!args.user && !args["workspace-id"]) throw new Error("Please provide at least one property to update.");
|
|
@@ -1074,7 +1059,7 @@ const updateCommand$1 = defineCommand({
|
|
|
1074
1059
|
workspaceId: newWorkspaceId
|
|
1075
1060
|
};
|
|
1076
1061
|
logger.out(profileInfo);
|
|
1077
|
-
}
|
|
1062
|
+
}
|
|
1078
1063
|
});
|
|
1079
1064
|
|
|
1080
1065
|
//#endregion
|
|
@@ -1125,15 +1110,14 @@ const secretValueArgs = {
|
|
|
1125
1110
|
|
|
1126
1111
|
//#endregion
|
|
1127
1112
|
//#region src/cli/commands/secret/create.ts
|
|
1128
|
-
const createSecretCommand =
|
|
1113
|
+
const createSecretCommand = defineAppCommand({
|
|
1129
1114
|
name: "create",
|
|
1130
1115
|
description: "Create a secret in a vault.",
|
|
1131
1116
|
args: z.object({
|
|
1132
|
-
...commonArgs,
|
|
1133
1117
|
...workspaceArgs,
|
|
1134
1118
|
...secretValueArgs
|
|
1135
1119
|
}).strict(),
|
|
1136
|
-
run:
|
|
1120
|
+
run: async (args) => {
|
|
1137
1121
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1138
1122
|
useProfile: true,
|
|
1139
1123
|
profile: args.profile
|
|
@@ -1157,21 +1141,20 @@ const createSecretCommand = defineCommand({
|
|
|
1157
1141
|
throw error;
|
|
1158
1142
|
}
|
|
1159
1143
|
logger.success(`Secret: ${args.name} created in vault: ${args["vault-name"]}`);
|
|
1160
|
-
}
|
|
1144
|
+
}
|
|
1161
1145
|
});
|
|
1162
1146
|
|
|
1163
1147
|
//#endregion
|
|
1164
1148
|
//#region src/cli/commands/secret/delete.ts
|
|
1165
|
-
const deleteSecretCommand =
|
|
1149
|
+
const deleteSecretCommand = defineAppCommand({
|
|
1166
1150
|
name: "delete",
|
|
1167
1151
|
description: "Delete a secret in a vault.",
|
|
1168
1152
|
args: z.object({
|
|
1169
|
-
...commonArgs,
|
|
1170
1153
|
...workspaceArgs,
|
|
1171
1154
|
...secretIdentifyArgs,
|
|
1172
1155
|
...confirmationArgs
|
|
1173
1156
|
}).strict(),
|
|
1174
|
-
run:
|
|
1157
|
+
run: async (args) => {
|
|
1175
1158
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1176
1159
|
useProfile: true,
|
|
1177
1160
|
profile: args.profile
|
|
@@ -1197,7 +1180,7 @@ const deleteSecretCommand = defineCommand({
|
|
|
1197
1180
|
throw error;
|
|
1198
1181
|
}
|
|
1199
1182
|
logger.success(`Secret: ${args.name} deleted from vault: ${args["vault-name"]}`);
|
|
1200
|
-
}
|
|
1183
|
+
}
|
|
1201
1184
|
});
|
|
1202
1185
|
|
|
1203
1186
|
//#endregion
|
|
@@ -1233,16 +1216,14 @@ async function secretList(options) {
|
|
|
1233
1216
|
return [secrets, nextPageToken];
|
|
1234
1217
|
})).map(secretInfo);
|
|
1235
1218
|
}
|
|
1236
|
-
const listSecretCommand =
|
|
1219
|
+
const listSecretCommand = defineAppCommand({
|
|
1237
1220
|
name: "list",
|
|
1238
1221
|
description: "List all secrets in a vault.",
|
|
1239
1222
|
args: z.object({
|
|
1240
|
-
...commonArgs,
|
|
1241
|
-
...jsonArgs,
|
|
1242
1223
|
...workspaceArgs,
|
|
1243
1224
|
...vaultArgs
|
|
1244
1225
|
}).strict(),
|
|
1245
|
-
run:
|
|
1226
|
+
run: async (args) => {
|
|
1246
1227
|
try {
|
|
1247
1228
|
const secrets = await secretList({
|
|
1248
1229
|
workspaceId: args["workspace-id"],
|
|
@@ -1254,20 +1235,19 @@ const listSecretCommand = defineCommand({
|
|
|
1254
1235
|
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
|
|
1255
1236
|
throw error;
|
|
1256
1237
|
}
|
|
1257
|
-
}
|
|
1238
|
+
}
|
|
1258
1239
|
});
|
|
1259
1240
|
|
|
1260
1241
|
//#endregion
|
|
1261
1242
|
//#region src/cli/commands/secret/update.ts
|
|
1262
|
-
const updateSecretCommand =
|
|
1243
|
+
const updateSecretCommand = defineAppCommand({
|
|
1263
1244
|
name: "update",
|
|
1264
1245
|
description: "Update a secret in a vault.",
|
|
1265
1246
|
args: z.object({
|
|
1266
|
-
...commonArgs,
|
|
1267
1247
|
...workspaceArgs,
|
|
1268
1248
|
...secretValueArgs
|
|
1269
1249
|
}).strict(),
|
|
1270
|
-
run:
|
|
1250
|
+
run: async (args) => {
|
|
1271
1251
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1272
1252
|
useProfile: true,
|
|
1273
1253
|
profile: args.profile
|
|
@@ -1288,7 +1268,7 @@ const updateSecretCommand = defineCommand({
|
|
|
1288
1268
|
throw error;
|
|
1289
1269
|
}
|
|
1290
1270
|
logger.success(`Secret: ${args.name} updated in vault: ${args["vault-name"]}`);
|
|
1291
|
-
}
|
|
1271
|
+
}
|
|
1292
1272
|
});
|
|
1293
1273
|
|
|
1294
1274
|
//#endregion
|
|
@@ -1300,15 +1280,14 @@ const nameArgs = { name: arg(z.string(), {
|
|
|
1300
1280
|
|
|
1301
1281
|
//#endregion
|
|
1302
1282
|
//#region src/cli/commands/secret/vault/create.ts
|
|
1303
|
-
const createCommand$1 =
|
|
1283
|
+
const createCommand$1 = defineAppCommand({
|
|
1304
1284
|
name: "create",
|
|
1305
1285
|
description: "Create a new Secret Manager vault.",
|
|
1306
1286
|
args: z.object({
|
|
1307
|
-
...commonArgs,
|
|
1308
1287
|
...workspaceArgs,
|
|
1309
1288
|
...nameArgs
|
|
1310
1289
|
}).strict(),
|
|
1311
|
-
run:
|
|
1290
|
+
run: async (args) => {
|
|
1312
1291
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1313
1292
|
useProfile: true,
|
|
1314
1293
|
profile: args.profile
|
|
@@ -1327,21 +1306,20 @@ const createCommand$1 = defineCommand({
|
|
|
1327
1306
|
throw error;
|
|
1328
1307
|
}
|
|
1329
1308
|
logger.success(`Vault: ${args.name} created`);
|
|
1330
|
-
}
|
|
1309
|
+
}
|
|
1331
1310
|
});
|
|
1332
1311
|
|
|
1333
1312
|
//#endregion
|
|
1334
1313
|
//#region src/cli/commands/secret/vault/delete.ts
|
|
1335
|
-
const deleteCommand$1 =
|
|
1314
|
+
const deleteCommand$1 = defineAppCommand({
|
|
1336
1315
|
name: "delete",
|
|
1337
1316
|
description: "Delete a Secret Manager vault.",
|
|
1338
1317
|
args: z.object({
|
|
1339
|
-
...commonArgs,
|
|
1340
1318
|
...workspaceArgs,
|
|
1341
1319
|
...nameArgs,
|
|
1342
1320
|
...confirmationArgs
|
|
1343
1321
|
}).strict(),
|
|
1344
|
-
run:
|
|
1322
|
+
run: async (args) => {
|
|
1345
1323
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1346
1324
|
useProfile: true,
|
|
1347
1325
|
profile: args.profile
|
|
@@ -1366,7 +1344,7 @@ const deleteCommand$1 = defineCommand({
|
|
|
1366
1344
|
throw error;
|
|
1367
1345
|
}
|
|
1368
1346
|
logger.success(`Vault: ${args.name} deleted`);
|
|
1369
|
-
}
|
|
1347
|
+
}
|
|
1370
1348
|
});
|
|
1371
1349
|
|
|
1372
1350
|
//#endregion
|
|
@@ -1401,21 +1379,17 @@ async function vaultList(options) {
|
|
|
1401
1379
|
return [vaults, nextPageToken];
|
|
1402
1380
|
})).map(vaultInfo);
|
|
1403
1381
|
}
|
|
1404
|
-
const listCommand$3 =
|
|
1382
|
+
const listCommand$3 = defineAppCommand({
|
|
1405
1383
|
name: "list",
|
|
1406
1384
|
description: "List all Secret Manager vaults in the workspace.",
|
|
1407
|
-
args: z.object({
|
|
1408
|
-
|
|
1409
|
-
...jsonArgs,
|
|
1410
|
-
...workspaceArgs
|
|
1411
|
-
}).strict(),
|
|
1412
|
-
run: withCommonArgs(async (args) => {
|
|
1385
|
+
args: z.object({ ...workspaceArgs }).strict(),
|
|
1386
|
+
run: async (args) => {
|
|
1413
1387
|
const vaults = await vaultList({
|
|
1414
1388
|
workspaceId: args["workspace-id"],
|
|
1415
1389
|
profile: args.profile
|
|
1416
1390
|
});
|
|
1417
1391
|
logger.out(vaults);
|
|
1418
|
-
}
|
|
1392
|
+
}
|
|
1419
1393
|
});
|
|
1420
1394
|
|
|
1421
1395
|
//#endregion
|
|
@@ -1607,12 +1581,10 @@ function logSkippedFiles(skippedFiles) {
|
|
|
1607
1581
|
logger.warn("Deployment completed, but some files failed to upload. These files may have unsupported content types or other validation issues. Please review the list below:");
|
|
1608
1582
|
for (const file of skippedFiles) logger.log(` - ${file}`);
|
|
1609
1583
|
}
|
|
1610
|
-
const deployCommand =
|
|
1584
|
+
const deployCommand = defineAppCommand({
|
|
1611
1585
|
name: "deploy",
|
|
1612
1586
|
description: "Deploy a static website from a local build directory.",
|
|
1613
1587
|
args: z.object({
|
|
1614
|
-
...commonArgs,
|
|
1615
|
-
...jsonArgs,
|
|
1616
1588
|
...workspaceArgs,
|
|
1617
1589
|
name: arg(z.string(), {
|
|
1618
1590
|
alias: "n",
|
|
@@ -1624,7 +1596,7 @@ const deployCommand = defineCommand({
|
|
|
1624
1596
|
completion: { type: "directory" }
|
|
1625
1597
|
})
|
|
1626
1598
|
}).strict(),
|
|
1627
|
-
run:
|
|
1599
|
+
run: async (args) => {
|
|
1628
1600
|
logger.info(`Deploying static website "${args.name}" from directory: ${args.dir}`);
|
|
1629
1601
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1630
1602
|
useProfile: true,
|
|
@@ -1648,24 +1620,22 @@ const deployCommand = defineCommand({
|
|
|
1648
1620
|
logger.success(`Static website "${name}" deployed successfully. URL: ${url}`);
|
|
1649
1621
|
logSkippedFiles(skippedFiles);
|
|
1650
1622
|
}
|
|
1651
|
-
}
|
|
1623
|
+
}
|
|
1652
1624
|
});
|
|
1653
1625
|
|
|
1654
1626
|
//#endregion
|
|
1655
1627
|
//#region src/cli/commands/staticwebsite/get.ts
|
|
1656
|
-
const getCommand =
|
|
1628
|
+
const getCommand = defineAppCommand({
|
|
1657
1629
|
name: "get",
|
|
1658
1630
|
description: "Get details of a specific static website.",
|
|
1659
1631
|
args: z.object({
|
|
1660
|
-
...commonArgs,
|
|
1661
|
-
...jsonArgs,
|
|
1662
1632
|
...workspaceArgs,
|
|
1663
1633
|
name: arg(z.string(), {
|
|
1664
1634
|
positional: true,
|
|
1665
1635
|
description: "Static website name"
|
|
1666
1636
|
})
|
|
1667
1637
|
}).strict(),
|
|
1668
|
-
run:
|
|
1638
|
+
run: async (args) => {
|
|
1669
1639
|
const client = await initOperatorClient(await loadAccessToken({
|
|
1670
1640
|
useProfile: true,
|
|
1671
1641
|
profile: args.profile
|
|
@@ -1693,7 +1663,7 @@ const getCommand = defineCommand({
|
|
|
1693
1663
|
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(notFoundErrorMessage);
|
|
1694
1664
|
throw error;
|
|
1695
1665
|
}
|
|
1696
|
-
}
|
|
1666
|
+
}
|
|
1697
1667
|
});
|
|
1698
1668
|
|
|
1699
1669
|
//#endregion
|
|
@@ -1727,15 +1697,11 @@ async function listStaticWebsites(options) {
|
|
|
1727
1697
|
allowedIpAddresses: site.allowedIpAddresses
|
|
1728
1698
|
}));
|
|
1729
1699
|
}
|
|
1730
|
-
const listCommand$2 =
|
|
1700
|
+
const listCommand$2 = defineAppCommand({
|
|
1731
1701
|
name: "list",
|
|
1732
1702
|
description: "List all static websites in a workspace.",
|
|
1733
|
-
args: z.object({
|
|
1734
|
-
|
|
1735
|
-
...jsonArgs,
|
|
1736
|
-
...workspaceArgs
|
|
1737
|
-
}).strict(),
|
|
1738
|
-
run: withCommonArgs(async (args) => {
|
|
1703
|
+
args: z.object({ ...workspaceArgs }).strict(),
|
|
1704
|
+
run: async (args) => {
|
|
1739
1705
|
const websites = await listStaticWebsites({
|
|
1740
1706
|
workspaceId: args["workspace-id"],
|
|
1741
1707
|
profile: args.profile
|
|
@@ -1753,7 +1719,7 @@ const listCommand$2 = defineCommand({
|
|
|
1753
1719
|
};
|
|
1754
1720
|
});
|
|
1755
1721
|
logger.out(formatted);
|
|
1756
|
-
}
|
|
1722
|
+
}
|
|
1757
1723
|
});
|
|
1758
1724
|
|
|
1759
1725
|
//#endregion
|
|
@@ -2008,7 +1974,7 @@ function resolveAllNamespaces(config, options) {
|
|
|
2008
1974
|
*/
|
|
2009
1975
|
async function runLiamBuild(schemaPath, cwd) {
|
|
2010
1976
|
fs$1.mkdirSync(cwd, { recursive: true });
|
|
2011
|
-
return await new Promise((resolve
|
|
1977
|
+
return await new Promise((resolve, reject) => {
|
|
2012
1978
|
let liamBinPath;
|
|
2013
1979
|
try {
|
|
2014
1980
|
liamBinPath = resolveCliBinPath({
|
|
@@ -2045,7 +2011,7 @@ async function runLiamBuild(schemaPath, cwd) {
|
|
|
2045
2011
|
reject(error);
|
|
2046
2012
|
});
|
|
2047
2013
|
child.on("close", (code) => {
|
|
2048
|
-
if (code === 0) resolve
|
|
2014
|
+
if (code === 0) resolve();
|
|
2049
2015
|
else {
|
|
2050
2016
|
if (stderrOutput) logger.error(stderrOutput);
|
|
2051
2017
|
logger.error("liam CLI exited with a non-zero code. Ensure `@liam-hq/cli erd build --format tbls --input schema.json` works in your project.");
|
|
@@ -2109,13 +2075,11 @@ async function prepareErdBuilds(options) {
|
|
|
2109
2075
|
})));
|
|
2110
2076
|
return targets;
|
|
2111
2077
|
}
|
|
2112
|
-
const erdExportCommand =
|
|
2078
|
+
const erdExportCommand = defineAppCommand({
|
|
2113
2079
|
name: "export",
|
|
2114
2080
|
description: "Export Liam ERD dist from applied TailorDB schema.",
|
|
2115
2081
|
args: z.object({
|
|
2116
|
-
...commonArgs,
|
|
2117
2082
|
...deploymentArgs,
|
|
2118
|
-
...jsonArgs,
|
|
2119
2083
|
namespace: arg(z.string().optional(), {
|
|
2120
2084
|
alias: "n",
|
|
2121
2085
|
description: "TailorDB namespace name (optional if only one namespace is defined in config)"
|
|
@@ -2126,7 +2090,7 @@ const erdExportCommand = defineCommand({
|
|
|
2126
2090
|
completion: { type: "directory" }
|
|
2127
2091
|
})
|
|
2128
2092
|
}).strict(),
|
|
2129
|
-
run:
|
|
2093
|
+
run: async (args) => {
|
|
2130
2094
|
const { client, workspaceId, config } = await initErdContext(args);
|
|
2131
2095
|
const outputDir = path.resolve(process.cwd(), String(args.output));
|
|
2132
2096
|
const results = await prepareErdBuilds({
|
|
@@ -2147,24 +2111,22 @@ const erdExportCommand = defineCommand({
|
|
|
2147
2111
|
logger.out(` - Liam ERD dist: ${result.distDir}`);
|
|
2148
2112
|
logger.out(` - tbls schema.json: ${result.schemaOutputPath}`);
|
|
2149
2113
|
}
|
|
2150
|
-
}
|
|
2114
|
+
}
|
|
2151
2115
|
});
|
|
2152
2116
|
|
|
2153
2117
|
//#endregion
|
|
2154
2118
|
//#region src/cli/commands/tailordb/erd/deploy.ts
|
|
2155
|
-
const erdDeployCommand =
|
|
2119
|
+
const erdDeployCommand = defineAppCommand({
|
|
2156
2120
|
name: "deploy",
|
|
2157
2121
|
description: "Deploy ERD static website for TailorDB namespace(s).",
|
|
2158
2122
|
args: z.object({
|
|
2159
|
-
...commonArgs,
|
|
2160
2123
|
...deploymentArgs,
|
|
2161
|
-
...jsonArgs,
|
|
2162
2124
|
namespace: arg(z.string().optional(), {
|
|
2163
2125
|
alias: "n",
|
|
2164
2126
|
description: "TailorDB namespace name (optional - deploys all namespaces with erdSite if omitted)"
|
|
2165
2127
|
})
|
|
2166
2128
|
}).strict(),
|
|
2167
|
-
run:
|
|
2129
|
+
run: async (args) => {
|
|
2168
2130
|
const { client, workspaceId, config } = await initErdContext(args);
|
|
2169
2131
|
const buildResults = await prepareErdBuilds({
|
|
2170
2132
|
client,
|
|
@@ -2192,7 +2154,7 @@ const erdDeployCommand = defineCommand({
|
|
|
2192
2154
|
logger.success(`ERD site "${result.erdSite}" deployed successfully.`);
|
|
2193
2155
|
logger.out(result.url);
|
|
2194
2156
|
}
|
|
2195
|
-
}
|
|
2157
|
+
}
|
|
2196
2158
|
});
|
|
2197
2159
|
|
|
2198
2160
|
//#endregion
|
|
@@ -2209,7 +2171,7 @@ async function runServeDist(results) {
|
|
|
2209
2171
|
logger.warn(`Multiple namespaces found. To serve another namespace, run:\n${commands}`);
|
|
2210
2172
|
}
|
|
2211
2173
|
fs$1.mkdirSync(primary.erdDir, { recursive: true });
|
|
2212
|
-
return await new Promise((resolve
|
|
2174
|
+
return await new Promise((resolve, reject) => {
|
|
2213
2175
|
let serveBinPath;
|
|
2214
2176
|
try {
|
|
2215
2177
|
serveBinPath = resolveCliBinPath({
|
|
@@ -2230,7 +2192,7 @@ async function runServeDist(results) {
|
|
|
2230
2192
|
reject(error);
|
|
2231
2193
|
});
|
|
2232
2194
|
child.on("exit", (code) => {
|
|
2233
|
-
if (code === 0) resolve
|
|
2195
|
+
if (code === 0) resolve();
|
|
2234
2196
|
else {
|
|
2235
2197
|
logger.error("serve CLI exited with a non-zero code. Ensure `serve dist` works in your project.");
|
|
2236
2198
|
reject(/* @__PURE__ */ new Error(`serve CLI exited with code ${code ?? 1}`));
|
|
@@ -2238,18 +2200,17 @@ async function runServeDist(results) {
|
|
|
2238
2200
|
});
|
|
2239
2201
|
});
|
|
2240
2202
|
}
|
|
2241
|
-
const erdServeCommand =
|
|
2203
|
+
const erdServeCommand = defineAppCommand({
|
|
2242
2204
|
name: "serve",
|
|
2243
2205
|
description: "Generate and serve ERD locally (liam build + serve dist). (beta)",
|
|
2244
2206
|
args: z.object({
|
|
2245
|
-
...commonArgs,
|
|
2246
2207
|
...deploymentArgs,
|
|
2247
2208
|
namespace: arg(z.string().optional(), {
|
|
2248
2209
|
alias: "n",
|
|
2249
2210
|
description: "TailorDB namespace name (uses first namespace in config if not specified)"
|
|
2250
2211
|
})
|
|
2251
2212
|
}).strict(),
|
|
2252
|
-
run:
|
|
2213
|
+
run: async (args) => {
|
|
2253
2214
|
const { client, workspaceId, config } = await initErdContext(args);
|
|
2254
2215
|
await runServeDist(await prepareErdBuilds({
|
|
2255
2216
|
client,
|
|
@@ -2257,7 +2218,7 @@ const erdServeCommand = defineCommand({
|
|
|
2257
2218
|
config,
|
|
2258
2219
|
namespace: args.namespace
|
|
2259
2220
|
}));
|
|
2260
|
-
}
|
|
2221
|
+
}
|
|
2261
2222
|
});
|
|
2262
2223
|
|
|
2263
2224
|
//#endregion
|
|
@@ -2306,8 +2267,8 @@ async function set(options) {
|
|
|
2306
2267
|
}))}:tailordb:${targetNamespace}`;
|
|
2307
2268
|
let currentMigration;
|
|
2308
2269
|
try {
|
|
2309
|
-
const { metadata
|
|
2310
|
-
const label = metadata
|
|
2270
|
+
const { metadata } = await client.getMetadata({ trn });
|
|
2271
|
+
const label = metadata?.labels?.["sdk-migration"];
|
|
2311
2272
|
currentMigration = label ? parseMigrationLabelNumber(label) ?? 0 : 0;
|
|
2312
2273
|
} catch {
|
|
2313
2274
|
currentMigration = 0;
|
|
@@ -2346,11 +2307,10 @@ async function set(options) {
|
|
|
2346
2307
|
});
|
|
2347
2308
|
logger.success(`Migration checkpoint set to ${styles.bold(formatMigrationNumber(migrationNumber))} for namespace ${styles.bold(targetNamespace)}`);
|
|
2348
2309
|
}
|
|
2349
|
-
const setCommand =
|
|
2310
|
+
const setCommand = defineAppCommand({
|
|
2350
2311
|
name: "set",
|
|
2351
2312
|
description: "Set migration checkpoint to a specific number.",
|
|
2352
2313
|
args: z.object({
|
|
2353
|
-
...commonArgs,
|
|
2354
2314
|
...deploymentArgs,
|
|
2355
2315
|
...confirmationArgs,
|
|
2356
2316
|
number: arg(z.string(), {
|
|
@@ -2362,7 +2322,7 @@ const setCommand = defineCommand({
|
|
|
2362
2322
|
description: "Target TailorDB namespace (required if multiple namespaces exist)"
|
|
2363
2323
|
})
|
|
2364
2324
|
}).strict(),
|
|
2365
|
-
run:
|
|
2325
|
+
run: async (args) => {
|
|
2366
2326
|
await set({
|
|
2367
2327
|
configPath: args.config,
|
|
2368
2328
|
number: args.number,
|
|
@@ -2371,7 +2331,7 @@ const setCommand = defineCommand({
|
|
|
2371
2331
|
workspaceId: args["workspace-id"],
|
|
2372
2332
|
profile: args.profile
|
|
2373
2333
|
});
|
|
2374
|
-
}
|
|
2334
|
+
}
|
|
2375
2335
|
});
|
|
2376
2336
|
|
|
2377
2337
|
//#endregion
|
|
@@ -2424,25 +2384,24 @@ async function status(options) {
|
|
|
2424
2384
|
}
|
|
2425
2385
|
logger.newline();
|
|
2426
2386
|
}
|
|
2427
|
-
const statusCommand =
|
|
2387
|
+
const statusCommand = defineAppCommand({
|
|
2428
2388
|
name: "status",
|
|
2429
2389
|
description: "Show the current migration status for TailorDB namespaces, including applied and pending migrations.",
|
|
2430
2390
|
args: z.object({
|
|
2431
|
-
...commonArgs,
|
|
2432
2391
|
...deploymentArgs,
|
|
2433
2392
|
namespace: arg(z.string().optional(), {
|
|
2434
2393
|
alias: "n",
|
|
2435
2394
|
description: "Target TailorDB namespace (shows all namespaces if not specified)"
|
|
2436
2395
|
})
|
|
2437
2396
|
}).strict(),
|
|
2438
|
-
run:
|
|
2397
|
+
run: async (args) => {
|
|
2439
2398
|
await status({
|
|
2440
2399
|
configPath: args.config,
|
|
2441
2400
|
namespace: args.namespace,
|
|
2442
2401
|
workspaceId: args["workspace-id"],
|
|
2443
2402
|
profile: args.profile
|
|
2444
2403
|
});
|
|
2445
|
-
}
|
|
2404
|
+
}
|
|
2446
2405
|
});
|
|
2447
2406
|
|
|
2448
2407
|
//#endregion
|
|
@@ -2479,11 +2438,11 @@ const tailordbCommand = defineCommand({
|
|
|
2479
2438
|
|
|
2480
2439
|
//#endregion
|
|
2481
2440
|
//#region src/cli/commands/user/current.ts
|
|
2482
|
-
const currentCommand =
|
|
2441
|
+
const currentCommand = defineAppCommand({
|
|
2483
2442
|
name: "current",
|
|
2484
2443
|
description: "Show current user.",
|
|
2485
|
-
args: z.object({
|
|
2486
|
-
run:
|
|
2444
|
+
args: z.object({}).strict(),
|
|
2445
|
+
run: async () => {
|
|
2487
2446
|
const config = readPlatformConfig();
|
|
2488
2447
|
if (!config.current_user) throw new Error(ml`
|
|
2489
2448
|
Current user not set.
|
|
@@ -2494,19 +2453,16 @@ const currentCommand = defineCommand({
|
|
|
2494
2453
|
Please login again using 'tailor-sdk login' command to register the user.
|
|
2495
2454
|
`);
|
|
2496
2455
|
logger.log(config.current_user);
|
|
2497
|
-
}
|
|
2456
|
+
}
|
|
2498
2457
|
});
|
|
2499
2458
|
|
|
2500
2459
|
//#endregion
|
|
2501
2460
|
//#region src/cli/commands/user/list.ts
|
|
2502
|
-
const listCommand$1 =
|
|
2461
|
+
const listCommand$1 = defineAppCommand({
|
|
2503
2462
|
name: "list",
|
|
2504
2463
|
description: "List all users.",
|
|
2505
|
-
args: z.object({
|
|
2506
|
-
|
|
2507
|
-
...jsonArgs
|
|
2508
|
-
}).strict(),
|
|
2509
|
-
run: withCommonArgs(async (args) => {
|
|
2464
|
+
args: z.object({}).strict(),
|
|
2465
|
+
run: async (args) => {
|
|
2510
2466
|
const config = readPlatformConfig();
|
|
2511
2467
|
const users = Object.keys(config.users);
|
|
2512
2468
|
if (users.length === 0) {
|
|
@@ -2524,7 +2480,7 @@ const listCommand$1 = defineCommand({
|
|
|
2524
2480
|
if (user === config.current_user) logger.success(`${user} (current)`, { mode: "plain" });
|
|
2525
2481
|
else logger.log(user);
|
|
2526
2482
|
});
|
|
2527
|
-
}
|
|
2483
|
+
}
|
|
2528
2484
|
});
|
|
2529
2485
|
|
|
2530
2486
|
//#endregion
|
|
@@ -2585,12 +2541,10 @@ function printCreatedToken(name, token, write, action) {
|
|
|
2585
2541
|
|
|
2586
2542
|
//#endregion
|
|
2587
2543
|
//#region src/cli/commands/user/pat/create.ts
|
|
2588
|
-
const createCommand =
|
|
2544
|
+
const createCommand = defineAppCommand({
|
|
2589
2545
|
name: "create",
|
|
2590
2546
|
description: "Create a new personal access token.",
|
|
2591
2547
|
args: z.object({
|
|
2592
|
-
...commonArgs,
|
|
2593
|
-
...jsonArgs,
|
|
2594
2548
|
name: arg(z.string(), {
|
|
2595
2549
|
positional: true,
|
|
2596
2550
|
description: "Token name"
|
|
@@ -2600,7 +2554,7 @@ const createCommand = defineCommand({
|
|
|
2600
2554
|
description: "Grant write permission (default: read-only)"
|
|
2601
2555
|
})
|
|
2602
2556
|
}).strict(),
|
|
2603
|
-
run:
|
|
2557
|
+
run: async (args) => {
|
|
2604
2558
|
const config = readPlatformConfig();
|
|
2605
2559
|
if (!config.current_user) throw new Error(ml`
|
|
2606
2560
|
No user logged in.
|
|
@@ -2614,22 +2568,19 @@ const createCommand = defineCommand({
|
|
|
2614
2568
|
});
|
|
2615
2569
|
if (!result.accessToken) throw new Error("Failed to create personal access token");
|
|
2616
2570
|
printCreatedToken(args.name, result.accessToken, args.write, "created");
|
|
2617
|
-
}
|
|
2571
|
+
}
|
|
2618
2572
|
});
|
|
2619
2573
|
|
|
2620
2574
|
//#endregion
|
|
2621
2575
|
//#region src/cli/commands/user/pat/delete.ts
|
|
2622
|
-
const deleteCommand =
|
|
2576
|
+
const deleteCommand = defineAppCommand({
|
|
2623
2577
|
name: "delete",
|
|
2624
2578
|
description: "Delete a personal access token.",
|
|
2625
|
-
args: z.object({
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
})
|
|
2631
|
-
}).strict(),
|
|
2632
|
-
run: withCommonArgs(async (args) => {
|
|
2579
|
+
args: z.object({ name: arg(z.string(), {
|
|
2580
|
+
positional: true,
|
|
2581
|
+
description: "Token name"
|
|
2582
|
+
}) }).strict(),
|
|
2583
|
+
run: async (args) => {
|
|
2633
2584
|
const config = readPlatformConfig();
|
|
2634
2585
|
if (!config.current_user) throw new Error(ml`
|
|
2635
2586
|
No user logged in.
|
|
@@ -2637,19 +2588,16 @@ const deleteCommand = defineCommand({
|
|
|
2637
2588
|
`);
|
|
2638
2589
|
await (await initOperatorClient(await fetchLatestToken(config, config.current_user))).deletePersonalAccessToken({ name: args.name });
|
|
2639
2590
|
logger.success(`Personal access token "${args.name}" deleted successfully.`);
|
|
2640
|
-
}
|
|
2591
|
+
}
|
|
2641
2592
|
});
|
|
2642
2593
|
|
|
2643
2594
|
//#endregion
|
|
2644
2595
|
//#region src/cli/commands/user/pat/list.ts
|
|
2645
|
-
const listCommand =
|
|
2596
|
+
const listCommand = defineAppCommand({
|
|
2646
2597
|
name: "list",
|
|
2647
2598
|
description: "List all personal access tokens.",
|
|
2648
|
-
args: z.object({
|
|
2649
|
-
|
|
2650
|
-
...jsonArgs
|
|
2651
|
-
}).strict(),
|
|
2652
|
-
run: withCommonArgs(async (args) => {
|
|
2599
|
+
args: z.object({}).strict(),
|
|
2600
|
+
run: async (args) => {
|
|
2653
2601
|
const config = readPlatformConfig();
|
|
2654
2602
|
if (!config.current_user) throw new Error(ml`
|
|
2655
2603
|
No user logged in.
|
|
@@ -2682,17 +2630,15 @@ const listCommand = defineCommand({
|
|
|
2682
2630
|
const paddedName = info.name.padStart(maxNameLength);
|
|
2683
2631
|
logger.log(`${paddedName}: ${info.scopes.join("/")}`);
|
|
2684
2632
|
});
|
|
2685
|
-
}
|
|
2633
|
+
}
|
|
2686
2634
|
});
|
|
2687
2635
|
|
|
2688
2636
|
//#endregion
|
|
2689
2637
|
//#region src/cli/commands/user/pat/update.ts
|
|
2690
|
-
const updateCommand =
|
|
2638
|
+
const updateCommand = defineAppCommand({
|
|
2691
2639
|
name: "update",
|
|
2692
2640
|
description: "Update a personal access token (delete and recreate).",
|
|
2693
2641
|
args: z.object({
|
|
2694
|
-
...commonArgs,
|
|
2695
|
-
...jsonArgs,
|
|
2696
2642
|
name: arg(z.string(), {
|
|
2697
2643
|
positional: true,
|
|
2698
2644
|
description: "Token name"
|
|
@@ -2702,7 +2648,7 @@ const updateCommand = defineCommand({
|
|
|
2702
2648
|
description: "Grant write permission (if not specified, keeps read-only)"
|
|
2703
2649
|
})
|
|
2704
2650
|
}).strict(),
|
|
2705
|
-
run:
|
|
2651
|
+
run: async (args) => {
|
|
2706
2652
|
const config = readPlatformConfig();
|
|
2707
2653
|
if (!config.current_user) throw new Error(ml`
|
|
2708
2654
|
No user logged in.
|
|
@@ -2717,7 +2663,7 @@ const updateCommand = defineCommand({
|
|
|
2717
2663
|
});
|
|
2718
2664
|
if (!result.accessToken) throw new Error("Failed to create personal access token");
|
|
2719
2665
|
printCreatedToken(args.name, result.accessToken, args.write, "updated");
|
|
2720
|
-
}
|
|
2666
|
+
}
|
|
2721
2667
|
});
|
|
2722
2668
|
|
|
2723
2669
|
//#endregion
|
|
@@ -2725,31 +2671,27 @@ const updateCommand = defineCommand({
|
|
|
2725
2671
|
const patCommand = defineCommand({
|
|
2726
2672
|
name: "pat",
|
|
2727
2673
|
description: "Manage personal access tokens.",
|
|
2728
|
-
args: listCommand.args,
|
|
2729
2674
|
subCommands: {
|
|
2730
2675
|
create: createCommand,
|
|
2731
2676
|
delete: deleteCommand,
|
|
2732
2677
|
list: listCommand,
|
|
2733
2678
|
update: updateCommand
|
|
2734
2679
|
},
|
|
2735
|
-
async run(
|
|
2736
|
-
await listCommand
|
|
2680
|
+
async run() {
|
|
2681
|
+
await runCommand(listCommand, []);
|
|
2737
2682
|
}
|
|
2738
2683
|
});
|
|
2739
2684
|
|
|
2740
2685
|
//#endregion
|
|
2741
2686
|
//#region src/cli/commands/user/switch.ts
|
|
2742
|
-
const switchCommand =
|
|
2687
|
+
const switchCommand = defineAppCommand({
|
|
2743
2688
|
name: "switch",
|
|
2744
2689
|
description: "Set current user.",
|
|
2745
|
-
args: z.object({
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
})
|
|
2751
|
-
}).strict(),
|
|
2752
|
-
run: withCommonArgs(async (args) => {
|
|
2690
|
+
args: z.object({ user: arg(z.string(), {
|
|
2691
|
+
positional: true,
|
|
2692
|
+
description: "User email"
|
|
2693
|
+
}) }).strict(),
|
|
2694
|
+
run: async (args) => {
|
|
2753
2695
|
const config = readPlatformConfig();
|
|
2754
2696
|
if (!config.users[args.user]) throw new Error(ml`
|
|
2755
2697
|
User "${args.user}" not found.
|
|
@@ -2758,7 +2700,7 @@ const switchCommand = defineCommand({
|
|
|
2758
2700
|
config.current_user = args.user;
|
|
2759
2701
|
writePlatformConfig(config);
|
|
2760
2702
|
logger.success(`Current user set to "${args.user}" successfully.`);
|
|
2761
|
-
}
|
|
2703
|
+
}
|
|
2762
2704
|
});
|
|
2763
2705
|
|
|
2764
2706
|
//#endregion
|
|
@@ -2875,7 +2817,21 @@ const mainCommand = withCompletionCommand(defineCommand({
|
|
|
2875
2817
|
workspace: workspaceCommand
|
|
2876
2818
|
}
|
|
2877
2819
|
}));
|
|
2878
|
-
runMain(mainCommand, {
|
|
2820
|
+
runMain(mainCommand, {
|
|
2821
|
+
version: packageJson.version,
|
|
2822
|
+
globalArgs: z.object(commonArgs),
|
|
2823
|
+
cleanup: async ({ error }) => {
|
|
2824
|
+
if (error) if (isCLIError(error)) {
|
|
2825
|
+
logger.log(error.format());
|
|
2826
|
+
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
2827
|
+
} else if (error instanceof Error) {
|
|
2828
|
+
logger.error(error.message);
|
|
2829
|
+
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
2830
|
+
} else logger.error(`Unknown error: ${error}`);
|
|
2831
|
+
const { shutdownTelemetry } = await import("../telemetry-DDQZRqHK.mjs");
|
|
2832
|
+
await shutdownTelemetry();
|
|
2833
|
+
}
|
|
2834
|
+
});
|
|
2879
2835
|
|
|
2880
2836
|
//#endregion
|
|
2881
2837
|
export { mainCommand };
|