rune-langium / codegen/src/export / LanguageProfile
Interface: LanguageProfile<T>
Defined in: packages/codegen/src/emit/language-profile.ts:44
Declarative target-level metadata for packaging (019 spec §3.2).
A LanguageProfile<T> tells GenericModelEmitter how to assemble whole-model artifacts for target T: how to render the barrel / index file, how to concatenate per-namespace outputs into a single file, what shared sidecar artifacts (runtime helpers, manifests, READMEs) ride alongside the core outputs, and what size limits apply to the single-file layout.
Profiles exist independently of NamespaceEmitter. Targets that have no per-namespace mode (Excel, GraphQL — both WholeModelEmitter) still ship a LanguageProfile so their hand-rolled emitters can delegate sidecar generation to a uniform mechanism.
Phase 0.5.1 ships only the interface; concrete Profile instances land in 0.5.2 (Zod), 0.5.3 (TypeScript), 0.5.4 (JSON Schema), and Phases 1-3 (Excel, SQL, Markdown, GraphQL).
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends Target | Target |
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
basicTypeMap | readonly | Readonly<Record<string, BuiltinMapping>> | Declarative mapping of builtin basic type names → target representation. Covers: boolean, number, string, time, pattern. | packages/codegen/src/emit/language-profile.ts:51 |
extension | readonly | string | Output extension for this target's primary files. Mirrors the value in TARGET_DESCRIPTORS[target].extension — duplicated here so emitter implementations don't need a back-reference to the registry. | packages/codegen/src/emit/language-profile.ts:77 |
libraryFuncMap | readonly | Readonly<Record<string, LibraryFuncMapping>> | Declarative mapping of builtin library function names → host binding. null = intentionally not emitted. | packages/codegen/src/emit/language-profile.ts:69 |
recordTypeMap | readonly | Readonly<Record<string, BuiltinMapping>> | Declarative mapping of builtin record type names → target representation. Covers: date, dateTime, zonedDateTime. | packages/codegen/src/emit/language-profile.ts:57 |
singleFileLimits? | readonly | { maxBytes?: number; maxNamespaces?: number; } | Per-target guardrails for single-file layout (019 spec §10.2). When concatenate() is about to emit and either limit is exceeded, GenericModelEmitter returns a single GeneratorOutput carrying a fatal severity: 'error', code: 'single-file-too-large' diagnostic instead of the concatenated content. Strict-mode callers (CLI, /api/codegen) see a GeneratorError; non-strict callers see the diagnostic in the returned output. Defaults: Zod/TS profiles set { maxNamespaces: 50, maxBytes: 1_048_576 }. JSON Schema / SQL profiles omit limits since single-file is their canonical shape and bytes are reasonable for typical models. undefined = no limits. | packages/codegen/src/emit/language-profile.ts:138 |
singleFileLimits.maxBytes? | public | number | - | packages/codegen/src/emit/language-profile.ts:140 |
singleFileLimits.maxNamespaces? | public | number | - | packages/codegen/src/emit/language-profile.ts:139 |
target | readonly | T | - | packages/codegen/src/emit/language-profile.ts:45 |
typeAliasMap | readonly | Readonly<Record<string, BuiltinMapping>> | Declarative mapping of builtin type alias names → target representation. Covers: int, productType, eventType, calculation. | packages/codegen/src/emit/language-profile.ts:63 |
Methods
concatenate()
concatenate(perNamespaceOutputs, registry): GeneratorOutput;Defined in: packages/codegen/src/emit/language-profile.ts:104
Produce a single bundled artifact from the per-namespace outputs. Used when the resolved layout is 'single-file'. The exact shape is target-specific: Zod/TS concatenate with proper imports/exports inlined; JSON Schema collapses every type into a $defs map.
Subject to singleFileLimits — GenericModelEmitter checks the size against the profile's limits before calling this and substitutes a single-file-too-large error diagnostic if exceeded.
Parameters
| Parameter | Type |
|---|---|
perNamespaceOutputs | readonly GeneratorOutput[] |
registry | NamespaceRegistry |
Returns
makeBarrel()
makeBarrel(perNamespaceOutputs, registry): GeneratorOutput | undefined;Defined in: packages/codegen/src/emit/language-profile.ts:89
Render an index / barrel artifact that references every per-namespace output. Examples: Zod re-export module, TypeScript barrel, Markdown index.md TOC. Return undefined to signal the target has no meaningful barrel concept (JSON Schema treats single-file as canonical bundling; SQL has no module system).
Called by GenericModelEmitter only when the resolved layout is 'barrel' (or future barrel-like values).
Parameters
| Parameter | Type |
|---|---|
perNamespaceOutputs | readonly GeneratorOutput[] |
registry | NamespaceRegistry |
Returns
GeneratorOutput | undefined
makeSharedArtifacts()
makeSharedArtifacts(perNamespaceOutputs, registry): GeneratorOutput[];Defined in: packages/codegen/src/emit/language-profile.ts:117
Shared sidecar artifacts that ride alongside every whole-model emission. Examples: Zod's runtime.zod.ts (the helpers extracted via suppressBoilerplate), an Excel workbook's manifest.json, a README explaining the bundle layout. Return an empty array when the target has no sidecars.
Called by GenericModelEmitter for both 'barrel' and 'single-file' layouts. For 'single-file', sidecars produce a multi-output response (zip) instead of the bare single artifact.
Parameters
| Parameter | Type |
|---|---|
perNamespaceOutputs | readonly GeneratorOutput[] |
registry | NamespaceRegistry |