specli 0.0.11 → 0.0.13
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/README.md +216 -325
- package/bin/cli.sh +27 -0
- package/dist/{src/ai → ai}/tools.d.ts +0 -1
- package/dist/ai/tools.js +161 -0
- package/dist/ai/tools.test.d.ts +1 -0
- package/dist/ai/tools.test.js +56 -0
- package/dist/{src/cli → cli}/auth-requirements.d.ts +0 -1
- package/dist/cli/auth-requirements.js +65 -0
- package/dist/cli/auth-requirements.test.d.ts +1 -0
- package/dist/cli/auth-requirements.test.js +16 -0
- package/dist/{src/cli → cli}/auth-schemes.d.ts +0 -1
- package/dist/cli/auth-schemes.js +112 -0
- package/dist/cli/auth-schemes.test.d.ts +1 -0
- package/dist/cli/auth-schemes.test.js +56 -0
- package/dist/{src/cli → cli}/capabilities.d.ts +0 -1
- package/dist/cli/capabilities.js +41 -0
- package/dist/cli/capabilities.test.d.ts +1 -0
- package/dist/cli/capabilities.test.js +84 -0
- package/dist/{src/cli → cli}/command-id.d.ts +0 -1
- package/dist/cli/command-id.js +8 -0
- package/dist/cli/command-id.test.d.ts +1 -0
- package/dist/cli/command-id.test.js +27 -0
- package/dist/{src/cli → cli}/command-index.d.ts +0 -1
- package/dist/cli/command-index.js +9 -0
- package/dist/{src/cli → cli}/command-model.d.ts +0 -1
- package/dist/cli/command-model.js +53 -0
- package/dist/cli/command-model.test.d.ts +1 -0
- package/dist/cli/command-model.test.js +40 -0
- package/dist/{src/cli → cli}/compile.d.ts +0 -1
- package/dist/cli/compile.js +79 -0
- package/dist/{src/cli → cli}/crypto.d.ts +0 -1
- package/dist/cli/crypto.js +9 -0
- package/dist/{src/cli → cli}/derive-name.d.ts +0 -1
- package/dist/cli/derive-name.js +96 -0
- package/dist/{src/cli → cli}/exec.d.ts +0 -1
- package/dist/cli/exec.js +50 -0
- package/dist/{src/cli → cli}/main.d.ts +0 -1
- package/dist/cli/main.js +177 -0
- package/dist/{src/cli → cli}/naming.d.ts +0 -1
- package/dist/cli/naming.js +191 -0
- package/dist/cli/naming.test.d.ts +1 -0
- package/dist/cli/naming.test.js +75 -0
- package/dist/{src/cli → cli}/operations.d.ts +0 -1
- package/dist/cli/operations.js +100 -0
- package/dist/cli/operations.test.d.ts +1 -0
- package/dist/cli/operations.test.js +51 -0
- package/dist/{src/cli → cli}/params.d.ts +0 -1
- package/dist/cli/params.js +36 -0
- package/dist/cli/params.test.d.ts +1 -0
- package/dist/cli/params.test.js +62 -0
- package/dist/{src/cli → cli}/pluralize.d.ts +0 -1
- package/dist/cli/pluralize.js +38 -0
- package/dist/{src/cli → cli}/positional.d.ts +0 -1
- package/dist/cli/positional.js +35 -0
- package/dist/cli/positional.test.d.ts +1 -0
- package/dist/cli/positional.test.js +60 -0
- package/dist/{src/cli → cli}/request-body.d.ts +0 -1
- package/dist/cli/request-body.js +44 -0
- package/dist/cli/request-body.test.d.ts +1 -0
- package/dist/cli/request-body.test.js +31 -0
- package/dist/{src/cli → cli}/runtime/argv.d.ts +0 -1
- package/dist/cli/runtime/argv.js +15 -0
- package/dist/{src/cli → cli}/runtime/auth/resolve.d.ts +0 -1
- package/dist/cli/runtime/auth/resolve.js +39 -0
- package/dist/{src/cli → cli}/runtime/body-flags.d.ts +0 -1
- package/dist/cli/runtime/body-flags.js +117 -0
- package/dist/cli/runtime/body-flags.test.d.ts +1 -0
- package/dist/cli/runtime/body-flags.test.js +192 -0
- package/dist/{src/cli → cli}/runtime/body.d.ts +0 -1
- package/dist/cli/runtime/body.js +16 -0
- package/dist/{src/cli → cli}/runtime/collect.d.ts +0 -1
- package/dist/cli/runtime/collect.js +3 -0
- package/dist/{src/cli → cli}/runtime/compat.d.ts +0 -1
- package/dist/cli/runtime/compat.js +78 -0
- package/dist/{src/cli → cli}/runtime/context.d.ts +0 -1
- package/dist/cli/runtime/context.js +44 -0
- package/dist/{src/cli → cli}/runtime/execute.d.ts +0 -1
- package/dist/cli/runtime/execute.js +106 -0
- package/dist/{src/cli → cli}/runtime/generated.d.ts +0 -1
- package/dist/cli/runtime/generated.js +168 -0
- package/dist/{src/cli → cli}/runtime/headers.d.ts +0 -1
- package/dist/cli/runtime/headers.js +30 -0
- package/dist/{src/cli → cli}/runtime/index.d.ts +0 -1
- package/dist/cli/runtime/index.js +3 -0
- package/dist/{src/cli → cli}/runtime/profile/secrets.d.ts +0 -1
- package/dist/cli/runtime/profile/secrets.js +53 -0
- package/dist/{src/cli → cli}/runtime/profile/store.d.ts +0 -1
- package/dist/cli/runtime/profile/store.js +63 -0
- package/dist/{src/cli → cli}/runtime/request.d.ts +0 -1
- package/dist/cli/runtime/request.js +283 -0
- package/dist/cli/runtime/request.test.d.ts +1 -0
- package/dist/cli/runtime/request.test.js +332 -0
- package/dist/{src/cli → cli}/runtime/server-url.d.ts +0 -1
- package/dist/cli/runtime/server-url.js +28 -0
- package/dist/{src/cli → cli}/runtime/template.d.ts +0 -1
- package/dist/cli/runtime/template.js +22 -0
- package/dist/cli/runtime/validate/ajv.d.ts +2 -0
- package/dist/cli/runtime/validate/ajv.js +11 -0
- package/dist/{src/cli → cli}/runtime/validate/coerce.d.ts +0 -1
- package/dist/cli/runtime/validate/coerce.js +63 -0
- package/dist/cli/runtime/validate/coerce.test.d.ts +1 -0
- package/dist/cli/runtime/validate/coerce.test.js +75 -0
- package/dist/{src/cli → cli}/runtime/validate/error.d.ts +0 -1
- package/dist/cli/runtime/validate/error.js +19 -0
- package/dist/{src/cli → cli}/runtime/validate/index.d.ts +0 -1
- package/dist/cli/runtime/validate/index.js +4 -0
- package/dist/{src/cli → cli}/runtime/validate/schema.d.ts +0 -1
- package/dist/cli/runtime/validate/schema.js +38 -0
- package/dist/{src/cli → cli}/schema-shape.d.ts +0 -1
- package/dist/cli/schema-shape.js +34 -0
- package/dist/{src/cli → cli}/schema.d.ts +0 -1
- package/dist/cli/schema.js +31 -0
- package/dist/{src/cli → cli}/server.d.ts +0 -1
- package/dist/cli/server.js +130 -0
- package/dist/cli/server.test.d.ts +1 -0
- package/dist/cli/server.test.js +49 -0
- package/dist/{src/cli → cli}/spec-id.d.ts +0 -1
- package/dist/cli/spec-id.js +8 -0
- package/dist/{src/cli → cli}/spec-loader.d.ts +0 -1
- package/dist/cli/spec-loader.js +40 -0
- package/dist/{src/cli → cli}/stable-json.d.ts +0 -1
- package/dist/cli/stable-json.js +29 -0
- package/dist/{src/cli → cli}/strings.d.ts +0 -1
- package/dist/cli/strings.js +20 -0
- package/dist/{src/cli → cli}/types.d.ts +0 -1
- package/dist/cli/types.js +3 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +51 -2324
- package/dist/compiled.d.ts +2 -0
- package/{src/compiled.ts → dist/compiled.js} +8 -11
- package/dist/macros/env.d.ts +10 -0
- package/dist/macros/env.js +22 -0
- package/dist/macros/spec.d.ts +5 -0
- package/dist/macros/spec.js +16 -0
- package/package.json +17 -25
- package/bin/specli.js +0 -26
- package/cli.ts +0 -77
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -53
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2032
- package/dist/index.js.map +0 -48
- package/dist/src/ai/tools.d.ts.map +0 -1
- package/dist/src/ai/tools.js +0 -1656
- package/dist/src/ai/tools.js.map +0 -45
- package/dist/src/cli/auth-requirements.d.ts.map +0 -1
- package/dist/src/cli/auth-requirements.js +0 -66
- package/dist/src/cli/auth-requirements.js.map +0 -10
- package/dist/src/cli/auth-schemes.d.ts.map +0 -1
- package/dist/src/cli/auth-schemes.js +0 -116
- package/dist/src/cli/auth-schemes.js.map +0 -11
- package/dist/src/cli/capabilities.d.ts.map +0 -1
- package/dist/src/cli/capabilities.js +0 -45
- package/dist/src/cli/capabilities.js.map +0 -10
- package/dist/src/cli/command-id.d.ts.map +0 -1
- package/dist/src/cli/command-id.js +0 -18
- package/dist/src/cli/command-id.js.map +0 -11
- package/dist/src/cli/command-index.d.ts.map +0 -1
- package/dist/src/cli/command-index.js +0 -15
- package/dist/src/cli/command-index.js.map +0 -10
- package/dist/src/cli/command-model.d.ts.map +0 -1
- package/dist/src/cli/command-model.js +0 -274
- package/dist/src/cli/command-model.js.map +0 -18
- package/dist/src/cli/compile.d.ts.map +0 -1
- package/dist/src/cli/compile.js +0 -146
- package/dist/src/cli/compile.js.map +0 -11
- package/dist/src/cli/crypto.d.ts.map +0 -1
- package/dist/src/cli/crypto.js +0 -15
- package/dist/src/cli/crypto.js.map +0 -10
- package/dist/src/cli/derive-name.d.ts.map +0 -1
- package/dist/src/cli/derive-name.js +0 -70
- package/dist/src/cli/derive-name.js.map +0 -10
- package/dist/src/cli/exec.d.ts.map +0 -1
- package/dist/src/cli/exec.js +0 -2077
- package/dist/src/cli/exec.js.map +0 -49
- package/dist/src/cli/main.d.ts.map +0 -1
- package/dist/src/cli/main.js +0 -2032
- package/dist/src/cli/main.js.map +0 -48
- package/dist/src/cli/naming.d.ts.map +0 -1
- package/dist/src/cli/naming.js +0 -216
- package/dist/src/cli/naming.js.map +0 -12
- package/dist/src/cli/operations.d.ts.map +0 -1
- package/dist/src/cli/operations.js +0 -103
- package/dist/src/cli/operations.js.map +0 -10
- package/dist/src/cli/params.d.ts.map +0 -1
- package/dist/src/cli/params.js +0 -79
- package/dist/src/cli/params.js.map +0 -12
- package/dist/src/cli/pluralize.d.ts.map +0 -1
- package/dist/src/cli/pluralize.js +0 -43
- package/dist/src/cli/pluralize.js.map +0 -10
- package/dist/src/cli/positional.d.ts.map +0 -1
- package/dist/src/cli/positional.js +0 -39
- package/dist/src/cli/positional.js.map +0 -10
- package/dist/src/cli/request-body.d.ts.map +0 -1
- package/dist/src/cli/request-body.js +0 -82
- package/dist/src/cli/request-body.js.map +0 -12
- package/dist/src/cli/runtime/argv.d.ts.map +0 -1
- package/dist/src/cli/runtime/argv.js +0 -22
- package/dist/src/cli/runtime/argv.js.map +0 -10
- package/dist/src/cli/runtime/auth/resolve.d.ts.map +0 -1
- package/dist/src/cli/runtime/auth/resolve.js +0 -38
- package/dist/src/cli/runtime/auth/resolve.js.map +0 -10
- package/dist/src/cli/runtime/body-flags.d.ts.map +0 -1
- package/dist/src/cli/runtime/body-flags.js +0 -86
- package/dist/src/cli/runtime/body-flags.js.map +0 -10
- package/dist/src/cli/runtime/body.d.ts.map +0 -1
- package/dist/src/cli/runtime/body.js +0 -40
- package/dist/src/cli/runtime/body.js.map +0 -11
- package/dist/src/cli/runtime/collect.d.ts.map +0 -1
- package/dist/src/cli/runtime/collect.js +0 -9
- package/dist/src/cli/runtime/collect.js.map +0 -10
- package/dist/src/cli/runtime/compat.d.ts.map +0 -1
- package/dist/src/cli/runtime/compat.js +0 -62
- package/dist/src/cli/runtime/compat.js.map +0 -10
- package/dist/src/cli/runtime/context.d.ts.map +0 -1
- package/dist/src/cli/runtime/context.js +0 -936
- package/dist/src/cli/runtime/context.js.map +0 -32
- package/dist/src/cli/runtime/execute.d.ts.map +0 -1
- package/dist/src/cli/runtime/execute.js +0 -670
- package/dist/src/cli/runtime/execute.js.map +0 -22
- package/dist/src/cli/runtime/generated.d.ts.map +0 -1
- package/dist/src/cli/runtime/generated.js +0 -869
- package/dist/src/cli/runtime/generated.js.map +0 -23
- package/dist/src/cli/runtime/headers.d.ts.map +0 -1
- package/dist/src/cli/runtime/headers.js +0 -36
- package/dist/src/cli/runtime/headers.js.map +0 -10
- package/dist/src/cli/runtime/index.d.ts.map +0 -1
- package/dist/src/cli/runtime/index.js +0 -1808
- package/dist/src/cli/runtime/index.js.map +0 -46
- package/dist/src/cli/runtime/profile/secrets.d.ts.map +0 -1
- package/dist/src/cli/runtime/profile/secrets.js +0 -51
- package/dist/src/cli/runtime/profile/secrets.js.map +0 -11
- package/dist/src/cli/runtime/profile/store.d.ts.map +0 -1
- package/dist/src/cli/runtime/profile/store.js +0 -102
- package/dist/src/cli/runtime/profile/store.js.map +0 -11
- package/dist/src/cli/runtime/request.d.ts.map +0 -1
- package/dist/src/cli/runtime/request.js +0 -571
- package/dist/src/cli/runtime/request.js.map +0 -21
- package/dist/src/cli/runtime/server-url.d.ts.map +0 -1
- package/dist/src/cli/runtime/server-url.js +0 -55
- package/dist/src/cli/runtime/server-url.js.map +0 -11
- package/dist/src/cli/runtime/template.d.ts.map +0 -1
- package/dist/src/cli/runtime/template.js +0 -29
- package/dist/src/cli/runtime/template.js.map +0 -10
- package/dist/src/cli/runtime/validate/ajv.d.ts +0 -3
- package/dist/src/cli/runtime/validate/ajv.d.ts.map +0 -1
- package/dist/src/cli/runtime/validate/ajv.js +0 -17
- package/dist/src/cli/runtime/validate/ajv.js.map +0 -10
- package/dist/src/cli/runtime/validate/coerce.d.ts.map +0 -1
- package/dist/src/cli/runtime/validate/coerce.js +0 -60
- package/dist/src/cli/runtime/validate/coerce.js.map +0 -10
- package/dist/src/cli/runtime/validate/error.d.ts.map +0 -1
- package/dist/src/cli/runtime/validate/error.js +0 -21
- package/dist/src/cli/runtime/validate/error.js.map +0 -10
- package/dist/src/cli/runtime/validate/index.d.ts.map +0 -1
- package/dist/src/cli/runtime/validate/index.js +0 -122
- package/dist/src/cli/runtime/validate/index.js.map +0 -13
- package/dist/src/cli/runtime/validate/schema.d.ts.map +0 -1
- package/dist/src/cli/runtime/validate/schema.js +0 -36
- package/dist/src/cli/runtime/validate/schema.js.map +0 -10
- package/dist/src/cli/schema-shape.d.ts.map +0 -1
- package/dist/src/cli/schema-shape.js +0 -41
- package/dist/src/cli/schema-shape.js.map +0 -10
- package/dist/src/cli/schema.d.ts.map +0 -1
- package/dist/src/cli/schema.js +0 -38
- package/dist/src/cli/schema.js.map +0 -10
- package/dist/src/cli/server.d.ts.map +0 -1
- package/dist/src/cli/server.js +0 -64
- package/dist/src/cli/server.js.map +0 -11
- package/dist/src/cli/spec-id.d.ts.map +0 -1
- package/dist/src/cli/spec-id.js +0 -21
- package/dist/src/cli/spec-id.js.map +0 -11
- package/dist/src/cli/spec-loader.d.ts.map +0 -1
- package/dist/src/cli/spec-loader.js +0 -110
- package/dist/src/cli/spec-loader.js.map +0 -15
- package/dist/src/cli/stable-json.d.ts.map +0 -1
- package/dist/src/cli/stable-json.js +0 -35
- package/dist/src/cli/stable-json.js.map +0 -10
- package/dist/src/cli/strings.d.ts.map +0 -1
- package/dist/src/cli/strings.js +0 -16
- package/dist/src/cli/strings.js.map +0 -10
- package/dist/src/cli/types.d.ts.map +0 -1
- package/dist/src/cli/types.js +0 -9
- package/dist/src/cli/types.js.map +0 -10
- package/index.ts +0 -1
- package/src/ai/tools.ts +0 -211
- package/src/cli/auth-requirements.ts +0 -91
- package/src/cli/auth-schemes.ts +0 -187
- package/src/cli/capabilities.ts +0 -88
- package/src/cli/command-id.ts +0 -16
- package/src/cli/command-index.ts +0 -19
- package/src/cli/command-model.ts +0 -128
- package/src/cli/compile.ts +0 -101
- package/src/cli/crypto.ts +0 -9
- package/src/cli/derive-name.ts +0 -101
- package/src/cli/exec.ts +0 -72
- package/src/cli/main.ts +0 -231
- package/src/cli/naming.ts +0 -224
- package/src/cli/operations.ts +0 -152
- package/src/cli/params.ts +0 -71
- package/src/cli/pluralize.ts +0 -41
- package/src/cli/positional.ts +0 -75
- package/src/cli/request-body.ts +0 -94
- package/src/cli/runtime/argv.ts +0 -14
- package/src/cli/runtime/auth/resolve.ts +0 -59
- package/src/cli/runtime/body-flags.ts +0 -176
- package/src/cli/runtime/body.ts +0 -24
- package/src/cli/runtime/collect.ts +0 -6
- package/src/cli/runtime/compat.ts +0 -89
- package/src/cli/runtime/context.ts +0 -62
- package/src/cli/runtime/execute.ts +0 -147
- package/src/cli/runtime/generated.ts +0 -242
- package/src/cli/runtime/headers.ts +0 -37
- package/src/cli/runtime/index.ts +0 -3
- package/src/cli/runtime/profile/secrets.ts +0 -83
- package/src/cli/runtime/profile/store.ts +0 -100
- package/src/cli/runtime/request.ts +0 -390
- package/src/cli/runtime/server-url.ts +0 -45
- package/src/cli/runtime/template.ts +0 -26
- package/src/cli/runtime/validate/ajv.ts +0 -13
- package/src/cli/runtime/validate/coerce.ts +0 -71
- package/src/cli/runtime/validate/error.ts +0 -29
- package/src/cli/runtime/validate/index.ts +0 -4
- package/src/cli/runtime/validate/schema.ts +0 -54
- package/src/cli/schema-shape.ts +0 -36
- package/src/cli/schema.ts +0 -76
- package/src/cli/server.ts +0 -88
- package/src/cli/spec-id.ts +0 -12
- package/src/cli/spec-loader.ts +0 -58
- package/src/cli/stable-json.ts +0 -35
- package/src/cli/strings.ts +0 -21
- package/src/cli/types.ts +0 -59
- package/src/macros/env.ts +0 -21
- package/src/macros/spec.ts +0 -17
package/src/cli/schema.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { AuthScheme } from "./auth-schemes.ts";
|
|
2
|
-
import type { Capabilities } from "./capabilities.ts";
|
|
3
|
-
import type { CommandModel } from "./command-model.ts";
|
|
4
|
-
import type { PlannedOperation } from "./naming.ts";
|
|
5
|
-
import type { ServerInfo } from "./server.ts";
|
|
6
|
-
import type { LoadedSpec, NormalizedOperation } from "./types.ts";
|
|
7
|
-
|
|
8
|
-
export type SchemaOutput = {
|
|
9
|
-
schemaVersion: 1;
|
|
10
|
-
openapi: {
|
|
11
|
-
version: string;
|
|
12
|
-
title?: string;
|
|
13
|
-
infoVersion?: string;
|
|
14
|
-
};
|
|
15
|
-
spec: {
|
|
16
|
-
id: string;
|
|
17
|
-
fingerprint: string;
|
|
18
|
-
source: LoadedSpec["source"];
|
|
19
|
-
};
|
|
20
|
-
capabilities: Capabilities;
|
|
21
|
-
servers: ServerInfo[];
|
|
22
|
-
authSchemes: AuthScheme[];
|
|
23
|
-
operations: NormalizedOperation[];
|
|
24
|
-
planned?: PlannedOperation[];
|
|
25
|
-
commands?: CommandModel;
|
|
26
|
-
commandsIndex?: import("./command-index.ts").CommandsIndex;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type MinimalSchemaOutput = Pick<
|
|
30
|
-
SchemaOutput,
|
|
31
|
-
"schemaVersion" | "openapi" | "spec" | "capabilities" | "commands"
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
export function buildSchemaOutput(
|
|
35
|
-
loaded: LoadedSpec,
|
|
36
|
-
operations: NormalizedOperation[],
|
|
37
|
-
planned: PlannedOperation[] | undefined,
|
|
38
|
-
servers: ServerInfo[],
|
|
39
|
-
authSchemes: AuthScheme[],
|
|
40
|
-
commands: CommandModel | undefined,
|
|
41
|
-
commandsIndex: import("./command-index.ts").CommandsIndex | undefined,
|
|
42
|
-
capabilities: Capabilities,
|
|
43
|
-
): SchemaOutput {
|
|
44
|
-
return {
|
|
45
|
-
schemaVersion: 1,
|
|
46
|
-
openapi: {
|
|
47
|
-
version: loaded.doc.openapi,
|
|
48
|
-
title: loaded.doc.info?.title,
|
|
49
|
-
infoVersion: loaded.doc.info?.version,
|
|
50
|
-
},
|
|
51
|
-
spec: {
|
|
52
|
-
id: loaded.id,
|
|
53
|
-
fingerprint: loaded.fingerprint,
|
|
54
|
-
source: loaded.source,
|
|
55
|
-
},
|
|
56
|
-
capabilities,
|
|
57
|
-
servers,
|
|
58
|
-
authSchemes,
|
|
59
|
-
operations,
|
|
60
|
-
planned,
|
|
61
|
-
commands,
|
|
62
|
-
commandsIndex,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function toMinimalSchemaOutput(
|
|
67
|
-
output: SchemaOutput,
|
|
68
|
-
): MinimalSchemaOutput {
|
|
69
|
-
return {
|
|
70
|
-
schemaVersion: output.schemaVersion,
|
|
71
|
-
openapi: output.openapi,
|
|
72
|
-
spec: output.spec,
|
|
73
|
-
capabilities: output.capabilities,
|
|
74
|
-
commands: output.commands,
|
|
75
|
-
};
|
|
76
|
-
}
|
package/src/cli/server.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { getSchemaEnumStrings } from "./schema-shape.ts";
|
|
2
|
-
import type { OpenApiDoc } from "./types.ts";
|
|
3
|
-
|
|
4
|
-
export type ServerVariable = {
|
|
5
|
-
name: string;
|
|
6
|
-
default?: string;
|
|
7
|
-
enum?: string[];
|
|
8
|
-
description?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type ServerInfo = {
|
|
12
|
-
url: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
variables: ServerVariable[];
|
|
15
|
-
variableNames: string[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type RawServerVariable = {
|
|
19
|
-
default?: unknown;
|
|
20
|
-
enum?: unknown;
|
|
21
|
-
description?: unknown;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type RawServer = {
|
|
25
|
-
url?: unknown;
|
|
26
|
-
description?: unknown;
|
|
27
|
-
variables?: unknown;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function extractVariableNames(url: string): string[] {
|
|
31
|
-
const names: string[] = [];
|
|
32
|
-
const re = /\{([^}]+)\}/g;
|
|
33
|
-
|
|
34
|
-
while (true) {
|
|
35
|
-
const match = re.exec(url);
|
|
36
|
-
if (!match) break;
|
|
37
|
-
names.push(match[1] ?? "");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return names.map((n) => n.trim()).filter(Boolean);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function listServers(doc: OpenApiDoc): ServerInfo[] {
|
|
44
|
-
const servers = doc.servers ?? [];
|
|
45
|
-
const out: ServerInfo[] = [];
|
|
46
|
-
|
|
47
|
-
for (const raw of servers) {
|
|
48
|
-
const s = raw as RawServer;
|
|
49
|
-
if (!s || typeof s !== "object") continue;
|
|
50
|
-
if (typeof s.url !== "string") continue;
|
|
51
|
-
|
|
52
|
-
const variableNames = extractVariableNames(s.url);
|
|
53
|
-
const variables: ServerVariable[] = [];
|
|
54
|
-
|
|
55
|
-
const rawVars =
|
|
56
|
-
s.variables &&
|
|
57
|
-
typeof s.variables === "object" &&
|
|
58
|
-
!Array.isArray(s.variables)
|
|
59
|
-
? (s.variables as Record<string, RawServerVariable>)
|
|
60
|
-
: {};
|
|
61
|
-
|
|
62
|
-
for (const name of variableNames) {
|
|
63
|
-
const v = rawVars[name];
|
|
64
|
-
const def = v?.default;
|
|
65
|
-
const desc = v?.description;
|
|
66
|
-
variables.push({
|
|
67
|
-
name,
|
|
68
|
-
default: typeof def === "string" ? def : undefined,
|
|
69
|
-
enum: getSchemaEnumStrings(v),
|
|
70
|
-
description: typeof desc === "string" ? desc : undefined,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
out.push({
|
|
75
|
-
url: s.url,
|
|
76
|
-
description:
|
|
77
|
-
typeof s.description === "string" ? s.description : undefined,
|
|
78
|
-
variables,
|
|
79
|
-
variableNames,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return out;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function getDefaultServerUrl(doc: OpenApiDoc): string | undefined {
|
|
87
|
-
return listServers(doc)[0]?.url;
|
|
88
|
-
}
|
package/src/cli/spec-id.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { kebabCase } from "./strings.ts";
|
|
2
|
-
import type { LoadedSpec } from "./types.ts";
|
|
3
|
-
|
|
4
|
-
export function getSpecId(
|
|
5
|
-
loaded: Pick<LoadedSpec, "doc" | "fingerprint">,
|
|
6
|
-
): string {
|
|
7
|
-
const title = loaded.doc.info?.title;
|
|
8
|
-
const fromTitle = title ? kebabCase(title) : "";
|
|
9
|
-
if (fromTitle) return fromTitle;
|
|
10
|
-
|
|
11
|
-
return loaded.fingerprint.slice(0, 12);
|
|
12
|
-
}
|
package/src/cli/spec-loader.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
2
|
-
|
|
3
|
-
import { sha256Hex } from "./crypto.ts";
|
|
4
|
-
import { parseYamlContent } from "./runtime/compat.ts";
|
|
5
|
-
import { getSpecId } from "./spec-id.ts";
|
|
6
|
-
import { stableStringify } from "./stable-json.ts";
|
|
7
|
-
import type { LoadedSpec, OpenApiDoc, SpecSource } from "./types.ts";
|
|
8
|
-
|
|
9
|
-
export type LoadSpecOptions = {
|
|
10
|
-
spec?: string;
|
|
11
|
-
embeddedSpecText?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function isProbablyUrl(input: string): boolean {
|
|
15
|
-
return /^https?:\/\//i.test(input);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function parseSpecText(text: string): unknown {
|
|
19
|
-
const trimmed = text.trimStart();
|
|
20
|
-
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
21
|
-
return JSON.parse(text);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return parseYamlContent(text);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function loadSpec(options: LoadSpecOptions): Promise<LoadedSpec> {
|
|
28
|
-
const { spec, embeddedSpecText } = options;
|
|
29
|
-
|
|
30
|
-
let source: SpecSource;
|
|
31
|
-
let inputForParser: unknown;
|
|
32
|
-
|
|
33
|
-
if (typeof embeddedSpecText === "string") {
|
|
34
|
-
source = "embedded";
|
|
35
|
-
inputForParser = parseSpecText(embeddedSpecText);
|
|
36
|
-
} else if (spec) {
|
|
37
|
-
source = isProbablyUrl(spec) ? "url" : "file";
|
|
38
|
-
inputForParser = spec;
|
|
39
|
-
} else {
|
|
40
|
-
throw new Error(
|
|
41
|
-
"Missing spec. Provide --spec <url|path> or build with an embedded spec.",
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const doc = (await SwaggerParser.dereference(
|
|
46
|
-
// biome-ignore lint/suspicious/noExplicitAny: unknown
|
|
47
|
-
inputForParser as any,
|
|
48
|
-
)) as OpenApiDoc;
|
|
49
|
-
|
|
50
|
-
if (!doc || typeof doc !== "object" || typeof doc.openapi !== "string") {
|
|
51
|
-
throw new Error("Loaded spec is not a valid OpenAPI document");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const fingerprint = await sha256Hex(stableStringify(doc));
|
|
55
|
-
const id = getSpecId({ doc, fingerprint });
|
|
56
|
-
|
|
57
|
-
return { source, id, fingerprint, doc };
|
|
58
|
-
}
|
package/src/cli/stable-json.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function stableStringify(
|
|
2
|
-
value: unknown,
|
|
3
|
-
options?: { space?: number },
|
|
4
|
-
): string {
|
|
5
|
-
const visiting = new WeakSet<object>();
|
|
6
|
-
return JSON.stringify(sort(value, visiting), null, options?.space);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function sort(value: unknown, visiting: WeakSet<object>): unknown {
|
|
10
|
-
if (value === null) return null;
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
if (visiting.has(value)) return { __specli_circular: true };
|
|
14
|
-
visiting.add(value);
|
|
15
|
-
const out = value.map((v) => sort(v, visiting));
|
|
16
|
-
visiting.delete(value);
|
|
17
|
-
return out;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (typeof value === "object") {
|
|
21
|
-
if (visiting.has(value)) return { __specli_circular: true };
|
|
22
|
-
visiting.add(value);
|
|
23
|
-
|
|
24
|
-
const obj = value as Record<string, unknown>;
|
|
25
|
-
const out: Record<string, unknown> = {};
|
|
26
|
-
for (const key of Object.keys(obj).sort()) {
|
|
27
|
-
out[key] = sort(obj[key], visiting);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
visiting.delete(value);
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return value;
|
|
35
|
-
}
|
package/src/cli/strings.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function kebabCase(input: string): string {
|
|
2
|
-
const trimmed = input.trim();
|
|
3
|
-
if (!trimmed) return "";
|
|
4
|
-
|
|
5
|
-
// Convert spaces/underscores/dots to dashes, split camelCase.
|
|
6
|
-
return trimmed
|
|
7
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
8
|
-
.replace(/[\s_.:/]+/g, "-")
|
|
9
|
-
.replace(/[^a-zA-Z0-9-]/g, "-")
|
|
10
|
-
.replace(/-+/g, "-")
|
|
11
|
-
.replace(/^-|-$/g, "")
|
|
12
|
-
.toLowerCase();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function titleCase(input: string): string {
|
|
16
|
-
return input
|
|
17
|
-
.split(/\s+/g)
|
|
18
|
-
.filter(Boolean)
|
|
19
|
-
.map((w) => w[0]?.toUpperCase() + w.slice(1))
|
|
20
|
-
.join(" ");
|
|
21
|
-
}
|
package/src/cli/types.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export type SpecSource = "embedded" | "file" | "url";
|
|
2
|
-
|
|
3
|
-
export type SecurityRequirement = Record<string, string[]>;
|
|
4
|
-
|
|
5
|
-
export type OpenApiDoc = {
|
|
6
|
-
openapi: string;
|
|
7
|
-
info?: {
|
|
8
|
-
title?: string;
|
|
9
|
-
version?: string;
|
|
10
|
-
};
|
|
11
|
-
servers?: Array<{ url: string; description?: string; variables?: unknown }>;
|
|
12
|
-
security?: SecurityRequirement[];
|
|
13
|
-
components?: {
|
|
14
|
-
securitySchemes?: Record<string, unknown>;
|
|
15
|
-
};
|
|
16
|
-
paths?: Record<string, unknown>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type NormalizedParameter = {
|
|
20
|
-
in: "path" | "query" | "header" | "cookie";
|
|
21
|
-
name: string;
|
|
22
|
-
required: boolean;
|
|
23
|
-
description?: string;
|
|
24
|
-
schema?: unknown;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Minimal JSON Schema-like shape for validation and flag expansion.
|
|
28
|
-
export type JsonSchema = Record<string, unknown>;
|
|
29
|
-
|
|
30
|
-
export function isJsonSchema(value: unknown): value is JsonSchema {
|
|
31
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type NormalizedRequestBody = {
|
|
35
|
-
required: boolean;
|
|
36
|
-
contentTypes: string[];
|
|
37
|
-
schemasByContentType: Record<string, unknown | undefined>;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type NormalizedOperation = {
|
|
41
|
-
key: string;
|
|
42
|
-
method: string;
|
|
43
|
-
path: string;
|
|
44
|
-
operationId?: string;
|
|
45
|
-
tags: string[];
|
|
46
|
-
summary?: string;
|
|
47
|
-
description?: string;
|
|
48
|
-
deprecated?: boolean;
|
|
49
|
-
security?: SecurityRequirement[];
|
|
50
|
-
parameters: NormalizedParameter[];
|
|
51
|
-
requestBody?: NormalizedRequestBody;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type LoadedSpec = {
|
|
55
|
-
source: SpecSource;
|
|
56
|
-
id: string;
|
|
57
|
-
fingerprint: string;
|
|
58
|
-
doc: OpenApiDoc;
|
|
59
|
-
};
|
package/src/macros/env.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bun macro: reads an environment variable at bundle-time.
|
|
3
|
-
* Returns undefined if the env var is not set.
|
|
4
|
-
*/
|
|
5
|
-
export function env(name: string): string | undefined {
|
|
6
|
-
if (!name) throw new Error("env macro: missing variable name");
|
|
7
|
-
return process.env[name];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Bun macro: reads a required environment variable at bundle-time.
|
|
12
|
-
* Throws if the env var is not set.
|
|
13
|
-
*/
|
|
14
|
-
export function envRequired(name: string): string {
|
|
15
|
-
if (!name) throw new Error("envRequired macro: missing variable name");
|
|
16
|
-
const value = process.env[name];
|
|
17
|
-
if (value === undefined) {
|
|
18
|
-
throw new Error(`Missing required env var: ${name}`);
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
}
|
package/src/macros/spec.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bun macro: loads an OpenAPI spec from a URL or file path at bundle-time.
|
|
3
|
-
* The spec text is inlined into the bundle.
|
|
4
|
-
*/
|
|
5
|
-
export async function loadSpec(spec: string): Promise<string> {
|
|
6
|
-
if (!spec) throw new Error("loadSpec macro: missing spec path/URL");
|
|
7
|
-
|
|
8
|
-
if (/^https?:\/\//i.test(spec)) {
|
|
9
|
-
const res = await fetch(spec);
|
|
10
|
-
if (!res.ok) {
|
|
11
|
-
throw new Error(`Failed to fetch spec: ${res.status} ${res.statusText}`);
|
|
12
|
-
}
|
|
13
|
-
return await res.text();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return await Bun.file(spec).text();
|
|
17
|
-
}
|