@kurotako/gen-typescript 0.1.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/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/dist/index.cjs +895 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +73 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +863 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/generator.ts","../src/artifact.ts","../src/names.ts","../src/emit/enums.ts","../src/render/scalars.ts","../src/emit/aliases.ts","../src/emit/barrel.ts","../src/render/jsdoc.ts","../src/render/field.ts","../src/render/relations.ts","../src/render/variants.ts","../src/emit/entity.ts","../src/emit/filters.ts","../src/emit/scalars.ts"],"sourcesContent":["/** `@kurotako/gen-typescript` — the TypeScript generator driver. */\nexport type { TypeScriptArtifactExtra } from './artifact.js';\nexport {\n TypeScriptAliasCycleError,\n TypeScriptAliasPublicNameCollisionError,\n TypeScriptEnumCollisionError,\n TypeScriptEnumPublicNameCollisionError,\n TypeScriptGenError,\n} from './errors.js';\nexport { typescriptGenerator } from './generator.js';\n","/**\n * `@kurotako/gen-typescript` error classes.\n *\n * Codes: `typescript_alias_cycle`, `typescript_alias_public_name_collision`,\n * `typescript_enum_collision`, `typescript_enum_public_name_collision`.\n */\nexport class TypeScriptGenError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = new.target.name;\n this.code = code;\n }\n}\n\n/**\n * Source aliases in a direct `ref` cycle cannot be represented by the emitted\n * pure TypeScript aliases.\n */\nexport class TypeScriptAliasCycleError extends TypeScriptGenError {\n readonly namespace: string;\n readonly aliasNames: string[];\n\n constructor(namespace: string, aliasNames: readonly string[]) {\n const sortedNames = [...aliasNames].sort((left, right) =>\n left.localeCompare(right),\n );\n super(\n 'typescript_alias_cycle',\n `source type aliases ${sortedNames.map((name) => `'${name}'`).join(', ')} form a direct reference cycle in namespace '${namespace}'; pure TypeScript aliases cannot represent it`,\n );\n this.namespace = namespace;\n this.aliasNames = sortedNames;\n }\n}\n\n/** Source aliases cannot reuse a public identifier emitted by this generator. */\nexport class TypeScriptAliasPublicNameCollisionError extends TypeScriptGenError {\n readonly namespace: string;\n readonly names: string[];\n\n constructor(namespace: string, names: readonly string[]) {\n const sortedNames = [...names].sort((left, right) =>\n left.localeCompare(right),\n );\n super(\n 'typescript_alias_public_name_collision',\n `source type aliases ${sortedNames.map((name) => `'${name}'`).join(', ')} collide with generated public identifiers in namespace '${namespace}'; rename one of the conflicting source definitions`,\n );\n this.namespace = namespace;\n this.names = sortedNames;\n }\n}\n\n/** An enum cannot reuse a non-enum identifier exported from the namespace barrel. */\nexport class TypeScriptEnumPublicNameCollisionError extends TypeScriptGenError {\n readonly namespace: string;\n readonly names: string[];\n\n constructor(namespace: string, names: readonly string[]) {\n const sortedNames = [...names].sort((left, right) =>\n left.localeCompare(right),\n );\n super(\n 'typescript_enum_public_name_collision',\n `source enums ${sortedNames.map((name) => `'${name}'`).join(', ')} collide with other public identifiers in namespace '${namespace}'; rename one of the conflicting source definitions`,\n );\n this.namespace = namespace;\n this.names = sortedNames;\n }\n}\n\n/**\n * Two distinct `EnumDef`s reachable in one source share a name. Names both\n * origins so the schema author can resolve the collision.\n */\nexport class TypeScriptEnumCollisionError extends TypeScriptGenError {\n readonly enumName: string;\n readonly firstOrigin: string;\n readonly secondOrigin: string;\n\n constructor(enumName: string, firstOrigin: string, secondOrigin: string) {\n super(\n 'typescript_enum_collision',\n `enum '${enumName}' is defined twice with different values (${firstOrigin} vs ${secondOrigin}); ` +\n 'rename one of them in the source schema',\n );\n this.enumName = enumName;\n this.firstOrigin = firstOrigin;\n this.secondOrigin = secondOrigin;\n }\n}\n","/** `typescriptGenerator` — emits pure TypeScript declarations from the IR. */\nimport { defineGenerator } from '@kurotako/config';\nimport type { GenerateContext, GenOutput, VirtualFile } from '@kurotako/core';\nimport { buildArtifact } from './artifact.js';\nimport { emitAliases } from './emit/aliases.js';\nimport { emitBarrel } from './emit/barrel.js';\nimport { emitEntity } from './emit/entity.js';\nimport { collectEnums, emitEnums } from './emit/enums.js';\nimport { collectFilterNames, emitFilters } from './emit/filters.js';\nimport { emitScalars } from './emit/scalars.js';\nimport {\n TypeScriptAliasCycleError,\n TypeScriptAliasPublicNameCollisionError,\n TypeScriptEnumPublicNameCollisionError,\n} from './errors.js';\nimport {\n FAMILIES,\n FAMILY_TOKEN,\n typeName,\n VARIANT_TOKEN,\n VARIANTS,\n} from './names.js';\nimport { collectTypeDependencies } from './render/scalars.js';\n\nfunction sourceUsesJsonValue(\n source: GenerateContext['ir']['sources'][string],\n): boolean {\n for (const entity of Object.values(source.entities)) {\n for (const field of entity.fields) {\n if (collectTypeDependencies(field.type, source, entity).usesJsonValue) {\n return true;\n }\n }\n }\n for (const alias of Object.values(source.typeAliases ?? {})) {\n if (collectTypeDependencies(alias.type, source, undefined).usesJsonValue) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Return aliases that participate in an alias-only `ref` cycle. A cycle passing\n * through an entity is valid TypeScript because the entity emits a structural\n * object type; bare aliases have no such structure to break the recursion.\n */\nfunction cyclicAliasNames(\n source: GenerateContext['ir']['sources'][string],\n cycles: GenerateContext['cycles'],\n): string[] {\n const aliases = source.typeAliases ?? {};\n const candidates = Object.keys(aliases).filter((name) =>\n cycles.has(`${source.namespace}.${name}`),\n );\n const candidateSet = new Set(candidates);\n const references = new Map<string, string[]>();\n\n for (const name of candidates) {\n const alias = aliases[name];\n if (alias === undefined) continue;\n const dependencies = collectTypeDependencies(alias.type, source, undefined);\n references.set(\n name,\n [...dependencies.aliases].filter((dependency) =>\n candidateSet.has(dependency),\n ),\n );\n }\n\n const reachesSelf = (start: string, current: string, seen: Set<string>) => {\n for (const next of references.get(current) ?? []) {\n if (next === start) return true;\n if (!seen.has(next)) {\n seen.add(next);\n if (reachesSelf(start, next, seen)) return true;\n }\n }\n return false;\n };\n\n return candidates.filter((name) => reachesSelf(name, name, new Set([name])));\n}\n\n/** Public barrel identifiers, separated by their enum, generated, and alias origins. */\nfunction generatedPublicNames(\n source: GenerateContext['ir']['sources'][string],\n): {\n enumNames: Set<string>;\n generatedTypeNames: Set<string>;\n aliasNames: Set<string>;\n} {\n // An enum's const and type intentionally share one identifier in TypeScript's\n // separate value and type namespaces, so it is recorded only once here.\n const enumNames = new Set(collectEnums(source).map(({ name }) => name));\n const generatedTypeNames = new Set<string>();\n\n for (const entity of Object.values(source.entities)) {\n for (const variant of VARIANTS) {\n for (const family of FAMILIES) {\n generatedTypeNames.add(\n typeName(entity.name, VARIANT_TOKEN[variant], FAMILY_TOKEN[family]),\n );\n }\n }\n }\n\n for (const name of collectFilterNames(source)) generatedTypeNames.add(name);\n if (sourceUsesJsonValue(source)) generatedTypeNames.add('JsonValue');\n return {\n enumNames,\n generatedTypeNames,\n aliasNames: new Set(Object.keys(source.typeAliases ?? {})),\n };\n}\n\nfunction validateSourceEmission(\n source: GenerateContext['ir']['sources'][string],\n cycles: GenerateContext['cycles'],\n): void {\n const aliasesInCycles = cyclicAliasNames(source, cycles);\n if (aliasesInCycles.length > 0) {\n throw new TypeScriptAliasCycleError(source.namespace, aliasesInCycles);\n }\n\n const { enumNames, generatedTypeNames, aliasNames } =\n generatedPublicNames(source);\n const aliasCollisions = [...aliasNames].filter(\n (name) => enumNames.has(name) || generatedTypeNames.has(name),\n );\n if (aliasCollisions.length > 0) {\n throw new TypeScriptAliasPublicNameCollisionError(\n source.namespace,\n aliasCollisions,\n );\n }\n\n const enumCollisions = [...enumNames].filter(\n (name) => generatedTypeNames.has(name) || aliasNames.has(name),\n );\n if (enumCollisions.length > 0) {\n throw new TypeScriptEnumPublicNameCollisionError(\n source.namespace,\n enumCollisions,\n );\n }\n}\n\n/** Pure, synchronous generator with no runtime dependency on generated code. */\nexport const typescriptGenerator = defineGenerator({\n name: 'typescript',\n\n generate(ctx: GenerateContext): GenOutput {\n const files: VirtualFile[] = [];\n for (const [namespace, source] of Object.entries(ctx.ir.sources)) {\n validateSourceEmission(source, ctx.cycles);\n const prefix = `${namespace}/typescript`;\n const emitsScalars = sourceUsesJsonValue(source);\n if (emitsScalars) {\n files.push({ path: `${prefix}/scalars.ts`, content: emitScalars() });\n }\n files.push({ path: `${prefix}/enums.ts`, content: emitEnums(source) });\n if (Object.keys(source.entities).length > 0) {\n files.push({\n path: `${prefix}/filters.ts`,\n content: emitFilters(source),\n });\n }\n if (Object.keys(source.typeAliases ?? {}).length > 0) {\n files.push({\n path: `${prefix}/aliases.ts`,\n content: emitAliases(source),\n });\n }\n for (const entity of Object.values(source.entities)) {\n files.push({\n path: `${prefix}/${entity.name}.type.ts`,\n content: emitEntity(source, entity, ctx.logger),\n });\n }\n files.push({\n path: `${prefix}/index.ts`,\n content: emitBarrel(\n source,\n emitsScalars,\n Object.keys(source.typeAliases ?? {}).length > 0,\n ),\n });\n }\n return { files, artifact: buildArtifact(ctx.ir) };\n },\n});\n","/** Assemble the TypeScript generator's full artifact symbol matrix. */\nimport type { EntitySymbols, GeneratorArtifact } from '@kurotako/core';\nimport type { IR } from '@kurotako/ir';\nimport { iterEntities } from '@kurotako/ir';\nimport { collectEnums } from './emit/enums.js';\nimport {\n barrelModule,\n entityModule,\n enumConst,\n enumsModule,\n enumTypeName,\n FAMILIES,\n FAMILY_TOKEN,\n type FamilyName,\n filtersModule,\n scalarsModule,\n typeName,\n VARIANT_TOKEN,\n VARIANTS,\n type VariantName,\n} from './names.js';\n\nexport interface TypeScriptArtifactExtra {\n families: ['flat', 'deep'];\n variants: ['full', 'create', 'update', 'where', 'select'];\n perNamespace: Record<\n string,\n {\n barrelModule: string;\n filtersModule: string;\n scalarsModule: string;\n enums: Record<\n string,\n { constName: string; typeName: string; module: string }\n >;\n }\n >;\n}\n\nfunction roleStem(variant: VariantName, family: FamilyName): string {\n const variantStem = variant === 'full' ? '' : variant;\n return family === 'flat'\n ? variantStem\n : variantStem === ''\n ? 'deep'\n : `${variantStem}Deep`;\n}\n\nfunction entitySymbols(name: string): Record<string, string> {\n const symbols: Record<string, string> = {};\n for (const variant of VARIANTS) {\n for (const family of FAMILIES) {\n const stem = roleStem(variant, family);\n const key = stem === '' ? 'type' : `${stem}Type`;\n symbols[key] = typeName(\n name,\n VARIANT_TOKEN[variant],\n FAMILY_TOKEN[family],\n );\n }\n }\n return symbols;\n}\n\n/** Build the consumable metadata independently of file emission. */\nexport function buildArtifact(ir: IR): GeneratorArtifact {\n const entities: Record<string, EntitySymbols> = {};\n for (const { namespace, entity } of iterEntities(ir)) {\n entities[`${namespace}.${entity.name}`] = {\n module: entityModule(namespace, entity.name),\n symbols: entitySymbols(entity.name),\n };\n }\n\n const perNamespace: TypeScriptArtifactExtra['perNamespace'] = {};\n for (const [namespace, source] of Object.entries(ir.sources)) {\n const enums: TypeScriptArtifactExtra['perNamespace'][string]['enums'] = {};\n for (const definition of collectEnums(source)) {\n enums[definition.name] = {\n constName: enumConst(definition.name),\n typeName: enumTypeName(definition.name),\n module: enumsModule(namespace),\n };\n }\n perNamespace[namespace] = {\n barrelModule: barrelModule(namespace),\n filtersModule: filtersModule(namespace),\n scalarsModule: scalarsModule(namespace),\n enums,\n };\n }\n\n return {\n entities,\n extra: {\n families: ['flat', 'deep'],\n variants: ['full', 'create', 'update', 'where', 'select'],\n perNamespace,\n } satisfies TypeScriptArtifactExtra,\n };\n}\n","/**\n * Deterministic identifier and module-specifier helpers.\n *\n * Identifiers are never namespace-prefixed; the namespace only drives the\n * `typescript/` output sub-tree.\n */\n\n/** PascalCase variant token embedded in a type identifier. */\nexport type Variant = '' | 'Create' | 'Update' | 'Where' | 'Select';\n\n/** Relation family token embedded in a type identifier. */\nexport type Family = '' | 'Deep';\n\n/** The five variant names, in their fixed order. */\nexport const VARIANTS = [\n 'full',\n 'create',\n 'update',\n 'where',\n 'select',\n] as const;\nexport type VariantName = (typeof VARIANTS)[number];\n\n/** The two relation families, in their fixed order. */\nexport const FAMILIES = ['flat', 'deep'] as const;\nexport type FamilyName = (typeof FAMILIES)[number];\n\n/** `VariantName` -> the PascalCase token used inside identifiers. */\nexport const VARIANT_TOKEN: Record<VariantName, Variant> = {\n full: '',\n create: 'Create',\n update: 'Update',\n where: 'Where',\n select: 'Select',\n};\n\n/** `FamilyName` -> the token used inside identifiers. */\nexport const FAMILY_TOKEN: Record<FamilyName, Family> = {\n flat: '',\n deep: 'Deep',\n};\n\n/** `${Entity}${Variant}${Family}Dto`. */\nexport function typeName(\n entity: string,\n variant: Variant = '',\n family: Family = '',\n): string {\n return `${entity}${variant}${family}Dto`;\n}\n\n/** Enum `const` array identifier — the resolved `EnumDef` name verbatim. */\nexport function enumConst(name: string): string {\n return name;\n}\n\n/** Enum type alias — shares the name with `enumConst` in TypeScript's type namespace. */\nexport function enumTypeName(name: string): string {\n return name;\n}\n\n// --- module specifiers (POSIX, extension-less) -------------------------------\n\n/** `${ns}/typescript/${entity}.type`. */\nexport function entityModule(namespace: string, entity: string): string {\n return `${namespace}/typescript/${entity}.type`;\n}\n\n/** `${ns}/typescript/enums`. */\nexport function enumsModule(namespace: string): string {\n return `${namespace}/typescript/enums`;\n}\n\n/** `${ns}/typescript/filters`. */\nexport function filtersModule(namespace: string): string {\n return `${namespace}/typescript/filters`;\n}\n\n/** `${ns}/typescript/scalars`. */\nexport function scalarsModule(namespace: string): string {\n return `${namespace}/typescript/scalars`;\n}\n\n/** `${ns}/typescript` — this generator's own barrel. */\nexport function barrelModule(namespace: string): string {\n return `${namespace}/typescript`;\n}\n","/** Source enums -> the shared enums.ts module. */\nimport type { EnumDef, SourceIR } from '@kurotako/ir';\nimport { TypeScriptEnumCollisionError } from '../errors.js';\nimport { enumConst, enumTypeName } from '../names.js';\n\nfunction sameValues(a: EnumDef, b: EnumDef): boolean {\n const left = a.values.map((value) => value.name);\n const right = b.values.map((value) => value.name);\n return (\n left.length === right.length && left.every((value, i) => value === right[i])\n );\n}\n\n/** All reachable definitions, deduplicated and sorted by their identifier. */\nexport function collectEnums(source: SourceIR): EnumDef[] {\n const byName = new Map<string, { definition: EnumDef; origin: string }>();\n const add = (definition: EnumDef, origin: string): void => {\n const previous = byName.get(definition.name);\n if (previous === undefined) {\n byName.set(definition.name, { definition, origin });\n } else if (!sameValues(previous.definition, definition)) {\n throw new TypeScriptEnumCollisionError(\n definition.name,\n previous.origin,\n origin,\n );\n }\n };\n\n for (const definition of Object.values(source.enums))\n add(definition, 'source-level');\n for (const entity of Object.values(source.entities)) {\n for (const definition of Object.values(entity.enums ?? {})) {\n add(definition, `entity '${entity.name}'`);\n }\n }\n\n return [...byName.values()]\n .map(({ definition }) => definition)\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\n/** Emit type/value enum pairs, which legally share an identifier in TypeScript. */\nexport function emitEnums(source: SourceIR): string {\n const blocks = collectEnums(source).map((definition) => {\n const values = definition.values\n .map((value) => JSON.stringify(value.name))\n .join(', ');\n const name = enumConst(definition.name);\n return `export const ${name} = [${values}] as const;\\nexport type ${enumTypeName(definition.name)} = (typeof ${name})[number];`;\n });\n return blocks.length === 0 ? 'export {};\\n' : `${blocks.join('\\n\\n')}\\n`;\n}\n","/** Field types -> bare TypeScript type strings and their emitted dependencies. */\nimport type { Entity, Field, FieldType, SourceIR } from '@kurotako/ir';\nimport { flattenUnion, resolveEnum, scalarTsType } from '@kurotako/ir';\nimport { typeName } from '../names.js';\n\nexport interface TypeDependencies {\n enums: Set<string>;\n entityRefs: Set<string>;\n aliases: Set<string>;\n usesJsonValue: boolean;\n}\n\nfunction emptyDependencies(): TypeDependencies {\n return {\n enums: new Set(),\n entityRefs: new Set(),\n aliases: new Set(),\n usesJsonValue: false,\n };\n}\n\n/** Collect imports required by a field type, including refs nested in unions. */\nexport function collectTypeDependencies(\n type: FieldType,\n source: SourceIR,\n entity: Entity | undefined,\n into: TypeDependencies = emptyDependencies(),\n): TypeDependencies {\n switch (type.kind) {\n case 'enum': {\n const definition = resolveEnum(source, entity, type.ref);\n into.enums.add(definition?.name ?? type.ref);\n break;\n }\n case 'ref':\n if (source.entities[type.ref] !== undefined) {\n into.entityRefs.add(type.ref);\n } else if (source.typeAliases?.[type.ref] !== undefined) {\n into.aliases.add(type.ref);\n }\n break;\n case 'scalar':\n if (scalarTsType(type) === 'JsonValue') {\n into.usesJsonValue = true;\n }\n break;\n case 'union':\n for (const variant of type.variants) {\n collectTypeDependencies(variant, source, entity, into);\n }\n break;\n case 'unknown':\n break;\n }\n return into;\n}\n\n/**\n * Render a `FieldType` recursively. Entity refs name their emitted flat DTO;\n * type-alias refs retain their declared name from the source alias registry.\n */\nexport function renderFieldType(type: FieldType, source: SourceIR): string {\n switch (type.kind) {\n case 'ref':\n return source.entities[type.ref] !== undefined\n ? typeName(type.ref)\n : type.ref;\n case 'union': {\n const variants = flattenUnion(type);\n return variants.length === 0\n ? 'unknown'\n : variants\n .map((variant) =>\n variant.kind === 'union'\n ? `(${renderFieldType(variant, source)})`\n : renderFieldType(variant, source),\n )\n .join(' | ');\n }\n case 'scalar':\n case 'enum':\n case 'unknown':\n return scalarTsType(type);\n }\n}\n\n/** The non-list, non-nullable type for a field. */\nexport function fieldTsType(\n field: Field,\n source: SourceIR,\n entity: Entity,\n): string {\n collectTypeDependencies(field.type, source, entity);\n return renderFieldType(field.type, source);\n}\n","/** Source type aliases -> the shared aliases.ts declaration module. */\nimport type { SourceIR } from '@kurotako/ir';\nimport { typeName } from '../names.js';\nimport { collectTypeDependencies, renderFieldType } from '../render/scalars.js';\n\n/** Emit source aliases and imports for their external entity/enum dependencies. */\nexport function emitAliases(source: SourceIR): string {\n const aliases = Object.values(source.typeAliases ?? {});\n const enums = new Set<string>();\n const entityRefs = new Set<string>();\n let usesJsonValue = false;\n\n for (const alias of aliases) {\n const dependencies = collectTypeDependencies(alias.type, source, undefined);\n for (const name of dependencies.enums) enums.add(name);\n for (const name of dependencies.entityRefs) entityRefs.add(name);\n usesJsonValue ||= dependencies.usesJsonValue;\n }\n\n const imports: Array<{ specifier: string; names: string[] }> = [];\n if (enums.size > 0) {\n imports.push({ specifier: './enums', names: [...enums] });\n }\n if (usesJsonValue) {\n imports.push({ specifier: './scalars', names: ['JsonValue'] });\n }\n for (const ref of entityRefs) {\n imports.push({\n specifier: `./${ref}.type`,\n names: [typeName(ref)],\n });\n }\n\n const blocks = aliases.map((alias) => {\n const doc = alias.doc === undefined ? '' : `/** ${alias.doc} */\\n`;\n return `${doc}export type ${alias.name} = ${renderFieldType(alias.type, source)};`;\n });\n const importBlock = imports\n .sort((left, right) => left.specifier.localeCompare(right.specifier))\n .map(\n ({ specifier, names }) =>\n `import type { ${names.sort((left, right) => left.localeCompare(right)).join(', ')} } from '${specifier}';`,\n )\n .join('\\n');\n\n return `${[importBlock, ...blocks].filter((block) => block !== '').join('\\n\\n')}\\n`;\n}\n","/** This generator's per-namespace barrel. */\nimport type { SourceIR } from '@kurotako/ir';\n\n/** Re-export every emitted shared and entity declaration module. */\nexport function emitBarrel(\n source: SourceIR,\n emitsScalars: boolean,\n emitsAliases = Object.keys(source.typeAliases ?? {}).length > 0,\n): string {\n const lines: string[] = [];\n if (emitsScalars) lines.push(\"export type * from './scalars';\");\n lines.push(\"export * from './enums';\");\n if (emitsAliases) lines.push(\"export type * from './aliases';\");\n if (Object.keys(source.entities).length > 0) {\n lines.push(\"export type * from './filters';\");\n }\n for (const entity of Object.values(source.entities)) {\n lines.push(`export type * from './${entity.name}.type';`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n","/** Field documentation and constraints -> an optional JSDoc block. */\nimport type { Field } from '@kurotako/ir';\n\n/** Render documentation-only metadata in a stable, human-readable order. */\nexport function jsDoc(field: Field): string {\n const tags: string[] = [];\n const constraints = field.constraints;\n\n if (constraints.min !== undefined) tags.push(`@min ${constraints.min}`);\n if (constraints.max !== undefined) tags.push(`@max ${constraints.max}`);\n if (constraints.minLength !== undefined) {\n tags.push(`@minLength ${constraints.minLength}`);\n }\n if (constraints.maxLength !== undefined) {\n tags.push(`@maxLength ${constraints.maxLength}`);\n }\n if (constraints.regex !== undefined) {\n tags.push(`@pattern ${constraints.regex}`);\n }\n if (constraints.format !== undefined) {\n tags.push(`@format ${constraints.format}`);\n }\n if (constraints.unique) tags.push('@unique');\n if (field.default?.kind === 'value') {\n tags.push(`@default ${JSON.stringify(field.default.value)}`);\n }\n if (field.type.kind === 'unknown') {\n tags.push(\n field.type.hint === undefined\n ? '@see unknown'\n : `@see unknown: ${field.type.hint}`,\n );\n }\n\n const prose = field.doc?.split('\\n') ?? [];\n if (prose.length === 0 && tags.length === 0) {\n return '';\n }\n\n const lines = [...prose];\n if (prose.length > 0 && tags.length > 0) lines.push('');\n lines.push(...tags);\n return ['/**', ...lines.map((line) => ` * ${line}`), ' */'].join('\\n');\n}\n","/** Assemble scalar and enum fields into TypeScript object members. */\nimport type { Entity, Field, SourceIR } from '@kurotako/ir';\nimport { jsDoc } from './jsdoc.js';\nimport { fieldTsType } from './scalars.js';\n\nexport interface MemberLineOptions {\n optional: boolean;\n}\n\n/** Render one field member, including documentation and list/null wrappers. */\nexport function memberLine(\n field: Field,\n opts: MemberLineOptions,\n source: SourceIR,\n entity: Entity,\n): string {\n let type = fieldTsType(field, source, entity);\n if (field.list) {\n if (type.includes(' | ')) type = `(${type})`;\n type = `${type}[]`;\n }\n if (field.nullable) type = `${type} | null`;\n\n const member = ` ${field.name}${opts.optional ? '?' : ''}: ${type};`;\n const doc = jsDoc(field);\n const indentedDoc = doc\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n');\n return doc === '' ? member : `${indentedDoc}\\n${member}`;\n}\n","/** Flat versus deep relation members. */\nimport type { Logger } from '@kurotako/core';\nimport type { Relation } from '@kurotako/ir';\nimport { isCrossSource } from '@kurotako/ir';\nimport {\n type FamilyName,\n typeName,\n VARIANT_TOKEN,\n type VariantName,\n} from '../names.js';\n\nexport interface RelationMember {\n type: string;\n optional: boolean;\n}\n\nexport interface RelationMemberOptions {\n fromNamespace: string;\n logger?: Logger;\n}\n\n/**\n * Render a relation member for the deep family. Cross-source links deliberately\n * stay flat because v1 has no stable cross-namespace module mapping.\n */\nexport function relationMember(\n relation: Relation,\n family: FamilyName,\n variant: VariantName,\n opts: RelationMemberOptions,\n): RelationMember | null {\n if (family === 'flat') return null;\n if (isCrossSource(opts.fromNamespace, relation)) {\n opts.logger?.debug(\n `gen-typescript: relation '${relation.name}' targets another source ('${relation.target.namespace}.${relation.target.entity}'); degrading to the FK id (flat) in the deep family`,\n );\n return null;\n }\n\n const target = relation.target.entity;\n const many = relation.cardinality === 'many';\n if (variant === 'where') {\n const dto = typeName(target, 'Where', 'Deep');\n return {\n type: many ? `{ some?: ${dto}; every?: ${dto}; none?: ${dto} }` : dto,\n optional: true,\n };\n }\n if (variant === 'select') {\n return {\n type: `boolean | ${typeName(target, 'Select', 'Deep')}`,\n optional: true,\n };\n }\n\n return {\n type: many\n ? `${typeName(target, VARIANT_TOKEN[variant], 'Deep')}[]`\n : typeName(target, VARIANT_TOKEN[variant], 'Deep'),\n optional: relation.optional || many || variant === 'update',\n };\n}\n","/** Shared payload field selection and Where-filter classification. */\nimport type { Entity, Field } from '@kurotako/ir';\nimport { createFields, isCreateOptional, updateFields } from '@kurotako/ir';\nimport type { VariantName } from '../names.js';\n\nexport interface FieldSelection {\n field: Field;\n optional: boolean;\n}\n\n/** The scalar/enum fields included by a generated type variant. */\nexport function variantFields(\n entity: Entity,\n variant: VariantName,\n): FieldSelection[] {\n switch (variant) {\n case 'full':\n return entity.fields.map((field) => ({\n field,\n optional: field.optional,\n }));\n case 'create':\n return createFields(entity).map((field) => ({\n field,\n optional: isCreateOptional(field),\n }));\n case 'update':\n return updateFields(entity).map((field) => ({ field, optional: true }));\n case 'where':\n case 'select':\n return entity.fields.map((field) => ({ field, optional: true }));\n }\n}\n\n/** The Where filter type for a direct scalar or enum field. */\nexport function filterClass(field: Field): string | null {\n if (field.type.kind === 'enum') return `Enum${field.type.ref}Filter`;\n if (field.type.kind !== 'scalar') return null;\n\n switch (field.type.scalar) {\n case 'string':\n case 'uuid':\n case 'decimal':\n case 'bytes':\n return 'StringFilter';\n case 'int':\n return 'IntFilter';\n case 'float':\n return 'FloatFilter';\n case 'bigint':\n return 'BigIntFilter';\n case 'boolean':\n return 'BoolFilter';\n case 'date':\n case 'datetime':\n return 'DateTimeFilter';\n case 'json':\n return null;\n }\n}\n","/** One entity -> its ten flat/deep TypeScript declaration variants. */\nimport type { Logger } from '@kurotako/core';\nimport type { Entity, SourceIR } from '@kurotako/ir';\nimport {\n FAMILIES,\n FAMILY_TOKEN,\n type FamilyName,\n typeName,\n VARIANT_TOKEN,\n VARIANTS,\n type VariantName,\n} from '../names.js';\nimport { memberLine } from '../render/field.js';\nimport { type RelationMember, relationMember } from '../render/relations.js';\nimport { collectTypeDependencies } from '../render/scalars.js';\nimport { filterClass, variantFields } from '../render/variants.js';\n\nfunction typeBlock(name: string, members: string[]): string {\n return `export type ${name} = {\\n${members.join('\\n')}\\n};`;\n}\n\nfunction relationLine(name: string, member: RelationMember): string {\n return ` ${name}${member.optional ? '?' : ''}: ${member.type};`;\n}\n\n/** Emit a type-only, specifier-sorted import block. */\nfunction importsFor(\n enums: Set<string>,\n aliases: Set<string>,\n filters: Set<string>,\n usesJsonValue: boolean,\n siblings: Map<string, Set<string>>,\n): string {\n const imports: Array<{ specifier: string; names: string[] }> = [];\n if (aliases.size > 0) {\n imports.push({ specifier: './aliases', names: [...aliases] });\n }\n if (enums.size > 0) {\n imports.push({ specifier: './enums', names: [...enums] });\n }\n if (filters.size > 0) {\n imports.push({ specifier: './filters', names: [...filters] });\n }\n if (usesJsonValue) {\n imports.push({ specifier: './scalars', names: ['JsonValue'] });\n }\n for (const [entity, names] of siblings) {\n imports.push({ specifier: `./${entity}.type`, names: [...names] });\n }\n return imports\n .sort((left, right) => left.specifier.localeCompare(right.specifier))\n .map(\n ({ specifier, names }) =>\n `import type { ${names.sort((left, right) => left.localeCompare(right)).join(', ')} } from '${specifier}';`,\n )\n .join('\\n');\n}\n\n/** Render an entity's complete variant/family matrix. */\nexport function emitEntity(\n source: SourceIR,\n entity: Entity,\n logger?: Logger,\n): string {\n const usedEnums = new Set<string>();\n const usedAliases = new Set<string>();\n const usedEntityRefs = new Set<string>();\n let usesJsonValue = false;\n const usedFilters = new Set<string>();\n const siblings = new Map<string, Set<string>>();\n\n for (const field of entity.fields) {\n const dependencies = collectTypeDependencies(field.type, source, entity);\n for (const name of dependencies.enums) usedEnums.add(name);\n for (const name of dependencies.aliases) usedAliases.add(name);\n for (const name of dependencies.entityRefs) usedEntityRefs.add(name);\n usesJsonValue ||= dependencies.usesJsonValue;\n }\n\n const trackSibling = (target: string, name: string): void => {\n if (target === entity.name) return;\n const names = siblings.get(target) ?? new Set<string>();\n names.add(name);\n siblings.set(target, names);\n };\n\n for (const ref of usedEntityRefs) {\n trackSibling(ref, typeName(ref));\n }\n\n const relation = (\n relationIndex: number,\n variant: VariantName,\n ): RelationMember | null => {\n const current = entity.relations[relationIndex];\n if (current === undefined) return null;\n const member = relationMember(current, 'deep', variant, {\n fromNamespace: source.namespace,\n logger,\n });\n if (member !== null) {\n trackSibling(\n current.target.entity,\n typeName(current.target.entity, VARIANT_TOKEN[variant], 'Deep'),\n );\n }\n return member;\n };\n\n const blocks: string[] = [];\n for (const variant of VARIANTS) {\n for (const family of FAMILIES) {\n const name = typeName(\n entity.name,\n VARIANT_TOKEN[variant],\n FAMILY_TOKEN[family],\n );\n if (variant === 'where') {\n blocks.push(renderWhere(name, family));\n } else if (variant === 'select') {\n blocks.push(renderSelect(name, family));\n } else {\n blocks.push(renderRecord(name, variant, family));\n }\n }\n }\n\n const imports = importsFor(\n usedEnums,\n usedAliases,\n usedFilters,\n usesJsonValue,\n siblings,\n );\n return `${[imports, '', ...blocks].join('\\n\\n').trim()}\\n`;\n\n function renderRecord(\n name: string,\n variant: Exclude<VariantName, 'where' | 'select'>,\n family: FamilyName,\n ): string {\n const own = variantFields(entity, variant).map((selection) =>\n memberLine(\n selection.field,\n { optional: variant === 'update' ? false : selection.optional },\n source,\n entity,\n ),\n );\n const relations: string[] = [];\n if (family === 'deep') {\n for (let index = 0; index < entity.relations.length; index += 1) {\n const current = entity.relations[index];\n const member = relation(index, variant);\n if (current !== undefined && member !== null) {\n relations.push(relationLine(current.name, member));\n }\n }\n }\n\n if (variant === 'update') {\n const base = `Partial<{\\n${own.join('\\n')}\\n}>`;\n return relations.length === 0\n ? `export type ${name} = ${base};`\n : `export type ${name} = ${base} & {\\n${relations.join('\\n')}\\n};`;\n }\n return typeBlock(name, [...own, ...relations]);\n }\n\n function renderWhere(name: string, family: FamilyName): string {\n const members: string[] = [];\n for (const field of entity.fields) {\n const filter = filterClass(field);\n if (filter === null) continue;\n usedFilters.add(filter);\n members.push(` ${field.name}?: ${filter};`);\n }\n if (family === 'deep') {\n for (let index = 0; index < entity.relations.length; index += 1) {\n const current = entity.relations[index];\n const member = relation(index, 'where');\n if (current !== undefined && member !== null) {\n members.push(relationLine(current.name, member));\n }\n }\n }\n members.push(\n ` AND?: ${name} | ${name}[];`,\n ` OR?: ${name} | ${name}[];`,\n ` NOT?: ${name} | ${name}[];`,\n );\n return typeBlock(name, members);\n }\n\n function renderSelect(name: string, family: FamilyName): string {\n const members = entity.fields.map((field) => ` ${field.name}?: boolean;`);\n for (let index = 0; index < entity.relations.length; index += 1) {\n const current = entity.relations[index];\n if (current === undefined) continue;\n if (family === 'flat') {\n members.push(` ${current.name}?: boolean;`);\n continue;\n }\n const member = relation(index, 'select');\n members.push(\n member === null\n ? ` ${current.name}?: boolean;`\n : relationLine(current.name, member),\n );\n }\n return typeBlock(name, members);\n }\n}\n","/** Shared Prisma-style Where filter interfaces. */\nimport type { SourceIR } from '@kurotako/ir';\nimport { scalarTsType } from '@kurotako/ir';\nimport { enumTypeName } from '../names.js';\nimport { filterClass } from '../render/variants.js';\n\nconst EQUALITY_OPS = ['equals', 'not'] as const;\nconst LIST_OPS = ['in', 'notIn'] as const;\nconst ORDER_OPS = ['lt', 'lte', 'gt', 'gte'] as const;\nconst STRING_OPS = ['contains', 'startsWith', 'endsWith'] as const;\nconst SCALAR_FILTER_ORDER = [\n 'StringFilter',\n 'IntFilter',\n 'FloatFilter',\n 'BigIntFilter',\n 'DateTimeFilter',\n 'BoolFilter',\n] as const;\n\ntype ScalarFilter = (typeof SCALAR_FILTER_ORDER)[number];\n\n/** Collect the public filter interface identifiers emitted for a source. */\nexport function collectFilterNames(source: SourceIR): Set<string> {\n const names = new Set<string>();\n for (const entity of Object.values(source.entities)) {\n for (const field of entity.fields) {\n const filter = filterClass(field);\n if (filter !== null) names.add(filter);\n }\n }\n return names;\n}\n\nfunction baseType(name: ScalarFilter): string {\n switch (name) {\n case 'StringFilter':\n return scalarTsType({ kind: 'scalar', scalar: 'string' });\n case 'IntFilter':\n case 'FloatFilter':\n return scalarTsType({ kind: 'scalar', scalar: 'int' });\n case 'BigIntFilter':\n return scalarTsType({ kind: 'scalar', scalar: 'bigint' });\n case 'DateTimeFilter':\n return scalarTsType({ kind: 'scalar', scalar: 'datetime' });\n case 'BoolFilter':\n return scalarTsType({ kind: 'scalar', scalar: 'boolean' });\n }\n}\n\nfunction operations(name: string): readonly string[] {\n if (name === 'BoolFilter') return EQUALITY_OPS;\n if (name === 'StringFilter') {\n return [...EQUALITY_OPS, ...LIST_OPS, ...ORDER_OPS, ...STRING_OPS];\n }\n return [...EQUALITY_OPS, ...LIST_OPS, ...ORDER_OPS];\n}\n\nfunction emitInterface(\n name: string,\n type: string,\n ops: readonly string[],\n): string {\n const members = ops.map((operation) => {\n const list = (LIST_OPS as readonly string[]).includes(operation);\n return ` ${operation}?: ${list ? `${type}[]` : type};`;\n });\n return `export interface ${name} {\\n${members.join('\\n')}\\n}`;\n}\n\n/** Emit only the direct scalar and enum classes used by a source's fields. */\nexport function emitFilters(source: SourceIR): string {\n const scalars = new Set<string>();\n const enums = new Set<string>();\n for (const entity of Object.values(source.entities)) {\n for (const field of entity.fields) {\n const filter = filterClass(field);\n if (filter === null) continue;\n if (field.type.kind === 'enum') enums.add(field.type.ref);\n else scalars.add(filter);\n }\n }\n\n const enumNames = [...enums].sort((left, right) => left.localeCompare(right));\n const blocks: string[] = [];\n for (const name of SCALAR_FILTER_ORDER) {\n if (scalars.has(name))\n blocks.push(emitInterface(name, baseType(name), operations(name)));\n }\n for (const name of enumNames) {\n blocks.push(\n emitInterface(`Enum${name}Filter`, enumTypeName(name), [\n ...EQUALITY_OPS,\n ...LIST_OPS,\n ]),\n );\n }\n\n const imports =\n enumNames.length === 0\n ? ''\n : `import type { ${enumNames.map(enumTypeName).join(', ')} } from './enums';\\n\\n`;\n return blocks.length === 0\n ? 'export {};\\n'\n : `${imports}${blocks.join('\\n\\n')}\\n`;\n}\n","/** The JsonValue helper emitted when at least one field needs it. */\nexport function emitScalars(): string {\n return `export type JsonValue =\n | null\n | boolean\n | number\n | string\n | JsonValue[]\n | { [key: string]: JsonValue };\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC;AAAA,EAET,YAAY,MAAc,SAAiB,SAA+B;AACxE,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO,WAAW;AACvB,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,4BAAN,cAAwC,mBAAmB;AAAA,EACvD;AAAA,EACA;AAAA,EAET,YAAY,WAAmB,YAA+B;AAC5D,UAAM,cAAc,CAAC,GAAG,UAAU,EAAE;AAAA,MAAK,CAAC,MAAM,UAC9C,KAAK,cAAc,KAAK;AAAA,IAC1B;AACA;AAAA,MACE;AAAA,MACA,uBAAuB,YAAY,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG,EAAE,KAAK,IAAI,CAAC,gDAAgD,SAAS;AAAA,IACnI;AACA,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;AAGO,IAAM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,iBAAW,UAAU,OAAO,OAAO,OAAO,QAAQ,GAAG;AACnD,cAAM,KAAK;AAAA,UACT,MAAM,GAAG,MAAM,IAAI,OAAO,IAAI;AAAA,UAC9B,SAAS,WAAW,QAAQ,QAAQ,IAAI,MAAM;AAAA,QAChD,CAAC;AAAA,MACH;AACA,YAAM,KAAK;AAAA,QACT,MAAM,GAAG,MAAM;AAAA,QACf,SAAS;AAAA,UACP;AAAA,UACA;AAAA,UACA,OAAO,KAAK,OAAO,eAAe,CAAC,CAAC,EAAE,SAAS;AAAA,QACjD;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO,EAAE,OAAO,UAAU,cAAc,IAAI,EAAE,EAAE;AAAA,EAClD;AACF,CAAC;","names":["import_ir","import_ir","import_ir","import_ir"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GenerateContext, GenOutput } from '@kurotako/core';
|
|
2
|
+
|
|
3
|
+
/** Assemble the TypeScript generator's full artifact symbol matrix. */
|
|
4
|
+
|
|
5
|
+
interface TypeScriptArtifactExtra {
|
|
6
|
+
families: ['flat', 'deep'];
|
|
7
|
+
variants: ['full', 'create', 'update', 'where', 'select'];
|
|
8
|
+
perNamespace: Record<string, {
|
|
9
|
+
barrelModule: string;
|
|
10
|
+
filtersModule: string;
|
|
11
|
+
scalarsModule: string;
|
|
12
|
+
enums: Record<string, {
|
|
13
|
+
constName: string;
|
|
14
|
+
typeName: string;
|
|
15
|
+
module: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `@kurotako/gen-typescript` error classes.
|
|
22
|
+
*
|
|
23
|
+
* Codes: `typescript_alias_cycle`, `typescript_alias_public_name_collision`,
|
|
24
|
+
* `typescript_enum_collision`, `typescript_enum_public_name_collision`.
|
|
25
|
+
*/
|
|
26
|
+
declare class TypeScriptGenError extends Error {
|
|
27
|
+
readonly code: string;
|
|
28
|
+
constructor(code: string, message: string, options?: {
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Source aliases in a direct `ref` cycle cannot be represented by the emitted
|
|
34
|
+
* pure TypeScript aliases.
|
|
35
|
+
*/
|
|
36
|
+
declare class TypeScriptAliasCycleError extends TypeScriptGenError {
|
|
37
|
+
readonly namespace: string;
|
|
38
|
+
readonly aliasNames: string[];
|
|
39
|
+
constructor(namespace: string, aliasNames: readonly string[]);
|
|
40
|
+
}
|
|
41
|
+
/** Source aliases cannot reuse a public identifier emitted by this generator. */
|
|
42
|
+
declare class TypeScriptAliasPublicNameCollisionError extends TypeScriptGenError {
|
|
43
|
+
readonly namespace: string;
|
|
44
|
+
readonly names: string[];
|
|
45
|
+
constructor(namespace: string, names: readonly string[]);
|
|
46
|
+
}
|
|
47
|
+
/** An enum cannot reuse a non-enum identifier exported from the namespace barrel. */
|
|
48
|
+
declare class TypeScriptEnumPublicNameCollisionError extends TypeScriptGenError {
|
|
49
|
+
readonly namespace: string;
|
|
50
|
+
readonly names: string[];
|
|
51
|
+
constructor(namespace: string, names: readonly string[]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Two distinct `EnumDef`s reachable in one source share a name. Names both
|
|
55
|
+
* origins so the schema author can resolve the collision.
|
|
56
|
+
*/
|
|
57
|
+
declare class TypeScriptEnumCollisionError extends TypeScriptGenError {
|
|
58
|
+
readonly enumName: string;
|
|
59
|
+
readonly firstOrigin: string;
|
|
60
|
+
readonly secondOrigin: string;
|
|
61
|
+
constructor(enumName: string, firstOrigin: string, secondOrigin: string);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Pure, synchronous generator with no runtime dependency on generated code. */
|
|
65
|
+
declare const typescriptGenerator: {
|
|
66
|
+
name: string;
|
|
67
|
+
dependsOn?: string[];
|
|
68
|
+
optionalDependsOn?: string[];
|
|
69
|
+
optionsSchema?: undefined;
|
|
70
|
+
generate(ctx: GenerateContext, options: void): GenOutput | Promise<GenOutput>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { TypeScriptAliasCycleError, TypeScriptAliasPublicNameCollisionError, type TypeScriptArtifactExtra, TypeScriptEnumCollisionError, TypeScriptEnumPublicNameCollisionError, TypeScriptGenError, typescriptGenerator };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GenerateContext, GenOutput } from '@kurotako/core';
|
|
2
|
+
|
|
3
|
+
/** Assemble the TypeScript generator's full artifact symbol matrix. */
|
|
4
|
+
|
|
5
|
+
interface TypeScriptArtifactExtra {
|
|
6
|
+
families: ['flat', 'deep'];
|
|
7
|
+
variants: ['full', 'create', 'update', 'where', 'select'];
|
|
8
|
+
perNamespace: Record<string, {
|
|
9
|
+
barrelModule: string;
|
|
10
|
+
filtersModule: string;
|
|
11
|
+
scalarsModule: string;
|
|
12
|
+
enums: Record<string, {
|
|
13
|
+
constName: string;
|
|
14
|
+
typeName: string;
|
|
15
|
+
module: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `@kurotako/gen-typescript` error classes.
|
|
22
|
+
*
|
|
23
|
+
* Codes: `typescript_alias_cycle`, `typescript_alias_public_name_collision`,
|
|
24
|
+
* `typescript_enum_collision`, `typescript_enum_public_name_collision`.
|
|
25
|
+
*/
|
|
26
|
+
declare class TypeScriptGenError extends Error {
|
|
27
|
+
readonly code: string;
|
|
28
|
+
constructor(code: string, message: string, options?: {
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Source aliases in a direct `ref` cycle cannot be represented by the emitted
|
|
34
|
+
* pure TypeScript aliases.
|
|
35
|
+
*/
|
|
36
|
+
declare class TypeScriptAliasCycleError extends TypeScriptGenError {
|
|
37
|
+
readonly namespace: string;
|
|
38
|
+
readonly aliasNames: string[];
|
|
39
|
+
constructor(namespace: string, aliasNames: readonly string[]);
|
|
40
|
+
}
|
|
41
|
+
/** Source aliases cannot reuse a public identifier emitted by this generator. */
|
|
42
|
+
declare class TypeScriptAliasPublicNameCollisionError extends TypeScriptGenError {
|
|
43
|
+
readonly namespace: string;
|
|
44
|
+
readonly names: string[];
|
|
45
|
+
constructor(namespace: string, names: readonly string[]);
|
|
46
|
+
}
|
|
47
|
+
/** An enum cannot reuse a non-enum identifier exported from the namespace barrel. */
|
|
48
|
+
declare class TypeScriptEnumPublicNameCollisionError extends TypeScriptGenError {
|
|
49
|
+
readonly namespace: string;
|
|
50
|
+
readonly names: string[];
|
|
51
|
+
constructor(namespace: string, names: readonly string[]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Two distinct `EnumDef`s reachable in one source share a name. Names both
|
|
55
|
+
* origins so the schema author can resolve the collision.
|
|
56
|
+
*/
|
|
57
|
+
declare class TypeScriptEnumCollisionError extends TypeScriptGenError {
|
|
58
|
+
readonly enumName: string;
|
|
59
|
+
readonly firstOrigin: string;
|
|
60
|
+
readonly secondOrigin: string;
|
|
61
|
+
constructor(enumName: string, firstOrigin: string, secondOrigin: string);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Pure, synchronous generator with no runtime dependency on generated code. */
|
|
65
|
+
declare const typescriptGenerator: {
|
|
66
|
+
name: string;
|
|
67
|
+
dependsOn?: string[];
|
|
68
|
+
optionalDependsOn?: string[];
|
|
69
|
+
optionsSchema?: undefined;
|
|
70
|
+
generate(ctx: GenerateContext, options: void): GenOutput | Promise<GenOutput>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { TypeScriptAliasCycleError, TypeScriptAliasPublicNameCollisionError, type TypeScriptArtifactExtra, TypeScriptEnumCollisionError, TypeScriptEnumPublicNameCollisionError, TypeScriptGenError, typescriptGenerator };
|