@counterfact/generator 0.1.5 → 0.1.6
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/CHANGELOG.md +15 -0
- package/dist/ast.d.ts +23 -0
- package/dist/ast.js +142 -0
- package/dist/coder.d.ts +16 -22
- package/dist/coder.js +15 -17
- package/dist/operation-coder.d.ts +4 -2
- package/dist/operation-coder.js +37 -24
- package/dist/operation-type-coder.d.ts +15 -20
- package/dist/operation-type-coder.js +111 -103
- package/dist/parameter-export-type-coder.d.ts +4 -3
- package/dist/parameters-type-coder.d.ts +2 -1
- package/dist/parameters-type-coder.js +7 -18
- package/dist/repository.d.ts +3 -10
- package/dist/repository.js +244 -95
- package/dist/response-type-coder.d.ts +7 -7
- package/dist/response-type-coder.js +37 -53
- package/dist/responses-type-coder.d.ts +4 -4
- package/dist/responses-type-coder.js +39 -26
- package/dist/scenario-file-generator.js +137 -134
- package/dist/schema-coder.d.ts +6 -4
- package/dist/schema-coder.js +31 -22
- package/dist/schema-type-coder.d.ts +9 -8
- package/dist/schema-type-coder.js +66 -62
- package/dist/script.d.ts +18 -95
- package/dist/script.js +137 -212
- package/dist/type-coder.d.ts +3 -1
- package/dist/type-coder.js +5 -1
- package/dist/versions-ts-generator.d.ts +0 -9
- package/dist/versions-ts-generator.js +46 -77
- package/package.json +4 -3
- package/src/README.md +23 -2
- package/dist/context-file-token.d.ts +0 -1
- package/dist/context-file-token.js +0 -1
- package/dist/printers.d.ts +0 -2
- package/dist/printers.js +0 -10
package/src/README.md
CHANGED
|
@@ -29,12 +29,33 @@ We can also use those types on the _client_ side, assuming the client is written
|
|
|
29
29
|
| `response-type-coder.ts` | `ResponseTypeCoder`: generates the type for a single HTTP response, including headers, content, and named examples |
|
|
30
30
|
| `schema-type-coder.ts` | `SchemaTypeCoder`: converts an OpenAPI schema definition to a TypeScript type (objects, arrays, unions, enums) |
|
|
31
31
|
| `schema-coder.ts` | `SchemaCoder`: generates a JSON Schema representation of an OpenAPI schema for use in runtime validation |
|
|
32
|
-
| `
|
|
33
|
-
| `printers.ts` | Utility functions for formatting TypeScript object literals in generated code |
|
|
32
|
+
| `ast.ts` | TypeScript AST construction and printing helpers |
|
|
34
33
|
| `read-only-comments.ts` | Standard warning comments inserted into generated type files to discourage manual edits |
|
|
35
34
|
|
|
36
35
|
## Architecture
|
|
37
36
|
|
|
37
|
+
### AST assembly
|
|
38
|
+
|
|
39
|
+
Type coders compose `TypeNode`s, and runtime coders compose `Expression`s through
|
|
40
|
+
`write()`. `Script` assembles import, export, and version declarations into a
|
|
41
|
+
`SourceFile`; the TypeScript printer emits it before Prettier formats the result.
|
|
42
|
+
Versioned operations register declaration builders rather than raw source text.
|
|
43
|
+
Context imports resolve their module paths before printing.
|
|
44
|
+
|
|
45
|
+
The standalone versions, scenario, middleware, and starter-file generators use
|
|
46
|
+
the same AST helpers. Repository regeneration reads existing route ASTs to find
|
|
47
|
+
exported handlers and imports, then inserts printed declarations without
|
|
48
|
+
reprinting user-authored text.
|
|
49
|
+
|
|
50
|
+
`ast.ts` centralizes printing, literal property names, type references, and
|
|
51
|
+
synthetic JSDoc. TypeScript is an explicit, pinned generator dependency because
|
|
52
|
+
its compiler API is used when the installed package generates files.
|
|
53
|
+
|
|
54
|
+
Keep OpenAPI traversal and file-writing policy separate from AST construction.
|
|
55
|
+
Existing route edits must survive regeneration, including when new handlers are
|
|
56
|
+
added. Check generated assignment behavior as well as snapshots when changing
|
|
57
|
+
type composition.
|
|
58
|
+
|
|
38
59
|
```
|
|
39
60
|
openapi.yaml
|
|
40
61
|
│
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CONTEXT_FILE_TOKEN = "@@CONTEXT_FILE_TOKEN@@";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const CONTEXT_FILE_TOKEN = "@@CONTEXT_FILE_TOKEN@@";
|
package/dist/printers.d.ts
DELETED
package/dist/printers.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function printObjectWithoutQuotes(entries) {
|
|
2
|
-
return `{\n${entries
|
|
3
|
-
.map(([key, value]) => `${key}: ${value}`)
|
|
4
|
-
.join(",\n")}\n}`;
|
|
5
|
-
}
|
|
6
|
-
export function printObject(entries) {
|
|
7
|
-
return `{\n${entries
|
|
8
|
-
.map(([key, value]) => `"${key}": ${value}`)
|
|
9
|
-
.join(",\n")}\n}`;
|
|
10
|
-
}
|