@prisma-next/emitter 0.13.0-dev.28 → 0.13.0-dev.29
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-type-generation-DXblsIrF.d.mts","names":[],"sources":["../src/domain-type-generation.ts"],"mappings":";;;;;iBAegB,cAAA,CAAe,KAAc;AAAA,iBA+B7B,kBAAA,CAAmB,GAAW;AAAA,iBAO9B,oBAAA,CAAqB,KAAa;AAAA,iBAIlC,uBAAA,CAAwB,GAAmB,EAAd,cAAc;AAAA,iBAO3C,iBAAA,CAAkB,KAAA,EAAO,MAAM,SAAS,cAAA;AAAA,iBAgBxC,uBAAA,CAAwB,SAAA,UAAmB,KAAA,EAAO,aAAa;AAAA,iBAgB/D,uBAAA,CAAwB,MAAA,EAAQ,MAAM,SAAS,aAAA;AAAA,iBAQ/C,0BAAA,CAA2B,SAAkC,EAAvB,MAAM;AAAA,iBA4E5C,kBAAA,CACd,MAAA,EAAQ,MAAA,SAAe,aAAA,GACvB,oBAAA,GAAuB,SAAA,UAAmB,KAAA,EAAO,aAAA;AAAA,iBAqCnC,kBAAA,CAAmB,OAAA,EAAS,eAAA,KAAoB,eAAe;AAAA,iBAa/D,mBAAA,CAAoB,OAA0B,EAAjB,eAAe;AAAA,iBAW5C,6BAAA,CACd,OAAA,EAAS,aAAa,CAAC,eAAA,GACvB,KAAA;AAAA,iBAMc,sBAAA,CAAuB,SAAkC,EAAvB,MAAM;AAAA,iBASxC,uBAAA,CAAwB,MAAA;EAAA,SAC7B,WAAA;EAAA,SACA,aAAA;EAAA,SACA,WAAA;AAAA;AAAA,KAaC,iBAAA;EAAA,SAA+B,KAAA;EAAA,SAAwB,MAAM;AAAA;AApNzE;;;;;AAAA,KAmOY,uBAAA,IACV,SAAA,UACA,SAAA,UACA,KAAA,EAAO,aAAA,KACJ,MAAM;;;AAvOwE;AAgBnF;;KA8NY,kBAAA,IA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numVal
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
let outputResolved;
|
|
181
|
+
let inputResolved;
|
|
181
182
|
const effectiveTypeParams = (type.typeParams && Object.keys(type.typeParams).length > 0 ? type.typeParams : void 0) ?? resolvedTypeParams;
|
|
182
183
|
if (codecLookup && effectiveTypeParams && Object.keys(effectiveTypeParams).length > 0) {
|
|
183
184
|
const rendered = codecLookup.renderOutputTypeFor(type.codecId, effectiveTypeParams);
|
|
184
185
|
if (rendered && isSafeTypeExpression(rendered)) outputResolved = rendered;
|
|
186
|
+
const renderedInput = codecLookup.renderInputTypeFor?.(type.codecId, effectiveTypeParams);
|
|
187
|
+
if (renderedInput && isSafeTypeExpression(renderedInput)) inputResolved = renderedInput;
|
|
185
188
|
}
|
|
186
189
|
const codecAccessor = `CodecTypes[${serializeValue(type.codecId)}]`;
|
|
187
190
|
return {
|
|
188
191
|
output: applyModifiers(outputResolved ?? `${codecAccessor}['output']`, field),
|
|
189
|
-
input: applyModifiers(`${codecAccessor}['input']`, field)
|
|
192
|
+
input: applyModifiers(inputResolved ?? `${codecAccessor}['input']`, field)
|
|
190
193
|
};
|
|
191
194
|
}
|
|
192
195
|
case "valueObject": return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-type-generation.mjs","names":[],"sources":["../src/domain-type-generation.ts"],"sourcesContent":["import type {\n ContractField,\n ContractManyToManyRelation,\n ContractModel,\n ContractValueObject,\n CrossReference,\n JsonValue,\n ValueSetRef,\n} from '@prisma-next/contract/types';\nimport type { CodecLookup } from '@prisma-next/framework-components/codec';\nimport type { TypesImportSpec } from '@prisma-next/framework-components/emission';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { isSafeTypeExpression } from './type-expression-safety';\n\nexport function serializeValue(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value === 'string') {\n const escaped = value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n return `'${escaped}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'bigint') {\n return `${value}n`;\n }\n if (Array.isArray(value)) {\n const items = value.map((v) => serializeValue(v)).join(', ');\n return `readonly [${items}]`;\n }\n if (typeof value === 'object') {\n const entries: string[] = [];\n for (const [k, v] of Object.entries(value)) {\n entries.push(`readonly ${serializeObjectKey(k)}: ${serializeValue(v)}`);\n }\n return `{ ${entries.join('; ')} }`;\n }\n return 'unknown';\n}\n\nexport function serializeObjectKey(key: string): string {\n if (/^[$A-Z_a-z][$\\w]*$/.test(key)) {\n return key;\n }\n return serializeValue(key);\n}\n\nexport function serializeNamespaceId(value: string): string {\n return `${serializeValue(value)} & NamespaceId`;\n}\n\nexport function serializeCrossReference(ref: CrossReference): string {\n const namespace = serializeNamespaceId(String(ref.namespace));\n const model = serializeValue(ref.model);\n const space = ref.space !== undefined ? `; readonly space: ${serializeValue(ref.space)}` : '';\n return `{ readonly namespace: ${namespace}; readonly model: ${model}${space} }`;\n}\n\nexport function generateRootsType(roots: Record<string, CrossReference> | undefined): string {\n if (!roots || Object.keys(roots).length === 0) {\n return 'Record<string, never>';\n }\n const entries = Object.entries(roots)\n .map(([key, value]) => `readonly ${serializeObjectKey(key)}: ${serializeCrossReference(value)}`)\n .join('; ');\n return `{ ${entries} }`;\n}\n\nfunction contractFieldModifierSuffix(field: ContractField): string {\n const many = field.many === true ? '; readonly many: true' : '';\n const dict = field.dict === true ? '; readonly dict: true' : '';\n return many + dict;\n}\n\nexport function generateModelFieldEntry(fieldName: string, field: ContractField): string {\n const mods = contractFieldModifierSuffix(field);\n const { nullable, type } = field;\n if (type.kind === 'scalar') {\n const typeParamsSpec =\n type.typeParams && Object.keys(type.typeParams).length > 0\n ? `; readonly typeParams: ${serializeValue(type.typeParams)}`\n : '';\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${nullable}; readonly type: { readonly kind: 'scalar'; readonly codecId: ${serializeValue(type.codecId)}${typeParamsSpec} }${mods} }`;\n }\n if (type.kind === 'valueObject') {\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${nullable}; readonly type: { readonly kind: 'valueObject'; readonly name: ${serializeValue(type.name)} }${mods} }`;\n }\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${nullable}; readonly type: ${serializeValue(type)}${mods} }`;\n}\n\nexport function generateModelFieldsType(fields: Record<string, ContractField>): string {\n const fieldEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(fields)) {\n fieldEntries.push(generateModelFieldEntry(fieldName, field));\n }\n return fieldEntries.length > 0 ? `{ ${fieldEntries.join('; ')} }` : 'Record<string, never>';\n}\n\nexport function generateModelRelationsType(relations: Record<string, unknown>): string {\n const relationEntries: string[] = [];\n\n for (const [relName, rel] of Object.entries(relations)) {\n if (typeof rel !== 'object' || rel === null) continue;\n const relObj = rel as Record<string, unknown>;\n\n // Option B: cross-space relations are declared but non-navigable.\n // A relation whose `to.space` is set lives in a foreign contract space;\n // emitting `never` for its entry makes `include` of it a compile error\n // while the relation is still present in the contract JSON for introspection.\n const toRef = relObj['to'];\n // Option B: cross-space relations are declared but non-navigable.\n // When the relation's `to` ref carries a `space` field the target lives\n // in a foreign contract space; emit `never` so `include` of it is a\n // compile error while the relation stays in the contract JSON.\n if (\n toRef !== null &&\n typeof toRef === 'object' &&\n 'space' in toRef &&\n toRef.space !== undefined\n ) {\n relationEntries.push(`readonly ${serializeObjectKey(relName)}: never`);\n continue;\n }\n\n const parts: string[] = [];\n\n if (toRef)\n parts.push(\n `readonly to: ${serializeCrossReference(blindCast<CrossReference, 'contract JSON schema-validated before serialization; truthy check above confirms presence'>(toRef))}`,\n );\n if (relObj['cardinality'])\n parts.push(`readonly cardinality: ${serializeValue(relObj['cardinality'])}`);\n\n const on = relObj['on'] as { localFields?: string[]; targetFields?: string[] } | undefined;\n if (on && (!on.localFields || !on.targetFields)) {\n throw new Error(\n `Relation \"${relName}\" has an \"on\" block but is missing localFields or targetFields`,\n );\n }\n if (on?.localFields && on.targetFields) {\n const localFields = on.localFields.map((f) => serializeValue(f)).join(', ');\n const targetFields = on.targetFields.map((f) => serializeValue(f)).join(', ');\n parts.push(\n `readonly on: { readonly localFields: readonly [${localFields}]; readonly targetFields: readonly [${targetFields}] }`,\n );\n }\n\n if (relObj['cardinality'] === 'N:M') {\n const { through } = blindCast<\n ContractManyToManyRelation,\n 'contract JSON schema-validated before serialization; cardinality N:M check above confirms the junction variant carries through'\n >(relObj);\n const table = serializeValue(through.table);\n const namespaceId = serializeValue(through.namespaceId);\n const parentColumns = through.parentColumns.map((c) => serializeValue(c)).join(', ');\n const childColumns = through.childColumns.map((c) => serializeValue(c)).join(', ');\n const targetColumns = through.targetColumns.map((c) => serializeValue(c)).join(', ');\n parts.push(\n `readonly through: { readonly table: ${table}; readonly namespaceId: ${namespaceId}; readonly parentColumns: readonly [${parentColumns}]; readonly childColumns: readonly [${childColumns}]; readonly targetColumns: readonly [${targetColumns}] }`,\n );\n }\n\n if (parts.length > 0) {\n relationEntries.push(`readonly ${serializeObjectKey(relName)}: { ${parts.join('; ')} }`);\n }\n }\n\n if (relationEntries.length === 0) {\n return 'Record<string, never>';\n }\n\n return `{ ${relationEntries.join('; ')} }`;\n}\n\nexport function generateModelsType(\n models: Record<string, ContractModel>,\n generateModelStorage: (modelName: string, model: ContractModel) => string,\n): string {\n if (!models || Object.keys(models).length === 0) {\n return 'Record<string, never>';\n }\n\n const modelTypes: string[] = [];\n for (const [modelName, model] of Object.entries(models).sort(([a], [b]) => a.localeCompare(b))) {\n const fieldsType = generateModelFieldsType(model.fields);\n const relationsType = generateModelRelationsType(model.relations);\n const storageType = generateModelStorage(modelName, model);\n\n const modelParts: string[] = [\n `readonly fields: ${fieldsType}`,\n `readonly relations: ${relationsType}`,\n `readonly storage: ${storageType}`,\n ];\n\n if (model.owner) {\n modelParts.push(`readonly owner: ${serializeValue(model.owner)}`);\n }\n if (model.discriminator) {\n modelParts.push(`readonly discriminator: ${serializeValue(model.discriminator)}`);\n }\n if (model.variants) {\n modelParts.push(`readonly variants: ${serializeValue(model.variants)}`);\n }\n if (model.base) {\n modelParts.push(`readonly base: ${serializeCrossReference(model.base)}`);\n }\n\n modelTypes.push(`readonly ${modelName}: { ${modelParts.join('; ')} }`);\n }\n\n return `{ ${modelTypes.join('; ')} }`;\n}\n\nexport function deduplicateImports(imports: TypesImportSpec[]): TypesImportSpec[] {\n const seenKeys = new Set<string>();\n const result: TypesImportSpec[] = [];\n for (const imp of imports) {\n const key = `${imp.package}::${imp.named}`;\n if (!seenKeys.has(key)) {\n seenKeys.add(key);\n result.push(imp);\n }\n }\n return result;\n}\n\nexport function generateImportLines(imports: TypesImportSpec[]): string[] {\n const requirements: ImportRequirement[] = imports.map((imp) => ({\n moduleSpecifier: imp.package,\n symbol: imp.named,\n alias: imp.alias,\n typeOnly: true,\n }));\n const rendered = renderImports(requirements);\n return rendered === '' ? [] : rendered.split('\\n');\n}\n\nexport function generateCodecTypeIntersection(\n imports: ReadonlyArray<TypesImportSpec>,\n named: string,\n): string {\n const aliases = imports.filter((imp) => imp.named === named).map((imp) => imp.alias);\n return aliases.join(' & ') || 'Record<string, never>';\n}\n\nexport function serializeExecutionType(execution: Record<string, unknown>): string {\n const parts: string[] = ['readonly executionHash: ExecutionHash'];\n for (const [key, value] of Object.entries(execution)) {\n if (key === 'executionHash') continue;\n parts.push(`readonly ${serializeObjectKey(key)}: ${serializeValue(value)}`);\n }\n return `{ ${parts.join('; ')} }`;\n}\n\nexport function generateHashTypeAliases(hashes: {\n readonly storageHash: string;\n readonly executionHash?: string;\n readonly profileHash: string;\n}): string {\n const executionHashType = hashes.executionHash\n ? `ExecutionHashBase<'${hashes.executionHash}'>`\n : 'ExecutionHashBase<string>';\n\n return [\n `export type StorageHash = StorageHashBase<'${hashes.storageHash}'>;`,\n `export type ExecutionHash = ${executionHashType};`,\n `export type ProfileHash = ProfileHashBase<'${hashes.profileHash}'>;`,\n ].join('\\n');\n}\n\nexport type ResolvedFieldType = { readonly input: string; readonly output: string };\n\nfunction applyModifiers(base: string, field: ContractField): string {\n let result = base;\n if (field.many === true) result = `ReadonlyArray<${result}>`;\n if (field.dict === true) result = `Readonly<Record<string, ${result}>>`;\n if (field.nullable) result = `${result} | null`;\n return result;\n}\n\n/**\n * Per-family resolver for typeParams that don't live inline on the framework-domain `ContractField`. SQL columns authored via a named `storage.types` entry carry their `typeRef` on the storage column (family-specific) rather than on the framework's domain field; the per-family emitter walks `storage.types[ref].typeParams` here so the framework emit path can render the parameterized output type.\n *\n * Returns `undefined` when the field has no resolvable typeParams (i.e. the column isn't parameterized, isn't a `typeRef`, or the family doesn't support named storage types).\n */\nexport type FieldTypeParamsResolver = (\n modelName: string,\n fieldName: string,\n model: ContractModel,\n) => Record<string, unknown> | undefined;\n\n/**\n * Resolves a domain field's `valueSet` ref to the member values of the referenced enum.\n * Returns `undefined` when the ref cannot be resolved to a domain enum, so the emit path\n * falls back to the codec channel.\n */\nexport type EnumValuesResolver = (ref: ValueSetRef) => readonly JsonValue[] | undefined;\n\nfunction renderEnumMemberLiteral(value: JsonValue): string | undefined {\n if (value === null) return 'null';\n if (typeof value === 'string') return serializeValue(value);\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n return undefined;\n}\n\nfunction renderEnumValueUnion(values: readonly JsonValue[]): string | undefined {\n if (values.length === 0) return undefined;\n const literals: string[] = [];\n for (const value of values) {\n const literal = renderEnumMemberLiteral(value);\n if (literal === undefined) return undefined;\n literals.push(literal);\n }\n const union = literals.join(' | ');\n return isSafeTypeExpression(union) ? union : undefined;\n}\n\nexport function resolveFieldType(\n field: ContractField,\n codecLookup?: CodecLookup,\n resolvedTypeParams?: Record<string, unknown>,\n resolveEnumValues?: EnumValuesResolver,\n): ResolvedFieldType {\n const { type } = field;\n\n switch (type.kind) {\n case 'scalar': {\n if (field.valueSet?.entityKind === 'enum' && resolveEnumValues) {\n const values = resolveEnumValues(field.valueSet);\n const union = values ? renderEnumValueUnion(values) : undefined;\n if (union !== undefined) {\n return {\n output: applyModifiers(union, field),\n input: applyModifiers(union, field),\n };\n }\n }\n let outputResolved: string | undefined;\n const inlineTypeParams =\n type.typeParams && Object.keys(type.typeParams).length > 0 ? type.typeParams : undefined;\n const effectiveTypeParams = inlineTypeParams ?? resolvedTypeParams;\n if (codecLookup && effectiveTypeParams && Object.keys(effectiveTypeParams).length > 0) {\n const rendered = codecLookup.renderOutputTypeFor(type.codecId, effectiveTypeParams);\n if (rendered && isSafeTypeExpression(rendered)) {\n outputResolved = rendered;\n }\n }\n const codecAccessor = `CodecTypes[${serializeValue(type.codecId)}]`;\n return {\n output: applyModifiers(outputResolved ?? `${codecAccessor}['output']`, field),\n input: applyModifiers(`${codecAccessor}['input']`, field),\n };\n }\n case 'valueObject':\n return {\n output: applyModifiers(`${type.name}Output`, field),\n input: applyModifiers(`${type.name}Input`, field),\n };\n case 'union': {\n const outputMembers = type.members.map((m) =>\n m.kind === 'scalar'\n ? `CodecTypes[${serializeValue(m.codecId)}]['output']`\n : `${m.name}Output`,\n );\n const inputMembers = type.members.map((m) =>\n m.kind === 'scalar'\n ? `CodecTypes[${serializeValue(m.codecId)}]['input']`\n : `${m.name}Input`,\n );\n return {\n output: applyModifiers(outputMembers.join(' | '), field),\n input: applyModifiers(inputMembers.join(' | '), field),\n };\n }\n default:\n return {\n output: applyModifiers('unknown', field),\n input: applyModifiers('unknown', field),\n };\n }\n}\n\nexport function generateFieldResolvedType(\n field: ContractField,\n codecLookup?: CodecLookup,\n side: 'input' | 'output' = 'output',\n): string {\n return resolveFieldType(field, codecLookup)[side];\n}\n\nexport function generateBothFieldTypesMaps(\n models: Record<string, ContractModel> | undefined,\n codecLookup?: CodecLookup,\n resolveFieldTypeParams?: FieldTypeParamsResolver,\n resolveEnumValues?: EnumValuesResolver,\n): ResolvedFieldType {\n if (!models || Object.keys(models).length === 0) {\n return { output: 'Record<string, never>', input: 'Record<string, never>' };\n }\n\n const outputModelEntries: string[] = [];\n const inputModelEntries: string[] = [];\n for (const [modelName, model] of Object.entries(models).sort(([a], [b]) => a.localeCompare(b))) {\n if (!model) continue;\n const outputFieldEntries: string[] = [];\n const inputFieldEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(model.fields)) {\n const inlineTypeParams =\n field.type.kind === 'scalar' &&\n field.type.typeParams &&\n Object.keys(field.type.typeParams).length > 0\n ? field.type.typeParams\n : undefined;\n const resolvedTypeParams =\n inlineTypeParams ?? resolveFieldTypeParams?.(modelName, fieldName, model);\n const resolved = resolveFieldType(field, codecLookup, resolvedTypeParams, resolveEnumValues);\n const key = `readonly ${serializeObjectKey(fieldName)}`;\n outputFieldEntries.push(`${key}: ${resolved.output}`);\n inputFieldEntries.push(`${key}: ${resolved.input}`);\n }\n const outputFields =\n outputFieldEntries.length > 0\n ? `{ ${outputFieldEntries.join('; ')} }`\n : 'Record<string, never>';\n const inputFields =\n inputFieldEntries.length > 0\n ? `{ ${inputFieldEntries.join('; ')} }`\n : 'Record<string, never>';\n const modelKey = `readonly ${serializeObjectKey(modelName)}`;\n outputModelEntries.push(`${modelKey}: ${outputFields}`);\n inputModelEntries.push(`${modelKey}: ${inputFields}`);\n }\n\n return {\n output: `{ ${outputModelEntries.join('; ')} }`,\n input: `{ ${inputModelEntries.join('; ')} }`,\n };\n}\n\nexport function generateFieldOutputTypesMap(\n models: Record<string, ContractModel> | undefined,\n codecLookup?: CodecLookup,\n resolveFieldTypeParams?: FieldTypeParamsResolver,\n resolveEnumValues?: EnumValuesResolver,\n): string {\n return generateBothFieldTypesMaps(models, codecLookup, resolveFieldTypeParams, resolveEnumValues)\n .output;\n}\n\nexport function generateFieldInputTypesMap(\n models: Record<string, ContractModel> | undefined,\n codecLookup?: CodecLookup,\n resolveFieldTypeParams?: FieldTypeParamsResolver,\n resolveEnumValues?: EnumValuesResolver,\n): string {\n return generateBothFieldTypesMaps(models, codecLookup, resolveFieldTypeParams, resolveEnumValues)\n .input;\n}\n\nexport function generateValueObjectType(\n _voName: string,\n vo: ContractValueObject,\n _valueObjects: Record<string, ContractValueObject>,\n side: 'input' | 'output' = 'output',\n codecLookup?: CodecLookup,\n): string {\n return resolveValueObjectType(_voName, vo, _valueObjects, codecLookup)[side];\n}\n\nexport function resolveValueObjectType(\n _voName: string,\n vo: ContractValueObject,\n _valueObjects: Record<string, ContractValueObject>,\n codecLookup?: CodecLookup,\n): ResolvedFieldType {\n const outputEntries: string[] = [];\n const inputEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(vo.fields)) {\n const resolved = resolveFieldType(field, codecLookup);\n const key = `readonly ${serializeObjectKey(fieldName)}`;\n outputEntries.push(`${key}: ${resolved.output}`);\n inputEntries.push(`${key}: ${resolved.input}`);\n }\n const empty = 'Record<string, never>';\n return {\n output: outputEntries.length > 0 ? `{ ${outputEntries.join('; ')} }` : empty,\n input: inputEntries.length > 0 ? `{ ${inputEntries.join('; ')} }` : empty,\n };\n}\n\nexport function generateContractFieldDescriptor(fieldName: string, field: ContractField): string {\n const mods: string[] = [];\n if (field.many === true) mods.push('; readonly many: true');\n if (field.dict === true) mods.push('; readonly dict: true');\n const modStr = mods.join('');\n\n const { type } = field;\n if (type.kind === 'scalar') {\n const typeParamsSpec =\n type.typeParams && Object.keys(type.typeParams).length > 0\n ? `; readonly typeParams: ${serializeValue(type.typeParams)}`\n : '';\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${field.nullable}; readonly type: { readonly kind: 'scalar'; readonly codecId: ${serializeValue(type.codecId)}${typeParamsSpec} }${modStr} }`;\n }\n if (type.kind === 'valueObject') {\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${field.nullable}; readonly type: { readonly kind: 'valueObject'; readonly name: ${serializeValue(type.name)} }${modStr} }`;\n }\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${field.nullable}; readonly type: ${serializeValue(type)}${modStr} }`;\n}\n\nexport function generateValueObjectsDescriptorType(\n valueObjects: Record<string, ContractValueObject> | undefined,\n): string {\n if (!valueObjects || Object.keys(valueObjects).length === 0) {\n return 'Record<string, never>';\n }\n\n const voEntries: string[] = [];\n for (const [voName, vo] of Object.entries(valueObjects)) {\n const fieldEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(vo.fields)) {\n fieldEntries.push(generateContractFieldDescriptor(fieldName, field));\n }\n const fieldsType =\n fieldEntries.length > 0 ? `{ ${fieldEntries.join('; ')} }` : 'Record<string, never>';\n voEntries.push(`readonly ${serializeObjectKey(voName)}: { readonly fields: ${fieldsType} }`);\n }\n\n return `{ ${voEntries.join('; ')} }`;\n}\n\nexport function generateValueObjectTypeAliases(\n valueObjects: Record<string, ContractValueObject> | undefined,\n codecLookup?: CodecLookup,\n): string {\n if (!valueObjects || Object.keys(valueObjects).length === 0) {\n return '';\n }\n\n const aliases: string[] = [];\n for (const [voName, vo] of Object.entries(valueObjects)) {\n const resolved = resolveValueObjectType(voName, vo, valueObjects, codecLookup);\n aliases.push(`export type ${voName}Output = ${resolved.output};`);\n aliases.push(`export type ${voName}Input = ${resolved.input};`);\n }\n return aliases.join('\\n');\n}\n"],"mappings":";;;;AAeA,SAAgB,eAAe,OAAwB;CACrD,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,UAAU,KAAA,GACZ,OAAO;CAET,IAAI,OAAO,UAAU,UAEnB,OAAO,IADS,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,KAC1C,EAAE;CAErB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,UACnB,OAAO,GAAG,MAAM;CAElB,IAAI,MAAM,QAAQ,KAAK,GAErB,OAAO,aADO,MAAM,KAAK,MAAM,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,IAC/B,EAAE;CAE5B,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,UAAoB,CAAC;EAC3B,KAAK,MAAM,CAA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Ae,OAAO,WAAW,SAAS,OAAO,EAAE;EAChE,QAAQ,KAAK,eAAe,OAAO,UAAU,SAAS,MAAM,EAAE;CAChE;CACA,OAAO,QAAQ,KAAK,IAAI;AAC1B"}
|
|
1
|
+
{"version":3,"file":"domain-type-generation.mjs","names":[],"sources":["../src/domain-type-generation.ts"],"sourcesContent":["import type {\n ContractField,\n ContractManyToManyRelation,\n ContractModel,\n ContractValueObject,\n CrossReference,\n JsonValue,\n ValueSetRef,\n} from '@prisma-next/contract/types';\nimport type { CodecLookup } from '@prisma-next/framework-components/codec';\nimport type { TypesImportSpec } from '@prisma-next/framework-components/emission';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { isSafeTypeExpression } from './type-expression-safety';\n\nexport function serializeValue(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value === 'string') {\n const escaped = value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n return `'${escaped}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'bigint') {\n return `${value}n`;\n }\n if (Array.isArray(value)) {\n const items = value.map((v) => serializeValue(v)).join(', ');\n return `readonly [${items}]`;\n }\n if (typeof value === 'object') {\n const entries: string[] = [];\n for (const [k, v] of Object.entries(value)) {\n entries.push(`readonly ${serializeObjectKey(k)}: ${serializeValue(v)}`);\n }\n return `{ ${entries.join('; ')} }`;\n }\n return 'unknown';\n}\n\nexport function serializeObjectKey(key: string): string {\n if (/^[$A-Z_a-z][$\\w]*$/.test(key)) {\n return key;\n }\n return serializeValue(key);\n}\n\nexport function serializeNamespaceId(value: string): string {\n return `${serializeValue(value)} & NamespaceId`;\n}\n\nexport function serializeCrossReference(ref: CrossReference): string {\n const namespace = serializeNamespaceId(String(ref.namespace));\n const model = serializeValue(ref.model);\n const space = ref.space !== undefined ? `; readonly space: ${serializeValue(ref.space)}` : '';\n return `{ readonly namespace: ${namespace}; readonly model: ${model}${space} }`;\n}\n\nexport function generateRootsType(roots: Record<string, CrossReference> | undefined): string {\n if (!roots || Object.keys(roots).length === 0) {\n return 'Record<string, never>';\n }\n const entries = Object.entries(roots)\n .map(([key, value]) => `readonly ${serializeObjectKey(key)}: ${serializeCrossReference(value)}`)\n .join('; ');\n return `{ ${entries} }`;\n}\n\nfunction contractFieldModifierSuffix(field: ContractField): string {\n const many = field.many === true ? '; readonly many: true' : '';\n const dict = field.dict === true ? '; readonly dict: true' : '';\n return many + dict;\n}\n\nexport function generateModelFieldEntry(fieldName: string, field: ContractField): string {\n const mods = contractFieldModifierSuffix(field);\n const { nullable, type } = field;\n if (type.kind === 'scalar') {\n const typeParamsSpec =\n type.typeParams && Object.keys(type.typeParams).length > 0\n ? `; readonly typeParams: ${serializeValue(type.typeParams)}`\n : '';\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${nullable}; readonly type: { readonly kind: 'scalar'; readonly codecId: ${serializeValue(type.codecId)}${typeParamsSpec} }${mods} }`;\n }\n if (type.kind === 'valueObject') {\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${nullable}; readonly type: { readonly kind: 'valueObject'; readonly name: ${serializeValue(type.name)} }${mods} }`;\n }\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${nullable}; readonly type: ${serializeValue(type)}${mods} }`;\n}\n\nexport function generateModelFieldsType(fields: Record<string, ContractField>): string {\n const fieldEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(fields)) {\n fieldEntries.push(generateModelFieldEntry(fieldName, field));\n }\n return fieldEntries.length > 0 ? `{ ${fieldEntries.join('; ')} }` : 'Record<string, never>';\n}\n\nexport function generateModelRelationsType(relations: Record<string, unknown>): string {\n const relationEntries: string[] = [];\n\n for (const [relName, rel] of Object.entries(relations)) {\n if (typeof rel !== 'object' || rel === null) continue;\n const relObj = rel as Record<string, unknown>;\n\n // Option B: cross-space relations are declared but non-navigable.\n // A relation whose `to.space` is set lives in a foreign contract space;\n // emitting `never` for its entry makes `include` of it a compile error\n // while the relation is still present in the contract JSON for introspection.\n const toRef = relObj['to'];\n // Option B: cross-space relations are declared but non-navigable.\n // When the relation's `to` ref carries a `space` field the target lives\n // in a foreign contract space; emit `never` so `include` of it is a\n // compile error while the relation stays in the contract JSON.\n if (\n toRef !== null &&\n typeof toRef === 'object' &&\n 'space' in toRef &&\n toRef.space !== undefined\n ) {\n relationEntries.push(`readonly ${serializeObjectKey(relName)}: never`);\n continue;\n }\n\n const parts: string[] = [];\n\n if (toRef)\n parts.push(\n `readonly to: ${serializeCrossReference(blindCast<CrossReference, 'contract JSON schema-validated before serialization; truthy check above confirms presence'>(toRef))}`,\n );\n if (relObj['cardinality'])\n parts.push(`readonly cardinality: ${serializeValue(relObj['cardinality'])}`);\n\n const on = relObj['on'] as { localFields?: string[]; targetFields?: string[] } | undefined;\n if (on && (!on.localFields || !on.targetFields)) {\n throw new Error(\n `Relation \"${relName}\" has an \"on\" block but is missing localFields or targetFields`,\n );\n }\n if (on?.localFields && on.targetFields) {\n const localFields = on.localFields.map((f) => serializeValue(f)).join(', ');\n const targetFields = on.targetFields.map((f) => serializeValue(f)).join(', ');\n parts.push(\n `readonly on: { readonly localFields: readonly [${localFields}]; readonly targetFields: readonly [${targetFields}] }`,\n );\n }\n\n if (relObj['cardinality'] === 'N:M') {\n const { through } = blindCast<\n ContractManyToManyRelation,\n 'contract JSON schema-validated before serialization; cardinality N:M check above confirms the junction variant carries through'\n >(relObj);\n const table = serializeValue(through.table);\n const namespaceId = serializeValue(through.namespaceId);\n const parentColumns = through.parentColumns.map((c) => serializeValue(c)).join(', ');\n const childColumns = through.childColumns.map((c) => serializeValue(c)).join(', ');\n const targetColumns = through.targetColumns.map((c) => serializeValue(c)).join(', ');\n parts.push(\n `readonly through: { readonly table: ${table}; readonly namespaceId: ${namespaceId}; readonly parentColumns: readonly [${parentColumns}]; readonly childColumns: readonly [${childColumns}]; readonly targetColumns: readonly [${targetColumns}] }`,\n );\n }\n\n if (parts.length > 0) {\n relationEntries.push(`readonly ${serializeObjectKey(relName)}: { ${parts.join('; ')} }`);\n }\n }\n\n if (relationEntries.length === 0) {\n return 'Record<string, never>';\n }\n\n return `{ ${relationEntries.join('; ')} }`;\n}\n\nexport function generateModelsType(\n models: Record<string, ContractModel>,\n generateModelStorage: (modelName: string, model: ContractModel) => string,\n): string {\n if (!models || Object.keys(models).length === 0) {\n return 'Record<string, never>';\n }\n\n const modelTypes: string[] = [];\n for (const [modelName, model] of Object.entries(models).sort(([a], [b]) => a.localeCompare(b))) {\n const fieldsType = generateModelFieldsType(model.fields);\n const relationsType = generateModelRelationsType(model.relations);\n const storageType = generateModelStorage(modelName, model);\n\n const modelParts: string[] = [\n `readonly fields: ${fieldsType}`,\n `readonly relations: ${relationsType}`,\n `readonly storage: ${storageType}`,\n ];\n\n if (model.owner) {\n modelParts.push(`readonly owner: ${serializeValue(model.owner)}`);\n }\n if (model.discriminator) {\n modelParts.push(`readonly discriminator: ${serializeValue(model.discriminator)}`);\n }\n if (model.variants) {\n modelParts.push(`readonly variants: ${serializeValue(model.variants)}`);\n }\n if (model.base) {\n modelParts.push(`readonly base: ${serializeCrossReference(model.base)}`);\n }\n\n modelTypes.push(`readonly ${modelName}: { ${modelParts.join('; ')} }`);\n }\n\n return `{ ${modelTypes.join('; ')} }`;\n}\n\nexport function deduplicateImports(imports: TypesImportSpec[]): TypesImportSpec[] {\n const seenKeys = new Set<string>();\n const result: TypesImportSpec[] = [];\n for (const imp of imports) {\n const key = `${imp.package}::${imp.named}`;\n if (!seenKeys.has(key)) {\n seenKeys.add(key);\n result.push(imp);\n }\n }\n return result;\n}\n\nexport function generateImportLines(imports: TypesImportSpec[]): string[] {\n const requirements: ImportRequirement[] = imports.map((imp) => ({\n moduleSpecifier: imp.package,\n symbol: imp.named,\n alias: imp.alias,\n typeOnly: true,\n }));\n const rendered = renderImports(requirements);\n return rendered === '' ? [] : rendered.split('\\n');\n}\n\nexport function generateCodecTypeIntersection(\n imports: ReadonlyArray<TypesImportSpec>,\n named: string,\n): string {\n const aliases = imports.filter((imp) => imp.named === named).map((imp) => imp.alias);\n return aliases.join(' & ') || 'Record<string, never>';\n}\n\nexport function serializeExecutionType(execution: Record<string, unknown>): string {\n const parts: string[] = ['readonly executionHash: ExecutionHash'];\n for (const [key, value] of Object.entries(execution)) {\n if (key === 'executionHash') continue;\n parts.push(`readonly ${serializeObjectKey(key)}: ${serializeValue(value)}`);\n }\n return `{ ${parts.join('; ')} }`;\n}\n\nexport function generateHashTypeAliases(hashes: {\n readonly storageHash: string;\n readonly executionHash?: string;\n readonly profileHash: string;\n}): string {\n const executionHashType = hashes.executionHash\n ? `ExecutionHashBase<'${hashes.executionHash}'>`\n : 'ExecutionHashBase<string>';\n\n return [\n `export type StorageHash = StorageHashBase<'${hashes.storageHash}'>;`,\n `export type ExecutionHash = ${executionHashType};`,\n `export type ProfileHash = ProfileHashBase<'${hashes.profileHash}'>;`,\n ].join('\\n');\n}\n\nexport type ResolvedFieldType = { readonly input: string; readonly output: string };\n\nfunction applyModifiers(base: string, field: ContractField): string {\n let result = base;\n if (field.many === true) result = `ReadonlyArray<${result}>`;\n if (field.dict === true) result = `Readonly<Record<string, ${result}>>`;\n if (field.nullable) result = `${result} | null`;\n return result;\n}\n\n/**\n * Per-family resolver for typeParams that don't live inline on the framework-domain `ContractField`. SQL columns authored via a named `storage.types` entry carry their `typeRef` on the storage column (family-specific) rather than on the framework's domain field; the per-family emitter walks `storage.types[ref].typeParams` here so the framework emit path can render the parameterized output type.\n *\n * Returns `undefined` when the field has no resolvable typeParams (i.e. the column isn't parameterized, isn't a `typeRef`, or the family doesn't support named storage types).\n */\nexport type FieldTypeParamsResolver = (\n modelName: string,\n fieldName: string,\n model: ContractModel,\n) => Record<string, unknown> | undefined;\n\n/**\n * Resolves a domain field's `valueSet` ref to the member values of the referenced enum.\n * Returns `undefined` when the ref cannot be resolved to a domain enum, so the emit path\n * falls back to the codec channel.\n */\nexport type EnumValuesResolver = (ref: ValueSetRef) => readonly JsonValue[] | undefined;\n\nfunction renderEnumMemberLiteral(value: JsonValue): string | undefined {\n if (value === null) return 'null';\n if (typeof value === 'string') return serializeValue(value);\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n return undefined;\n}\n\nfunction renderEnumValueUnion(values: readonly JsonValue[]): string | undefined {\n if (values.length === 0) return undefined;\n const literals: string[] = [];\n for (const value of values) {\n const literal = renderEnumMemberLiteral(value);\n if (literal === undefined) return undefined;\n literals.push(literal);\n }\n const union = literals.join(' | ');\n return isSafeTypeExpression(union) ? union : undefined;\n}\n\nexport function resolveFieldType(\n field: ContractField,\n codecLookup?: CodecLookup,\n resolvedTypeParams?: Record<string, unknown>,\n resolveEnumValues?: EnumValuesResolver,\n): ResolvedFieldType {\n const { type } = field;\n\n switch (type.kind) {\n case 'scalar': {\n if (field.valueSet?.entityKind === 'enum' && resolveEnumValues) {\n const values = resolveEnumValues(field.valueSet);\n const union = values ? renderEnumValueUnion(values) : undefined;\n if (union !== undefined) {\n return {\n output: applyModifiers(union, field),\n input: applyModifiers(union, field),\n };\n }\n }\n let outputResolved: string | undefined;\n let inputResolved: string | undefined;\n const inlineTypeParams =\n type.typeParams && Object.keys(type.typeParams).length > 0 ? type.typeParams : undefined;\n const effectiveTypeParams = inlineTypeParams ?? resolvedTypeParams;\n if (codecLookup && effectiveTypeParams && Object.keys(effectiveTypeParams).length > 0) {\n const rendered = codecLookup.renderOutputTypeFor(type.codecId, effectiveTypeParams);\n if (rendered && isSafeTypeExpression(rendered)) {\n outputResolved = rendered;\n }\n const renderedInput = codecLookup.renderInputTypeFor?.(type.codecId, effectiveTypeParams);\n if (renderedInput && isSafeTypeExpression(renderedInput)) {\n inputResolved = renderedInput;\n }\n }\n const codecAccessor = `CodecTypes[${serializeValue(type.codecId)}]`;\n return {\n output: applyModifiers(outputResolved ?? `${codecAccessor}['output']`, field),\n input: applyModifiers(inputResolved ?? `${codecAccessor}['input']`, field),\n };\n }\n case 'valueObject':\n return {\n output: applyModifiers(`${type.name}Output`, field),\n input: applyModifiers(`${type.name}Input`, field),\n };\n case 'union': {\n const outputMembers = type.members.map((m) =>\n m.kind === 'scalar'\n ? `CodecTypes[${serializeValue(m.codecId)}]['output']`\n : `${m.name}Output`,\n );\n const inputMembers = type.members.map((m) =>\n m.kind === 'scalar'\n ? `CodecTypes[${serializeValue(m.codecId)}]['input']`\n : `${m.name}Input`,\n );\n return {\n output: applyModifiers(outputMembers.join(' | '), field),\n input: applyModifiers(inputMembers.join(' | '), field),\n };\n }\n default:\n return {\n output: applyModifiers('unknown', field),\n input: applyModifiers('unknown', field),\n };\n }\n}\n\nexport function generateFieldResolvedType(\n field: ContractField,\n codecLookup?: CodecLookup,\n side: 'input' | 'output' = 'output',\n): string {\n return resolveFieldType(field, codecLookup)[side];\n}\n\nexport function generateBothFieldTypesMaps(\n models: Record<string, ContractModel> | undefined,\n codecLookup?: CodecLookup,\n resolveFieldTypeParams?: FieldTypeParamsResolver,\n resolveEnumValues?: EnumValuesResolver,\n): ResolvedFieldType {\n if (!models || Object.keys(models).length === 0) {\n return { output: 'Record<string, never>', input: 'Record<string, never>' };\n }\n\n const outputModelEntries: string[] = [];\n const inputModelEntries: string[] = [];\n for (const [modelName, model] of Object.entries(models).sort(([a], [b]) => a.localeCompare(b))) {\n if (!model) continue;\n const outputFieldEntries: string[] = [];\n const inputFieldEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(model.fields)) {\n const inlineTypeParams =\n field.type.kind === 'scalar' &&\n field.type.typeParams &&\n Object.keys(field.type.typeParams).length > 0\n ? field.type.typeParams\n : undefined;\n const resolvedTypeParams =\n inlineTypeParams ?? resolveFieldTypeParams?.(modelName, fieldName, model);\n const resolved = resolveFieldType(field, codecLookup, resolvedTypeParams, resolveEnumValues);\n const key = `readonly ${serializeObjectKey(fieldName)}`;\n outputFieldEntries.push(`${key}: ${resolved.output}`);\n inputFieldEntries.push(`${key}: ${resolved.input}`);\n }\n const outputFields =\n outputFieldEntries.length > 0\n ? `{ ${outputFieldEntries.join('; ')} }`\n : 'Record<string, never>';\n const inputFields =\n inputFieldEntries.length > 0\n ? `{ ${inputFieldEntries.join('; ')} }`\n : 'Record<string, never>';\n const modelKey = `readonly ${serializeObjectKey(modelName)}`;\n outputModelEntries.push(`${modelKey}: ${outputFields}`);\n inputModelEntries.push(`${modelKey}: ${inputFields}`);\n }\n\n return {\n output: `{ ${outputModelEntries.join('; ')} }`,\n input: `{ ${inputModelEntries.join('; ')} }`,\n };\n}\n\nexport function generateFieldOutputTypesMap(\n models: Record<string, ContractModel> | undefined,\n codecLookup?: CodecLookup,\n resolveFieldTypeParams?: FieldTypeParamsResolver,\n resolveEnumValues?: EnumValuesResolver,\n): string {\n return generateBothFieldTypesMaps(models, codecLookup, resolveFieldTypeParams, resolveEnumValues)\n .output;\n}\n\nexport function generateFieldInputTypesMap(\n models: Record<string, ContractModel> | undefined,\n codecLookup?: CodecLookup,\n resolveFieldTypeParams?: FieldTypeParamsResolver,\n resolveEnumValues?: EnumValuesResolver,\n): string {\n return generateBothFieldTypesMaps(models, codecLookup, resolveFieldTypeParams, resolveEnumValues)\n .input;\n}\n\nexport function generateValueObjectType(\n _voName: string,\n vo: ContractValueObject,\n _valueObjects: Record<string, ContractValueObject>,\n side: 'input' | 'output' = 'output',\n codecLookup?: CodecLookup,\n): string {\n return resolveValueObjectType(_voName, vo, _valueObjects, codecLookup)[side];\n}\n\nexport function resolveValueObjectType(\n _voName: string,\n vo: ContractValueObject,\n _valueObjects: Record<string, ContractValueObject>,\n codecLookup?: CodecLookup,\n): ResolvedFieldType {\n const outputEntries: string[] = [];\n const inputEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(vo.fields)) {\n const resolved = resolveFieldType(field, codecLookup);\n const key = `readonly ${serializeObjectKey(fieldName)}`;\n outputEntries.push(`${key}: ${resolved.output}`);\n inputEntries.push(`${key}: ${resolved.input}`);\n }\n const empty = 'Record<string, never>';\n return {\n output: outputEntries.length > 0 ? `{ ${outputEntries.join('; ')} }` : empty,\n input: inputEntries.length > 0 ? `{ ${inputEntries.join('; ')} }` : empty,\n };\n}\n\nexport function generateContractFieldDescriptor(fieldName: string, field: ContractField): string {\n const mods: string[] = [];\n if (field.many === true) mods.push('; readonly many: true');\n if (field.dict === true) mods.push('; readonly dict: true');\n const modStr = mods.join('');\n\n const { type } = field;\n if (type.kind === 'scalar') {\n const typeParamsSpec =\n type.typeParams && Object.keys(type.typeParams).length > 0\n ? `; readonly typeParams: ${serializeValue(type.typeParams)}`\n : '';\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${field.nullable}; readonly type: { readonly kind: 'scalar'; readonly codecId: ${serializeValue(type.codecId)}${typeParamsSpec} }${modStr} }`;\n }\n if (type.kind === 'valueObject') {\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${field.nullable}; readonly type: { readonly kind: 'valueObject'; readonly name: ${serializeValue(type.name)} }${modStr} }`;\n }\n return `readonly ${serializeObjectKey(fieldName)}: { readonly nullable: ${field.nullable}; readonly type: ${serializeValue(type)}${modStr} }`;\n}\n\nexport function generateValueObjectsDescriptorType(\n valueObjects: Record<string, ContractValueObject> | undefined,\n): string {\n if (!valueObjects || Object.keys(valueObjects).length === 0) {\n return 'Record<string, never>';\n }\n\n const voEntries: string[] = [];\n for (const [voName, vo] of Object.entries(valueObjects)) {\n const fieldEntries: string[] = [];\n for (const [fieldName, field] of Object.entries(vo.fields)) {\n fieldEntries.push(generateContractFieldDescriptor(fieldName, field));\n }\n const fieldsType =\n fieldEntries.length > 0 ? `{ ${fieldEntries.join('; ')} }` : 'Record<string, never>';\n voEntries.push(`readonly ${serializeObjectKey(voName)}: { readonly fields: ${fieldsType} }`);\n }\n\n return `{ ${voEntries.join('; ')} }`;\n}\n\nexport function generateValueObjectTypeAliases(\n valueObjects: Record<string, ContractValueObject> | undefined,\n codecLookup?: CodecLookup,\n): string {\n if (!valueObjects || Object.keys(valueObjects).length === 0) {\n return '';\n }\n\n const aliases: string[] = [];\n for (const [voName, vo] of Object.entries(valueObjects)) {\n const resolved = resolveValueObjectType(voName, vo, valueObjects, codecLookup);\n aliases.push(`export type ${voName}Output = ${resolved.output};`);\n aliases.push(`export type ${voName}Input = ${resolved.input};`);\n }\n return aliases.join('\\n');\n}\n"],"mappings":";;;;AAeA,SAAgB,eAAe,OAAwB;CACrD,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,UAAU,KAAA,GACZ,OAAO;CAET,IAAI,OAAO,UAAU,UAEnB,OAAO,IADS,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,KAC1C,EAAE;CAErB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,UACnB,OAAO,GAAG,MAAM;CAElB,IAAI,MAAM,QAAQ,KAAK,GAErB,OAAO,aADO,MAAM,KAAK,MAAM,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,IAC/B,EAAE;CAE5B,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,UAAoB,CAAC;EAC3B,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GACvC,QAAQ,KAAK,YAAY,mBAAmB,CAAC,EAAE,IAAI,eAAe,CAAC,GAAG;EAExE,OAAO,KAAK,QAAQ,KAAK,IAAI,EAAE;CACjC;CACA,OAAO;AACT;AAEA,SAAgB,mBAAmB,KAAqB;CACtD,IAAI,qBAAqB,KAAK,GAAG,GAC/B,OAAO;CAET,OAAO,eAAe,GAAG;AAC3B;AAEA,SAAgB,qBAAqB,OAAuB;CAC1D,OAAO,GAAG,eAAe,KAAK,EAAE;AAClC;AAEA,SAAgB,wBAAwB,KAA6B;CAInE,OAAO,yBAHW,qBAAqB,OAAO,IAAI,SAAS,CAGnB,EAAE,oBAF5B,eAAe,IAAI,KAEiC,IADpD,IAAI,UAAU,KAAA,IAAY,qBAAqB,e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BAAmB,SAAS,EAAE,yBAAyB,MAAM,SAAS,mBAAmB,eAAe,IAAI,IAAI,OAAO;AAC5I;AAEA,SAAgB,mCACd,cACQ;CACR,IAAI,CAAC,gBAAgB,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACxD,OAAO;CAGT,MAAM,YAAsB,CAAC;CAC7B,KAAK,MAAM,CAAC,QAAQ,OAAO,OAAO,QAAQ,YAAY,GAAG;EACvD,MAAM,eAAyB,CAAC;EAChC,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,GAAG,MAAM,GACvD,aAAa,KAAK,gCAAgC,WAAW,KAAK,CAAC;EAErE,MAAM,aACJ,aAAa,SAAS,IAAI,KAAK,aAAa,KAAK,IAAI,EAAE,MAAM;EAC/D,UAAU,KAAK,YAAY,mBAAmB,MAAM,EAAE,uBAAuB,WAAW,GAAG;CAC7F;CAEA,OAAO,KAAK,UAAU,KAAK,IAAI,EAAE;AACnC;AAEA,SAAgB,+BACd,cACA,aACQ;CACR,IAAI,CAAC,gBAAgB,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACxD,OAAO;CAGT,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,CAAC,QAAQ,OAAO,OAAO,QAAQ,YAAY,GAAG;EACvD,MAAM,WAAW,uBAAuB,QAAQ,IAAI,cAAc,WAAW;EAC7E,QAAQ,KAAK,eAAe,OAAO,WAAW,SAAS,OAAO,EAAE;EAChE,QAAQ,KAAK,eAAe,OAAO,UAAU,SAAS,MAAM,EAAE;CAChE;CACA,OAAO,QAAQ,KAAK,IAAI;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/emitter",
|
|
3
|
-
"version": "0.13.0-dev.
|
|
3
|
+
"version": "0.13.0-dev.29",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/contract": "0.13.0-dev.
|
|
9
|
-
"@prisma-next/framework-components": "0.13.0-dev.
|
|
10
|
-
"@prisma-next/operations": "0.13.0-dev.
|
|
11
|
-
"@prisma-next/ts-render": "0.13.0-dev.
|
|
12
|
-
"@prisma-next/utils": "0.13.0-dev.
|
|
8
|
+
"@prisma-next/contract": "0.13.0-dev.29",
|
|
9
|
+
"@prisma-next/framework-components": "0.13.0-dev.29",
|
|
10
|
+
"@prisma-next/operations": "0.13.0-dev.29",
|
|
11
|
+
"@prisma-next/ts-render": "0.13.0-dev.29",
|
|
12
|
+
"@prisma-next/utils": "0.13.0-dev.29",
|
|
13
13
|
"arktype": "^2.2.0",
|
|
14
14
|
"prettier": "^3.8.3"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@prisma-next/test-utils": "0.13.0-dev.
|
|
18
|
-
"@prisma-next/tsconfig": "0.13.0-dev.
|
|
17
|
+
"@prisma-next/test-utils": "0.13.0-dev.29",
|
|
18
|
+
"@prisma-next/tsconfig": "0.13.0-dev.29",
|
|
19
19
|
"@types/node": "25.9.1",
|
|
20
|
-
"@prisma-next/tsdown": "0.13.0-dev.
|
|
20
|
+
"@prisma-next/tsdown": "0.13.0-dev.29",
|
|
21
21
|
"tsdown": "0.22.1",
|
|
22
22
|
"typescript": "5.9.3",
|
|
23
23
|
"vitest": "4.1.8"
|
|
@@ -342,6 +342,7 @@ export function resolveFieldType(
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
let outputResolved: string | undefined;
|
|
345
|
+
let inputResolved: string | undefined;
|
|
345
346
|
const inlineTypeParams =
|
|
346
347
|
type.typeParams && Object.keys(type.typeParams).length > 0 ? type.typeParams : undefined;
|
|
347
348
|
const effectiveTypeParams = inlineTypeParams ?? resolvedTypeParams;
|
|
@@ -350,11 +351,15 @@ export function resolveFieldType(
|
|
|
350
351
|
if (rendered && isSafeTypeExpression(rendered)) {
|
|
351
352
|
outputResolved = rendered;
|
|
352
353
|
}
|
|
354
|
+
const renderedInput = codecLookup.renderInputTypeFor?.(type.codecId, effectiveTypeParams);
|
|
355
|
+
if (renderedInput && isSafeTypeExpression(renderedInput)) {
|
|
356
|
+
inputResolved = renderedInput;
|
|
357
|
+
}
|
|
353
358
|
}
|
|
354
359
|
const codecAccessor = `CodecTypes[${serializeValue(type.codecId)}]`;
|
|
355
360
|
return {
|
|
356
361
|
output: applyModifiers(outputResolved ?? `${codecAccessor}['output']`, field),
|
|
357
|
-
input: applyModifiers(`${codecAccessor}['input']`, field),
|
|
362
|
+
input: applyModifiers(inputResolved ?? `${codecAccessor}['input']`, field),
|
|
358
363
|
};
|
|
359
364
|
}
|
|
360
365
|
case 'valueObject':
|