@contractkit/plugin-typescript 0.34.1 → 0.36.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.
@@ -5,9 +5,9 @@ $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly
5
5
  CLI tsup v8.5.1
6
6
  CLI Target: esnext
7
7
  ESM Build start
8
- ESM dist/index.js 221.06 KB
9
- ESM dist/index.js.map 514.96 KB
10
- ESM ⚡️ Build success in 514ms
8
+ ESM dist/index.js 230.12 KB
9
+ ESM dist/index.js.map 542.08 KB
10
+ ESM ⚡️ Build success in 359ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 5728ms
13
- DTS dist/index.d.ts 5.14 KB
12
+ DTS ⚡️ Build success in 3932ms
13
+ DTS dist/index.d.ts 11.34 KB
@@ -3,36 +3,43 @@ $ vitest run --coverage
3
3
   RUN  v4.1.5 /home/runner/work/ContractKit/ContractKit/packages/plugin-typescript
4
4
  Coverage enabled with v8
5
5
 
6
- ✓ tests/codegen-contract.test.ts (147 tests) 222ms
7
- ✓ tests/codegen-operation.test.ts (159 tests) 241ms
8
- ✓ tests/codegen-sdk.test.ts (173 tests) 405ms
9
- ✓ tests/codegen-plain-types.test.ts (67 tests) 63ms
10
- ✓ tests/codegen-server.test.ts (33 tests) 149ms
11
- ✓ tests/pipeline.test.ts (34 tests) 413ms
12
- ✓ tests/ts-render.test.ts (5 tests) 8ms
13
- ✓ tests/codegen-mcp.test.ts (31 tests) 49ms
14
- ✓ tests/escaping-security.test.ts (18 tests) 30ms
6
+ ✓ tests/codegen-operation.test.ts (166 tests) 190ms
7
+ ✓ tests/codegen-contract.test.ts (147 tests) 182ms
8
+ ✓ tests/codegen-sdk.test.ts (173 tests) 228ms
9
+ ✓ tests/codegen-plain-types.test.ts (67 tests) 39ms
10
+ ✓ tests/codegen-server.test.ts (39 tests) 129ms
11
+ ✓ tests/pipeline.test.ts (34 tests) 542ms
12
+ ✓ tests/codegen-mcp.test.ts (33 tests) 52ms
13
+ ✓ tests/server-framework-fastify.test.ts (25 tests) 11ms
14
+ ✓ tests/codegen-operation-framework.test.ts (14 tests) 9ms
15
+ ✓ tests/server-framework-koa.test.ts (19 tests) 22ms
16
+ ✓ tests/ts-render.test.ts (5 tests) 10ms
17
+ ✓ tests/server-framework.test.ts (4 tests) 13ms
18
+ ✓ tests/escaping-security.test.ts (18 tests) 20ms
15
19
 
16
-  Test Files  9 passed (9)
17
-  Tests  667 passed (667)
18
-  Start at  17:41:52
19
-  Duration  10.27s (transform 6.12s, setup 0ms, import 20.30s, tests 1.58s, environment 24ms)
20
+  Test Files  13 passed (13)
21
+  Tests  744 passed (744)
22
+  Start at  19:51:10
23
+  Duration  9.04s (transform 3.75s, setup 0ms, import 16.64s, tests 1.45s, environment 3ms)
20
24
 
21
25
   % Coverage report from v8
22
26
  -------------------|---------|----------|---------|---------|-------------------
23
27
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
24
28
  -------------------|---------|----------|---------|---------|-------------------
25
- All files | 83.37 | 77.38 | 86.64 | 86 |
26
- src | 83.19 | 77.06 | 86.23 | 85.83 |
29
+ All files | 84.73 | 78.53 | 88.26 | 87.45 |
30
+ src | 84.57 | 78.23 | 87.97 | 87.3 |
27
31
  ...n-contract.ts | 90.13 | 85.89 | 90.51 | 90.9 | ...1166,1171-1172
28
- codegen-mcp.ts | 82.75 | 74.53 | 84.21 | 86.19 | ...99,304-305,390
29
- ...-operation.ts | 83.06 | 80.46 | 80.28 | 85.15 | ...1045,1050-1051
32
+ codegen-mcp.ts | 83.44 | 75.46 | 84.21 | 86.61 | ...01,306-307,392
33
+ ...-operation.ts | 83.68 | 80.85 | 81.08 | 85.74 | ...1114,1119-1120
30
34
  ...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
31
35
  ...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
32
36
  codegen-sdk.ts | 88.46 | 80.47 | 90.55 | 91.36 | ...1891,1895-1896
33
37
  ...al-runtime.ts | 100 | 100 | 100 | 100 |
34
- index.ts | 68.64 | 55.2 | 75.4 | 71.67 | ...1121,1137-1156
38
+ index.ts | 77.23 | 65.81 | 83.6 | 81.28 | ...1153,1169-1188
35
39
  path-utils.ts | 70.5 | 52.27 | 100 | 73.72 | ...75-178,226-241
40
+ ...rk-fastify.ts | 100 | 100 | 100 | 100 |
41
+ ...mework-koa.ts | 100 | 100 | 100 | 100 |
42
+ ...-framework.ts | 100 | 100 | 100 | 100 |
36
43
  ts-render.ts | 86.04 | 88.23 | 80 | 90.14 | 103,191,224-232
37
44
  tests | 94.73 | 95.12 | 93.54 | 96 |
38
45
  helpers.ts | 94.73 | 95.12 | 93.54 | 96 | 120,128
package/CHANGELOG.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # @contractkit/contractkit-plugin-typescript
2
2
 
3
+ ## 0.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 18263e2: Generate Fastify routers with `server.framework: "fastify"`.
8
+
9
+ ```json
10
+ "server": { "framework": "fastify", "baseDir": "apps/api/" }
11
+ ```
12
+
13
+ Output targets `@maroonedsoftware/fastify`, whose exported surface mirrors the Koa one, so a contract compiles to the same handlers either way:
14
+
15
+ ```ts
16
+ BillingRouter.post('/payments', requirePolicy(), bodyParserMiddleware(['json']), async (request, reply) => {
17
+ const body = await parseAndValidate(request.parsedBody, PaymentInput);
18
+
19
+ const service = request.container.get(PaymentService);
20
+ const result: Payment = await service.create(body);
21
+
22
+ reply.status(200);
23
+ reply.type('application/json');
24
+ return reply.send(result);
25
+ });
26
+ ```
27
+
28
+ Three differences are worth knowing before you switch:
29
+ - **The request is the context.** Handlers take `(request, reply)`, and params, query, headers, the DI container and the parsed body all hang off `request`. Fastify's own `request.body` is never populated, because ServerKit parses lazily per route.
30
+ - **Responses are returned, not assigned.** A handler that neither returns a body nor calls `send` leaves the request hanging, so a bodyless 204 emits an explicit `return reply.send();` where Koa emits nothing at all.
31
+ - **Content type comes from `requestMediaType(request)`.** Fastify has no accessor that strips the parameters off the header, and a raw `application/json; charset=utf-8` matches none of the MIME literals an operation declares.
32
+
33
+ `koa` remains the default and its output is unchanged. The generated `mcp.router.ts` follows the setting, using `reply.hijack()` where the Koa mount sets `ctx.respond = false`.
34
+
35
+ Separately, a path parameter whose name collides with an identifier the handler already binds is now renamed. `/threads/{reply}` emitted `const { reply } = ...` inside `async (request, reply) => {`, a redeclaration under `tsc` and a temporal-dead-zone `ReferenceError` at runtime; the same held on Koa for a parameter named `ctx`, and on both for one named after a generator local such as `body` or `query`. Only the local binding moves, so the wire name, the schema key and the route placeholder are untouched.
36
+
37
+ ## 0.35.0
38
+
39
+ ### Minor Changes
40
+
41
+ - 731ab7a: Add `server.framework`, and render the generated router through a framework adapter.
42
+
43
+ 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:
44
+
45
+ ```json
46
+ "server": { "framework": "koa", "baseDir": "apps/api/" }
47
+ ```
48
+
49
+ `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:
50
+
51
+ ```
52
+ plugin-typescript: server.framework 'express' is not supported — expected one of: koa.
53
+ ```
54
+
55
+ The optional `mcp.router.ts` follows the same setting, including when there is no `server` sub-config at all, where it stays Koa.
56
+
57
+ 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.
58
+
3
59
  ## 0.34.1
4
60
 
5
61
  ### 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 Koa router files from `operation` declarations and optionally type files from `contract` declarations.
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: `"koa"` or `"fastify"`. Also selects the `mcp.router.ts` flavour. |
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
- ### Koa router shape (from `operation`)
133
+ ### Router shape (from `operation`)
133
134
 
134
- Each operation file generates one Koa router. 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
+ Each operation file generates one router, targeting the framework named by `framework`. On Koa a handler is `async ctx => {}` writing `ctx.status` / `ctx.type` / `ctx.body`; on Fastify it is `async (request, reply) => {}` reading `request.parsedBody` and returning `reply.send(...)`. Validation, service dispatch and the response shape are identical either way. 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
 
@@ -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
- /** Generate the optional `mcp.router.ts` — the standard ServerKit route wiring for the dispatcher. */
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;AAUhI,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,EA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,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 Koa router module. */
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 `ctx.body`,
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 Koa router module for every operation in `root`, including the imports, type
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
@@ -66,7 +74,7 @@ export declare function inferService(op: OpOperationNode, route: OpRouteNode, fi
66
74
  *
67
75
  * @returns The rendered argument list, or an empty string when the method takes no arguments.
68
76
  */
69
- export declare function buildArgs(route: OpRouteNode, op: OpOperationNode): string;
77
+ export declare function buildArgs(route: OpRouteNode, op: OpOperationNode, bindings?: Map<string, string>): string;
70
78
  /**
71
79
  * Derive the PascalCase base name used for router, service, and type names from a contract file path.
72
80
  *
@@ -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;AAmC3B;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CA0E5F;AAID,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,M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,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAuBzG;AA2bD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWnD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ/E"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,21 @@
1
1
  import type { ContractKitPlugin } from '@contractkit/core';
2
- /** Koa server output: routers, and the type or Zod schema files they import. */
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
+ export { FASTIFY_SERVER_FRAMEWORK } from './server-framework-fastify.js';
6
+ /** Server output: routers, and the type or Zod schema files they import. */
3
7
  export interface ServerConfig {
4
8
  /** Directory (relative to rootDir) where server files are written. Default: rootDir. */
5
9
  baseDir?: string;
10
+ /**
11
+ * HTTP framework the generated routers target. Also selects the flavour of the optional
12
+ * `mcp.router.ts` the `mcp` sub-config emits. Supported: `'koa'`. Default `'koa'`.
13
+ */
14
+ framework?: ServerFrameworkName;
6
15
  /** When true, `output.types` emits Zod schema files (via `generateContract`). When false/omitted, emits plain TypeScript. */
7
16
  zod?: boolean;
8
17
  output?: {
9
- /** Path template for Koa router files. Supports {filename}, {dir}, {area}. */
18
+ /** Path template for router files. Supports {filename}, {dir}, {area}. */
10
19
  routes?: string;
11
20
  /** Path template for type/schema files. Supports {filename}, {dir}, {area}. */
12
21
  types?: string;
@@ -81,7 +90,7 @@ export interface McpConfig {
81
90
  */
82
91
  types?: string;
83
92
  };
84
- /** Emit the `mcp.router.ts` route boilerplate. Default true. */
93
+ /** Emit the `mcp.router.ts` route boilerplate. Its framework follows `server.framework`. Default true. */
85
94
  emitRouter?: boolean;
86
95
  /** Mount path used in the emitted router. Default `/mcp`. */
87
96
  path?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,iBAAiB,EASpB,MAAM,mBAAmB,CAAC;AAqD3B,gFAAgF;AAChF,MAAM,WAAW,YAAY;IACzB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6HAA6H;IAC7H,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE;QACL,8EAA8E;QAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,+EAA+E;QAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,mGAAmG;AACnG,MAAM,WAAW,SAAS;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,sFAAsF;AACtF,MAAM,WAAW,SAAS;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;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