@sdk-it/command 0.43.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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +443 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/build-op-command.d.ts +13 -0
- package/dist/lib/build-op-command.d.ts.map +1 -0
- package/dist/lib/command.d.ts +12 -0
- package/dist/lib/command.d.ts.map +1 -0
- package/dist/lib/flags.d.ts +12 -0
- package/dist/lib/flags.d.ts.map +1 -0
- package/dist/lib/input.d.ts +9 -0
- package/dist/lib/input.d.ts.map +1 -0
- package/dist/lib/introspect.d.ts +16 -0
- package/dist/lib/introspect.d.ts.map +1 -0
- package/dist/lib/output.d.ts +5 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/package.json +33 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
// packages/command/src/lib/command.ts
|
|
2
|
+
import { Command as Command2, Option as Option3 } from "commander";
|
|
3
|
+
import { createRpc } from "@sdk-it/rpc";
|
|
4
|
+
import { forEachOperation as forEachOperation2, loadSpec, toIR } from "@sdk-it/spec";
|
|
5
|
+
|
|
6
|
+
// packages/command/src/lib/build-op-command.ts
|
|
7
|
+
import { Command, Option as Option2 } from "commander";
|
|
8
|
+
import { ZodError } from "zod";
|
|
9
|
+
import { buildInput as buildInput2, operationSchema as operationSchema2 } from "@sdk-it/typescript";
|
|
10
|
+
import { schemaToZod } from "@sdk-it/rpc";
|
|
11
|
+
|
|
12
|
+
// packages/command/src/lib/flags.ts
|
|
13
|
+
import { InvalidArgumentError, Option } from "commander";
|
|
14
|
+
import { followRef, isRef } from "@sdk-it/core";
|
|
15
|
+
function resolve(ir, schema) {
|
|
16
|
+
return isRef(schema) ? followRef(ir, schema.$ref) : schema;
|
|
17
|
+
}
|
|
18
|
+
function isPrimitiveType(type) {
|
|
19
|
+
return type === "string" || type === "number" || type === "integer" || type === "boolean" || type === "null";
|
|
20
|
+
}
|
|
21
|
+
function canBeFlag(ir, schema) {
|
|
22
|
+
if (schema.oneOf || schema.anyOf || schema.allOf) return false;
|
|
23
|
+
if (schema.enum) return true;
|
|
24
|
+
const type = schema.type;
|
|
25
|
+
if (Array.isArray(type)) {
|
|
26
|
+
return type.every((t) => isPrimitiveType(t));
|
|
27
|
+
}
|
|
28
|
+
if (isPrimitiveType(type)) return true;
|
|
29
|
+
if (type === "array" && schema.items) {
|
|
30
|
+
const items = Array.isArray(schema.items) ? schema.items[0] : schema.items;
|
|
31
|
+
if (!items) return false;
|
|
32
|
+
const resolved = resolve(ir, items);
|
|
33
|
+
const itemType = resolved.type;
|
|
34
|
+
return !resolved.oneOf && !resolved.anyOf && !resolved.allOf && (isPrimitiveType(itemType) || !!resolved.enum);
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
function coerceNumber(value, integer) {
|
|
39
|
+
const n = Number(value);
|
|
40
|
+
if (Number.isNaN(n)) {
|
|
41
|
+
throw new InvalidArgumentError(`"${value}" is not a valid number`);
|
|
42
|
+
}
|
|
43
|
+
return integer ? Math.trunc(n) : n;
|
|
44
|
+
}
|
|
45
|
+
function coerceBoolean(value) {
|
|
46
|
+
const lower = value.toLowerCase();
|
|
47
|
+
if (lower === "true" || lower === "1" || lower === "yes" || lower === "on") {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (lower === "false" || lower === "0" || lower === "no" || lower === "off") {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
throw new InvalidArgumentError(`"${value}" is not a valid boolean`);
|
|
54
|
+
}
|
|
55
|
+
function describe(schema, required) {
|
|
56
|
+
const base = schema.description ?? "";
|
|
57
|
+
const pieces = [];
|
|
58
|
+
if (schema.type) pieces.push(String(schema.type));
|
|
59
|
+
if (schema.format) pieces.push(`format: ${schema.format}`);
|
|
60
|
+
if (required) pieces.push("required");
|
|
61
|
+
if (schema.default !== void 0) {
|
|
62
|
+
pieces.push(`default: ${JSON.stringify(schema.default)}`);
|
|
63
|
+
}
|
|
64
|
+
const tag = pieces.length ? ` (${pieces.join(", ")})` : "";
|
|
65
|
+
return base + tag;
|
|
66
|
+
}
|
|
67
|
+
function addFlagsFromSchema(command2, schema, ir) {
|
|
68
|
+
const names = /* @__PURE__ */ new Set();
|
|
69
|
+
const skipped = [];
|
|
70
|
+
const properties = schema.properties ?? {};
|
|
71
|
+
const required = new Set(schema.required ?? []);
|
|
72
|
+
for (const [name, propOrRef] of Object.entries(properties)) {
|
|
73
|
+
const prop = resolve(ir, propOrRef);
|
|
74
|
+
if (!canBeFlag(ir, prop)) {
|
|
75
|
+
skipped.push({
|
|
76
|
+
name,
|
|
77
|
+
reason: "complex schema \u2014 supply via --input-file or stdin"
|
|
78
|
+
});
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const isRequired = required.has(name);
|
|
82
|
+
const desc = describe(prop, isRequired);
|
|
83
|
+
if (prop.enum && Array.isArray(prop.enum)) {
|
|
84
|
+
const opt = new Option(`--${name} <value>`, desc).choices(
|
|
85
|
+
prop.enum.map((v) => String(v))
|
|
86
|
+
);
|
|
87
|
+
command2.addOption(opt);
|
|
88
|
+
names.add(name);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const primaryType = Array.isArray(prop.type) ? prop.type[0] : prop.type;
|
|
92
|
+
if (primaryType === "boolean") {
|
|
93
|
+
command2.addOption(new Option(`--${name}`, desc));
|
|
94
|
+
command2.addOption(new Option(`--no-${name}`, `Disable --${name}`));
|
|
95
|
+
names.add(name);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (primaryType === "array") {
|
|
99
|
+
const items = Array.isArray(prop.items) ? prop.items[0] : prop.items;
|
|
100
|
+
const itemSchema = items ? resolve(ir, items) : {};
|
|
101
|
+
const itemType = Array.isArray(itemSchema.type) ? itemSchema.type[0] : itemSchema.type;
|
|
102
|
+
const opt = new Option(
|
|
103
|
+
`--${name} <value>`,
|
|
104
|
+
`${desc} (repeatable)`
|
|
105
|
+
).argParser((value, previous) => {
|
|
106
|
+
const acc = previous ?? [];
|
|
107
|
+
if (itemType === "number" || itemType === "integer") {
|
|
108
|
+
return [...acc, coerceNumber(value, itemType === "integer")];
|
|
109
|
+
}
|
|
110
|
+
if (itemType === "boolean") {
|
|
111
|
+
return [...acc, coerceBoolean(value)];
|
|
112
|
+
}
|
|
113
|
+
return [...acc, value];
|
|
114
|
+
});
|
|
115
|
+
command2.addOption(opt);
|
|
116
|
+
names.add(name);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (primaryType === "number" || primaryType === "integer") {
|
|
120
|
+
const opt = new Option(`--${name} <value>`, desc).argParser(
|
|
121
|
+
(v) => coerceNumber(v, primaryType === "integer")
|
|
122
|
+
);
|
|
123
|
+
command2.addOption(opt);
|
|
124
|
+
names.add(name);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
command2.addOption(new Option(`--${name} <value>`, desc));
|
|
128
|
+
names.add(name);
|
|
129
|
+
}
|
|
130
|
+
return { names, skipped };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// packages/command/src/lib/input.ts
|
|
134
|
+
import { readFile } from "node:fs/promises";
|
|
135
|
+
async function readStdinIfPiped() {
|
|
136
|
+
if (process.stdin.isTTY) return void 0;
|
|
137
|
+
const chunks = [];
|
|
138
|
+
for await (const chunk of process.stdin) {
|
|
139
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
140
|
+
}
|
|
141
|
+
if (chunks.length === 0) return void 0;
|
|
142
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
143
|
+
if (!raw) return void 0;
|
|
144
|
+
try {
|
|
145
|
+
return JSON.parse(raw);
|
|
146
|
+
} catch (err) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Failed to parse JSON from stdin: ${err.message}`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function readJsonFile(path) {
|
|
153
|
+
try {
|
|
154
|
+
const raw = await readFile(path, "utf8");
|
|
155
|
+
return JSON.parse(raw);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
`Failed to read JSON from ${path}: ${err.message}`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function isPlainObject(value) {
|
|
163
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
164
|
+
}
|
|
165
|
+
function mergeSources(file, stdin, flags) {
|
|
166
|
+
const fileObj = isPlainObject(file) ? file : {};
|
|
167
|
+
const stdinObj = isPlainObject(stdin) ? stdin : {};
|
|
168
|
+
return { ...fileObj, ...stdinObj, ...flags };
|
|
169
|
+
}
|
|
170
|
+
async function resolveInput({
|
|
171
|
+
flags,
|
|
172
|
+
inputFile,
|
|
173
|
+
schema,
|
|
174
|
+
flagNames
|
|
175
|
+
}) {
|
|
176
|
+
const onlySchemaFlags = {};
|
|
177
|
+
for (const name of flagNames) {
|
|
178
|
+
if (flags[name] !== void 0) {
|
|
179
|
+
onlySchemaFlags[name] = flags[name];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const file = inputFile ? await readJsonFile(inputFile) : void 0;
|
|
183
|
+
const stdin = await readStdinIfPiped();
|
|
184
|
+
const merged = mergeSources(file, stdin, onlySchemaFlags);
|
|
185
|
+
const parsed = await schema.parseAsync(merged);
|
|
186
|
+
return parsed;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// packages/command/src/lib/introspect.ts
|
|
190
|
+
import {
|
|
191
|
+
forEachOperation
|
|
192
|
+
} from "@sdk-it/spec";
|
|
193
|
+
import { buildInput, operationSchema } from "@sdk-it/typescript";
|
|
194
|
+
var CONTENT_TYPE_PRIORITY = [
|
|
195
|
+
"application/json",
|
|
196
|
+
"application/problem+json",
|
|
197
|
+
"text/plain",
|
|
198
|
+
"application/xml",
|
|
199
|
+
"application/x-www-form-urlencoded",
|
|
200
|
+
"multipart/form-data"
|
|
201
|
+
];
|
|
202
|
+
function pickContentSchema(content) {
|
|
203
|
+
for (const ct of CONTENT_TYPE_PRIORITY) {
|
|
204
|
+
if (content[ct]?.schema) return content[ct].schema;
|
|
205
|
+
}
|
|
206
|
+
const sorted = Object.keys(content).sort();
|
|
207
|
+
for (const key of sorted) {
|
|
208
|
+
if (content[key]?.schema) return content[key].schema;
|
|
209
|
+
}
|
|
210
|
+
return void 0;
|
|
211
|
+
}
|
|
212
|
+
function responseSchemas(operation) {
|
|
213
|
+
const out = {};
|
|
214
|
+
for (const [status, response] of Object.entries(operation.responses ?? {})) {
|
|
215
|
+
const content = response.content;
|
|
216
|
+
out[status] = content ? pickContentSchema(content) : void 0;
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function describeOperation(ir, op, method, path) {
|
|
221
|
+
const details = buildInput(ir, op);
|
|
222
|
+
const input = operationSchema(ir, op, details.ct);
|
|
223
|
+
return {
|
|
224
|
+
operationId: op.operationId,
|
|
225
|
+
name: op["x-fn-name"],
|
|
226
|
+
method: method.toUpperCase(),
|
|
227
|
+
path,
|
|
228
|
+
tag: op.tags?.[0],
|
|
229
|
+
summary: op.summary,
|
|
230
|
+
description: op.description,
|
|
231
|
+
input,
|
|
232
|
+
responses: responseSchemas(op)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function describeAllOperations(ir) {
|
|
236
|
+
const descriptors = {};
|
|
237
|
+
forEachOperation(ir, (entry, op) => {
|
|
238
|
+
descriptors[op["x-fn-name"]] = describeOperation(
|
|
239
|
+
ir,
|
|
240
|
+
op,
|
|
241
|
+
entry.method,
|
|
242
|
+
entry.path
|
|
243
|
+
);
|
|
244
|
+
});
|
|
245
|
+
return descriptors;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// packages/command/src/lib/output.ts
|
|
249
|
+
function hasData(value) {
|
|
250
|
+
return typeof value === "object" && value !== null && "data" in value;
|
|
251
|
+
}
|
|
252
|
+
function stringifyJson(value) {
|
|
253
|
+
const pretty = process.stdout.isTTY;
|
|
254
|
+
return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
|
|
255
|
+
}
|
|
256
|
+
function formatOutput(value, mode) {
|
|
257
|
+
const payload = hasData(value) ? value.data : value;
|
|
258
|
+
if (payload === null || payload === void 0) return "";
|
|
259
|
+
if (mode === "raw") {
|
|
260
|
+
if (typeof payload === "string") return payload;
|
|
261
|
+
return stringifyJson(payload);
|
|
262
|
+
}
|
|
263
|
+
return stringifyJson(payload);
|
|
264
|
+
}
|
|
265
|
+
function writeOutput(value, mode) {
|
|
266
|
+
const formatted = formatOutput(value, mode);
|
|
267
|
+
if (formatted.length === 0) return;
|
|
268
|
+
process.stdout.write(formatted + "\n");
|
|
269
|
+
}
|
|
270
|
+
function writeError(error) {
|
|
271
|
+
const payload = { error: true };
|
|
272
|
+
if (error && typeof error === "object") {
|
|
273
|
+
const err = error;
|
|
274
|
+
if ("status" in err) payload.status = err.status;
|
|
275
|
+
const hasData2 = "data" in err;
|
|
276
|
+
if (hasData2) payload.data = err.data;
|
|
277
|
+
if ("message" in err && !hasData2) payload.message = err.message;
|
|
278
|
+
if (err instanceof Error) {
|
|
279
|
+
payload.message = err.message;
|
|
280
|
+
payload.name = err.name;
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
payload.message = String(error);
|
|
284
|
+
}
|
|
285
|
+
process.stderr.write(JSON.stringify(payload, null, 2) + "\n");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// packages/command/src/lib/build-op-command.ts
|
|
289
|
+
function buildOpCommand({
|
|
290
|
+
ir,
|
|
291
|
+
operation,
|
|
292
|
+
method,
|
|
293
|
+
path,
|
|
294
|
+
client
|
|
295
|
+
}) {
|
|
296
|
+
const name = operation["x-fn-name"] ?? operation.operationId;
|
|
297
|
+
const summary = operation.summary ?? operation.description ?? "";
|
|
298
|
+
const cmd = new Command(name).description(summary);
|
|
299
|
+
const details = buildInput2(ir, operation);
|
|
300
|
+
const inputJsonSchema = operationSchema2(ir, operation, details.ct);
|
|
301
|
+
const inputZodSchema = schemaToZod(inputJsonSchema, ir, { required: true });
|
|
302
|
+
const flagMap = addFlagsFromSchema(cmd, inputJsonSchema, ir);
|
|
303
|
+
cmd.addOption(
|
|
304
|
+
new Option2(
|
|
305
|
+
"--input-file <path>",
|
|
306
|
+
"Read input JSON from file (merged with flags and stdin)"
|
|
307
|
+
)
|
|
308
|
+
);
|
|
309
|
+
cmd.addOption(
|
|
310
|
+
new Option2(
|
|
311
|
+
"--describe",
|
|
312
|
+
"Print this operation's schema as JSON and exit"
|
|
313
|
+
)
|
|
314
|
+
);
|
|
315
|
+
if (flagMap.skipped.length) {
|
|
316
|
+
const hints = flagMap.skipped.map((s) => ` --${s.name}: ${s.reason}`).join("\n");
|
|
317
|
+
cmd.addHelpText(
|
|
318
|
+
"after",
|
|
319
|
+
`
|
|
320
|
+
Fields supplied via --input-file or stdin only:
|
|
321
|
+
${hints}`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
const endpoint = `${method.toUpperCase()} ${path}`;
|
|
325
|
+
cmd.action(async (_, thisCommand) => {
|
|
326
|
+
const opts = thisCommand.optsWithGlobals();
|
|
327
|
+
if (opts.describe) {
|
|
328
|
+
const desc = describeOperation(ir, operation, method, path);
|
|
329
|
+
process.stdout.write(JSON.stringify(desc, null, 2) + "\n");
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const outputMode = opts.output ?? "json";
|
|
333
|
+
const inputFile = opts.inputFile;
|
|
334
|
+
const flagValues = {};
|
|
335
|
+
for (const n of flagMap.names) {
|
|
336
|
+
if (opts[n] !== void 0) flagValues[n] = opts[n];
|
|
337
|
+
}
|
|
338
|
+
let input;
|
|
339
|
+
try {
|
|
340
|
+
input = await resolveInput({
|
|
341
|
+
flags: flagValues,
|
|
342
|
+
inputFile,
|
|
343
|
+
schema: inputZodSchema,
|
|
344
|
+
flagNames: flagMap.names
|
|
345
|
+
});
|
|
346
|
+
} catch (err) {
|
|
347
|
+
if (err instanceof ZodError) {
|
|
348
|
+
writeError({ message: "Invalid input", issues: err.issues });
|
|
349
|
+
} else {
|
|
350
|
+
writeError(err);
|
|
351
|
+
}
|
|
352
|
+
process.exitCode = 2;
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
const response = await client.request(endpoint, input);
|
|
357
|
+
writeOutput(response, outputMode);
|
|
358
|
+
} catch (err) {
|
|
359
|
+
writeError(err);
|
|
360
|
+
process.exitCode = 1;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
return cmd;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// packages/command/src/lib/command.ts
|
|
367
|
+
function coerceSpec(spec) {
|
|
368
|
+
if (typeof spec === "string") return loadSpec(spec);
|
|
369
|
+
return Promise.resolve(spec);
|
|
370
|
+
}
|
|
371
|
+
async function command(spec, options) {
|
|
372
|
+
const raw = await coerceSpec(spec);
|
|
373
|
+
const ir = toIR({ spec: raw, responses: { flattenErrorResponses: true } });
|
|
374
|
+
const envPrefix = options.name.replace(/[^a-zA-Z0-9]/g, "_").toUpperCase();
|
|
375
|
+
const tokenEnv = options.tokenEnv ?? `${envPrefix}_TOKEN`;
|
|
376
|
+
const baseUrlEnv = options.baseUrlEnv ?? `${envPrefix}_BASE_URL`;
|
|
377
|
+
const envToken = process.env[tokenEnv];
|
|
378
|
+
const envBaseUrl = process.env[baseUrlEnv];
|
|
379
|
+
const resolvedBaseUrl = options.baseUrl ?? envBaseUrl ?? ir.servers?.[0]?.url;
|
|
380
|
+
if (!resolvedBaseUrl) {
|
|
381
|
+
throw new Error(
|
|
382
|
+
`No base URL available. Pass options.baseUrl, set $${baseUrlEnv}, or add a servers entry to the OpenAPI spec.`
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
const client = createRpc(ir, {
|
|
386
|
+
token: options.token ?? envToken,
|
|
387
|
+
baseUrl: resolvedBaseUrl,
|
|
388
|
+
fetch: options.fetch,
|
|
389
|
+
headers: options.headers
|
|
390
|
+
});
|
|
391
|
+
const program = new Command2(options.name);
|
|
392
|
+
if (options.description) program.description(options.description);
|
|
393
|
+
if (options.version) program.version(options.version);
|
|
394
|
+
program.addOption(
|
|
395
|
+
new Option3(
|
|
396
|
+
"--token <token>",
|
|
397
|
+
`API bearer token (or set $${tokenEnv})`
|
|
398
|
+
)
|
|
399
|
+
);
|
|
400
|
+
program.addOption(
|
|
401
|
+
new Option3(
|
|
402
|
+
"--base-url <url>",
|
|
403
|
+
`API base URL (or set $${baseUrlEnv})`
|
|
404
|
+
)
|
|
405
|
+
);
|
|
406
|
+
program.addOption(
|
|
407
|
+
new Option3("--output <mode>", "Output format").choices([
|
|
408
|
+
"json",
|
|
409
|
+
"raw"
|
|
410
|
+
]).default("json")
|
|
411
|
+
);
|
|
412
|
+
program.hook("preAction", (thisCommand) => {
|
|
413
|
+
const opts = thisCommand.opts();
|
|
414
|
+
const override = {};
|
|
415
|
+
if (typeof opts.token === "string") override.token = opts.token;
|
|
416
|
+
if (typeof opts.baseUrl === "string") override.baseUrl = opts.baseUrl;
|
|
417
|
+
if (Object.keys(override).length) {
|
|
418
|
+
client.setOptions(override);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
forEachOperation2(ir, (entry, operation) => {
|
|
422
|
+
program.addCommand(
|
|
423
|
+
buildOpCommand({
|
|
424
|
+
ir,
|
|
425
|
+
operation,
|
|
426
|
+
method: entry.method,
|
|
427
|
+
path: entry.path,
|
|
428
|
+
client
|
|
429
|
+
})
|
|
430
|
+
);
|
|
431
|
+
});
|
|
432
|
+
program.addCommand(
|
|
433
|
+
new Command2("schema").description("Print all operation schemas as JSON").action(() => {
|
|
434
|
+
const all = describeAllOperations(ir);
|
|
435
|
+
process.stdout.write(JSON.stringify(all, null, 2) + "\n");
|
|
436
|
+
})
|
|
437
|
+
);
|
|
438
|
+
return program;
|
|
439
|
+
}
|
|
440
|
+
export {
|
|
441
|
+
command
|
|
442
|
+
};
|
|
443
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/command.ts", "../src/lib/build-op-command.ts", "../src/lib/flags.ts", "../src/lib/input.ts", "../src/lib/introspect.ts", "../src/lib/output.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command, Option } from 'commander';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\n\nimport { type ClientOptions, createRpc } from '@sdk-it/rpc';\nimport { forEachOperation, loadSpec, toIR } from '@sdk-it/spec';\n\nimport { buildOpCommand } from './build-op-command.ts';\nimport { describeAllOperations } from './introspect.ts';\n\nexport interface CommandOptions extends Partial<ClientOptions> {\n name: string;\n description?: string;\n version?: string;\n tokenEnv?: string;\n baseUrlEnv?: string;\n}\n\nfunction coerceSpec(\n spec: string | OpenAPIObject,\n): Promise<OpenAPIObject> {\n if (typeof spec === 'string') return loadSpec(spec);\n return Promise.resolve(spec);\n}\n\nexport async function command(\n spec: string | OpenAPIObject,\n options: CommandOptions,\n): Promise<Command> {\n const raw = await coerceSpec(spec);\n const ir = toIR({ spec: raw, responses: { flattenErrorResponses: true } });\n\n const envPrefix = options.name.replace(/[^a-zA-Z0-9]/g, '_').toUpperCase();\n const tokenEnv = options.tokenEnv ?? `${envPrefix}_TOKEN`;\n const baseUrlEnv = options.baseUrlEnv ?? `${envPrefix}_BASE_URL`;\n\n const envToken = process.env[tokenEnv];\n const envBaseUrl = process.env[baseUrlEnv];\n const resolvedBaseUrl =\n options.baseUrl ?? envBaseUrl ?? ir.servers?.[0]?.url;\n\n if (!resolvedBaseUrl) {\n throw new Error(\n `No base URL available. Pass options.baseUrl, set $${baseUrlEnv}, or add a servers entry to the OpenAPI spec.`,\n );\n }\n\n const client = createRpc(ir, {\n token: options.token ?? envToken,\n baseUrl: resolvedBaseUrl,\n fetch: options.fetch,\n headers: options.headers,\n });\n\n const program = new Command(options.name);\n if (options.description) program.description(options.description);\n if (options.version) program.version(options.version);\n\n program.addOption(\n new Option(\n '--token <token>',\n `API bearer token (or set $${tokenEnv})`,\n ),\n );\n program.addOption(\n new Option(\n '--base-url <url>',\n `API base URL (or set $${baseUrlEnv})`,\n ),\n );\n program.addOption(\n new Option('--output <mode>', 'Output format').choices([\n 'json',\n 'raw',\n ]).default('json'),\n );\n\n program.hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts() as Record<string, unknown>;\n const override: Partial<ClientOptions> = {};\n if (typeof opts.token === 'string') override.token = opts.token;\n if (typeof opts.baseUrl === 'string') override.baseUrl = opts.baseUrl;\n if (Object.keys(override).length) {\n client.setOptions(override);\n }\n });\n\n forEachOperation(ir, (entry, operation) => {\n program.addCommand(\n buildOpCommand({\n ir,\n operation,\n method: entry.method,\n path: entry.path,\n client,\n }),\n );\n });\n\n program.addCommand(\n new Command('schema')\n .description('Print all operation schemas as JSON')\n .action(() => {\n const all = describeAllOperations(ir);\n process.stdout.write(JSON.stringify(all, null, 2) + '\\n');\n }),\n );\n\n return program;\n}\n", "import { Command, Option } from 'commander';\nimport { ZodError } from 'zod';\n\nimport type { Client } from '@sdk-it/rpc';\nimport type { IR, TunedOperationObject } from '@sdk-it/spec';\nimport { buildInput, operationSchema } from '@sdk-it/typescript';\nimport { schemaToZod } from '@sdk-it/rpc';\n\nimport { addFlagsFromSchema } from './flags.ts';\nimport { resolveInput } from './input.ts';\nimport { describeOperation } from './introspect.ts';\nimport {\n type OutputMode,\n writeError,\n writeOutput,\n} from './output.ts';\n\ninterface BuildOpCommandArgs {\n ir: IR;\n operation: TunedOperationObject;\n method: string;\n path: string;\n client: Client;\n}\n\nexport function buildOpCommand({\n ir,\n operation,\n method,\n path,\n client,\n}: BuildOpCommandArgs): Command {\n const name = operation['x-fn-name'] ?? operation.operationId;\n const summary = operation.summary ?? operation.description ?? '';\n\n const cmd = new Command(name).description(summary);\n\n const details = buildInput(ir, operation);\n const inputJsonSchema = operationSchema(ir, operation, details.ct);\n const inputZodSchema = schemaToZod(inputJsonSchema, ir, { required: true });\n const flagMap = addFlagsFromSchema(cmd, inputJsonSchema, ir);\n\n cmd.addOption(\n new Option(\n '--input-file <path>',\n 'Read input JSON from file (merged with flags and stdin)',\n ),\n );\n cmd.addOption(\n new Option(\n '--describe',\n 'Print this operation\\'s schema as JSON and exit',\n ),\n );\n\n if (flagMap.skipped.length) {\n const hints = flagMap.skipped\n .map((s) => ` --${s.name}: ${s.reason}`)\n .join('\\n');\n cmd.addHelpText(\n 'after',\n `\\nFields supplied via --input-file or stdin only:\\n${hints}`,\n );\n }\n\n const endpoint = `${method.toUpperCase()} ${path}`;\n\n cmd.action(async (_: unknown, thisCommand: Command) => {\n const opts = thisCommand.optsWithGlobals() as Record<string, unknown>;\n\n if (opts.describe) {\n const desc = describeOperation(ir, operation, method, path);\n process.stdout.write(JSON.stringify(desc, null, 2) + '\\n');\n return;\n }\n\n const outputMode = (opts.output as OutputMode) ?? 'json';\n const inputFile = opts.inputFile as string | undefined;\n\n const flagValues: Record<string, unknown> = {};\n for (const n of flagMap.names) {\n if (opts[n] !== undefined) flagValues[n] = opts[n];\n }\n\n let input: unknown;\n try {\n input = await resolveInput({\n flags: flagValues,\n inputFile,\n schema: inputZodSchema,\n flagNames: flagMap.names,\n });\n } catch (err) {\n if (err instanceof ZodError) {\n writeError({ message: 'Invalid input', issues: err.issues });\n } else {\n writeError(err);\n }\n process.exitCode = 2;\n return;\n }\n\n try {\n const response = await client.request(endpoint, input as never);\n writeOutput(response, outputMode);\n } catch (err) {\n writeError(err);\n process.exitCode = 1;\n }\n });\n\n return cmd;\n}\n", "import { type Command, InvalidArgumentError, Option } from 'commander';\nimport type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { followRef, isRef } from '@sdk-it/core';\nimport type { IR } from '@sdk-it/spec';\n\nfunction resolve(\n ir: IR,\n schema: SchemaObject | ReferenceObject,\n): SchemaObject {\n return isRef(schema) ? (followRef(ir, schema.$ref) as SchemaObject) : schema;\n}\n\nfunction isPrimitiveType(type: unknown): boolean {\n return (\n type === 'string' ||\n type === 'number' ||\n type === 'integer' ||\n type === 'boolean' ||\n type === 'null'\n );\n}\n\nfunction canBeFlag(ir: IR, schema: SchemaObject): boolean {\n if (schema.oneOf || schema.anyOf || schema.allOf) return false;\n if (schema.enum) return true;\n const type = schema.type;\n if (Array.isArray(type)) {\n return type.every((t) => isPrimitiveType(t));\n }\n if (isPrimitiveType(type)) return true;\n if (type === 'array' && schema.items) {\n const items = Array.isArray(schema.items)\n ? schema.items[0]\n : schema.items;\n if (!items) return false;\n const resolved = resolve(ir, items);\n const itemType = resolved.type;\n return (\n !resolved.oneOf &&\n !resolved.anyOf &&\n !resolved.allOf &&\n (isPrimitiveType(itemType) || !!resolved.enum)\n );\n }\n return false;\n}\n\nfunction coerceNumber(value: string, integer: boolean): number {\n const n = Number(value);\n if (Number.isNaN(n)) {\n throw new InvalidArgumentError(`\"${value}\" is not a valid number`);\n }\n return integer ? Math.trunc(n) : n;\n}\n\nfunction coerceBoolean(value: string): boolean {\n const lower = value.toLowerCase();\n if (lower === 'true' || lower === '1' || lower === 'yes' || lower === 'on') {\n return true;\n }\n if (\n lower === 'false' ||\n lower === '0' ||\n lower === 'no' ||\n lower === 'off'\n ) {\n return false;\n }\n throw new InvalidArgumentError(`\"${value}\" is not a valid boolean`);\n}\n\nfunction describe(schema: SchemaObject, required: boolean): string {\n const base = schema.description ?? '';\n const pieces: string[] = [];\n if (schema.type) pieces.push(String(schema.type));\n if (schema.format) pieces.push(`format: ${schema.format}`);\n if (required) pieces.push('required');\n if (schema.default !== undefined) {\n pieces.push(`default: ${JSON.stringify(schema.default)}`);\n }\n const tag = pieces.length ? ` (${pieces.join(', ')})` : '';\n return base + tag;\n}\n\nexport interface FlagMap {\n names: Set<string>;\n skipped: Array<{ name: string; reason: string }>;\n}\n\nexport function addFlagsFromSchema(\n command: Command,\n schema: SchemaObject,\n ir: IR,\n): FlagMap {\n const names = new Set<string>();\n const skipped: FlagMap['skipped'] = [];\n const properties = schema.properties ?? {};\n const required = new Set(schema.required ?? []);\n\n for (const [name, propOrRef] of Object.entries(properties)) {\n const prop = resolve(ir, propOrRef as SchemaObject | ReferenceObject);\n if (!canBeFlag(ir, prop)) {\n skipped.push({\n name,\n reason: 'complex schema \u2014 supply via --input-file or stdin',\n });\n continue;\n }\n\n const isRequired = required.has(name);\n const desc = describe(prop, isRequired);\n\n if (prop.enum && Array.isArray(prop.enum)) {\n const opt = new Option(`--${name} <value>`, desc).choices(\n prop.enum.map((v) => String(v)),\n );\n command.addOption(opt);\n names.add(name);\n continue;\n }\n\n const primaryType = Array.isArray(prop.type) ? prop.type[0] : prop.type;\n\n if (primaryType === 'boolean') {\n command.addOption(new Option(`--${name}`, desc));\n command.addOption(new Option(`--no-${name}`, `Disable --${name}`));\n names.add(name);\n continue;\n }\n\n if (primaryType === 'array') {\n const items = Array.isArray(prop.items) ? prop.items[0] : prop.items;\n const itemSchema = items\n ? resolve(ir, items as SchemaObject | ReferenceObject)\n : ({} as SchemaObject);\n const itemType = Array.isArray(itemSchema.type)\n ? itemSchema.type[0]\n : itemSchema.type;\n const opt = new Option(\n `--${name} <value>`,\n `${desc} (repeatable)`,\n ).argParser((value, previous: unknown[] | undefined) => {\n const acc = previous ?? [];\n if (itemType === 'number' || itemType === 'integer') {\n return [...acc, coerceNumber(value, itemType === 'integer')];\n }\n if (itemType === 'boolean') {\n return [...acc, coerceBoolean(value)];\n }\n return [...acc, value];\n });\n command.addOption(opt);\n names.add(name);\n continue;\n }\n\n if (primaryType === 'number' || primaryType === 'integer') {\n const opt = new Option(`--${name} <value>`, desc).argParser((v) =>\n coerceNumber(v, primaryType === 'integer'),\n );\n command.addOption(opt);\n names.add(name);\n continue;\n }\n\n command.addOption(new Option(`--${name} <value>`, desc));\n names.add(name);\n }\n\n return { names, skipped };\n}\n", "import { readFile } from 'node:fs/promises';\nimport type { ZodSchema } from 'zod';\n\nasync function readStdinIfPiped(): Promise<unknown> {\n if (process.stdin.isTTY) return undefined;\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n if (chunks.length === 0) return undefined;\n const raw = Buffer.concat(chunks).toString('utf8').trim();\n if (!raw) return undefined;\n try {\n return JSON.parse(raw);\n } catch (err) {\n throw new Error(\n `Failed to parse JSON from stdin: ${(err as Error).message}`,\n );\n }\n}\n\nasync function readJsonFile(path: string): Promise<unknown> {\n try {\n const raw = await readFile(path, 'utf8');\n return JSON.parse(raw);\n } catch (err) {\n throw new Error(\n `Failed to read JSON from ${path}: ${(err as Error).message}`,\n );\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === 'object' && value !== null && !Array.isArray(value)\n );\n}\n\nfunction mergeSources(\n file: unknown,\n stdin: unknown,\n flags: Record<string, unknown>,\n): Record<string, unknown> {\n const fileObj = isPlainObject(file) ? file : {};\n const stdinObj = isPlainObject(stdin) ? stdin : {};\n return { ...fileObj, ...stdinObj, ...flags };\n}\n\nexport interface ResolveInputOptions {\n flags: Record<string, unknown>;\n inputFile?: string;\n schema: ZodSchema;\n flagNames: Set<string>;\n}\n\nexport async function resolveInput({\n flags,\n inputFile,\n schema,\n flagNames,\n}: ResolveInputOptions): Promise<unknown> {\n const onlySchemaFlags: Record<string, unknown> = {};\n for (const name of flagNames) {\n if (flags[name] !== undefined) {\n onlySchemaFlags[name] = flags[name];\n }\n }\n\n const file = inputFile ? await readJsonFile(inputFile) : undefined;\n const stdin = await readStdinIfPiped();\n const merged = mergeSources(file, stdin, onlySchemaFlags);\n\n const parsed = await schema.parseAsync(merged);\n return parsed;\n}\n", "import type { SchemaObject } from 'openapi3-ts/oas31';\n\nimport {\n type IR,\n type TunedOperationObject,\n forEachOperation,\n} from '@sdk-it/spec';\nimport { buildInput, operationSchema } from '@sdk-it/typescript';\n\nexport interface OperationDescriptor {\n operationId: string;\n name: string;\n method: string;\n path: string;\n tag?: string;\n summary?: string;\n description?: string;\n input: SchemaObject;\n responses: Record<string, SchemaObject | undefined>;\n}\n\nconst CONTENT_TYPE_PRIORITY = [\n 'application/json',\n 'application/problem+json',\n 'text/plain',\n 'application/xml',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n];\n\nfunction pickContentSchema(\n content: Record<string, { schema?: SchemaObject }>,\n): SchemaObject | undefined {\n for (const ct of CONTENT_TYPE_PRIORITY) {\n if (content[ct]?.schema) return content[ct].schema;\n }\n const sorted = Object.keys(content).sort();\n for (const key of sorted) {\n if (content[key]?.schema) return content[key].schema;\n }\n return undefined;\n}\n\nfunction responseSchemas(\n operation: TunedOperationObject,\n): Record<string, SchemaObject | undefined> {\n const out: Record<string, SchemaObject | undefined> = {};\n for (const [status, response] of Object.entries(operation.responses ?? {})) {\n const content = (response as { content?: Record<string, { schema?: SchemaObject }> }).content;\n out[status] = content ? pickContentSchema(content) : undefined;\n }\n return out;\n}\n\nexport function describeOperation(\n ir: IR,\n op: TunedOperationObject,\n method: string,\n path: string,\n): OperationDescriptor {\n const details = buildInput(ir, op);\n const input = operationSchema(ir, op, details.ct) as SchemaObject;\n return {\n operationId: op.operationId,\n name: op['x-fn-name'],\n method: method.toUpperCase(),\n path,\n tag: op.tags?.[0],\n summary: op.summary,\n description: op.description,\n input,\n responses: responseSchemas(op),\n };\n}\n\nexport function describeAllOperations(\n ir: IR,\n): Record<string, OperationDescriptor> {\n const descriptors: Record<string, OperationDescriptor> = {};\n forEachOperation(ir, (entry, op) => {\n descriptors[op['x-fn-name']] = describeOperation(\n ir,\n op,\n entry.method,\n entry.path,\n );\n });\n return descriptors;\n}\n", "export type OutputMode = 'json' | 'raw';\n\nfunction hasData(value: unknown): value is { data: unknown } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'data' in (value as Record<string, unknown>)\n );\n}\n\nfunction stringifyJson(value: unknown): string {\n const pretty = process.stdout.isTTY;\n return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);\n}\n\nexport function formatOutput(value: unknown, mode: OutputMode): string {\n const payload = hasData(value) ? value.data : value;\n\n if (payload === null || payload === undefined) return '';\n\n if (mode === 'raw') {\n if (typeof payload === 'string') return payload;\n return stringifyJson(payload);\n }\n\n return stringifyJson(payload);\n}\n\nexport function writeOutput(value: unknown, mode: OutputMode): void {\n const formatted = formatOutput(value, mode);\n if (formatted.length === 0) return;\n process.stdout.write(formatted + '\\n');\n}\n\nexport function writeError(error: unknown): void {\n const payload: Record<string, unknown> = { error: true };\n if (error && typeof error === 'object') {\n const err = error as Record<string, unknown>;\n if ('status' in err) payload.status = err.status;\n const hasData = 'data' in err;\n if (hasData) payload.data = err.data;\n if ('message' in err && !hasData) payload.message = err.message;\n if (err instanceof Error) {\n payload.message = err.message;\n payload.name = err.name;\n }\n } else {\n payload.message = String(error);\n }\n process.stderr.write(JSON.stringify(payload, null, 2) + '\\n');\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAAA,UAAS,UAAAC,eAAc;AAGhC,SAA6B,iBAAiB;AAC9C,SAAS,oBAAAC,mBAAkB,UAAU,YAAY;;;ACJjD,SAAS,SAAS,UAAAC,eAAc;AAChC,SAAS,gBAAgB;AAIzB,SAAS,cAAAC,aAAY,mBAAAC,wBAAuB;AAC5C,SAAS,mBAAmB;;;ACN5B,SAAuB,sBAAsB,cAAc;AAG3D,SAAS,WAAW,aAAa;AAGjC,SAAS,QACP,IACA,QACc;AACd,SAAO,MAAM,MAAM,IAAK,UAAU,IAAI,OAAO,IAAI,IAAqB;AACxE;AAEA,SAAS,gBAAgB,MAAwB;AAC/C,SACE,SAAS,YACT,SAAS,YACT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,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ;AAAA,IACN,IAAIF,SAAQ,QAAQ,EACjB,YAAY,qCAAqC,EACjD,OAAO,MAAM;AACZ,YAAM,MAAM,sBAAsB,EAAE;AACpC,cAAQ,OAAO,MAAM,KAAK,UAAU,KAAK,MAAM,CAAC,IAAI,IAAI;AAAA,IAC1D,CAAC;AAAA,EACL;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["Command", "Option", "forEachOperation", "Option", "buildInput", "operationSchema", "command", "hasData", "buildInput", "operationSchema", "Option", "Command", "Option", "forEachOperation"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { Client } from '@sdk-it/rpc';
|
|
3
|
+
import type { IR, TunedOperationObject } from '@sdk-it/spec';
|
|
4
|
+
interface BuildOpCommandArgs {
|
|
5
|
+
ir: IR;
|
|
6
|
+
operation: TunedOperationObject;
|
|
7
|
+
method: string;
|
|
8
|
+
path: string;
|
|
9
|
+
client: Client;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildOpCommand({ ir, operation, method, path, client, }: BuildOpCommandArgs): Command;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=build-op-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-op-command.d.ts","sourceRoot":"","sources":["../../src/lib/build-op-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAG5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAa7D,UAAU,kBAAkB;IAC1B,EAAE,EAAE,EAAE,CAAC;IACP,SAAS,EAAE,oBAAoB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,EAC7B,EAAE,EACF,SAAS,EACT,MAAM,EACN,IAAI,EACJ,MAAM,GACP,EAAE,kBAAkB,GAAG,OAAO,CAiF9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
3
|
+
import { type ClientOptions } from '@sdk-it/rpc';
|
|
4
|
+
export interface CommandOptions extends Partial<ClientOptions> {
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
tokenEnv?: string;
|
|
9
|
+
baseUrlEnv?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function command(spec: string | OpenAPIObject, options: CommandOptions): Promise<Command>;
|
|
12
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/lib/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,aAAa,CAAC;AAM5D,MAAM,WAAW,cAAe,SAAQ,OAAO,CAAC,aAAa,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AASD,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,CAiFlB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Command } from 'commander';
|
|
2
|
+
import type { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
|
+
import type { IR } from '@sdk-it/spec';
|
|
4
|
+
export interface FlagMap {
|
|
5
|
+
names: Set<string>;
|
|
6
|
+
skipped: Array<{
|
|
7
|
+
name: string;
|
|
8
|
+
reason: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare function addFlagsFromSchema(command: Command, schema: SchemaObject, ir: IR): FlagMap;
|
|
12
|
+
//# sourceMappingURL=flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../src/lib/flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAgC,MAAM,WAAW,CAAC;AACvE,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGvE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAiFvC,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,EACpB,EAAE,EAAE,EAAE,GACL,OAAO,CA6ET"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ZodSchema } from 'zod';
|
|
2
|
+
export interface ResolveInputOptions {
|
|
3
|
+
flags: Record<string, unknown>;
|
|
4
|
+
inputFile?: string;
|
|
5
|
+
schema: ZodSchema;
|
|
6
|
+
flagNames: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveInput({ flags, inputFile, schema, flagNames, }: ResolveInputOptions): Promise<unknown>;
|
|
9
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/lib/input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AA+CrC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAED,wBAAsB,YAAY,CAAC,EACjC,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAcxC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
+
import { type IR, type TunedOperationObject } from '@sdk-it/spec';
|
|
3
|
+
export interface OperationDescriptor {
|
|
4
|
+
operationId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
method: string;
|
|
7
|
+
path: string;
|
|
8
|
+
tag?: string;
|
|
9
|
+
summary?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
input: SchemaObject;
|
|
12
|
+
responses: Record<string, SchemaObject | undefined>;
|
|
13
|
+
}
|
|
14
|
+
export declare function describeOperation(ir: IR, op: TunedOperationObject, method: string, path: string): OperationDescriptor;
|
|
15
|
+
export declare function describeAllOperations(ir: IR): Record<string, OperationDescriptor>;
|
|
16
|
+
//# sourceMappingURL=introspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../src/lib/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EACL,KAAK,EAAE,EACP,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC,CAAC;CACrD;AAmCD,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,mBAAmB,CAcrB;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,EAAE,GACL,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAWrC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type OutputMode = 'json' | 'raw';
|
|
2
|
+
export declare function formatOutput(value: unknown, mode: OutputMode): string;
|
|
3
|
+
export declare function writeOutput(value: unknown, mode: OutputMode): void;
|
|
4
|
+
export declare function writeError(error: unknown): void;
|
|
5
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;AAexC,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAWrE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAIlE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAgB/C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sdk-it/command",
|
|
3
|
+
"version": "0.43.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"./package.json": "./package.json",
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"!**/*.tsbuildinfo",
|
|
22
|
+
"!**/*.test.*"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@sdk-it/core": "0.43.0",
|
|
26
|
+
"@sdk-it/rpc": "0.43.0",
|
|
27
|
+
"@sdk-it/spec": "0.43.0",
|
|
28
|
+
"@sdk-it/typescript": "0.43.0",
|
|
29
|
+
"commander": "^13.0.0",
|
|
30
|
+
"openapi3-ts": "4.5.0",
|
|
31
|
+
"zod": "^3.25.76 || ^4.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|