langium-zod 0.5.4 → 0.7.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/README.md +23 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +37 -0
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +5 -71
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +34 -158
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/emitters/domain.d.ts +40 -0
- package/dist/emitters/domain.d.ts.map +1 -0
- package/dist/emitters/domain.js +370 -0
- package/dist/emitters/domain.js.map +1 -0
- package/dist/generate.d.ts +70 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +183 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/projection.d.ts +5 -0
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js +17 -1
- package/dist/projection.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -64,3 +64,26 @@ Generated output uses Zod 4 and exports named schemas like `<TypeName>Schema`.
|
|
|
64
64
|
- Langium 4.x
|
|
65
65
|
- Zod 4.x
|
|
66
66
|
|
|
67
|
+
## Domain target (experimental)
|
|
68
|
+
|
|
69
|
+
Besides Zod schemas, langium-zod can emit a **domain surface** — quirk-free read
|
|
70
|
+
interfaces, a `toDomain(node)` read projection, and field-precise write accessors:
|
|
71
|
+
|
|
72
|
+
langium-zod generate --domain --domain-out src/generated/domain.ts
|
|
73
|
+
|
|
74
|
+
Mechanical rules are generic (a single cross-reference flattens to a `$refText`
|
|
75
|
+
string). Project-specific renames and read-only merges are supplied via
|
|
76
|
+
`domainOverlays` in `langium-zod.config.js`:
|
|
77
|
+
|
|
78
|
+
export default {
|
|
79
|
+
domainOverlays: {
|
|
80
|
+
types: {
|
|
81
|
+
Choice: { renames: { attributes: 'options' } },
|
|
82
|
+
RosettaFunction: { merges: [{ from: ['conditions', 'postConditions'], to: 'conditions' }] }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Merges are read-only on the merged name; write accessors target the source
|
|
88
|
+
fields (`addConditions`, `addPostConditions`) — there is no merged setter.
|
|
89
|
+
|
package/dist/api.d.ts
CHANGED
|
@@ -117,4 +117,11 @@ export type PublicZodGeneratorConfig = ZodGeneratorConfig;
|
|
|
117
117
|
* @see {@link ZodGeneratorConfig}
|
|
118
118
|
*/
|
|
119
119
|
export declare function generateZodSchemas(config: ZodGeneratorConfig): string;
|
|
120
|
+
/**
|
|
121
|
+
* Programmatic entry point for the domain target. Runs the same extract pipeline
|
|
122
|
+
* as {@link generateZodSchemas}, then emits the domain surface (read interfaces +
|
|
123
|
+
* `toDomain` projection + field-precise write accessors). Writes to
|
|
124
|
+
* `config.domainOutputPath` when set.
|
|
125
|
+
*/
|
|
126
|
+
export declare function generateDomainSchemas(config: ZodGeneratorConfig): string;
|
|
120
127
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAUtD,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAS1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAkGrE;AAcD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CA8BxE"}
|
package/dist/api.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ZodGeneratorError } from './errors.js';
|
|
|
6
6
|
import { extractTypeDescriptors } from './extractor.js';
|
|
7
7
|
import { generateZodCode } from './generator.js';
|
|
8
8
|
import { applyProjectionToDescriptors, resolveEffectiveStripFields } from './projection.js';
|
|
9
|
+
import { generateDomainCode } from './emitters/domain.js';
|
|
9
10
|
import { detectRecursiveTypes } from './recursion-detector.js';
|
|
10
11
|
function resolveAstTypes(astTypes) {
|
|
11
12
|
return {
|
|
@@ -220,4 +221,40 @@ function buildDescriptorPipeline(astTypes, config) {
|
|
|
220
221
|
});
|
|
221
222
|
return descriptors;
|
|
222
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Programmatic entry point for the domain target. Runs the same extract pipeline
|
|
226
|
+
* as {@link generateZodSchemas}, then emits the domain surface (read interfaces +
|
|
227
|
+
* `toDomain` projection + field-precise write accessors). Writes to
|
|
228
|
+
* `config.domainOutputPath` when set.
|
|
229
|
+
*/
|
|
230
|
+
export function generateDomainSchemas(config) {
|
|
231
|
+
let rawAstTypes;
|
|
232
|
+
if (config.astTypes) {
|
|
233
|
+
rawAstTypes = config.astTypes;
|
|
234
|
+
}
|
|
235
|
+
else if (config.grammar) {
|
|
236
|
+
rawAstTypes = collectAst(config.grammar);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
throw new ZodGeneratorError('Missing grammar or astTypes in ZodGeneratorConfig', {
|
|
240
|
+
suggestion: "Provide astTypes from Langium's collectAst() or pass a grammar object"
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const astTypes = resolveAstTypes(rawAstTypes);
|
|
244
|
+
const descriptors = buildDescriptorPipeline(astTypes, config);
|
|
245
|
+
// Note: regexOverrides (regex-enum upgrades) are intentionally NOT applied here —
|
|
246
|
+
// the domain surface uses type references + primitives, never regex-enum shapes.
|
|
247
|
+
const source = generateDomainCode(descriptors, {
|
|
248
|
+
projection: config.projection,
|
|
249
|
+
stripInternals: config.stripInternals,
|
|
250
|
+
overlays: config.domainOverlays,
|
|
251
|
+
// Forward config-file normalizations to the emitter (additive extends/members aliases).
|
|
252
|
+
normalizations: config.projection?.normalizations
|
|
253
|
+
});
|
|
254
|
+
if (config.domainOutputPath) {
|
|
255
|
+
mkdirSync(dirname(config.domainOutputPath), { recursive: true });
|
|
256
|
+
writeFileSync(config.domainOutputPath, source, 'utf8');
|
|
257
|
+
}
|
|
258
|
+
return source;
|
|
259
|
+
}
|
|
223
260
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAK/D,SAAS,eAAe,CAAC,QAAsB;IAC7C,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,EAAE;Q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E;YAC/E,UAAU,EAAE,uEAAuE;SACpF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9D,kFAAkF;IAClF,iFAAiF;IACjF,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE;QAC7C,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,QAAQ,EAAE,MAAM,CAAC,cAAc;QAC/B,wFAAwF;QACxF,cAAc,EAAE,MAAM,CAAC,UAAU,EAAE,cAAc;KAClD,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC5B,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,aAAa,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
/**
|
|
6
|
-
* Path to `langium-config.json`. Defaults to `langium-config.json` in cwd.
|
|
7
|
-
* Only used when picked up via the CLI; programmatic API ignores it.
|
|
8
|
-
*/
|
|
9
|
-
langiumConfig?: string;
|
|
10
|
-
/** Explicit output path. Overrides derived path from langium-config.json `out` field. */
|
|
11
|
-
outputPath?: string;
|
|
12
|
-
}
|
|
2
|
+
import type { LangiumZodConfig } from './generate.js';
|
|
3
|
+
export { generate, getUnknownFilterNames } from './generate.js';
|
|
4
|
+
export type { GenerateOptions, LangiumZodConfig } from './generate.js';
|
|
13
5
|
/**
|
|
14
6
|
* Merges CLI `--include` / `--exclude` flag values with the base filter from a
|
|
15
7
|
* user config file, producing a deduplicated, conflict-free filter pair.
|
|
@@ -28,72 +20,14 @@ export interface LangiumZodConfig extends Omit<ZodGeneratorConfig, 'grammar' | '
|
|
|
28
20
|
* generator config.
|
|
29
21
|
*/
|
|
30
22
|
export declare function resolveFilterOverrides(base: Pick<LangiumZodConfig, 'include' | 'exclude'>, includeArg?: string, excludeArg?: string): Pick<LangiumZodConfig, 'include' | 'exclude'>;
|
|
31
|
-
/**
|
|
32
|
-
* Returns the subset of `requested` names that are not present in
|
|
33
|
-
* `availableTypeNames`.
|
|
34
|
-
*
|
|
35
|
-
* Used to surface warnings when the user's `--include` or `--exclude` list
|
|
36
|
-
* references type names that do not exist in the parsed grammar, helping catch
|
|
37
|
-
* typos before generation runs.
|
|
38
|
-
*
|
|
39
|
-
* @param requested - The type names requested by the user (include or exclude
|
|
40
|
-
* list). Returns an empty array immediately when this is `undefined` or empty.
|
|
41
|
-
* @param availableTypeNames - All type names present in the parsed Langium grammar
|
|
42
|
-
* (both interface types and union/datatype rule types).
|
|
43
|
-
* @returns An array of names from `requested` that are absent from
|
|
44
|
-
* `availableTypeNames`.
|
|
45
|
-
*/
|
|
46
|
-
export declare function getUnknownFilterNames(requested: string[] | undefined, availableTypeNames: string[]): string[];
|
|
47
|
-
/**
|
|
48
|
-
* Options accepted by the programmatic {@link generate} function.
|
|
49
|
-
*
|
|
50
|
-
* Allows the core generation logic to be invoked directly from other tools or
|
|
51
|
-
* scripts without going through the CLI argument parser.
|
|
52
|
-
*/
|
|
53
|
-
export interface GenerateOptions {
|
|
54
|
-
/** Absolute path to langium-config.json */
|
|
55
|
-
langiumConfigPath: string;
|
|
56
|
-
/** Merged generator config (from user's langium-zod.config.js + CLI flags) */
|
|
57
|
-
config?: LangiumZodConfig;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Programmatic entry point for the `langium-zod generate` command.
|
|
61
|
-
*
|
|
62
|
-
* Loads `langium-config.json` from `opts.langiumConfigPath`, resolves the grammar
|
|
63
|
-
* file path, parses the grammar with Langium services (including eager import
|
|
64
|
-
* loading so cross-file references link correctly), then calls
|
|
65
|
-
* {@link generateZodSchemas} with the merged configuration. Prints a success
|
|
66
|
-
* message to stdout when generation completes.
|
|
67
|
-
*
|
|
68
|
-
* @param opts - {@link GenerateOptions} specifying the langium config path and
|
|
69
|
-
* optional pre-merged generator config.
|
|
70
|
-
* @throws `Error` when the langium-config.json or grammar file cannot be found, or
|
|
71
|
-
* when the config defines no languages.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* import { generate } from 'langium-zod';
|
|
76
|
-
* import { resolve } from 'node:path';
|
|
77
|
-
*
|
|
78
|
-
* await generate({
|
|
79
|
-
* langiumConfigPath: resolve(process.cwd(), 'langium-config.json'),
|
|
80
|
-
* config: {
|
|
81
|
-
* outputPath: 'src/generated/zod-schemas.ts',
|
|
82
|
-
* stripInternals: true,
|
|
83
|
-
* },
|
|
84
|
-
* });
|
|
85
|
-
* // Prints: ✓ Generated Zod schemas → src/generated/zod-schemas.ts
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare function generate(opts: GenerateOptions): Promise<void>;
|
|
89
23
|
/**
|
|
90
24
|
* CLI entry point executed when the `langium-zod` binary is invoked directly.
|
|
91
25
|
*
|
|
92
26
|
* Parses `process.argv`, resolves `langium-config.json`, loads an optional
|
|
93
27
|
* `langium-zod.config.js` from the same directory, merges all CLI flag overrides
|
|
94
28
|
* (--out, --include, --exclude, --projection, --strip-internals, --conformance,
|
|
95
|
-
* --cross-ref-validation), then delegates to
|
|
96
|
-
* with code 1 on error.
|
|
29
|
+
* --cross-ref-validation, --domain, --domain-only), then delegates to
|
|
30
|
+
* {@link generate}. Exits the process with code 1 on error.
|
|
97
31
|
*/
|
|
98
32
|
export declare function main(): Promise<void>;
|
|
99
33
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAoCvE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC,EACnD,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC,CAc/C;AAiDD;;;;;;;;GAQG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAkH1C"}
|
package/dist/cli.js
CHANGED
|
@@ -5,16 +5,23 @@
|
|
|
5
5
|
* Usage:
|
|
6
6
|
* langium-zod generate [--config langium-config.json] [--out src/generated/zod-schemas.ts]
|
|
7
7
|
* langium-zod --help
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This module carries the `#!` shebang and `process.argv` parsing. The programmatic
|
|
11
|
+
* generation core lives in `./generate.ts` (shebang-free) so the package's main
|
|
12
|
+
* entry can re-export `generate` without dragging the shebang into consumer bundle
|
|
13
|
+
* graphs. The moved symbols are re-exported below for backward compatibility.
|
|
8
14
|
*/
|
|
9
|
-
import { existsSync
|
|
15
|
+
import { existsSync } from 'node:fs';
|
|
10
16
|
import { dirname, join, resolve } from 'node:path';
|
|
11
17
|
import { pathToFileURL } from 'node:url';
|
|
12
|
-
import {
|
|
13
|
-
import { createLangiumGrammarServices, resolveImportUri } from 'langium/grammar';
|
|
14
|
-
import { NodeFileSystem } from 'langium/node';
|
|
15
|
-
import { generateZodSchemas } from './api.js';
|
|
16
|
-
import { resolveAstTypesPath } from './conformance.js';
|
|
18
|
+
import { generate } from './generate.js';
|
|
17
19
|
import { loadProjectionConfig } from './projection.js';
|
|
20
|
+
// Re-export the programmatic core for callers that import from the CLI entry.
|
|
21
|
+
export { generate, getUnknownFilterNames } from './generate.js';
|
|
22
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
// Argument parsing helpers
|
|
24
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
18
25
|
function parseCsvList(value) {
|
|
19
26
|
const seen = new Set();
|
|
20
27
|
const parsed = [];
|
|
@@ -68,36 +75,6 @@ export function resolveFilterOverrides(base, includeArg, excludeArg) {
|
|
|
68
75
|
exclude: excludeSource
|
|
69
76
|
};
|
|
70
77
|
}
|
|
71
|
-
function warnUnknownFilterNames(filterName, requested, availableTypeNames) {
|
|
72
|
-
const unknown = getUnknownFilterNames(requested, availableTypeNames);
|
|
73
|
-
if (unknown.length === 0) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const availableList = availableTypeNames.length > 0 ? availableTypeNames.join(', ') : '(none)';
|
|
77
|
-
console.warn(`Warning: Unknown ${filterName} type name(s): ${unknown.join(', ')}. Available types: ${availableList}`);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Returns the subset of `requested` names that are not present in
|
|
81
|
-
* `availableTypeNames`.
|
|
82
|
-
*
|
|
83
|
-
* Used to surface warnings when the user's `--include` or `--exclude` list
|
|
84
|
-
* references type names that do not exist in the parsed grammar, helping catch
|
|
85
|
-
* typos before generation runs.
|
|
86
|
-
*
|
|
87
|
-
* @param requested - The type names requested by the user (include or exclude
|
|
88
|
-
* list). Returns an empty array immediately when this is `undefined` or empty.
|
|
89
|
-
* @param availableTypeNames - All type names present in the parsed Langium grammar
|
|
90
|
-
* (both interface types and union/datatype rule types).
|
|
91
|
-
* @returns An array of names from `requested` that are absent from
|
|
92
|
-
* `availableTypeNames`.
|
|
93
|
-
*/
|
|
94
|
-
export function getUnknownFilterNames(requested, availableTypeNames) {
|
|
95
|
-
if (!requested || requested.length === 0) {
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
|
-
const available = new Set(availableTypeNames);
|
|
99
|
-
return requested.filter((name) => !available.has(name));
|
|
100
|
-
}
|
|
101
78
|
// ────────────────────────────────────────────────────────────────────────────
|
|
102
79
|
// Helpers
|
|
103
80
|
// ────────────────────────────────────────────────────────────────────────────
|
|
@@ -119,6 +96,9 @@ OPTIONS
|
|
|
119
96
|
--ast-types <path> Path to generated AST declarations (ast.ts)
|
|
120
97
|
--conformance-out <path> Output path for conformance artifact
|
|
121
98
|
--cross-ref-validation Emit runtime cross-reference schema factories
|
|
99
|
+
--domain Also emit the domain surface (domain.ts)
|
|
100
|
+
--domain-only Emit ONLY the domain surface (implies --domain, skips Zod schemas)
|
|
101
|
+
--domain-out <path> Output path for the domain surface
|
|
122
102
|
--help Show this help message
|
|
123
103
|
|
|
124
104
|
CONFIGURATION
|
|
@@ -136,126 +116,6 @@ CONFIGURATION
|
|
|
136
116
|
};
|
|
137
117
|
`);
|
|
138
118
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Recursively load imported grammar files so that DocumentBuilder can link
|
|
141
|
-
* cross-file references correctly (mirrors langium-cli's eagerLoad strategy).
|
|
142
|
-
*/
|
|
143
|
-
async function eagerLoad(document, documents, visited = new Set()) {
|
|
144
|
-
const key = document.uri.toString();
|
|
145
|
-
if (visited.has(key))
|
|
146
|
-
return;
|
|
147
|
-
visited.add(key);
|
|
148
|
-
const grammar = document.parseResult?.value;
|
|
149
|
-
if (!grammar)
|
|
150
|
-
return;
|
|
151
|
-
// Grammar.imports is an array of GrammarImport nodes; resolveImportUri handles the URI
|
|
152
|
-
const imports = grammar.imports ?? [];
|
|
153
|
-
for (const imp of imports) {
|
|
154
|
-
const importUri = resolveImportUri(imp);
|
|
155
|
-
if (importUri) {
|
|
156
|
-
const importedDoc = await documents.getOrCreateDocument(importUri);
|
|
157
|
-
await eagerLoad(importedDoc, documents, visited);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Programmatic entry point for the `langium-zod generate` command.
|
|
163
|
-
*
|
|
164
|
-
* Loads `langium-config.json` from `opts.langiumConfigPath`, resolves the grammar
|
|
165
|
-
* file path, parses the grammar with Langium services (including eager import
|
|
166
|
-
* loading so cross-file references link correctly), then calls
|
|
167
|
-
* {@link generateZodSchemas} with the merged configuration. Prints a success
|
|
168
|
-
* message to stdout when generation completes.
|
|
169
|
-
*
|
|
170
|
-
* @param opts - {@link GenerateOptions} specifying the langium config path and
|
|
171
|
-
* optional pre-merged generator config.
|
|
172
|
-
* @throws `Error` when the langium-config.json or grammar file cannot be found, or
|
|
173
|
-
* when the config defines no languages.
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```ts
|
|
177
|
-
* import { generate } from 'langium-zod';
|
|
178
|
-
* import { resolve } from 'node:path';
|
|
179
|
-
*
|
|
180
|
-
* await generate({
|
|
181
|
-
* langiumConfigPath: resolve(process.cwd(), 'langium-config.json'),
|
|
182
|
-
* config: {
|
|
183
|
-
* outputPath: 'src/generated/zod-schemas.ts',
|
|
184
|
-
* stripInternals: true,
|
|
185
|
-
* },
|
|
186
|
-
* });
|
|
187
|
-
* // Prints: ✓ Generated Zod schemas → src/generated/zod-schemas.ts
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
export async function generate(opts) {
|
|
191
|
-
const { langiumConfigPath } = opts;
|
|
192
|
-
const userConfig = opts.config ?? {};
|
|
193
|
-
// ── 1. Load langium-config.json ─────────────────────────────────────────
|
|
194
|
-
if (!existsSync(langiumConfigPath)) {
|
|
195
|
-
throw new Error(`langium-config.json not found: ${langiumConfigPath}`);
|
|
196
|
-
}
|
|
197
|
-
const langiumConfig = JSON.parse(readFileSync(langiumConfigPath, 'utf8'));
|
|
198
|
-
const configDir = dirname(langiumConfigPath);
|
|
199
|
-
const languages = langiumConfig.languages;
|
|
200
|
-
if (!languages || languages.length === 0) {
|
|
201
|
-
throw new Error('No languages defined in langium-config.json');
|
|
202
|
-
}
|
|
203
|
-
const grammarRelPath = languages[0].grammar;
|
|
204
|
-
const grammarAbsPath = resolve(configDir, grammarRelPath);
|
|
205
|
-
if (!existsSync(grammarAbsPath)) {
|
|
206
|
-
throw new Error(`Grammar file not found: ${grammarAbsPath}`);
|
|
207
|
-
}
|
|
208
|
-
// ── 2. Resolve output path ───────────────────────────────────────────────
|
|
209
|
-
const outDir = langiumConfig.out
|
|
210
|
-
? resolve(configDir, langiumConfig.out)
|
|
211
|
-
: resolve(configDir, 'src/generated');
|
|
212
|
-
const outputPath = userConfig.outputPath ?? join(outDir, 'zod-schemas.ts');
|
|
213
|
-
const conformanceConfig = userConfig.conformance;
|
|
214
|
-
if (conformanceConfig) {
|
|
215
|
-
const resolvedAstTypesPath = conformanceConfig.astTypesPath
|
|
216
|
-
? resolve(configDir, conformanceConfig.astTypesPath)
|
|
217
|
-
: langiumConfig.astTypes
|
|
218
|
-
? resolve(configDir, langiumConfig.astTypes)
|
|
219
|
-
: resolveAstTypesPath(configDir, outDir);
|
|
220
|
-
if (!existsSync(resolvedAstTypesPath)) {
|
|
221
|
-
throw new Error(`Unable to resolve ast types path for conformance: ${resolvedAstTypesPath}`);
|
|
222
|
-
}
|
|
223
|
-
userConfig.conformance = {
|
|
224
|
-
astTypesPath: resolvedAstTypesPath,
|
|
225
|
-
outputPath: conformanceConfig.outputPath
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
// ── 3. Parse grammar using Langium services ──────────────────────────────
|
|
229
|
-
const { shared, grammar: grammarServices } = createLangiumGrammarServices(NodeFileSystem);
|
|
230
|
-
void grammarServices; // used only for type-checking if needed later
|
|
231
|
-
const langiumDocuments = shared.workspace.LangiumDocuments;
|
|
232
|
-
const documentBuilder = shared.workspace.DocumentBuilder;
|
|
233
|
-
const grammarUri = URI.file(grammarAbsPath);
|
|
234
|
-
const entryDocument = await langiumDocuments.getOrCreateDocument(grammarUri);
|
|
235
|
-
// Recursively load imported files so references resolve correctly
|
|
236
|
-
await eagerLoad(entryDocument, langiumDocuments);
|
|
237
|
-
// Build (parse + link) all loaded documents
|
|
238
|
-
await documentBuilder.build(langiumDocuments.all.toArray(), {
|
|
239
|
-
validation: false
|
|
240
|
-
});
|
|
241
|
-
const grammar = entryDocument.parseResult.value;
|
|
242
|
-
const availableTypeNames = [
|
|
243
|
-
...(grammar.interfaces ?? []).map((entry) => entry.name),
|
|
244
|
-
...(grammar.types ?? []).map((entry) => entry.name)
|
|
245
|
-
]
|
|
246
|
-
.filter((name) => typeof name === 'string')
|
|
247
|
-
.sort((left, right) => left.localeCompare(right));
|
|
248
|
-
warnUnknownFilterNames('include', userConfig.include, availableTypeNames);
|
|
249
|
-
warnUnknownFilterNames('exclude', userConfig.exclude, availableTypeNames);
|
|
250
|
-
// ── 4. Generate schemas ──────────────────────────────────────────────────
|
|
251
|
-
const { langiumConfig: _ignored, outputPath: _op, ...restConfig } = userConfig;
|
|
252
|
-
generateZodSchemas({
|
|
253
|
-
grammar,
|
|
254
|
-
outputPath,
|
|
255
|
-
...restConfig
|
|
256
|
-
});
|
|
257
|
-
console.log(`✓ Generated Zod schemas → ${outputPath}`);
|
|
258
|
-
}
|
|
259
119
|
// ────────────────────────────────────────────────────────────────────────────
|
|
260
120
|
// CLI entry point
|
|
261
121
|
// ────────────────────────────────────────────────────────────────────────────
|
|
@@ -265,8 +125,8 @@ export async function generate(opts) {
|
|
|
265
125
|
* Parses `process.argv`, resolves `langium-config.json`, loads an optional
|
|
266
126
|
* `langium-zod.config.js` from the same directory, merges all CLI flag overrides
|
|
267
127
|
* (--out, --include, --exclude, --projection, --strip-internals, --conformance,
|
|
268
|
-
* --cross-ref-validation), then delegates to
|
|
269
|
-
* with code 1 on error.
|
|
128
|
+
* --cross-ref-validation, --domain, --domain-only), then delegates to
|
|
129
|
+
* {@link generate}. Exits the process with code 1 on error.
|
|
270
130
|
*/
|
|
271
131
|
export async function main() {
|
|
272
132
|
const args = process.argv.slice(2);
|
|
@@ -293,6 +153,9 @@ export async function main() {
|
|
|
293
153
|
const stripInternalsEnabled = args.includes('--strip-internals');
|
|
294
154
|
const conformanceEnabled = args.includes('--conformance');
|
|
295
155
|
const crossRefValidationEnabled = args.includes('--cross-ref-validation');
|
|
156
|
+
const domainOnlyEnabled = args.includes('--domain-only');
|
|
157
|
+
const domainEnabled = args.includes('--domain') || domainOnlyEnabled;
|
|
158
|
+
const domainOutFlagValue = getArgValue(args, '--domain-out');
|
|
296
159
|
// ── Locate langium-config.json ───────────────────────────────────────────
|
|
297
160
|
const configFileName = configFlagValue ?? 'langium-config.json';
|
|
298
161
|
const langiumConfigPath = resolve(process.cwd(), configFileName);
|
|
@@ -346,6 +209,19 @@ export async function main() {
|
|
|
346
209
|
crossRefValidation: true
|
|
347
210
|
};
|
|
348
211
|
}
|
|
212
|
+
if (domainEnabled) {
|
|
213
|
+
userConfig = {
|
|
214
|
+
...userConfig,
|
|
215
|
+
emitDomain: true,
|
|
216
|
+
// --domain-only emits the domain surface WITHOUT regenerating Zod schemas,
|
|
217
|
+
// so a domain generate can use its own (full) projection without clobbering
|
|
218
|
+
// a separately-projected zod-schemas.ts.
|
|
219
|
+
domainOnly: domainOnlyEnabled,
|
|
220
|
+
domainOutputPath: domainOutFlagValue
|
|
221
|
+
? resolve(process.cwd(), domainOutFlagValue)
|
|
222
|
+
: userConfig.domainOutputPath
|
|
223
|
+
};
|
|
224
|
+
}
|
|
349
225
|
try {
|
|
350
226
|
await generate({ langiumConfigPath, config: userConfig });
|
|
351
227
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings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gBAClC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC;gBAC5C,CAAC,CAAC,UAAU,CAAC,gBAAgB;SAChC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,EAAE,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,gDAAgD;AAChD,MAAM,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;IACvB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAE7C,IAAI,MAAM,EAAE,CAAC;IACX,KAAK,IAAI,EAAE,CAAC;AACd,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Grammar, LangiumCoreServices } from 'langium';
|
|
2
2
|
import type { AstTypesLike } from './types.js';
|
|
3
3
|
import type { ProjectionConfig } from './projection.js';
|
|
4
|
+
import type { DomainOverlayConfig } from './emitters/domain.js';
|
|
4
5
|
/**
|
|
5
6
|
* Include/exclude filter that controls which Langium type names are emitted
|
|
6
7
|
* during schema generation.
|
|
@@ -163,6 +164,14 @@ export interface ZodGeneratorConfig extends FilterConfig {
|
|
|
163
164
|
* properties.
|
|
164
165
|
*/
|
|
165
166
|
objectStyle?: 'loose' | 'strict';
|
|
167
|
+
/** When true, the CLI also emits the domain surface to `domainOutputPath`. */
|
|
168
|
+
emitDomain?: boolean;
|
|
169
|
+
/** When true (CLI `--domain-only`), emit ONLY the domain surface and skip Zod-schema generation. */
|
|
170
|
+
domainOnly?: boolean;
|
|
171
|
+
/** Output path for the generated domain surface (`domain.ts`). */
|
|
172
|
+
domainOutputPath?: string;
|
|
173
|
+
/** Project-specific semantic overlays (renames + read-only merges) supplied by the consumer for the domain target. */
|
|
174
|
+
domainOverlays?: DomainOverlayConfig;
|
|
166
175
|
}
|
|
167
176
|
/**
|
|
168
177
|
* Default output path used when no explicit `outputPath` is provided and the
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,C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src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAkLA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAElE,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IACzD,OAAO;QACL,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,EAAE;QAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,EAAE;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ZodTypeDescriptor } from '../types.js';
|
|
2
|
+
import { type ProjectionConfig } from '../projection.js';
|
|
3
|
+
export interface DomainOverlayTypeConfig {
|
|
4
|
+
/** Source field → domain field. Bidirectional: read & write both target the source. */
|
|
5
|
+
renames?: Record<string, string>;
|
|
6
|
+
/** Read-only aggregations: concat `from` source arrays into one `to` read field. */
|
|
7
|
+
merges?: Array<{
|
|
8
|
+
from: string[];
|
|
9
|
+
to: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export interface DomainOverlayConfig {
|
|
13
|
+
types?: Record<string, DomainOverlayTypeConfig>;
|
|
14
|
+
}
|
|
15
|
+
export interface NormalizationConfig {
|
|
16
|
+
/** Canonical field name to add (e.g. `'extends'` or `'members'`). */
|
|
17
|
+
as: string;
|
|
18
|
+
/**
|
|
19
|
+
* Per-kind source field: `{ TypeName: 'sourceFieldName' }`.
|
|
20
|
+
* The alias reuses the source field's already-projected `tsType` and `readExpr` verbatim.
|
|
21
|
+
* Values match the post-rename domain field name. If the source field is absent on a
|
|
22
|
+
* kind's planned fields, the alias is silently skipped for that kind.
|
|
23
|
+
*/
|
|
24
|
+
from: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export interface DomainGenerationOptions {
|
|
27
|
+
/** Reuses the Zod projection for `defaults.strip` + per-type `fields`. */
|
|
28
|
+
projection?: ProjectionConfig;
|
|
29
|
+
/** Drop `$`-internal metadata fields (`$container`, `$cstNode`, …). */
|
|
30
|
+
stripInternals?: boolean;
|
|
31
|
+
overlays?: DomainOverlayConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Additive read-only normalizations: each entry appends a canonical alias field to
|
|
34
|
+
* every kind that maps to a source field via `from`, reusing the source field's
|
|
35
|
+
* projected `tsType` and `readExpr`. No setter is emitted for alias fields.
|
|
36
|
+
*/
|
|
37
|
+
normalizations?: Record<string, NormalizationConfig>;
|
|
38
|
+
}
|
|
39
|
+
export declare function generateDomainCode(descriptors: ZodTypeDescriptor[], options?: DomainGenerationOptions): string;
|
|
40
|
+
//# sourceMappingURL=domain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../src/emitters/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAgC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAcvF,MAAM,WAAW,uBAAuB;IACtC,uFAAuF;IACvF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,oFAAoF;IACpF,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,uEAAuE;IACvE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CACtD;AA2XD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,iBAAiB,EAAE,EAChC,OAAO,GAAE,uBAA4B,GACpC,MAAM,CA2DR"}
|