@counterfact/generator 0.1.4 → 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/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
- | `context-file-token.ts` | Exports a placeholder token used to reference context file paths during code generation |
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@@";
@@ -1,2 +0,0 @@
1
- export declare function printObjectWithoutQuotes(entries: [string, string][]): string;
2
- export declare function printObject(entries: [string, string][]): string;
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
- }