@contractkit/plugin-typescript 0.34.1 → 0.35.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/.turbo/turbo-build$colon$ci.log +5 -5
- package/.turbo/turbo-test$colon$ci.log +23 -18
- package/CHANGELOG.md +22 -0
- package/README.md +4 -3
- package/dist/codegen-mcp.d.ts +8 -1
- package/dist/codegen-mcp.d.ts.map +1 -1
- package/dist/codegen-operation.d.ts +12 -4
- package/dist/codegen-operation.d.ts.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +215 -88
- package/dist/index.js.map +1 -1
- package/dist/server-framework-koa.d.ts +7 -0
- package/dist/server-framework-koa.d.ts.map +1 -0
- package/dist/server-framework.d.ts +94 -0
- package/dist/server-framework.d.ts.map +1 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/src/codegen-mcp.ts +11 -25
- package/src/codegen-operation.ts +99 -74
- package/src/index.ts +36 -5
- package/src/server-framework-koa.ts +112 -0
- package/src/server-framework.ts +119 -0
- package/tests/codegen-mcp.test.ts +12 -0
- package/tests/codegen-operation-framework.test.ts +140 -0
- package/tests/codegen-operation.test.ts +29 -0
- package/tests/codegen-server.test.ts +56 -0
- package/tests/server-framework-koa.test.ts +115 -0
- package/tests/server-framework.test.ts +24 -0
|
@@ -5,9 +5,9 @@ $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly
|
|
|
5
5
|
[34mCLI[39m tsup v8.5.1
|
|
6
6
|
[34mCLI[39m Target: esnext
|
|
7
7
|
[34mESM[39m Build start
|
|
8
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
9
|
-
[32mESM[39m [1mdist/index.js.map [22m[
|
|
10
|
-
[32mESM[39m ⚡️ Build success in
|
|
8
|
+
[32mESM[39m [1mdist/index.js [22m[32m225.18 KB[39m
|
|
9
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m531.21 KB[39m
|
|
10
|
+
[32mESM[39m ⚡️ Build success in 386ms
|
|
11
11
|
[34mDTS[39m Build start
|
|
12
|
-
[32mDTS[39m ⚡️ Build success in
|
|
13
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
12
|
+
[32mDTS[39m ⚡️ Build success in 3500ms
|
|
13
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.53 KB[39m
|
|
@@ -3,36 +3,41 @@ $ vitest run --coverage
|
|
|
3
3
|
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.5 [39m[90m/home/runner/work/ContractKit/ContractKit/packages/plugin-typescript[39m
|
|
4
4
|
[2mCoverage enabled with [22m[33mv8[39m
|
|
5
5
|
|
|
6
|
-
[32m✓[39m tests/codegen-
|
|
7
|
-
[32m✓[39m tests/codegen-
|
|
8
|
-
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m173 tests[22m[2m)[22m[
|
|
9
|
-
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m67 tests[22m[2m)[22m[32m
|
|
10
|
-
[32m✓[39m tests/codegen-server.test.ts [2m([22m[
|
|
11
|
-
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m
|
|
12
|
-
[32m✓[39m tests/
|
|
13
|
-
[32m✓[39m tests/codegen-
|
|
14
|
-
[32m✓[39m tests/
|
|
6
|
+
[32m✓[39m tests/codegen-operation.test.ts [2m([22m[2m161 tests[22m[2m)[22m[32m 207[2mms[22m[39m
|
|
7
|
+
[32m✓[39m tests/codegen-contract.test.ts [2m([22m[2m147 tests[22m[2m)[22m[32m 155[2mms[22m[39m
|
|
8
|
+
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m173 tests[22m[2m)[22m[32m 256[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m67 tests[22m[2m)[22m[32m 54[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m39 tests[22m[2m)[22m[32m 147[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m 433[2mms[22m[39m
|
|
12
|
+
[32m✓[39m tests/codegen-mcp.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m 29[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/codegen-operation-framework.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
14
|
+
[32m✓[39m tests/server-framework-koa.test.ts [2m([22m[2m19 tests[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
15
|
+
[32m✓[39m tests/ts-render.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
16
|
+
[32m✓[39m tests/escaping-security.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 22[2mms[22m[39m
|
|
17
|
+
[32m✓[39m tests/server-framework.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
15
18
|
|
|
16
|
-
[2m Test Files [22m [1m[
|
|
17
|
-
[2m Tests [22m [1m[
|
|
18
|
-
[2m Start at [22m
|
|
19
|
-
[2m Duration [22m
|
|
19
|
+
[2m Test Files [22m [1m[32m12 passed[39m[22m[90m (12)[39m
|
|
20
|
+
[2m Tests [22m [1m[32m708 passed[39m[22m[90m (708)[39m
|
|
21
|
+
[2m Start at [22m 18:00:17
|
|
22
|
+
[2m Duration [22m 7.85s[2m (transform 4.21s, setup 0ms, import 14.10s, tests 1.34s, environment 1ms)[22m
|
|
20
23
|
|
|
21
24
|
[34m % [39m[2mCoverage report from [22m[33mv8[39m
|
|
22
25
|
-------------------|---------|----------|---------|---------|-------------------
|
|
23
26
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
24
27
|
-------------------|---------|----------|---------|---------|-------------------
|
|
25
|
-
All files |
|
|
26
|
-
src |
|
|
28
|
+
All files | 84.59 | 78.42 | 87.93 | 87.3 |
|
|
29
|
+
src | 84.42 | 78.12 | 87.61 | 87.16 |
|
|
27
30
|
...n-contract.ts | 90.13 | 85.89 | 90.51 | 90.9 | ...1166,1171-1172
|
|
28
|
-
codegen-mcp.ts |
|
|
29
|
-
...-operation.ts | 83.
|
|
31
|
+
codegen-mcp.ts | 83.44 | 75.46 | 84.21 | 86.61 | ...01,306-307,392
|
|
32
|
+
...-operation.ts | 83.27 | 80.62 | 80.82 | 85.33 | ...1070,1075-1076
|
|
30
33
|
...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
|
|
31
34
|
...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
|
|
32
35
|
codegen-sdk.ts | 88.46 | 80.47 | 90.55 | 91.36 | ...1891,1895-1896
|
|
33
36
|
...al-runtime.ts | 100 | 100 | 100 | 100 |
|
|
34
|
-
index.ts |
|
|
37
|
+
index.ts | 77.23 | 65.81 | 83.6 | 81.28 | ...1152,1168-1187
|
|
35
38
|
path-utils.ts | 70.5 | 52.27 | 100 | 73.72 | ...75-178,226-241
|
|
39
|
+
...mework-koa.ts | 100 | 100 | 100 | 100 |
|
|
40
|
+
...-framework.ts | 100 | 100 | 100 | 100 |
|
|
36
41
|
ts-render.ts | 86.04 | 88.23 | 80 | 90.14 | 103,191,224-232
|
|
37
42
|
tests | 94.73 | 95.12 | 93.54 | 96 |
|
|
38
43
|
helpers.ts | 94.73 | 95.12 | 93.54 | 96 | 120,128
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @contractkit/contractkit-plugin-typescript
|
|
2
2
|
|
|
3
|
+
## 0.35.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 731ab7a: Add `server.framework`, and render the generated router through a framework adapter.
|
|
8
|
+
|
|
9
|
+
The server sub-generator emitted the Koa flavour of ServerKit inline: `ServerKitRouter()`, `async ctx => {`, `ctx.params`, `ctx.parsedBody`, `ctx.container.get`, `ctx.status`, `ctx.set`, `ctx.type`, `ctx.body`, and a wholly Koa-specific `mcp.router.ts`. Every one of those strings now comes from a `ServerFramework` adapter, and `server.framework` selects it:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
"server": { "framework": "koa", "baseDir": "apps/api/" }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`koa` is the only supported value and the default, so **generated output is unchanged, byte for byte** — the option exists so a later release can target another framework without touching the generator. A name with no adapter fails config validation rather than emitting code that cannot run:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
plugin-typescript: server.framework 'express' is not supported — expected one of: koa.
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The optional `mcp.router.ts` follows the same setting, including when there is no `server` sub-config at all, where it stays Koa.
|
|
22
|
+
|
|
23
|
+
Two internal changes came with it. `generateParamValidation` decided whether it was rendering query params or path params by comparing its accessor argument against the literals `'ctx.query'` and `'ctx.params'`, so the query-string array coercion and the destructuring of path params both hung on the exact spelling of a Koa accessor; it now takes the kind explicitly. And the response seam is shaped for a framework that ends a response by returning rather than by assigning: the adapter supplies the terminal statement for bodyless responses too, and supplies whatever closes a status case, since a `return` followed by a `break` is unreachable code.
|
|
24
|
+
|
|
3
25
|
## 0.34.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -52,11 +52,12 @@ Add the plugin to `contractkit.config.json`. Each sub-config is independent —
|
|
|
52
52
|
|
|
53
53
|
### `server`
|
|
54
54
|
|
|
55
|
-
Generates
|
|
55
|
+
Generates server router files from `operation` declarations and optionally type files from `contract` declarations.
|
|
56
56
|
|
|
57
57
|
| Option | Type | Default | Description |
|
|
58
58
|
|---|---|---|---|
|
|
59
59
|
| `baseDir` | `string` | `rootDir` | Base directory for output files |
|
|
60
|
+
| `framework` | `string` | `"koa"` | HTTP framework the routers target. Only `koa` is supported today. |
|
|
60
61
|
| `zod` | `boolean` | `false` | Emit Zod schemas in `output.types` instead of plain interfaces |
|
|
61
62
|
| `output.routes` | `string` | — | Path template for router files |
|
|
62
63
|
| `output.types` | `string` | — | Path template for type/schema files |
|
|
@@ -129,9 +130,9 @@ Contracts with `readonly` or `writeonly` fields generate up to three schemas:
|
|
|
129
130
|
|
|
130
131
|
Contracts without visibility modifiers generate a single `Model` schema.
|
|
131
132
|
|
|
132
|
-
###
|
|
133
|
+
### Router shape (from `operation`)
|
|
133
134
|
|
|
134
|
-
Each operation file generates one
|
|
135
|
+
Each operation file generates one router, targeting the framework named by `framework` (`koa` today). Request bodies and path/query params are validated against the Zod schemas (when `zod: true`) or plain types. Handlers are expected to be exported from the service module specified by `servicePathTemplate`.
|
|
135
136
|
|
|
136
137
|
Responses are only type-annotated by default. With `validateResponses: true` (which requires `zod: true`) the service's return value is re-parsed against its declared response schema and the parsed value is written to `ctx.body`, so a service returning a shape the contract does not allow fails with a 500 instead of shipping it. See [docs/config.md](../../docs/config.md#validateresponses) for the caveats — notably that models using `format(input=…)`/`format(output=…)` are skipped.
|
|
137
138
|
|
package/dist/codegen-mcp.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OpRootNode } from '@contractkit/core';
|
|
2
|
+
import type { ServerFramework } from './server-framework.js';
|
|
2
3
|
export interface McpCodegenOptions {
|
|
3
4
|
/** Absolute path of the file being generated. Used to compute relative imports. */
|
|
4
5
|
outPath?: string;
|
|
@@ -31,8 +32,14 @@ export interface McpAggregatorEntry {
|
|
|
31
32
|
}
|
|
32
33
|
/** Generate the aggregator `mcp.tools.ts` that assembles the single McpToolHandlerMap. */
|
|
33
34
|
export declare function generateMcpAggregator(entries: McpAggregatorEntry[]): string;
|
|
34
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Generate the optional `mcp.router.ts` — the standard ServerKit route wiring for the dispatcher.
|
|
37
|
+
*
|
|
38
|
+
* The whole file is framework-specific boilerplate rather than a per-operation render, so the
|
|
39
|
+
* adapter owns the template. Defaults to Koa, matching the router generator.
|
|
40
|
+
*/
|
|
35
41
|
export declare function generateMcpRouter(options?: {
|
|
36
42
|
path?: string;
|
|
43
|
+
framework?: ServerFramework;
|
|
37
44
|
}): string;
|
|
38
45
|
//# sourceMappingURL=codegen-mcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-mcp.d.ts","sourceRoot":"","sources":["../src/codegen-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA8E,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"codegen-mcp.d.ts","sourceRoot":"","sources":["../src/codegen-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA8E,MAAM,mBAAmB,CAAC;AAOhI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,MAAM,WAAW,iBAAiB;IAC9B,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qDAAqD;IACrD,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AASD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,UAAQ,GAAG,OAAO,CASnF;AAmWD,0GAA0G;AAC1G,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,sGAAsG;AACtG,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CA0DzF;AAED,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IAC/B,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAuB3E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,eAAe,CAAA;CAAO,GAAG,MAAM,CAGtG"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { OpRootNode, OpRouteNode, OpOperationNode, ContractTypeNode } from '@contractkit/core';
|
|
2
|
+
import type { ServerFramework } from './server-framework.js';
|
|
3
|
+
/** Which request-side object a validation block reads from. Names the variable the block declares. */
|
|
4
|
+
export type ParamKind = 'params' | 'query' | 'headers';
|
|
2
5
|
/**
|
|
3
6
|
* Deep structural equality on ContractTypeNode, ignoring source locations on inline fields.
|
|
4
7
|
* Used to decide whether multiple declared request MIMEs can share a single validate path.
|
|
5
8
|
*/
|
|
6
9
|
export declare function bodyTypesStructurallyEqual(a: ContractTypeNode, b: ContractTypeNode): boolean;
|
|
7
|
-
/** Options controlling how {@link generateOp} renders a
|
|
10
|
+
/** Options controlling how {@link generateOp} renders a server router module. */
|
|
8
11
|
export interface OpCodegenOptions {
|
|
9
12
|
servicePathTemplate?: string;
|
|
10
13
|
typeImportPathTemplate?: string;
|
|
@@ -22,8 +25,8 @@ export interface OpCodegenOptions {
|
|
|
22
25
|
*/
|
|
23
26
|
includeInternal?: boolean;
|
|
24
27
|
/**
|
|
25
|
-
* Re-parse the service result through its declared response schema before writing
|
|
26
|
-
* and write the parsed value. Requires the type file to hold Zod schemas (`server.zod`) —
|
|
28
|
+
* Re-parse the service result through its declared response schema before writing the response
|
|
29
|
+
* body, and write the parsed value. Requires the type file to hold Zod schemas (`server.zod`) —
|
|
27
30
|
* plain interfaces are types, with no runtime schema value to validate against. Default false.
|
|
28
31
|
*/
|
|
29
32
|
validateResponses?: boolean;
|
|
@@ -33,9 +36,14 @@ export interface OpCodegenOptions {
|
|
|
33
36
|
* post-transform shape, which the schema itself cannot re-parse.
|
|
34
37
|
*/
|
|
35
38
|
modelsWithTransform?: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Which HTTP framework the emitted router targets. Every framework-specific string in the output
|
|
41
|
+
* comes from here. Defaults to Koa, the only framework shipped today.
|
|
42
|
+
*/
|
|
43
|
+
framework?: ServerFramework;
|
|
36
44
|
}
|
|
37
45
|
/**
|
|
38
|
-
* Generate a
|
|
46
|
+
* Generate a server router module for every operation in `root`, including the imports, type
|
|
39
47
|
* aliases, and handler list.
|
|
40
48
|
*
|
|
41
49
|
* Imports are derived from the generated body — each candidate symbol is emitted only if it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-operation.d.ts","sourceRoot":"","sources":["../src/codegen-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,WAAW,EACX,eAAe,EAGf,gBAAgB,EAInB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"codegen-operation.d.ts","sourceRoot":"","sources":["../src/codegen-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,WAAW,EACX,eAAe,EAGf,gBAAgB,EAInB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,sGAAsG;AACtG,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AA0BvD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CA0E5F;AAID,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC7B,mBA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|
import type { ContractKitPlugin } from '@contractkit/core';
|
|
2
|
-
|
|
2
|
+
import { type ServerFrameworkName } from './server-framework.js';
|
|
3
|
+
export { SERVER_FRAMEWORK_NAMES, DEFAULT_SERVER_FRAMEWORK_NAME, resolveServerFramework, SERVER_FRAMEWORKS, type ServerFramework, type ServerFrameworkName, } from './server-framework.js';
|
|
4
|
+
export { KOA_SERVER_FRAMEWORK } from './server-framework-koa.js';
|
|
5
|
+
/** Server output: routers, and the type or Zod schema files they import. */
|
|
3
6
|
export interface ServerConfig {
|
|
4
7
|
/** Directory (relative to rootDir) where server files are written. Default: rootDir. */
|
|
5
8
|
baseDir?: string;
|
|
9
|
+
/**
|
|
10
|
+
* HTTP framework the generated routers target. Also selects the flavour of the optional
|
|
11
|
+
* `mcp.router.ts` the `mcp` sub-config emits. Supported: `'koa'`. Default `'koa'`.
|
|
12
|
+
*/
|
|
13
|
+
framework?: ServerFrameworkName;
|
|
6
14
|
/** When true, `output.types` emits Zod schema files (via `generateContract`). When false/omitted, emits plain TypeScript. */
|
|
7
15
|
zod?: boolean;
|
|
8
16
|
output?: {
|
|
9
|
-
/** Path template for
|
|
17
|
+
/** Path template for router files. Supports {filename}, {dir}, {area}. */
|
|
10
18
|
routes?: string;
|
|
11
19
|
/** Path template for type/schema files. Supports {filename}, {dir}, {area}. */
|
|
12
20
|
types?: string;
|
|
@@ -81,7 +89,7 @@ export interface McpConfig {
|
|
|
81
89
|
*/
|
|
82
90
|
types?: string;
|
|
83
91
|
};
|
|
84
|
-
/** Emit the `mcp.router.ts` route boilerplate. Default true. */
|
|
92
|
+
/** Emit the `mcp.router.ts` route boilerplate. Its framework follows `server.framework`. Default true. */
|
|
85
93
|
emitRouter?: boolean;
|
|
86
94
|
/** Mount path used in the emitted router. Default `/mcp`. */
|
|
87
95
|
path?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names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