@ir-kit/cli 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +81 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +42 -0
- package/dist/bin.js.map +1 -0
- package/dist/command-spec.d.ts +11 -0
- package/dist/command-spec.d.ts.map +1 -0
- package/dist/command-spec.js +2 -0
- package/dist/command-spec.js.map +1 -0
- package/dist/commands/_load-openapi.d.ts +7 -0
- package/dist/commands/_load-openapi.d.ts.map +1 -0
- package/dist/commands/_load-openapi.js +15 -0
- package/dist/commands/_load-openapi.js.map +1 -0
- package/dist/commands/docs.d.ts +10 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +55 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/fn-schema-diff.d.ts +10 -0
- package/dist/commands/fn-schema-diff.d.ts.map +1 -0
- package/dist/commands/fn-schema-diff.js +46 -0
- package/dist/commands/fn-schema-diff.js.map +1 -0
- package/dist/commands/fn-schema-extract.d.ts +25 -0
- package/dist/commands/fn-schema-extract.d.ts.map +1 -0
- package/dist/commands/fn-schema-extract.js +189 -0
- package/dist/commands/fn-schema-extract.js.map +1 -0
- package/dist/commands/fn-schema-inspect.d.ts +16 -0
- package/dist/commands/fn-schema-inspect.d.ts.map +1 -0
- package/dist/commands/fn-schema-inspect.js +118 -0
- package/dist/commands/fn-schema-inspect.js.map +1 -0
- package/dist/commands/fn-schema-scan.d.ts +13 -0
- package/dist/commands/fn-schema-scan.d.ts.map +1 -0
- package/dist/commands/fn-schema-scan.js +92 -0
- package/dist/commands/fn-schema-scan.js.map +1 -0
- package/dist/commands/k6-bundle.d.ts +10 -0
- package/dist/commands/k6-bundle.d.ts.map +1 -0
- package/dist/commands/k6-bundle.js +38 -0
- package/dist/commands/k6-bundle.js.map +1 -0
- package/dist/commands/k6-sync.d.ts +14 -0
- package/dist/commands/k6-sync.d.ts.map +1 -0
- package/dist/commands/k6-sync.js +61 -0
- package/dist/commands/k6-sync.js.map +1 -0
- package/dist/commands/recon.d.ts +13 -0
- package/dist/commands/recon.d.ts.map +1 -0
- package/dist/commands/recon.js +62 -0
- package/dist/commands/recon.js.map +1 -0
- package/dist/commands/sdk-all.d.ts +11 -0
- package/dist/commands/sdk-all.d.ts.map +1 -0
- package/dist/commands/sdk-all.js +82 -0
- package/dist/commands/sdk-all.js.map +1 -0
- package/dist/commands/sdk-go.d.ts +13 -0
- package/dist/commands/sdk-go.d.ts.map +1 -0
- package/dist/commands/sdk-go.js +53 -0
- package/dist/commands/sdk-go.js.map +1 -0
- package/dist/commands/sdk-k6.d.ts +11 -0
- package/dist/commands/sdk-k6.d.ts.map +1 -0
- package/dist/commands/sdk-k6.js +40 -0
- package/dist/commands/sdk-k6.js.map +1 -0
- package/dist/commands/sdk-kotlin.d.ts +13 -0
- package/dist/commands/sdk-kotlin.d.ts.map +1 -0
- package/dist/commands/sdk-kotlin.js +54 -0
- package/dist/commands/sdk-kotlin.js.map +1 -0
- package/dist/commands/sdk-swift.d.ts +12 -0
- package/dist/commands/sdk-swift.d.ts.map +1 -0
- package/dist/commands/sdk-swift.js +49 -0
- package/dist/commands/sdk-swift.js.map +1 -0
- package/dist/commands/sdk-typescript.d.ts +9 -0
- package/dist/commands/sdk-typescript.d.ts.map +1 -0
- package/dist/commands/sdk-typescript.js +29 -0
- package/dist/commands/sdk-typescript.js.map +1 -0
- package/dist/commands/spec-convert.d.ts +11 -0
- package/dist/commands/spec-convert.d.ts.map +1 -0
- package/dist/commands/spec-convert.js +69 -0
- package/dist/commands/spec-convert.js.map +1 -0
- package/dist/commands/spec-diff.d.ts +10 -0
- package/dist/commands/spec-diff.d.ts.map +1 -0
- package/dist/commands/spec-diff.js +53 -0
- package/dist/commands/spec-diff.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +10 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +78 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema-args.d.ts +24 -0
- package/dist/schema-args.d.ts.map +1 -0
- package/dist/schema-args.js +130 -0
- package/dist/schema-args.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { generate } from "@ir-kit/openapi-go";
|
|
2
|
+
import { loadOpenAPIForSdk } from "./_load-openapi.js";
|
|
3
|
+
const args = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
input: {
|
|
7
|
+
type: "string",
|
|
8
|
+
description: "OpenAPI spec path, URL, or .tsp file",
|
|
9
|
+
},
|
|
10
|
+
output: { type: "string", description: "Output directory" },
|
|
11
|
+
clean: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
description: "Wipe output directory before writing",
|
|
14
|
+
default: true,
|
|
15
|
+
},
|
|
16
|
+
normalize: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
description: "Apply hey-api spec normalization",
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
gomod: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Emit go.mod with this module path (e.g. github.com/me/sdk)",
|
|
24
|
+
},
|
|
25
|
+
packageName: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Go package name (default: 'api')",
|
|
28
|
+
},
|
|
29
|
+
defaultTag: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Tag used when an op has none (default: 'Default')",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ["input", "output"],
|
|
35
|
+
};
|
|
36
|
+
export const sdkGoCommand = {
|
|
37
|
+
path: ["sdk", "go"],
|
|
38
|
+
description: "Generate a Go SDK from an OpenAPI / TypeSpec spec",
|
|
39
|
+
args,
|
|
40
|
+
handler: async (input) => {
|
|
41
|
+
const doc = await loadOpenAPIForSdk(input.input);
|
|
42
|
+
await generate({
|
|
43
|
+
input: doc,
|
|
44
|
+
output: input.output,
|
|
45
|
+
clean: input.clean,
|
|
46
|
+
normalize: input.normalize,
|
|
47
|
+
packageName: input.packageName,
|
|
48
|
+
defaultTag: input.defaultTag,
|
|
49
|
+
...(input.gomod ? { gomod: { module: input.gomod } } : {}),
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=sdk-go.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-go.js","sourceRoot":"","sources":["../../src/commands/sdk-go.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAYvD,MAAM,IAAI,GAAW;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sCAAsC;SACpD;QACD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;QAC3D,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,sCAAsC;YACnD,OAAO,EAAE,IAAI;SACd;QACD,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,kCAAkC;YAC/C,OAAO,EAAE,KAAK;SACf;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4DAA4D;SAC1E;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,kCAAkC;SAChD;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mDAAmD;SACjE;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAA6B;IACpD,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;IACnB,WAAW,EAAE,mDAAmD;IAChE,IAAI;IACJ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,QAAQ,CAAC;YACb,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3D,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandSpec } from "../command-spec.js";
|
|
2
|
+
interface Input {
|
|
3
|
+
input: string;
|
|
4
|
+
output: string;
|
|
5
|
+
normalize?: boolean;
|
|
6
|
+
scaffold?: boolean;
|
|
7
|
+
defaultBaseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const sdkK6Command: CommandSpec<Input, void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=sdk-k6.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-k6.d.ts","sourceRoot":"","sources":["../../src/commands/sdk-k6.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAyBD,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAejD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { generate } from "@ir-kit/k6-gen";
|
|
2
|
+
import { loadOpenAPIForSdk } from "./_load-openapi.js";
|
|
3
|
+
const args = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
input: { type: "string", description: "OpenAPI spec path or URL" },
|
|
7
|
+
output: { type: "string", description: "Output directory" },
|
|
8
|
+
normalize: {
|
|
9
|
+
type: "boolean",
|
|
10
|
+
description: "Apply spec normalization",
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
scaffold: {
|
|
14
|
+
type: "boolean",
|
|
15
|
+
description: "Also emit per-operation loadtest stubs",
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
defaultBaseUrl: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Default base URL (falls back to spec.servers[0].url)",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ["input", "output"],
|
|
24
|
+
};
|
|
25
|
+
export const sdkK6Command = {
|
|
26
|
+
path: ["sdk", "k6"],
|
|
27
|
+
description: "Generate a typed k6 client + types + faker-backed data builders",
|
|
28
|
+
args,
|
|
29
|
+
handler: async (input) => {
|
|
30
|
+
const doc = await loadOpenAPIForSdk(input.input);
|
|
31
|
+
await generate({
|
|
32
|
+
input: doc,
|
|
33
|
+
output: input.output,
|
|
34
|
+
normalize: input.normalize,
|
|
35
|
+
scaffold: input.scaffold,
|
|
36
|
+
defaultBaseUrl: input.defaultBaseUrl,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=sdk-k6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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
|
+
import type { CommandSpec } from "../command-spec.js";
|
|
2
|
+
interface Input {
|
|
3
|
+
input: string;
|
|
4
|
+
output: string;
|
|
5
|
+
clean?: boolean;
|
|
6
|
+
normalize?: boolean;
|
|
7
|
+
gradle?: boolean;
|
|
8
|
+
packageName?: string;
|
|
9
|
+
defaultTag?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const sdkKotlinCommand: CommandSpec<Input, void>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=sdk-kotlin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-kotlin.d.ts","sourceRoot":"","sources":["../../src/commands/sdk-kotlin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAqCD,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAgBrD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { generate } from "@ir-kit/openapi-kotlin";
|
|
2
|
+
import { loadOpenAPIForSdk } from "./_load-openapi.js";
|
|
3
|
+
const args = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
input: {
|
|
7
|
+
type: "string",
|
|
8
|
+
description: "OpenAPI spec path, URL, or .tsp file",
|
|
9
|
+
},
|
|
10
|
+
output: { type: "string", description: "Output directory" },
|
|
11
|
+
clean: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
description: "Wipe output before writing",
|
|
14
|
+
default: true,
|
|
15
|
+
},
|
|
16
|
+
normalize: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
description: "Apply spec normalization",
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
gradle: {
|
|
22
|
+
type: "boolean",
|
|
23
|
+
description: "Emit build.gradle.kts + settings.gradle.kts at output root",
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
packageName: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Kotlin package name (default: 'com.example.api')",
|
|
29
|
+
},
|
|
30
|
+
defaultTag: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Tag for untagged ops (default: 'Default')",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["input", "output"],
|
|
36
|
+
};
|
|
37
|
+
export const sdkKotlinCommand = {
|
|
38
|
+
path: ["sdk", "kotlin"],
|
|
39
|
+
description: "Generate a Kotlin SDK from an OpenAPI / TypeSpec spec",
|
|
40
|
+
args,
|
|
41
|
+
handler: async (input) => {
|
|
42
|
+
const doc = await loadOpenAPIForSdk(input.input);
|
|
43
|
+
await generate({
|
|
44
|
+
input: doc,
|
|
45
|
+
output: input.output,
|
|
46
|
+
clean: input.clean,
|
|
47
|
+
normalize: input.normalize,
|
|
48
|
+
packageName: input.packageName,
|
|
49
|
+
defaultTag: input.defaultTag,
|
|
50
|
+
gradle: input.gradle,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=sdk-kotlin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-kotlin.js","sourceRoot":"","sources":["../../src/commands/sdk-kotlin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAYvD,MAAM,IAAI,GAAW;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EA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ommandSpec } from "../command-spec.js";
|
|
2
|
+
interface Input {
|
|
3
|
+
input: string;
|
|
4
|
+
output: string;
|
|
5
|
+
clean?: boolean;
|
|
6
|
+
normalize?: boolean;
|
|
7
|
+
swiftPackage?: boolean;
|
|
8
|
+
defaultTag?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sdkSwiftCommand: CommandSpec<Input, void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=sdk-swift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-swift.d.ts","sourceRoot":"","sources":["../../src/commands/sdk-swift.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAiCD,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAepD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { generate } from "@ir-kit/openapi-swift";
|
|
2
|
+
import { loadOpenAPIForSdk } from "./_load-openapi.js";
|
|
3
|
+
const args = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
input: {
|
|
7
|
+
type: "string",
|
|
8
|
+
description: "OpenAPI spec path, URL, or .tsp file",
|
|
9
|
+
},
|
|
10
|
+
output: { type: "string", description: "Output directory" },
|
|
11
|
+
clean: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
description: "Wipe output before writing",
|
|
14
|
+
default: true,
|
|
15
|
+
},
|
|
16
|
+
normalize: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
description: "Apply spec normalization",
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
swiftPackage: {
|
|
22
|
+
type: "boolean",
|
|
23
|
+
description: "Emit Package.swift at output root",
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
defaultTag: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Tag for untagged ops (default: 'Default')",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ["input", "output"],
|
|
32
|
+
};
|
|
33
|
+
export const sdkSwiftCommand = {
|
|
34
|
+
path: ["sdk", "swift"],
|
|
35
|
+
description: "Generate a Swift SDK from an OpenAPI / TypeSpec spec",
|
|
36
|
+
args,
|
|
37
|
+
handler: async (input) => {
|
|
38
|
+
const doc = await loadOpenAPIForSdk(input.input);
|
|
39
|
+
await generate({
|
|
40
|
+
input: doc,
|
|
41
|
+
output: input.output,
|
|
42
|
+
clean: input.clean,
|
|
43
|
+
normalize: input.normalize,
|
|
44
|
+
defaultTag: input.defaultTag,
|
|
45
|
+
package: input.swiftPackage,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=sdk-swift.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-swift.js","sourceRoot":"","sources":["../../src/commands/sdk-swift.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAWvD,MAAM,IAAI,GAAW;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sCAAsC;SACpD;QACD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;QAC3D,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,4BAA4B;YACzC,OAAO,EAAE,IAAI;SACd;QACD,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE,KAAK;SACf;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,mCAAmC;YAChD,OAAO,EAAE,KAAK;SACf;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2CAA2C;SACzD;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,sDAAsD;IACnE,IAAI;IACJ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,QAAQ,CAAC;YACb,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,YAAY;SAC5B,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandSpec } from "../command-spec.js";
|
|
2
|
+
interface Input {
|
|
3
|
+
input: string;
|
|
4
|
+
output: string;
|
|
5
|
+
normalize?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const sdkTypescriptCommand: CommandSpec<Input, void>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=sdk-typescript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-typescript.d.ts","sourceRoot":"","sources":["../../src/commands/sdk-typescript.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAgBD,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAYzD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { generate } from "@ir-kit/openapi-typescript";
|
|
2
|
+
import { loadOpenAPIForSdk } from "./_load-openapi.js";
|
|
3
|
+
const args = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
input: { type: "string", description: "OpenAPI spec path or URL" },
|
|
7
|
+
output: { type: "string", description: "Output directory" },
|
|
8
|
+
normalize: {
|
|
9
|
+
type: "boolean",
|
|
10
|
+
description: "Apply spec normalization",
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
required: ["input", "output"],
|
|
15
|
+
};
|
|
16
|
+
export const sdkTypescriptCommand = {
|
|
17
|
+
path: ["sdk", "typescript"],
|
|
18
|
+
description: "Generate a TypeScript SDK (delegates to @hey-api/openapi-ts)",
|
|
19
|
+
args,
|
|
20
|
+
handler: async (input) => {
|
|
21
|
+
const doc = await loadOpenAPIForSdk(input.input);
|
|
22
|
+
await generate({
|
|
23
|
+
input: doc,
|
|
24
|
+
output: input.output,
|
|
25
|
+
normalize: input.normalize,
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=sdk-typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-typescript.js","sourceRoot":"","sources":["../../src/commands/sdk-typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAItD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAQvD,MAAM,IAAI,GAAW;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;QAClE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;QAC3D,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE,KAAK;SACf;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAA6B;IAC5D,IAAI,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,8DAA8D;IAC3E,IAAI;IACJ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,QAAQ,CAAC;YACb,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandSpec } from "../command-spec.js";
|
|
2
|
+
interface Input {
|
|
3
|
+
input: string;
|
|
4
|
+
to: string;
|
|
5
|
+
from?: string;
|
|
6
|
+
out?: string;
|
|
7
|
+
format?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const specConvertCommand: CommandSpec<Input, void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=spec-convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-convert.d.ts","sourceRoot":"","sources":["../../src/commands/spec-convert.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmCD,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAyCvD,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { convertSpec, listConverters } from "@ir-kit/spec-convert";
|
|
4
|
+
const targetFormats = Array.from(new Set(listConverters().map((p) => p.to))).sort();
|
|
5
|
+
const sourceFormats = Array.from(new Set(listConverters().map((p) => p.from))).sort();
|
|
6
|
+
const args = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
input: { type: "string", description: "Spec file path or URL" },
|
|
10
|
+
to: { type: "string", description: "Target format", enum: targetFormats },
|
|
11
|
+
from: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Source format (auto-detected if omitted)",
|
|
14
|
+
enum: sourceFormats,
|
|
15
|
+
},
|
|
16
|
+
out: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "Output path. File for single-doc/source targets; directory for multi-file targets (json-schema, proto).",
|
|
19
|
+
},
|
|
20
|
+
format: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "JSON document output format (ignored for source/files targets)",
|
|
23
|
+
enum: ["json", "yaml"],
|
|
24
|
+
default: "json",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ["input", "to"],
|
|
28
|
+
};
|
|
29
|
+
export const specConvertCommand = {
|
|
30
|
+
path: ["spec", "convert"],
|
|
31
|
+
description: "Convert between API spec formats (OpenAPI, AsyncAPI, TypeSpec, Protobuf, JSON Schema)",
|
|
32
|
+
args,
|
|
33
|
+
handler: async (input) => {
|
|
34
|
+
const result = await convertSpec({
|
|
35
|
+
input: input.input,
|
|
36
|
+
to: input.to,
|
|
37
|
+
from: input.from,
|
|
38
|
+
});
|
|
39
|
+
if (result.output.kind === "files") {
|
|
40
|
+
if (!input.out) {
|
|
41
|
+
throw new Error(`Target '${input.to}' produces multiple files; pass --out <directory>.`);
|
|
42
|
+
}
|
|
43
|
+
const dir = resolve(input.out);
|
|
44
|
+
for (const [rel, content] of Object.entries(result.output.files)) {
|
|
45
|
+
const dest = join(dir, rel);
|
|
46
|
+
await mkdir(dirname(dest), { recursive: true });
|
|
47
|
+
await writeFile(dest, content);
|
|
48
|
+
}
|
|
49
|
+
process.stdout.write(`Wrote ${Object.keys(result.output.files).length} file(s) to ${dir}\n`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const text = result.output.kind === "source"
|
|
53
|
+
? result.output.source
|
|
54
|
+
: serialize(result.output.document, input.format ?? "json");
|
|
55
|
+
if (input.out) {
|
|
56
|
+
await writeFile(input.out, text);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
process.stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
function serialize(doc, format) {
|
|
64
|
+
if (format === "yaml") {
|
|
65
|
+
throw new Error("YAML output not yet wired — pipe through `yq` for now:\n ir spec convert input.tsp --to openapi3 | yq -P");
|
|
66
|
+
}
|
|
67
|
+
return JSON.stringify(doc, null, 2);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=spec-convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-convert.js","sourceRoot":"","sources":["../../src/commands/spec-convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO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I,KAAK,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF,CAAC;AAEF,SAAS,SAAS,CAAC,GAAY,EAAE,MAAc;IAC7C,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandSpec } from "../command-spec.js";
|
|
2
|
+
interface Input {
|
|
3
|
+
before: string;
|
|
4
|
+
after: string;
|
|
5
|
+
out?: string;
|
|
6
|
+
failOnBreaking?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const specDiffCommand: CommandSpec<Input, void>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=spec-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-diff.d.ts","sourceRoot":"","sources":["../../src/commands/spec-diff.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,UAAU,KAAK;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA0BD,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAkCpD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { diffSpecs } from "@ir-kit/spec-diff";
|
|
3
|
+
const args = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
before: {
|
|
7
|
+
type: "string",
|
|
8
|
+
description: "Base spec (file path or URL)",
|
|
9
|
+
},
|
|
10
|
+
after: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "Head spec to compare against base (file path or URL)",
|
|
13
|
+
},
|
|
14
|
+
out: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Write full JSON diff report to this path",
|
|
17
|
+
},
|
|
18
|
+
failOnBreaking: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
description: "Exit non-zero if any breaking changes are detected",
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ["before", "after"],
|
|
25
|
+
};
|
|
26
|
+
export const specDiffCommand = {
|
|
27
|
+
path: ["spec", "diff"],
|
|
28
|
+
description: "Diff two specs (any supported format) — converts both to OpenAPI 3 and classifies breaking vs non-breaking changes",
|
|
29
|
+
args,
|
|
30
|
+
handler: async (input) => {
|
|
31
|
+
const result = await diffSpecs({
|
|
32
|
+
before: input.before,
|
|
33
|
+
after: input.after,
|
|
34
|
+
});
|
|
35
|
+
const { summary, diffs } = result;
|
|
36
|
+
const lines = [
|
|
37
|
+
`${summary.total} change(s): ${summary.breaking} breaking, ${summary.nonBreaking} non-breaking, ${summary.annotation} annotation, ${summary.unclassified} unclassified, ${summary.deprecated} deprecated`,
|
|
38
|
+
`(${result.before.from} → ${result.after.from})`,
|
|
39
|
+
"",
|
|
40
|
+
];
|
|
41
|
+
for (const diff of diffs) {
|
|
42
|
+
lines.push(` [${diff.type}] ${diff.action} /${diff.path.join("/")}${diff.description ? ` — ${diff.description}` : ""}`);
|
|
43
|
+
}
|
|
44
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
45
|
+
if (input.out) {
|
|
46
|
+
await writeFile(input.out, JSON.stringify(result, null, 2));
|
|
47
|
+
}
|
|
48
|
+
if (input.failOnBreaking && summary.breaking > 0) {
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=spec-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-diff.js","sourceRoot":"","sources":["../../src/commands/spec-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAW9C,MAAM,IAAI,GAAW;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,8BAA8B;SAC5C;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sDAAsD;SACpE;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,0CAA0C;SACxD;QACD,cAAc,EAAE;YACd,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,oDAAoD;YACjE,OAAO,EAAE,KAAK;SACf;KACF;IACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IACtB,WAAW,EACT,oHAAoH;IACtH,IAAI;IACJ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;YAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;QAEH,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAClC,MAAM,KAAK,GAAG;YACZ,GAAG,OAAO,CAAC,KAAK,eAAe,OAAO,CAAC,QAAQ,cAAc,OAAO,CAAC,WAAW,kBAAkB,OAAO,CAAC,UAAU,gBAAgB,OAAO,CAAC,YAAY,kBAAkB,OAAO,CAAC,UAAU,aAAa;YACzM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG;YAChD,EAAE;SACH,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CACR,MAAM,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GACrD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAChD,EAAE,CACH,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,KAAK,CAAC,cAAc,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { AnyCommandSpec, CommandSpec, OutputFormat, } from "./command-spec.js";
|
|
2
|
+
export { reconCommand } from "./commands/recon.js";
|
|
3
|
+
export { sdkAllCommand } from "./commands/sdk-all.js";
|
|
4
|
+
export { sdkGoCommand } from "./commands/sdk-go.js";
|
|
5
|
+
export { sdkK6Command } from "./commands/sdk-k6.js";
|
|
6
|
+
export { sdkKotlinCommand } from "./commands/sdk-kotlin.js";
|
|
7
|
+
export { sdkSwiftCommand } from "./commands/sdk-swift.js";
|
|
8
|
+
export { sdkTypescriptCommand } from "./commands/sdk-typescript.js";
|
|
9
|
+
export { specConvertCommand } from "./commands/spec-convert.js";
|
|
10
|
+
export { type RunCliOptions, runCli } from "./runtime.js";
|
|
11
|
+
export { fillFromPrompts, schemaToCittyArgs, validateInput, } from "./schema-args.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,aAAa,GACd,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { reconCommand } from "./commands/recon.js";
|
|
2
|
+
export { sdkAllCommand } from "./commands/sdk-all.js";
|
|
3
|
+
export { sdkGoCommand } from "./commands/sdk-go.js";
|
|
4
|
+
export { sdkK6Command } from "./commands/sdk-k6.js";
|
|
5
|
+
export { sdkKotlinCommand } from "./commands/sdk-kotlin.js";
|
|
6
|
+
export { sdkSwiftCommand } from "./commands/sdk-swift.js";
|
|
7
|
+
export { sdkTypescriptCommand } from "./commands/sdk-typescript.js";
|
|
8
|
+
export { specConvertCommand } from "./commands/spec-convert.js";
|
|
9
|
+
export { runCli } from "./runtime.js";
|
|
10
|
+
export { fillFromPrompts, schemaToCittyArgs, validateInput, } from "./schema-args.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAsB,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,aAAa,GACd,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyCommandSpec } from "./command-spec.js";
|
|
2
|
+
export interface RunCliOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
description: string;
|
|
6
|
+
commands: ReadonlyArray<AnyCommandSpec>;
|
|
7
|
+
}
|
|
8
|
+
export declare function runCli(opts: RunCliOptions): Promise<void>;
|
|
9
|
+
export type { AnyCommandSpec };
|
|
10
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAiFxD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACzC;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB/D;AAED,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { defineCommand, runMain } from "citty";
|
|
2
|
+
import { fillFromPrompts, schemaToCittyArgs, validateInput, } from "./schema-args.js";
|
|
3
|
+
function commandToCitty(spec) {
|
|
4
|
+
const argsDef = schemaToCittyArgs(spec.args);
|
|
5
|
+
const name = spec.path[spec.path.length - 1] ?? "command";
|
|
6
|
+
return defineCommand({
|
|
7
|
+
meta: { name, description: spec.description },
|
|
8
|
+
args: argsDef,
|
|
9
|
+
run: async ({ args }) => {
|
|
10
|
+
const partial = stripCittyMeta(args);
|
|
11
|
+
const filled = await fillFromPrompts(spec.args, partial, {
|
|
12
|
+
title: `ir ${spec.path.join(" ")}`,
|
|
13
|
+
});
|
|
14
|
+
validateInput(spec.args, filled);
|
|
15
|
+
await spec.handler(filled);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function stripCittyMeta(args) {
|
|
20
|
+
const out = {};
|
|
21
|
+
for (const [k, v] of Object.entries(args)) {
|
|
22
|
+
if (k === "_")
|
|
23
|
+
continue;
|
|
24
|
+
if (v === undefined)
|
|
25
|
+
continue;
|
|
26
|
+
if (typeof v === "string" && v === "")
|
|
27
|
+
continue;
|
|
28
|
+
out[k] = v;
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function buildTree(commands) {
|
|
33
|
+
const root = { subCommands: {} };
|
|
34
|
+
for (const cmd of commands) {
|
|
35
|
+
let cursor = root;
|
|
36
|
+
for (let i = 0; i < cmd.path.length - 1; i++) {
|
|
37
|
+
const seg = cmd.path[i];
|
|
38
|
+
cursor.subCommands[seg] ??= { subCommands: {} };
|
|
39
|
+
cursor = cursor.subCommands[seg];
|
|
40
|
+
}
|
|
41
|
+
const leafName = cmd.path[cmd.path.length - 1];
|
|
42
|
+
cursor.subCommands[leafName] = { subCommands: {}, leaf: cmd };
|
|
43
|
+
}
|
|
44
|
+
return root;
|
|
45
|
+
}
|
|
46
|
+
function treeToCitty(node, name, description) {
|
|
47
|
+
const subCommands = {};
|
|
48
|
+
for (const [childName, child] of Object.entries(node.subCommands)) {
|
|
49
|
+
if (child.leaf) {
|
|
50
|
+
subCommands[childName] = commandToCitty(child.leaf);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
subCommands[childName] = treeToCitty(child, childName, `${childName} subcommands`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return defineCommand({
|
|
57
|
+
meta: { name, description },
|
|
58
|
+
subCommands,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export async function runCli(opts) {
|
|
62
|
+
const tree = buildTree(opts.commands);
|
|
63
|
+
const root = defineCommand({
|
|
64
|
+
meta: {
|
|
65
|
+
name: opts.name,
|
|
66
|
+
version: opts.version,
|
|
67
|
+
description: opts.description,
|
|
68
|
+
},
|
|
69
|
+
subCommands: Object.fromEntries(Object.entries(tree.subCommands).map(([childName, child]) => [
|
|
70
|
+
childName,
|
|
71
|
+
child.leaf
|
|
72
|
+
? commandToCitty(child.leaf)
|
|
73
|
+
: treeToCitty(child, childName, `${childName} subcommands`),
|
|
74
|
+
])),
|
|
75
|
+
});
|
|
76
|
+
await runMain(root);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAQ1B,SAAS,cAAc,CAAC,IAAoB;IAC1C,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC;IAC1D,OAAO,aAAa,CAAC;QACnB,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;QAC7C,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YACtB,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE;gBACvD,KAAK,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;aACnC,CAAC,CAAC;YACH,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACjC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CACrB,IAA6B;IAE7B,MAAM,GAAG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