@procedures/cli-kit 0.0.0-bootstrap.0 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,117 @@
1
+ /**
2
+ * A command line for a procedure registry.
3
+ *
4
+ * `createProcedureCli()` makes a program from the procedures: the flags come from the input
5
+ * schemas, and the help comes from the metadata. A missing argument is a question in a
6
+ * terminal. A value `@<file>` is the text of the file. A format hook of a procedure writes its
7
+ * human output.
8
+ */
9
+ import { type Method } from "@procedures/client";
10
+ import { type GlobalFlag, type Globals } from "./args.js";
11
+ import { type Asker, type Terminal } from "./ask.js";
12
+ import { type CommandLike } from "./fields.js";
13
+ import { type OutputFormat, type Print } from "./format.js";
14
+ /** The global flags of each program of `createProcedureCli()`. The option `globals` adds more. */
15
+ export declare const STANDARD_GLOBAL_FLAGS: readonly GlobalFlag[];
16
+ /** The commands of a program: a list of procedures or descriptions, or a registry. */
17
+ export type CommandSource = readonly CommandLike[] | {
18
+ getAll(): readonly CommandLike[];
19
+ };
20
+ /** The options of a call of a `CliClient`. */
21
+ export interface CliCallOptions {
22
+ /** The signal that aborts the call. */
23
+ signal?: AbortSignal | undefined;
24
+ }
25
+ /**
26
+ * The client that runs the commands, for example a `Client` of `@procedures/client` over HTTP.
27
+ * The command line uses `stream()` when the client has it, and else `call()`.
28
+ */
29
+ export interface CliClient {
30
+ /** This function gives each item of the result of a procedure. */
31
+ stream?(method: Method, payload: unknown, options?: CliCallOptions): AsyncIterable<unknown>;
32
+ /** This function gives the result of a procedure. */
33
+ call?(method: Method, payload: unknown, options?: CliCallOptions): Promise<unknown>;
34
+ }
35
+ /** The data that a format hook gets. */
36
+ export interface FormatContext {
37
+ /** The path of the command. */
38
+ path: readonly string[];
39
+ /** The input of the command. */
40
+ input: unknown;
41
+ /** The output format: `text` or `streaming`. */
42
+ format: OutputFormat;
43
+ /** The print functions of the program. */
44
+ print: Print;
45
+ }
46
+ /**
47
+ * A format hook writes the human output of one procedure. It gives a text or lines, and the
48
+ * program prints them. Or it prints with `context.print` and gives nothing. The program uses a
49
+ * hook only for the formats `text` and `streaming`. `--json` and `--format table` do not use it.
50
+ */
51
+ export type FormatHook = (result: unknown, context: FormatContext) => string | readonly string[] | undefined | void;
52
+ /** The options of `createProcedureCli()`. */
53
+ export interface ProcedureCliOptions {
54
+ /** The name of the program, as a person types it. */
55
+ name: string;
56
+ /** The version that `--version` shows. Without it, `--version` shows the help. */
57
+ version?: string | undefined;
58
+ /** The text after the name in the first line of the help. */
59
+ description?: string | undefined;
60
+ /**
61
+ * The commands: procedures, descriptions of procedures, or a registry. A function gives them
62
+ * when the program starts, for example from a lazy import.
63
+ */
64
+ procedures: CommandSource | (() => CommandSource | Promise<CommandSource>);
65
+ /**
66
+ * The client that runs the commands. A function makes the client from the global flags, for
67
+ * example from `--port`. Without a client, the commands run in this process on the procedures.
68
+ */
69
+ client?: CliClient | ((globals: Globals) => CliClient | Promise<CliClient>) | undefined;
70
+ /** More global flags. A flag with the long name of a standard flag replaces it. */
71
+ globals?: readonly GlobalFlag[] | undefined;
72
+ /** The format hooks, by the path of the procedure with dots, for example `"job.status"`. */
73
+ format?: Readonly<Record<string, FormatHook>> | undefined;
74
+ /** The print functions. The default writes plain text to the console. */
75
+ print?: Print | undefined;
76
+ /** The lines of the help after the list of the commands. */
77
+ footer?: readonly string[] | undefined;
78
+ /** The terminal state that decides if the program asks. Tests give a fake. */
79
+ terminal?: Terminal | undefined;
80
+ /** The function that asks one question. Tests give a fake. */
81
+ ask?: Asker | undefined;
82
+ /**
83
+ * The function that reads a file for a value `@<file>`. The default reads the file as UTF-8.
84
+ * `false` turns `@<file>` off: a value that starts with `@` stays text.
85
+ */
86
+ readFile?: ((path: string) => string) | false | undefined;
87
+ }
88
+ /** The options of one run. */
89
+ export interface ProcedureCliRunOptions {
90
+ /** The signal that aborts the call of the command. */
91
+ signal?: AbortSignal | undefined;
92
+ }
93
+ /** A program of `createProcedureCli()`. */
94
+ export interface ProcedureCli {
95
+ /** The name of the program. */
96
+ readonly name: string;
97
+ /** The global flags of the program. */
98
+ readonly globals: readonly GlobalFlag[];
99
+ /**
100
+ * This function starts one command line (without the program name) and gives the exit code.
101
+ * The exit code is 1 for an unknown command, an invalid input, an error or a failed result.
102
+ * Else the exit code is 0.
103
+ */
104
+ run(argv: readonly string[], options?: ProcedureCliRunOptions): Promise<number>;
105
+ }
106
+ /**
107
+ * This function makes a command line for a procedure registry. The program gives help, `--json`,
108
+ * questions for missing arguments, `@<file>` input and short flags from `meta.shorts`.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const cli = createProcedureCli({ name: "tool", version: "1.0.0", procedures: registry });
113
+ * process.exitCode = await cli.run(process.argv.slice(2));
114
+ * ```
115
+ */
116
+ export declare function createProcedureCli(options: ProcedureCliOptions): ProcedureCli;
117
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAML,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAkC,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1F,OAAO,EAAqE,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExH,OAAO,EAA0C,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAA4B,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAGtF,kGAAkG;AAClG,eAAO,MAAM,qBAAqB,EAAE,SAAS,UAAU,EAOtD,CAAC;AAIF,sFAAsF;AACtF,MAAM,MAAM,aAAa,GAAG,SAAS,WAAW,EAAE,GAAG;IAAE,MAAM,IAAI,SAAS,WAAW,EAAE,CAAA;CAAE,CAAC;AAE1F,8CAA8C;AAC9C,M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a program from the procedures: the flags come from the input
5
+ * schemas, and the help comes from the metadata. A missing argument is a question in a
6
+ * terminal. A value `@<file>` is the text of the file. A format hook of a procedure writes its
7
+ * human output.
8
+ */
9
+ import { readFileSync } from "node:fs";
10
+ import { Client, LocalTransport, ProcedureRegistry, pathToMethod, } from "@procedures/client";
11
+ import { findChildren, parseCommandLine } from "./args.js";
12
+ import { askMissing, canAsk, missingFields, processTerminal, terminalAsker } from "./ask.js";
13
+ import { failureOf } from "./failure.js";
14
+ import { fieldsOf, resultFieldsOf } from "./fields.js";
15
+ import { formatOutput, plainPrint } from "./format.js";
16
+ import { generateHelp, groupHelp, rootHelp, validationMessage } from "./help.js";
17
+ /** The global flags of each program of `createProcedureCli()`. The option `globals` adds more. */
18
+ export const STANDARD_GLOBAL_FLAGS = [
19
+ { long: "help", short: "h", takesValue: false, description: "Show the help" },
20
+ { long: "version", short: "v", takesValue: false, hidden: true, description: "Show the version" },
21
+ { long: "format", short: "f", takesValue: true, description: "The output format: text, json, table or streaming" },
22
+ { long: "json", takesValue: false, description: "Write the result as JSON (the same as --format json)" },
23
+ { long: "data", takesValue: true, description: "The input as a JSON object, or @<file> for a file with the JSON object" },
24
+ { long: "no-input", takesValue: false, description: "Never ask for a missing argument (also when CI is set)" },
25
+ ];
26
+ const OUTPUT_FORMATS = ["text", "json", "table", "streaming"];
27
+ /** This function gives the global flags: the standard flags, then the flags of the options. */
28
+ function mergeGlobals(extra) {
29
+ const names = new Set(extra.map((flag) => flag.long));
30
+ return [...STANDARD_GLOBAL_FLAGS.filter((flag) => !names.has(flag.long)), ...extra];
31
+ }
32
+ /** This function gives the list of a command source. */
33
+ function commandsOf(source) {
34
+ return "getAll" in source ? source.getAll() : source;
35
+ }
36
+ /** This function gives the text of an error. */
37
+ function messageOf(error) {
38
+ return error instanceof Error ? error.message : String(error);
39
+ }
40
+ /** This function makes a client in this process over the procedures of a source. */
41
+ function localClient(source) {
42
+ let registry;
43
+ if (source instanceof ProcedureRegistry) {
44
+ registry = source;
45
+ }
46
+ else {
47
+ registry = new ProcedureRegistry();
48
+ for (const procedure of commandsOf(source))
49
+ registry.register(procedure);
50
+ }
51
+ const client = new Client({ transport: new LocalTransport({ registry }) }).useRegistry(registry);
52
+ return {
53
+ stream: (method, payload, options) => client.stream(method, payload, options?.signal ? { signal: options.signal } : {}),
54
+ };
55
+ }
56
+ /** This function gives each item of the result of a call. */
57
+ async function* itemsOf(client, method, payload, options) {
58
+ if (client.stream) {
59
+ yield* client.stream(method, payload, options);
60
+ return;
61
+ }
62
+ if (client.call) {
63
+ yield await client.call(method, payload, options);
64
+ return;
65
+ }
66
+ throw new Error("The client has no stream() and no call()");
67
+ }
68
+ /**
69
+ * This function makes a command line for a procedure registry. The program gives help, `--json`,
70
+ * questions for missing arguments, `@<file>` input and short flags from `meta.shorts`.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const cli = createProcedureCli({ name: "tool", version: "1.0.0", procedures: registry });
75
+ * process.exitCode = await cli.run(process.argv.slice(2));
76
+ * ```
77
+ */
78
+ export function createProcedureCli(options) {
79
+ const { name } = options;
80
+ const globalFlags = mergeGlobals(options.globals ?? []);
81
+ const readFile = options.readFile === false ? undefined : (options.readFile ?? ((path) => readFileSync(path, "utf8")));
82
+ const run = async (argv, runOptions = {}) => {
83
+ const print = options.print ?? plainPrint();
84
+ let code = 0;
85
+ const fail = (message, hint) => {
86
+ print.error(message);
87
+ if (hint)
88
+ print.info(hint);
89
+ code = 1;
90
+ };
91
+ try {
92
+ const source = typeof options.procedures === "function" ? await options.procedures() : options.procedures;
93
+ const commands = commandsOf(source);
94
+ const parsed = parseCommandLine(argv, commands, { name, globals: globalFlags, readFile });
95
+ const { path, procedure, globals } = parsed;
96
+ const command = `${name} ${path.join(" ")}`;
97
+ // An unknown command is the first problem to report
98
+ if (path.length > 0 && !procedure) {
99
+ const isGroup = findChildren(commands, path).length > 0;
100
+ if (!isGroup || parsed.extraArguments.length > 0) {
101
+ const words = [...path, ...parsed.extraArguments.slice(0, 1)];
102
+ fail(`Unknown command: ${name} ${words.join(" ")}`, `Run '${name} --help' for available commands.`);
103
+ return code;
104
+ }
105
+ }
106
+ if (parsed.errors.length > 0) {
107
+ for (const error of parsed.errors)
108
+ print.error(error);
109
+ print.info(`Run '${path.length > 0 ? `${command} --help` : `${name} --help`}' for the options.`);
110
+ return 1;
111
+ }
112
+ if (globals["version"] === true && options.version !== undefined) {
113
+ print.info(`${name} v${options.version}`);
114
+ return 0;
115
+ }
116
+ const formatOverride = globals["json"] === true ? "json" : globals["format"] === undefined ? undefined : String(globals["format"]);
117
+ if (formatOverride !== undefined && !OUTPUT_FORMATS.includes(formatOverride)) {
118
+ fail(`Invalid format: ${formatOverride}. Valid formats: ${OUTPUT_FORMATS.join(", ")}`);
119
+ return code;
120
+ }
121
+ // The help of the program, of a group or of a command
122
+ if (path.length === 0) {
123
+ const title = `${name}${options.version !== undefined ? ` v${options.version}` : ""}${options.description ? ` - ${options.description}` : ""}`;
124
+ for (const line of rootHelp(commands, { name, title, footer: options.footer }))
125
+ print.info(line);
126
+ return 0;
127
+ }
128
+ if (globals["help"] === true || !procedure) {
129
+ if (procedure) {
130
+ const meta = (procedure.metadata ?? {});
131
+ print.info(generateHelp(path, meta, fieldsOf(procedure), resultFieldsOf(procedure), { name, globals: globalFlags }));
132
+ }
133
+ else {
134
+ for (const line of groupHelp(name, commands, path) ?? [])
135
+ print.info(line);
136
+ }
137
+ return 0;
138
+ }
139
+ const meta = (procedure.metadata ?? {});
140
+ const outputFormat = (formatOverride ?? meta.output ?? "text");
141
+ // --data: the input as one JSON object. The flags and the arguments go over its fields.
142
+ let input = parsed.input;
143
+ if (globals["data"] !== undefined) {
144
+ let text = String(globals["data"]);
145
+ if (text.startsWith("@") && !text.startsWith("@@") && text.length > 1) {
146
+ if (!readFile) {
147
+ fail(`--data ${text}: this program reads no files`);
148
+ return code;
149
+ }
150
+ text = readFile(text.slice(1));
151
+ }
152
+ else if (text.startsWith("@@")) {
153
+ text = text.slice(1);
154
+ }
155
+ let data;
156
+ try {
157
+ data = JSON.parse(text);
158
+ }
159
+ catch (error) {
160
+ fail(`--data needs a JSON object: ${messageOf(error)}`);
161
+ return code;
162
+ }
163
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
164
+ fail("--data needs a JSON object");
165
+ return code;
166
+ }
167
+ input = { ...data, ...input };
168
+ }
169
+ // A required argument that is missing: in a terminal, the program asks for it
170
+ const missing = missingFields(fieldsOf(procedure), input);
171
+ if (missing.length > 0 && canAsk(globals["no-input"] === true, meta, options.terminal ?? processTerminal())) {
172
+ const asked = await askMissing(missing, input, options.ask ?? terminalAsker);
173
+ if (!asked.ok) {
174
+ fail(asked.cancelled ? "Cancelled" : `Invalid input for ${command}:\n ${asked.error}`);
175
+ return code;
176
+ }
177
+ input = asked.input;
178
+ }
179
+ // A procedure with a schema validates the input here. A description without a schema
180
+ // leaves the validation to the client.
181
+ let validated = input;
182
+ const schema = procedure.input;
183
+ if (typeof schema?.parse === "function") {
184
+ try {
185
+ validated = schema.parse(input);
186
+ }
187
+ catch (error) {
188
+ fail(`Invalid input for ${command}:\n ${validationMessage(error)}`, `Run '${command} --help' for the options.`);
189
+ return code;
190
+ }
191
+ }
192
+ else {
193
+ const stillMissing = missingFields(fieldsOf(procedure), input);
194
+ if (stillMissing.length > 0) {
195
+ const names = stillMissing.map((field) => `${field.name}: Required`).join("\n ");
196
+ fail(`Invalid input for ${command}:\n ${names}`, `Run '${command} --help' for the options.`);
197
+ return code;
198
+ }
199
+ }
200
+ const client = options.client === undefined
201
+ ? localClient(source)
202
+ : typeof options.client === "function"
203
+ ? await options.client(globals)
204
+ : options.client;
205
+ // Each item prints when it arrives. A failed item makes the command fail.
206
+ const hook = outputFormat === "text" || outputFormat === "streaming" ? options.format?.[path.join(".")] : undefined;
207
+ let failure;
208
+ const printItem = (item) => {
209
+ const text = hook ? hook(item, { path, input: validated, format: outputFormat, print }) : undefined;
210
+ if (typeof text === "string") {
211
+ print.info(text);
212
+ }
213
+ else if (Array.isArray(text)) {
214
+ for (const line of text)
215
+ print.info(line);
216
+ }
217
+ else if (!hook) {
218
+ formatOutput(print, item, outputFormat);
219
+ }
220
+ failure ??= failureOf(item);
221
+ };
222
+ const spinner = outputFormat === "streaming" ? print.spin(`Running ${path.join(" ")}...`) : undefined;
223
+ try {
224
+ let items = 0;
225
+ for await (const item of itemsOf(client, pathToMethod(path), validated, { signal: runOptions.signal })) {
226
+ if (spinner && items === 0)
227
+ spinner.stop();
228
+ items++;
229
+ printItem(item);
230
+ }
231
+ if (spinner) {
232
+ if (failure === undefined)
233
+ spinner.succeed(`${path.join(" ")} complete`);
234
+ else
235
+ spinner.fail(`${path.join(" ")} failed`);
236
+ }
237
+ }
238
+ catch (error) {
239
+ spinner?.stop();
240
+ throw error;
241
+ }
242
+ if (failure !== undefined) {
243
+ fail(`${command} failed: ${failure}`);
244
+ }
245
+ }
246
+ catch (error) {
247
+ fail(`Error: ${messageOf(error)}`);
248
+ }
249
+ return code;
250
+ };
251
+ return { name, globals: globalFlags, run };
252
+ }
253
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAiC,MAAM,WAAW,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAA6B,MAAM,UAAU,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAkC,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAiC,MA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reports a failure in one of three ways, and the command line exits with code 1 for each:
5
+ *
6
+ * 1. It throws an error. This is the usual way.
7
+ * 2. It returns an object with `success: false`. Use this when the result has more to show,
8
+ * for example the list of problems of `lib audit`.
9
+ * 3. It returns an object with a numeric `exitCode` that is not 0. Use this for a procedure that
10
+ * runs an external command (`vitest run`, `shell run`), so the caller sees the command's result.
11
+ *
12
+ * For a streaming procedure, each item is examined: one failed item makes the command fail.
13
+ */
14
+ /** A short description of the failure that a result reports, or undefined when it reports none */
15
+ export declare function failureOf(result: unknown): string | undefined;
16
+ //# sourceMappingURL=failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kGAAkG;AAClG,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAa7D"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Procedure-level failure
3
+ *
4
+ * A procedure reports a failure in one of three ways, and the command line exits with code 1 for each:
5
+ *
6
+ * 1. It throws an error. This is the usual way.
7
+ * 2. It returns an object with `success: false`. Use this when the result has more to show,
8
+ * for example the list of problems of `lib audit`.
9
+ * 3. It returns an object with a numeric `exitCode` that is not 0. Use this for a procedure that
10
+ * runs an external command (`vitest run`, `shell run`), so the caller sees the command's result.
11
+ *
12
+ * For a streaming procedure, each item is examined: one failed item makes the command fail.
13
+ */
14
+ /** A short description of the failure that a result reports, or undefined when it reports none */
15
+ export function failureOf(result) {
16
+ if (!result || typeof result !== "object" || Array.isArray(result)) {
17
+ return undefined;
18
+ }
19
+ const record = result;
20
+ const exitCode = record["exitCode"];
21
+ if (typeof exitCode === "number" && exitCode !== 0) {
22
+ return `exit code ${exitCode}`;
23
+ }
24
+ if (record["success"] === false) {
25
+ return firstText(record["error"]) ?? firstText(record["errors"]) ?? firstText(record["message"]) ?? "success: false";
26
+ }
27
+ return undefined;
28
+ }
29
+ /** The first text of a value: a string, the message of an error object, or the first of a list */
30
+ function firstText(value) {
31
+ if (typeof value === "string" && value.length > 0) {
32
+ return value;
33
+ }
34
+ if (Array.isArray(value)) {
35
+ for (const item of value) {
36
+ const text = firstText(item);
37
+ if (text)
38
+ return text;
39
+ }
40
+ return undefined;
41
+ }
42
+ if (value && typeof value === "object" && typeof value.message === "string") {
43
+ return value.message;
44
+ }
45
+ return undefined;
46
+ }
47
+ //# sourceMappingURL=failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.js","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kGAAkG;AAClG,MAAM,UAAU,SAAS,CAAC,MAAe;IACvC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,MAAiC,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnD,OAAO,aAAa,QAAQ,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,gBAAgB,CAAC;IACvH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,kGAAkG;AAClG,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC;QACxB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACvG,OAAQ,KAA6B,CAAC,OAAO,CAAC;IAChD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * The fields of a procedure input, as a command line sees them.
3
+ *
4
+ * This module reads the field types of an input schema from its JSON Schema, converts the text of
5
+ * the command line to those types, and merges repeated values. The schema validates the result.
6
+ */
7
+ /**
8
+ * CLI metadata that can be attached to procedures via .meta()
9
+ */
10
+ export interface CLIMeta {
11
+ /** Description for help text */
12
+ description?: string;
13
+ /** Field names that are positional args (in order). An array field that is last takes the rest. */
14
+ args?: string[];
15
+ /** Short flag mappings: { fieldName: "f" } */
16
+ shorts?: Record<string, string>;
17
+ /** Output format hint */
18
+ output?: "text" | "json" | "table" | "streaming";
19
+ /** Whether to prompt for missing required fields */
20
+ interactive?: boolean;
21
+ }
22
+ /**
23
+ * The kinds of field the CLI can convert to. "any" is a field with no usable type: its value is
24
+ * JSON when it parses as JSON, and text otherwise.
25
+ */
26
+ export type FieldKind = "string" | "number" | "bigint" | "boolean" | "enum" | "literal" | "date" | "array" | "record" | "object" | "union" | "any";
27
+ /**
28
+ * The type of a schema field, as the CLI sees it
29
+ */
30
+ export interface FieldType {
31
+ kind: FieldKind;
32
+ /** The item type of an array */
33
+ item?: FieldType;
34
+ /** The value type of a record */
35
+ value?: FieldType;
36
+ /** The member types of a union */
37
+ options?: FieldType[];
38
+ /** The values of an enum */
39
+ values?: readonly string[];
40
+ /** The value of a literal */
41
+ literal?: unknown;
42
+ }
43
+ /**
44
+ * Extracted schema field info for help generation
45
+ */
46
+ export interface SchemaFieldInfo {
47
+ name: string;
48
+ /** The display name of the type, for the help text */
49
+ type: string;
50
+ /** The type the CLI converts values to */
51
+ fieldType: FieldType;
52
+ required: boolean;
53
+ description: string | undefined;
54
+ defaultValue: unknown;
55
+ enumValues: readonly string[] | undefined;
56
+ }
57
+ /**
58
+ * The CLI type of a schema: a procedure schema (a Standard Schema such as zod 4) or its JSON
59
+ * Schema. The type comes from the JSON Schema, so every schema library works. (Before, the
60
+ * parser read the private fields of zod 3.)
61
+ */
62
+ export declare function fieldTypeOf(schema: unknown): FieldType;
63
+ /**
64
+ * The display name of a type, for the help text
65
+ */
66
+ export declare function typeName(type: FieldType): string;
67
+ /**
68
+ * Extract field information from a schema: a procedure schema or its JSON Schema. A schema that
69
+ * is not an object (or that has no JSON Schema) gives no fields: the CLI then passes its flags
70
+ * through.
71
+ */
72
+ export declare function extractSchemaFields(schema: unknown): SchemaFieldInfo[];
73
+ /** The result of a conversion: the value, or a message for the user */
74
+ export type Converted = {
75
+ ok: true;
76
+ value: unknown;
77
+ } | {
78
+ ok: false;
79
+ error: string;
80
+ };
81
+ /**
82
+ * Convert the CLI text of one value to a field type
83
+ */
84
+ export declare function convertValue(text: string, type: FieldType, label: string): Converted;
85
+ /**
86
+ * Add a converted value to a field that already has one. Arrays collect and records merge,
87
+ * so a repeated flag adds to the field. Other fields take the last value.
88
+ */
89
+ export declare function mergeValue(previous: unknown, next: unknown, type: FieldType): unknown;
90
+ /**
91
+ * Convert camelCase to kebab-case
92
+ */
93
+ export declare function toKebab(str: string): string;
94
+ /**
95
+ * Convert kebab-case to camelCase
96
+ */
97
+ export declare function toCamel(str: string): string;
98
+ /**
99
+ * A command as the command line sees it: a procedure of a registry (with its input schema), or a
100
+ * description of a procedure (with the fields of its input), for example the manifest of `mark`.
101
+ */
102
+ export interface CommandLike {
103
+ path: readonly string[];
104
+ metadata?: unknown;
105
+ /** The input schema of a procedure of the registry */
106
+ input?: unknown;
107
+ /** The output schema of a procedure of the registry */
108
+ output?: unknown;
109
+ /** The fields of the input of a description */
110
+ fields?: readonly SchemaFieldInfo[];
111
+ /** The fields of the result of a description */
112
+ resultFields?: readonly SchemaFieldInfo[];
113
+ }
114
+ /** This function gives the fields of the input of a command: from its description, or read from its schema. */
115
+ export declare function fieldsOf(command: CommandLike): SchemaFieldInfo[];
116
+ /**
117
+ * The fields of the result of a procedure, from its output schema: only for a result that is an
118
+ * object (a union, a stream item or a pass-through schema gives none).
119
+ */
120
+ export declare function resultFieldsOfSchema(output: unknown): SchemaFieldInfo[];
121
+ /** This function gives the fields of the result of a command: from its description, or read from its output schema. */
122
+ export declare function resultFieldsOf(command: CommandLike): SchemaFieldInfo[];
123
+ /** A field that only the metadata names (the schema has no readable shape) */
124
+ export declare function fieldWithoutSchema(name: string): SchemaFieldInfo;
125
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mGAAmG;IACnG,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,yBAAyB;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;IACjD,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,SA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