@contractkit/plugin-typescript 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.turbo/turbo-build$colon$ci.log +35 -0
  2. package/.turbo/turbo-build.log +15 -0
  3. package/.turbo/turbo-test$colon$ci.log +81 -0
  4. package/.turbo/turbo-test.log +19 -0
  5. package/CHANGELOG.md +151 -0
  6. package/README.md +153 -0
  7. package/coverage/base.css +224 -0
  8. package/coverage/block-navigation.js +87 -0
  9. package/coverage/clover.xml +1882 -0
  10. package/coverage/coverage-final.json +9 -0
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +131 -0
  13. package/coverage/prettify.css +1 -0
  14. package/coverage/prettify.js +2 -0
  15. package/coverage/sort-arrow-sprite.png +0 -0
  16. package/coverage/sorter.js +210 -0
  17. package/coverage/src/codegen-contract.ts.html +3331 -0
  18. package/coverage/src/codegen-operation.ts.html +2530 -0
  19. package/coverage/src/codegen-plain-types.ts.html +901 -0
  20. package/coverage/src/codegen-sdk.ts.html +2797 -0
  21. package/coverage/src/index.html +206 -0
  22. package/coverage/src/index.ts.html +1360 -0
  23. package/coverage/src/path-utils.ts.html +649 -0
  24. package/coverage/src/ts-render.ts.html +592 -0
  25. package/coverage/tests/helpers.ts.html +826 -0
  26. package/coverage/tests/index.html +116 -0
  27. package/dist/codegen-contract.d.ts +56 -0
  28. package/dist/codegen-contract.d.ts.map +1 -0
  29. package/dist/codegen-operation.d.ts +25 -0
  30. package/dist/codegen-operation.d.ts.map +1 -0
  31. package/dist/codegen-plain-types.d.ts +10 -0
  32. package/dist/codegen-plain-types.d.ts.map +1 -0
  33. package/dist/codegen-sdk.d.ts +38 -0
  34. package/dist/codegen-sdk.d.ts.map +1 -0
  35. package/dist/index.d.ts +77 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +3162 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/path-utils.d.ts +15 -0
  40. package/dist/path-utils.d.ts.map +1 -0
  41. package/dist/ts-render.d.ts +20 -0
  42. package/dist/ts-render.d.ts.map +1 -0
  43. package/eslint.config.js +6 -0
  44. package/package.json +43 -0
  45. package/src/codegen-contract.ts +1082 -0
  46. package/src/codegen-operation.ts +815 -0
  47. package/src/codegen-plain-types.ts +272 -0
  48. package/src/codegen-sdk.ts +904 -0
  49. package/src/index.ts +425 -0
  50. package/src/path-utils.ts +188 -0
  51. package/src/ts-render.ts +169 -0
  52. package/tests/codegen-contract.test.ts +1004 -0
  53. package/tests/codegen-operation.test.ts +939 -0
  54. package/tests/codegen-plain-types.test.ts +636 -0
  55. package/tests/codegen-sdk.test.ts +1500 -0
  56. package/tests/codegen-server.test.ts +192 -0
  57. package/tests/helpers.ts +247 -0
  58. package/tests/pipeline.test.ts +372 -0
  59. package/tsconfig.json +9 -0
  60. package/vitest.config.ts +14 -0
@@ -0,0 +1,116 @@
1
+
2
+ <!doctype html>
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <title>Code coverage report for tests</title>
7
+ <meta charset="utf-8" />
8
+ <link rel="stylesheet" href="../prettify.css" />
9
+ <link rel="stylesheet" href="../base.css" />
10
+ <link rel="shortcut icon" type="image/x-icon" href="../favicon.png" />
11
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
12
+ <style type='text/css'>
13
+ .coverage-summary .sorter {
14
+ background-image: url(../sort-arrow-sprite.png);
15
+ }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <div class='wrapper'>
21
+ <div class='pad1'>
22
+ <h1><a href="../index.html">All files</a> tests</h1>
23
+ <div class='clearfix'>
24
+
25
+ <div class='fl pad1y space-right2'>
26
+ <span class="strong">90.38% </span>
27
+ <span class="quiet">Statements</span>
28
+ <span class='fraction'>47/52</span>
29
+ </div>
30
+
31
+
32
+ <div class='fl pad1y space-right2'>
33
+ <span class="strong">90.9% </span>
34
+ <span class="quiet">Branches</span>
35
+ <span class='fraction'>30/33</span>
36
+ </div>
37
+
38
+
39
+ <div class='fl pad1y space-right2'>
40
+ <span class="strong">89.28% </span>
41
+ <span class="quiet">Functions</span>
42
+ <span class='fraction'>25/28</span>
43
+ </div>
44
+
45
+
46
+ <div class='fl pad1y space-right2'>
47
+ <span class="strong">93.47% </span>
48
+ <span class="quiet">Lines</span>
49
+ <span class='fraction'>43/46</span>
50
+ </div>
51
+
52
+
53
+ </div>
54
+ <p class="quiet">
55
+ Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
56
+ </p>
57
+ <template id="filterTemplate">
58
+ <div class="quiet">
59
+ Filter:
60
+ <input type="search" id="fileSearch">
61
+ </div>
62
+ </template>
63
+ </div>
64
+ <div class='status-line high'></div>
65
+ <div class="pad1">
66
+ <table class="coverage-summary">
67
+ <thead>
68
+ <tr>
69
+ <th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
70
+ <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
71
+ <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
72
+ <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
73
+ <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
74
+ <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
75
+ <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
76
+ <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
77
+ <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
78
+ <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
79
+ </tr>
80
+ </thead>
81
+ <tbody><tr>
82
+ <td class="file high" data-value="helpers.ts"><a href="helpers.ts.html">helpers.ts</a></td>
83
+ <td data-value="90.38" class="pic high">
84
+ <div class="chart"><div class="cover-fill" style="width: 90%"></div><div class="cover-empty" style="width: 10%"></div></div>
85
+ </td>
86
+ <td data-value="90.38" class="pct high">90.38%</td>
87
+ <td data-value="52" class="abs high">47/52</td>
88
+ <td data-value="90.9" class="pct high">90.9%</td>
89
+ <td data-value="33" class="abs high">30/33</td>
90
+ <td data-value="89.28" class="pct high">89.28%</td>
91
+ <td data-value="28" class="abs high">25/28</td>
92
+ <td data-value="93.47" class="pct high">93.47%</td>
93
+ <td data-value="46" class="abs high">43/46</td>
94
+ </tr>
95
+
96
+ </tbody>
97
+ </table>
98
+ </div>
99
+ <div class='push'></div><!-- for sticky footer -->
100
+ </div><!-- /wrapper -->
101
+ <div class='footer quiet pad2 space-top1 center small'>
102
+ Code coverage generated by
103
+ <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
+ at 2026-04-29T12:51:10.318Z
105
+ </div>
106
+ <script src="../prettify.js"></script>
107
+ <script>
108
+ window.onload = function () {
109
+ prettyPrint();
110
+ };
111
+ </script>
112
+ <script src="../sorter.js"></script>
113
+ <script src="../block-navigation.js"></script>
114
+ </body>
115
+ </html>
116
+
@@ -0,0 +1,56 @@
1
+ import type { ContractRootNode, ModelNode, ContractTypeNode, ObjectMode } from '@contractkit/core';
2
+ export declare function modeToWrapper(mode: ObjectMode): string;
3
+ export interface ContractCodegenContext {
4
+ /** Map from model name → absolute output file path */
5
+ modelOutPaths: Map<string, string>;
6
+ /** Absolute output file path for the current contract file */
7
+ currentOutPath: string;
8
+ /** Set of model names that have Input variants (models with visibility modifiers) */
9
+ modelsWithInput?: Set<string>;
10
+ /** Set of model names that have Output variants (models with format(output=...)) */
11
+ modelsWithOutput?: Set<string>;
12
+ /** If set, import JsonValue from this path instead of re-declaring it (avoids barrel re-export conflicts) */
13
+ jsonValueImportPath?: string;
14
+ }
15
+ /**
16
+ * Compute which models need Input variants, including transitive dependencies.
17
+ * A model needs an Input variant if it has visibility-modified fields, OR if
18
+ * any of its field types (recursively) reference a model that has an Input variant.
19
+ */
20
+ export declare function computeModelsWithInput(models: ModelNode[], externalModelsWithInput?: Set<string>): Set<string>;
21
+ export declare function generateContract(root: ContractRootNode, context?: ContractCodegenContext): string;
22
+ export declare function renderType(type: ContractTypeNode, parseCaseTransform?: 'snake' | 'pascal', defaultMode?: ObjectMode): string;
23
+ /**
24
+ * Like renderType, but substitutes model refs with their Input variant
25
+ * when the model has visibility modifiers, and coerces scalars from strings.
26
+ * Used for Input (write) schema fields so that sub-type references also
27
+ * point to their Input variants.
28
+ */
29
+ export declare function renderInputType(type: ContractTypeNode, modelsWithInput?: Set<string>, defaultMode?: ObjectMode): string;
30
+ /**
31
+ * Like renderType, but wraps array types with z.preprocess to handle
32
+ * query strings where a single value arrives as a string instead of a string[].
33
+ * Also uses Input variants for model refs when modelsWithInput is provided.
34
+ */
35
+ export declare function renderQueryType(type: ContractTypeNode, modelsWithInput?: Set<string>, defaultMode?: ObjectMode): string;
36
+ export declare function typeNeedsScalar(type: ContractTypeNode, name: string): boolean;
37
+ export declare function rootNeedsScalar(root: ContractRootNode, name: string): boolean;
38
+ export declare function typeNeedsDateTime(type: ContractTypeNode): boolean;
39
+ export declare function collectExternalRefs(root: ContractRootNode): string[];
40
+ /** Collect external Input variant refs needed for Input schema fields. */
41
+ export declare function collectExternalInputRefs(root: ContractRootNode, modelsWithInput: Set<string>): string[];
42
+ /**
43
+ * Topologically sort models so dependencies are emitted before dependents.
44
+ * Falls back to source order for cycles (which would need z.lazy at runtime).
45
+ */
46
+ export declare function topoSortModels(models: ModelNode[]): ModelNode[];
47
+ /**
48
+ * Resolve the import path for an external model reference.
49
+ * When a codegen context is available, computes the correct relative path
50
+ * from the current file to the referenced model's output file.
51
+ * Falls back to same-directory PascalCase → dot.case convention.
52
+ */
53
+ export declare function resolveImportPath(refName: string, context?: ContractCodegenContext): string;
54
+ /** Convert PascalCase to dot-separated lowercase: CounterpartyAccount → counterparty.account */
55
+ export declare function pascalToDotCase(name: string): string;
56
+ //# sourceMappingURL=codegen-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen-contract.d.ts","sourceRoot":"","sources":["../src/codegen-contract.ts"],"names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vH;AA0CD,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAuB7E;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAiBjE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAcpE;AAED,0EAA0E;AAC1E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CA4BvG;AAmCD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CA6D/D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAgB3F;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,25 @@
1
+ import type { OpRootNode, ContractTypeNode } from '@contractkit/core';
2
+ /**
3
+ * Deep structural equality on ContractTypeNode, ignoring source locations on inline fields.
4
+ * Used to decide whether multiple declared request MIMEs can share a single validate path.
5
+ */
6
+ export declare function bodyTypesStructurallyEqual(a: ContractTypeNode, b: ContractTypeNode): boolean;
7
+ export interface OpCodegenOptions {
8
+ servicePathTemplate?: string;
9
+ typeImportPathTemplate?: string;
10
+ outPath?: string;
11
+ /** Map from model name → absolute output file path (for cross-module type imports) */
12
+ modelOutPaths?: Map<string, string>;
13
+ /** Set of model names that have Input variants (models with visibility modifiers) */
14
+ modelsWithInput?: Set<string>;
15
+ /** Set of model names that have Output variants (models with format(output=...)) */
16
+ modelsWithOutput?: Set<string>;
17
+ /**
18
+ * Whether to emit handlers for operations marked `internal`. Defaults to `true` because
19
+ * the server still needs routes for internal endpoints; set to `false` to omit them
20
+ * from the generated router entirely.
21
+ */
22
+ includeInternal?: boolean;
23
+ }
24
+ export declare function generateOp(root: OpRootNode, options?: OpCodegenOptions): string;
25
+ //# sourceMappingURL=codegen-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen-operation.d.ts","sourceRoot":"","sources":["../src/codegen-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgC,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAmC7H;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAkE5F;AAID,MAAM,WAAW,gBAAgB;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qFAAqF;IACrF,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAwEnF"}
@@ -0,0 +1,10 @@
1
+ import type { ContractRootNode } from '@contractkit/core';
2
+ import type { ContractCodegenContext } from './codegen-contract.js';
3
+ /**
4
+ * Generate plain TypeScript interfaces/types from a contract AST.
5
+ * Unlike `generateContract()` which produces Zod schemas, this emits
6
+ * vanilla TypeScript `interface` and `type` declarations suitable
7
+ * for SDK consumers that don't need runtime validation.
8
+ */
9
+ export declare function generatePlainTypes(root: ContractRootNode, context?: ContractCodegenContext): string;
10
+ //# sourceMappingURL=codegen-plain-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen-plain-types.d.ts","sourceRoot":"","sources":["../src/codegen-plain-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAapE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAyCnG"}
@@ -0,0 +1,38 @@
1
+ import type { OpRootNode } from '@contractkit/core';
2
+ export interface SdkCodegenOptions {
3
+ typeImportPathTemplate?: string;
4
+ outPath?: string;
5
+ /** Map from model name → absolute output file path (for cross-module type imports) */
6
+ modelOutPaths?: Map<string, string>;
7
+ /** Absolute path to the shared sdk-options.ts file (if set, imports SdkOptions instead of defining inline) */
8
+ sdkOptionsPath?: string;
9
+ /** Set of model names that have Input variants (models with visibility modifiers) */
10
+ modelsWithInput?: Set<string>;
11
+ /** Set of model names that have Output variants (models with format(output=...)) */
12
+ modelsWithOutput?: Set<string>;
13
+ /**
14
+ * Whether to emit SDK methods for operations marked `internal`. Defaults to `false` —
15
+ * internal ops are omitted from the SDK so consumers don't pick them up. Set to `true`
16
+ * to include them (e.g. for an internal-use SDK).
17
+ */
18
+ includeInternal?: boolean;
19
+ }
20
+ /**
21
+ * Returns true if the root contains at least one operation eligible for SDK emission.
22
+ * With `includeInternal: false` (default) that means at least one non-internal op; with
23
+ * `includeInternal: true` any op qualifies.
24
+ */
25
+ export declare function hasPublicOperations(root: OpRootNode, includeInternal?: boolean): boolean;
26
+ export declare function generateSdk(root: OpRootNode, options?: SdkCodegenOptions): string;
27
+ export declare function deriveClientClassName(file: string): string;
28
+ export declare function deriveClientPropertyName(file: string): string;
29
+ /** Generate the shared SdkOptions interface file. */
30
+ export declare function generateSdkOptions(): string;
31
+ export interface SdkClientInfo {
32
+ className: string;
33
+ propertyName: string;
34
+ importPath: string;
35
+ }
36
+ /** Generate the sdk.ts aggregator that wraps all clients into a single Sdk class. */
37
+ export declare function generateSdkAggregator(clients: SdkClientInfo[], sdkOptionsImportPath?: string, sdkClassName?: string): string;
38
+ //# sourceMappingURL=codegen-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen-sdk.d.ts","sourceRoot":"","sources":["../src/codegen-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkF,MAAM,mBAAmB,CAAC;AA2DpI,MAAM,WAAW,iBAAiB;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,8GAA8G;IAC9G,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qFAAqF;IACrF,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,UAAQ,GAAG,OAAO,CAOtF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAmHrF;AAsTD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7D;AA2QD,qDAAqD;AACrD,wBAAgB,kBAAkB,IAAI,MAAM,CA6E3C;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,qFAAqF;AACrF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,oBAAoB,SAAqB,EAAE,YAAY,SAAQ,GAAG,MAAM,CAyBvI"}
@@ -0,0 +1,77 @@
1
+ import type { ContractKitPlugin } from '@contractkit/core';
2
+ export interface ServerConfig {
3
+ /** Directory (relative to rootDir) where server files are written. Default: rootDir. */
4
+ baseDir?: string;
5
+ /**
6
+ * When true, `output.types` emits Zod schema files (via `generateContract`).
7
+ * When false/omitted, `output.types` emits plain TypeScript interfaces.
8
+ */
9
+ zod?: boolean;
10
+ output?: {
11
+ /** Path template for Koa router files. Supports {filename}, {dir}, {area}. Default: `{filename}.router.ts`. */
12
+ routes?: string;
13
+ /**
14
+ * Path template for type/schema files. Supports {filename}, {dir}, {area}.
15
+ * Generates Zod schemas when `zod: true`, otherwise plain TypeScript interfaces.
16
+ */
17
+ types?: string;
18
+ };
19
+ /** Import path template for service implementations. Supports {module}. */
20
+ servicePathTemplate?: string;
21
+ /**
22
+ * Whether to emit handlers for operations marked `internal`. Defaults to `true` —
23
+ * the server still needs routes for internal endpoints. Set to `false` to omit them.
24
+ */
25
+ includeInternal?: boolean;
26
+ }
27
+ export interface SdkConfig {
28
+ /** Directory (relative to rootDir) where SDK files are written. Default: rootDir. */
29
+ baseDir?: string;
30
+ /** Name used for the aggregator SDK class (e.g. "homegrown" → `HomegrownSdk`). */
31
+ name?: string;
32
+ /**
33
+ * When true, `output.types` emits Zod schema files (via `generateContract`).
34
+ * When false/omitted, `output.types` emits plain TypeScript interfaces.
35
+ */
36
+ zod?: boolean;
37
+ output?: {
38
+ /** Path template for the SDK aggregator file. Supports {name}. Default: `sdk.ts`. */
39
+ sdk?: string;
40
+ /** Path template for SDK type files. Supports {filename}, {dir}, {area}. */
41
+ types?: string;
42
+ /** Path template for client class files. Supports {filename}, {dir}, {area}. */
43
+ clients?: string;
44
+ };
45
+ /**
46
+ * Whether to emit SDK methods for operations marked `internal`. Defaults to `false` —
47
+ * internal ops are omitted from the SDK so consumers don't pick them up. Set to `true`
48
+ * for an internal-use SDK that should expose them.
49
+ */
50
+ includeInternal?: boolean;
51
+ }
52
+ export interface ZodConfig {
53
+ /** Directory (relative to rootDir) where Zod schema files are written. Default: rootDir. */
54
+ baseDir?: string;
55
+ /** Output path template. Supports {filename}, {dir}. Default: `{filename}.schema.ts` alongside source. */
56
+ output?: string;
57
+ }
58
+ export interface TypesConfig {
59
+ /** Directory (relative to rootDir) where plain TypeScript type files are written. Default: rootDir. */
60
+ baseDir?: string;
61
+ /** Output path template. Supports {filename}, {dir}. Default: `{filename}.types.ts` alongside source. */
62
+ output?: string;
63
+ }
64
+ export interface TypescriptPluginConfig {
65
+ /** Generate Koa router files from `operation` declarations. */
66
+ server?: ServerConfig;
67
+ /** Generate TypeScript SDK client files from `operation` declarations. */
68
+ sdk?: SdkConfig;
69
+ /** Generate Zod schema files from `contract` declarations. */
70
+ zod?: ZodConfig;
71
+ /** Generate plain TypeScript interface/type files from `contract` declarations (no Zod runtime). */
72
+ types?: TypesConfig;
73
+ }
74
+ declare const plugin: ContractKitPlugin;
75
+ export default plugin;
76
+ export declare function createTypescriptPlugin(config: TypescriptPluginConfig, rootDir: string): ContractKitPlugin;
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAwB3D,MAAM,WAAW,YAAY;IACzB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE;QACL,+GAA+G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