@liase/cli 1.0.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright © 2024 Callum Gare
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ > :warning: **This package is currently experimental and the API is both poorly documented and likely to change**
2
+
3
+ # liase CLI (`@liase/cli`)
4
+
5
+ A CLI tool for [liase](https://github.com/callumgare/liase).
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { getRunCommand } from "./subcommands/run.js";
4
+ import { getShowSchemaCommand } from "./subcommands/show-schema.js";
5
+ import { getWebUiCommand } from "./subcommands/web-ui.js";
6
+ const program = new Command();
7
+ program.addCommand(await getRunCommand());
8
+ program.addCommand(await getShowSchemaCommand());
9
+ program.addCommand(await getWebUiCommand());
10
+ program.parseAsync();
@@ -0,0 +1,18 @@
1
+ import { type Plugin, type RequestHandler, type Source } from "@liase/core";
2
+ import { Option } from "commander";
3
+ type LiaseDetails = {
4
+ source?: Source;
5
+ requestHandler?: RequestHandler;
6
+ plugins: Plugin[];
7
+ };
8
+ export declare function getLiaseDetailsFromArgs(): Promise<LiaseDetails>;
9
+ export declare function getSharedLiaseOptions({ source, plugins }: LiaseDetails): {
10
+ sourceOption: Option;
11
+ requestHandlerOption: Option;
12
+ pluginsOption: Option;
13
+ cacheNetworkRequestsOption: Option;
14
+ secretsSetOption: Option;
15
+ };
16
+ export declare function getRequestFromArgs(options: Record<string, unknown>, requestHandler?: RequestHandler): Record<string, unknown>;
17
+ export {};
18
+ //# sourceMappingURL=liase-details.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liase-details.d.ts","sourceRoot":"","sources":["../../src/lib/liase-details.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,MAAM,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAG5C,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAgBF,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,YAAY,CAAC,CA+ErE;AAED,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY;;;;;;EA6CtE;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,cAAc,CAAC,EAAE,cAAc,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB"}
@@ -0,0 +1,105 @@
1
+ import { Liase, } from "@liase/core";
2
+ import { Command, Option } from "commander";
3
+ import { tsImport } from "tsx/esm/api";
4
+ // In order to add more details to the help text of some command and their arguments
5
+ // we want to look some some details of some of the args the user may have given us.
6
+ // For example if viewing the help text of the "run" command and they've also given
7
+ // us the "--source" argument with the value "bluesky" then we want the list of valid
8
+ // options for the "--requestHandler" to show only the request handlers provided by
9
+ // the bluesky source. But to do this we need to first parse what options the user has
10
+ // given us.
11
+ // We normally can't do this before we define all the details for our commands
12
+ // so to get around this we create a "shadow" command object with the subcommands and
13
+ // subcommand options we care about, parse this in order to determine which values
14
+ // the user has given us, then finally we lookup any relevant info based on this and
15
+ // return it so it can be used for building our actual options.
16
+ let cachedLiaseDetails = undefined;
17
+ export async function getLiaseDetailsFromArgs() {
18
+ if (!cachedLiaseDetails) {
19
+ const program = new Command();
20
+ const silenceCommand = (command) => command
21
+ .helpCommand(false)
22
+ .helpOption("")
23
+ .exitOverride()
24
+ .configureOutput({
25
+ writeOut: () => { },
26
+ writeErr: () => { },
27
+ outputError: () => { },
28
+ })
29
+ .allowUnknownOption();
30
+ silenceCommand(program);
31
+ let options = {};
32
+ function addSubcommand(program, subcommandName) {
33
+ const command = new Command();
34
+ command
35
+ .name(subcommandName)
36
+ .option("-s, --source <source id>")
37
+ .option("-r, --requestHandler <request handler id>")
38
+ .option("-p, --plugins <comma separated list of filepaths to plugins>")
39
+ .action((_options) => {
40
+ options = _options;
41
+ });
42
+ silenceCommand(command);
43
+ program.addCommand(command);
44
+ return command;
45
+ }
46
+ addSubcommand(program, "run");
47
+ addSubcommand(program, "show-schema");
48
+ addSubcommand(program, "web-ui");
49
+ try {
50
+ program.parse();
51
+ }
52
+ catch (error) {
53
+ // We don't care if there's an error
54
+ }
55
+ const sourceId = options.source;
56
+ const requestHandlerId = options.requestHandler;
57
+ const pluginFilePaths = typeof options.plugins === "string" ? options.plugins.split(",") : [];
58
+ const plugins = await Promise.all(pluginFilePaths
59
+ .filter((path) => path)
60
+ .map(async (pluginFilePath) => await tsImport(pluginFilePath, import.meta.url))).then((modules) => modules.map((module) => module.default));
61
+ const mediaFinder = new Liase({ plugins });
62
+ const source = mediaFinder.sources.find((source) => source.id === sourceId);
63
+ if (sourceId && !source) {
64
+ throw Error(`Could not find source for "${sourceId}"`);
65
+ }
66
+ const requestHandler = source?.requestHandlers.find((handler) => handler.id === requestHandlerId);
67
+ if (source && requestHandlerId && !requestHandler) {
68
+ throw Error(`Could not find request handler for "${requestHandlerId}"`);
69
+ }
70
+ cachedLiaseDetails = { source, requestHandler, plugins };
71
+ }
72
+ return cachedLiaseDetails;
73
+ }
74
+ export function getSharedLiaseOptions({ source, plugins }) {
75
+ const sourceOption = new Option("-s, --source <source id>", "Media finder source ID").makeOptionMandatory(true);
76
+ const requestHandlerOption = new Option("-r, --requestHandler <request handler id>", "ID of the request handler").makeOptionMandatory(true);
77
+ const pluginsOption = new Option("-p, --plugins <comma separated list of filepaths to plugins>", "Plugins to load");
78
+ const secretsSetOption = new Option("--secretsSet <secrets set name>", "Finds secrets set with given name and uses secrets in query");
79
+ const cacheNetworkRequestsOption = new Option("--cacheNetworkRequests <caching option>", `"never" will never cache network requests, "auto" will cache requests that seem like they might be cacheable and store them for as long as they seem fresh, ` +
80
+ `"always" will always cache requests with no expiry.`)
81
+ .choices(["never", "auto", "always"])
82
+ .default("always");
83
+ const mediaFinder = new Liase({ plugins });
84
+ sourceOption.choices(mediaFinder.sources.map((source) => source.id));
85
+ if (source) {
86
+ requestHandlerOption.choices(source.requestHandlers.map((handler) => handler.id));
87
+ }
88
+ return {
89
+ sourceOption,
90
+ requestHandlerOption,
91
+ pluginsOption,
92
+ cacheNetworkRequestsOption,
93
+ secretsSetOption,
94
+ };
95
+ }
96
+ export function getRequestFromArgs(options, requestHandler) {
97
+ const request = {};
98
+ if (requestHandler) {
99
+ for (const key in requestHandler.requestSchema.shape) {
100
+ request[key] = options[key];
101
+ }
102
+ }
103
+ request.queryType = options.requestHandler;
104
+ return request;
105
+ }
@@ -0,0 +1,8 @@
1
+ import { type LiaseQuery } from "@liase/core";
2
+ export declare function getLiaseQuery({ request, secretsSet, cacheNetworkRequests, loadPluginsFromArgs, }: {
3
+ request: Record<string, unknown>;
4
+ secretsSet?: string;
5
+ cacheNetworkRequests?: "never" | "auto" | "always";
6
+ loadPluginsFromArgs?: boolean;
7
+ }): Promise<LiaseQuery>;
8
+ //# sourceMappingURL=liase-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liase-query.d.ts","sourceRoot":"","sources":["../../src/lib/liase-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AAIrB,wBAAsB,aAAa,CAAC,EAClC,OAAO,EACP,UAAU,EACV,oBAAoB,EACpB,mBAAmB,GACpB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IACnD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,OAAO,CAAC,UAAU,CAAC,CAsBtB"}
@@ -0,0 +1,25 @@
1
+ import { createLiaseQuery, } from "@liase/core";
2
+ import { getLiaseDetailsFromArgs } from "./liase-details.js";
3
+ import { getSecretsSets } from "./secrets.js";
4
+ export async function getLiaseQuery({ request, secretsSet, cacheNetworkRequests, loadPluginsFromArgs, }) {
5
+ const plugins = [];
6
+ if (loadPluginsFromArgs) {
7
+ const liaseDetails = await getLiaseDetailsFromArgs();
8
+ plugins.push(...liaseDetails.plugins);
9
+ }
10
+ let secrets = {};
11
+ if (secretsSet) {
12
+ const secretsSets = await getSecretsSets();
13
+ secrets = secretsSets[secretsSet];
14
+ }
15
+ return createLiaseQuery({
16
+ request: request,
17
+ queryOptions: {
18
+ secrets,
19
+ cacheNetworkRequests,
20
+ },
21
+ finderOptions: {
22
+ plugins,
23
+ },
24
+ });
25
+ }
@@ -0,0 +1,6 @@
1
+ import { type Server } from "node:http";
2
+ export declare function startProxyServer(): Promise<{
3
+ origin: string;
4
+ server: Server;
5
+ }>;
6
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/lib/proxy.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAG9C,wBAAgB,gBAAgB,IAAI,OAAO,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAiDD"}
@@ -0,0 +1,48 @@
1
+ import http from "node:http";
2
+ import { ProxyServer } from "@refactorjs/http-proxy";
3
+ export function startProxyServer() {
4
+ const proxy = new ProxyServer();
5
+ proxy.on("proxyRes", (proxyRes, req, res) => {
6
+ res.setHeader("Access-Control-Allow-Origin", "*");
7
+ proxyRes.pipe(res);
8
+ });
9
+ const server = http.createServer((req, res) => {
10
+ const targetUrlString = req.url?.replace(/^\//, "") || "";
11
+ let targetUrl;
12
+ try {
13
+ targetUrl = new URL(targetUrlString);
14
+ }
15
+ catch (error) {
16
+ res.statusCode = 400;
17
+ res.end(`Invalid url "${targetUrlString}"`);
18
+ return;
19
+ }
20
+ req.url = targetUrl.pathname + targetUrl.search;
21
+ proxy.web(req, res, {
22
+ target: targetUrl.origin,
23
+ changeOrigin: true,
24
+ secure: false,
25
+ selfHandleResponse: true,
26
+ });
27
+ });
28
+ process.on("SIGINT", () => {
29
+ server.close();
30
+ });
31
+ return new Promise((resolve, reject) => {
32
+ server.on("error", reject);
33
+ server.on("listening", () => {
34
+ const address = server.address();
35
+ if (address === null) {
36
+ throw Error("Could not create proxy server");
37
+ }
38
+ const formattedAddress = typeof address === "object"
39
+ ? `http://localhost:${address.port}`
40
+ : address;
41
+ resolve({
42
+ server,
43
+ origin: formattedAddress,
44
+ });
45
+ });
46
+ server.listen();
47
+ });
48
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getSecretsSets(): Promise<Record<string, Record<string, unknown>>>;
2
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/lib/secrets.ts"],"names":[],"mappings":"AAKA,wBAAsB,cAAc,qDA+BnC"}
@@ -0,0 +1,30 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ let cachedSecretSets;
4
+ export async function getSecretsSets() {
5
+ const defaultSecretSetsConfigPath = "./.secrets-sets.json";
6
+ const customSecretSetsConfigPath = process.env.SECRETS_SETS_CONFIG_PATH
7
+ ? path.resolve(process.env.SECRETS_SETS_CONFIG_PATH)
8
+ : "";
9
+ const secretSetsConfigPath = customSecretSetsConfigPath ?? defaultSecretSetsConfigPath;
10
+ if (!cachedSecretSets) {
11
+ let configString;
12
+ try {
13
+ configString = await fs.readFile(secretSetsConfigPath, "utf8");
14
+ }
15
+ catch (error) {
16
+ if (customSecretSetsConfigPath) {
17
+ console.warn(`Secrets sets config path set to ${secretSetsConfigPath} but file not found or accessible.`);
18
+ }
19
+ configString = "{}";
20
+ }
21
+ try {
22
+ cachedSecretSets = JSON.parse(configString);
23
+ }
24
+ catch (error) {
25
+ console.warn(`Secrets sets config path set to ${secretSetsConfigPath} but file is not valid JSON.`);
26
+ cachedSecretSets = {};
27
+ }
28
+ }
29
+ return cachedSecretSets;
30
+ }
@@ -0,0 +1,50 @@
1
+ import { type Primitive, type ZodFirstPartySchemaTypes, type z } from "zod";
2
+ type SimpleSchema = ({
3
+ type: "string";
4
+ default?: string;
5
+ checks?: z.ZodStringCheck[];
6
+ } | {
7
+ type: "number";
8
+ default?: number;
9
+ checks?: Array<z.ZodNumberCheck | z.ZodBigIntCheck>;
10
+ } | {
11
+ type: "boolean";
12
+ default?: boolean;
13
+ } | {
14
+ type: "date";
15
+ default?: Date | string;
16
+ checks?: z.ZodDateCheck[];
17
+ } | {
18
+ type: "object";
19
+ children: {
20
+ [key: string]: SimpleSchema;
21
+ };
22
+ default?: {
23
+ [key: string]: unknown;
24
+ };
25
+ } | {
26
+ type: "array";
27
+ children: SimpleSchema;
28
+ default?: unknown[];
29
+ } | {
30
+ type: SimpleSchema[];
31
+ default?: unknown;
32
+ } | {
33
+ type: "literal";
34
+ value: Primitive;
35
+ valueType: "string" | "number" | "boolean" | "null" | "other";
36
+ default?: never;
37
+ } | {
38
+ type: "null";
39
+ default?: null;
40
+ } | {
41
+ type: "other" | "undefined";
42
+ default?: unknown;
43
+ zodTypeName: ZodFirstPartySchemaTypes["_def"]["typeName"];
44
+ }) & {
45
+ optional?: boolean;
46
+ description?: string;
47
+ };
48
+ export declare function zodSchemaToSimpleSchema(zodSchema: ZodFirstPartySchemaTypes): SimpleSchema;
49
+ export {};
50
+ //# sourceMappingURL=zod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/lib/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,wBAAwB,EAE7B,KAAK,CAAC,EACP,MAAM,KAAK,CAAC;AAEb,KAAK,YAAY,GAAG,CAChB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC;CAC7B,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;CACrD,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC;CAC3B,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAC;IAC1C,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACtC,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB,GACD;IACE,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IAC9D,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB,GACD;IACE,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;CAC3D,CACJ,GAAG;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAuEF,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,wBAAwB,GAClC,YAAY,CAyLd"}
@@ -0,0 +1,196 @@
1
+ import { ZodFirstPartyTypeKind, } from "zod";
2
+ function isZodType(zodSchema, type) {
3
+ return zodSchema?.constructor?.name === type;
4
+ }
5
+ export function zodSchemaToSimpleSchema(zodSchema) {
6
+ let simpleSchema;
7
+ const zodTypeName = zodSchema._def.typeName;
8
+ const description = zodSchema._def.description;
9
+ const defaultProps = {
10
+ ...(description ? { description } : {}),
11
+ };
12
+ // We don't use instanceof to match against an imported Zod class because the zod schema may be created
13
+ // with a different version of the Zod library and thus not be matched with instanceof
14
+ if (isZodType(zodSchema, "ZodObject")) {
15
+ simpleSchema = {
16
+ ...defaultProps,
17
+ type: "object",
18
+ children: {},
19
+ };
20
+ for (const [name, zodType] of Object.entries(zodSchema._def.shape())) {
21
+ simpleSchema.children[name] = zodSchemaToSimpleSchema(zodType);
22
+ }
23
+ }
24
+ else if (isZodType(zodSchema, "ZodIntersection")) {
25
+ const left = zodSchemaToSimpleSchema(zodSchema._def.left);
26
+ const right = zodSchemaToSimpleSchema(zodSchema._def.right);
27
+ simpleSchema = {
28
+ ...defaultProps,
29
+ type: "object",
30
+ children: { ...left.children, ...right.children },
31
+ };
32
+ }
33
+ else if (isZodType(zodSchema, "ZodArray")) {
34
+ simpleSchema = {
35
+ ...defaultProps,
36
+ type: "array",
37
+ children: zodSchemaToSimpleSchema(zodSchema._def.type),
38
+ };
39
+ }
40
+ else if (isZodType(zodSchema, "ZodSet")) {
41
+ simpleSchema = {
42
+ ...defaultProps,
43
+ type: "array",
44
+ children: zodSchemaToSimpleSchema(zodSchema._def.valueType),
45
+ };
46
+ }
47
+ else if (isZodType(zodSchema, "ZodUnion") ||
48
+ isZodType(zodSchema, "ZodDiscriminatedUnion")) {
49
+ const zodTypesInUnion = zodSchema._def.options;
50
+ const simpleSchemaTypesInUnion = zodTypesInUnion.map(zodSchemaToSimpleSchema);
51
+ simpleSchema = { ...defaultProps, type: simpleSchemaTypesInUnion };
52
+ const unionIncludesUndefined = simpleSchemaTypesInUnion.some((schema) => schema.type === "other" && schema.zodTypeName === "ZodUndefined");
53
+ if (unionIncludesUndefined) {
54
+ simpleSchema.optional = true;
55
+ }
56
+ }
57
+ else if (isZodType(zodSchema, "ZodOptional")) {
58
+ simpleSchema = {
59
+ ...defaultProps,
60
+ ...zodSchemaToSimpleSchema(zodSchema._def.innerType),
61
+ optional: true,
62
+ };
63
+ }
64
+ else if (isZodType(zodSchema, "ZodString")) {
65
+ simpleSchema = { ...defaultProps, type: "string" };
66
+ if (zodSchema._def.checks.length)
67
+ simpleSchema.checks = zodSchema._def.checks;
68
+ }
69
+ else if (isZodType(zodSchema, "ZodNumber") ||
70
+ isZodType(zodSchema, "ZodBigInt")) {
71
+ simpleSchema = { ...defaultProps, type: "number" };
72
+ if (zodSchema._def.checks.length)
73
+ simpleSchema.checks = zodSchema._def.checks;
74
+ }
75
+ else if (isZodType(zodSchema, "ZodBoolean")) {
76
+ simpleSchema = { ...defaultProps, type: "boolean" };
77
+ }
78
+ else if (isZodType(zodSchema, "ZodDate")) {
79
+ simpleSchema = { ...defaultProps, type: "date" };
80
+ if (zodSchema._def.checks.length)
81
+ simpleSchema.checks = zodSchema._def.checks;
82
+ }
83
+ else if (isZodType(zodSchema, "ZodNull")) {
84
+ simpleSchema = { ...defaultProps, type: "null" };
85
+ }
86
+ else if (isZodType(zodSchema, "ZodLiteral")) {
87
+ const value = zodSchema._def.value;
88
+ let valueType;
89
+ if (typeof value === "string") {
90
+ valueType = "string";
91
+ }
92
+ else if (typeof value === "number" || typeof value === "bigint") {
93
+ valueType = "number";
94
+ }
95
+ else if (typeof value === "boolean") {
96
+ valueType = "boolean";
97
+ }
98
+ else if (value === null) {
99
+ valueType = "null";
100
+ }
101
+ else {
102
+ valueType = "other";
103
+ }
104
+ simpleSchema = {
105
+ ...defaultProps,
106
+ type: "literal",
107
+ value,
108
+ valueType,
109
+ };
110
+ }
111
+ else if (isZodType(zodSchema, "ZodEnum")) {
112
+ const enumValues = zodSchema._def.values;
113
+ simpleSchema = {
114
+ ...defaultProps,
115
+ type: enumValues.map((enumValue) => ({
116
+ type: "literal",
117
+ value: enumValue,
118
+ valueType: "string",
119
+ zodTypeName: ZodFirstPartyTypeKind.ZodLiteral,
120
+ })),
121
+ };
122
+ }
123
+ else if (isZodType(zodSchema, "ZodEffects")) {
124
+ simpleSchema = {
125
+ ...defaultProps,
126
+ ...zodSchemaToSimpleSchema(zodSchema._def.schema),
127
+ };
128
+ }
129
+ else if (isZodType(zodSchema, "ZodNativeEnum")) {
130
+ simpleSchema = { ...defaultProps, type: "number" };
131
+ }
132
+ else if (isZodType(zodSchema, "ZodNullable")) {
133
+ simpleSchema = {
134
+ ...defaultProps,
135
+ type: [
136
+ zodSchemaToSimpleSchema(zodSchema._def.innerType),
137
+ { type: "null" },
138
+ ],
139
+ };
140
+ }
141
+ else if (isZodType(zodSchema, "ZodDefault")) {
142
+ simpleSchema = {
143
+ ...defaultProps,
144
+ ...zodSchemaToSimpleSchema(zodSchema._def.innerType),
145
+ default: zodSchema._def.defaultValue(),
146
+ };
147
+ }
148
+ else if (isZodType(zodSchema, "ZodCatch")) {
149
+ simpleSchema = {
150
+ ...defaultProps,
151
+ ...zodSchemaToSimpleSchema(zodSchema._def.innerType),
152
+ };
153
+ }
154
+ else if (isZodType(zodSchema, "ZodBranded")) {
155
+ simpleSchema = {
156
+ ...defaultProps,
157
+ ...zodSchemaToSimpleSchema(zodSchema._def.type),
158
+ };
159
+ }
160
+ else if (isZodType(zodSchema, "ZodPipeline")) {
161
+ simpleSchema = {
162
+ ...defaultProps,
163
+ ...zodSchemaToSimpleSchema(zodSchema._def.in),
164
+ };
165
+ }
166
+ else if (isZodType(zodSchema, "ZodAny") ||
167
+ isZodType(zodSchema, "ZodUndefined") ||
168
+ isZodType(zodSchema, "ZodNaN") ||
169
+ isZodType(zodSchema, "ZodUnknown") ||
170
+ isZodType(zodSchema, "ZodNever") ||
171
+ isZodType(zodSchema, "ZodVoid") ||
172
+ isZodType(zodSchema, "ZodTuple") ||
173
+ isZodType(zodSchema, "ZodRecord") ||
174
+ isZodType(zodSchema, "ZodMap") ||
175
+ isZodType(zodSchema, "ZodFunction") ||
176
+ isZodType(zodSchema, "ZodLazy") ||
177
+ isZodType(zodSchema, "ZodVoid") ||
178
+ isZodType(zodSchema, "ZodPromise") ||
179
+ isZodType(zodSchema, "ZodReadonly") ||
180
+ isZodType(zodSchema, "ZodSymbol")) {
181
+ simpleSchema = {
182
+ ...defaultProps,
183
+ type: "other",
184
+ zodTypeName,
185
+ };
186
+ }
187
+ else {
188
+ zodSchema; // Ensure we have a case for every type in ZodFirstPartySchemaTypes
189
+ simpleSchema = {
190
+ ...defaultProps,
191
+ type: "other",
192
+ zodTypeName,
193
+ };
194
+ }
195
+ return simpleSchema;
196
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function getRunCommand(): Promise<Command>;
3
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/subcommands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAW5C,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CA+ItD"}