@prisma/orm-family-mongo 0.16.0-dev.36
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/LICENSE +201 -0
- package/README.md +27 -0
- package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs +176 -0
- package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs.map +1 -0
- package/dist/canonicalization-hooks-DF3Z6sjO.mjs +22 -0
- package/dist/canonicalization-hooks-DF3Z6sjO.mjs.map +1 -0
- package/dist/codec.d.mts +2 -0
- package/dist/codec.mjs +2 -0
- package/dist/config-types-CFDf9ivE.mjs +37 -0
- package/dist/config-types-CFDf9ivE.mjs.map +1 -0
- package/dist/config-types-CQOf5N7R.d.mts +12 -0
- package/dist/config-types-CQOf5N7R.d.mts.map +1 -0
- package/dist/contract-builder-BFq0gOMV.mjs +634 -0
- package/dist/contract-builder-BFq0gOMV.mjs.map +1 -0
- package/dist/contract-builder-DB8nguDE.d.mts +445 -0
- package/dist/contract-builder-DB8nguDE.d.mts.map +1 -0
- package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs +9 -0
- package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs.map +1 -0
- package/dist/contract-psl.d.mts +45 -0
- package/dist/contract-psl.d.mts.map +1 -0
- package/dist/contract-psl.mjs +2 -0
- package/dist/contract-psl__provider.d.mts +15 -0
- package/dist/contract-psl__provider.d.mts.map +1 -0
- package/dist/contract-psl__provider.mjs +82 -0
- package/dist/contract-psl__provider.mjs.map +1 -0
- package/dist/contract-ts.d.mts +3 -0
- package/dist/contract-ts.mjs +3 -0
- package/dist/contract-ts__config-types.d.mts +2 -0
- package/dist/contract-ts__config-types.mjs +2 -0
- package/dist/contract-ts__contract-builder.d.mts +2 -0
- package/dist/contract-ts__contract-builder.mjs +2 -0
- package/dist/contract.d.mts +3 -0
- package/dist/contract.mjs +3 -0
- package/dist/contract__canonicalization-hooks.d.mts +9 -0
- package/dist/contract__canonicalization-hooks.d.mts.map +1 -0
- package/dist/contract__canonicalization-hooks.mjs +2 -0
- package/dist/contract__entity-kinds.d.mts +17 -0
- package/dist/contract__entity-kinds.d.mts.map +1 -0
- package/dist/contract__entity-kinds.mjs +2 -0
- package/dist/control-C7-kthr1.d.mts +193 -0
- package/dist/control-C7-kthr1.d.mts.map +1 -0
- package/dist/control-CClR5JMr.mjs +127 -0
- package/dist/control-CClR5JMr.mjs.map +1 -0
- package/dist/control-CFr3tYsg.mjs +398 -0
- package/dist/control-CFr3tYsg.mjs.map +1 -0
- package/dist/control-Cj81sPbj.d.mts +101 -0
- package/dist/control-Cj81sPbj.d.mts.map +1 -0
- package/dist/control-adapter-Db5pT77b.d.mts +83 -0
- package/dist/control-adapter-Db5pT77b.d.mts.map +1 -0
- package/dist/dist-C7Ykq48Q.mjs +19 -0
- package/dist/dist-C7Ykq48Q.mjs.map +1 -0
- package/dist/dist-Czwqx_i3.mjs +58 -0
- package/dist/dist-Czwqx_i3.mjs.map +1 -0
- package/dist/dist-DHrEJnhK.mjs +236 -0
- package/dist/dist-DHrEJnhK.mjs.map +1 -0
- package/dist/dist-Dyp05u64.mjs +1546 -0
- package/dist/dist-Dyp05u64.mjs.map +1 -0
- package/dist/emitter.d.mts +22 -0
- package/dist/emitter.d.mts.map +1 -0
- package/dist/emitter.mjs +2 -0
- package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs +603 -0
- package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map +1 -0
- package/dist/execution-CKnUiOfm.d.mts +48 -0
- package/dist/execution-CKnUiOfm.d.mts.map +1 -0
- package/dist/execution-D5XyZ5XS.mjs +1269 -0
- package/dist/execution-D5XyZ5XS.mjs.map +1 -0
- package/dist/exports-Bx-hlnZ3.mjs +209 -0
- package/dist/exports-Bx-hlnZ3.mjs.map +1 -0
- package/dist/exports-CJMh0VTU.mjs +156 -0
- package/dist/exports-CJMh0VTU.mjs.map +1 -0
- package/dist/family.d.mts +10 -0
- package/dist/family.mjs +9 -0
- package/dist/family__control-adapter.d.mts +2 -0
- package/dist/family__control-adapter.mjs +1 -0
- package/dist/family__control.d.mts +2 -0
- package/dist/family__control.mjs +3 -0
- package/dist/family__ir.d.mts +3 -0
- package/dist/family__ir.mjs +4 -0
- package/dist/family__migration.d.mts +2 -0
- package/dist/family__migration.mjs +2 -0
- package/dist/family__pack.d.mts +2 -0
- package/dist/family__pack.mjs +16 -0
- package/dist/family__pack.mjs.map +1 -0
- package/dist/family__runtime.d.mts +3 -0
- package/dist/family__runtime.mjs +2 -0
- package/dist/family__schema-verify.d.mts +2 -0
- package/dist/family__schema-verify.mjs +2 -0
- package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs +234 -0
- package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs.map +1 -0
- package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts +588 -0
- package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts.map +1 -0
- package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs +181 -0
- package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs.map +1 -0
- package/dist/index-BR0ue13b.d.mts +136 -0
- package/dist/index-BR0ue13b.d.mts.map +1 -0
- package/dist/index-Cd2zLiU6.d.mts +128 -0
- package/dist/index-Cd2zLiU6.d.mts.map +1 -0
- package/dist/index-DAOkcTCK.d.mts +151 -0
- package/dist/index-DAOkcTCK.d.mts.map +1 -0
- package/dist/index-Dv2PNMiG.d.mts +53 -0
- package/dist/index-Dv2PNMiG.d.mts.map +1 -0
- package/dist/index-DxoO-ywI.d.mts +178 -0
- package/dist/index-DxoO-ywI.d.mts.map +1 -0
- package/dist/index-wKMm41HC.d.mts +30 -0
- package/dist/index-wKMm41HC.d.mts.map +1 -0
- package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs +1091 -0
- package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs.map +1 -0
- package/dist/ir-CQrenTYt.d.mts +147 -0
- package/dist/ir-CQrenTYt.d.mts.map +1 -0
- package/dist/ir-Ch2aPr7a.mjs +62 -0
- package/dist/ir-Ch2aPr7a.mjs.map +1 -0
- package/dist/lowering.d.mts +2 -0
- package/dist/lowering.mjs +1 -0
- package/dist/migration-CNDQv5yB.d.mts +50 -0
- package/dist/migration-CNDQv5yB.d.mts.map +1 -0
- package/dist/migration-dcM7u4HG.mjs +52 -0
- package/dist/migration-dcM7u4HG.mjs.map +1 -0
- package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs +119 -0
- package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map +1 -0
- package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts +27 -0
- package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts.map +1 -0
- package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs +17 -0
- package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs.map +1 -0
- package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts +536 -0
- package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts.map +1 -0
- package/dist/mongodb-types-B4HmhF1S.d.mts +2 -0
- package/dist/orm.d.mts +311 -0
- package/dist/orm.d.mts.map +1 -0
- package/dist/orm.mjs +664 -0
- package/dist/orm.mjs.map +1 -0
- package/dist/pack-D9aLY50F.d.mts +44 -0
- package/dist/pack-D9aLY50F.d.mts.map +1 -0
- package/dist/query-ast.d.mts +5 -0
- package/dist/query-ast.mjs +4 -0
- package/dist/query-ast__control.d.mts +4 -0
- package/dist/query-ast__control.mjs +3 -0
- package/dist/query-ast__execution.d.mts +3 -0
- package/dist/query-ast__execution.mjs +3 -0
- package/dist/query-builder.d.mts +836 -0
- package/dist/query-builder.d.mts.map +1 -0
- package/dist/query-builder.mjs +3 -0
- package/dist/query-builder__contract-free.d.mts +83 -0
- package/dist/query-builder__contract-free.d.mts.map +1 -0
- package/dist/query-builder__contract-free.mjs +107 -0
- package/dist/query-builder__contract-free.mjs.map +1 -0
- package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts +822 -0
- package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts.map +1 -0
- package/dist/runtime-DPkRW4iu.d.mts +1 -0
- package/dist/runtime.d.mts +286 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +532 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-ir.d.mts +2 -0
- package/dist/schema-ir.mjs +2 -0
- package/dist/schema-verify-DJGr28XW.d.mts +23 -0
- package/dist/schema-verify-DJGr28XW.d.mts.map +1 -0
- package/dist/value.d.mts +2 -0
- package/dist/value.mjs +2 -0
- package/dist/value__mongodb-types.d.mts +2 -0
- package/dist/value__mongodb-types.mjs +1 -0
- package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs +447 -0
- package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs.map +1 -0
- package/dist/wire.d.mts +3 -0
- package/dist/wire.mjs +190 -0
- package/dist/wire.mjs.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpreter-BxbUTQ3k-ClR98Ned.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-psl/dist/interpreter-BxbUTQ3k.mjs"],"sourcesContent":["import { MongoIndex, MongoStorage, MongoValidator, applyPolymorphicScopeToMongoIndex, buildMongoNamespace } from \"@internal/mongo-contract\";\nimport { computeProfileHash, computeStorageHash } from \"@internal/contract/hashing\";\nimport { crossRef } from \"@internal/contract/types\";\nimport { errorEnumCodecNotInPackStack } from \"@internal/errors/control\";\nimport { instantiateAuthoringEntityType, isAuthoringEntityTypeDescriptor } from \"@internal/framework-components/authoring\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { nodePslSpan, parseQuotedStringLiteral } from \"@internal/psl-parser\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\n//#region src/derive-json-schema.ts\nfunction resolveBsonType(codecId, codecLookup) {\n\treturn codecLookup?.targetTypesFor(codecId)?.[0];\n}\nfunction fieldToBsonSchema(field, valueObjects, codecLookup, valueSets) {\n\tif (field.type.kind === \"scalar\") {\n\t\tconst bsonType = resolveBsonType(field.type.codecId, codecLookup);\n\t\tif (!bsonType) return void 0;\n\t\tconst enumValues = field.valueSet !== void 0 ? valueSets?.[field.valueSet.entityName]?.values ?? null : null;\n\t\tif (\"many\" in field && field.many) {\n\t\t\tconst items = { bsonType };\n\t\t\tif (enumValues) items[\"enum\"] = enumValues;\n\t\t\treturn {\n\t\t\t\tbsonType: \"array\",\n\t\t\t\titems\n\t\t\t};\n\t\t}\n\t\tif (field.nullable) {\n\t\t\tconst s = { bsonType: [\"null\", bsonType] };\n\t\t\tif (enumValues) s[\"enum\"] = [...enumValues, null];\n\t\t\treturn s;\n\t\t}\n\t\tconst s = { bsonType };\n\t\tif (enumValues) s[\"enum\"] = enumValues;\n\t\treturn s;\n\t}\n\tif (field.type.kind === \"valueObject\") {\n\t\tconst vo = valueObjects?.[field.type.name];\n\t\tif (!vo) return void 0;\n\t\tconst voSchema = deriveObjectSchema(vo.fields, valueObjects, codecLookup, valueSets);\n\t\tif (\"many\" in field && field.many) return {\n\t\t\tbsonType: \"array\",\n\t\t\titems: voSchema\n\t\t};\n\t\tif (field.nullable) return { oneOf: [{ bsonType: \"null\" }, voSchema] };\n\t\treturn voSchema;\n\t}\n}\nfunction deriveObjectSchema(fields, valueObjects, codecLookup, valueSets) {\n\tconst properties = {};\n\tconst required = [];\n\tfor (const [fieldName, field] of Object.entries(fields)) {\n\t\tconst schema = fieldToBsonSchema(field, valueObjects, codecLookup, valueSets);\n\t\tif (schema) {\n\t\t\tproperties[fieldName] = schema;\n\t\t\tif (!field.nullable) required.push(fieldName);\n\t\t}\n\t}\n\tconst result = {\n\t\tbsonType: \"object\",\n\t\tproperties,\n\t\tadditionalProperties: false\n\t};\n\tif (required.length > 0) result[\"required\"] = required.sort();\n\treturn result;\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction deriveJsonSchema(fields, valueObjects, codecLookup, valueSets) {\n\treturn new MongoValidator({\n\t\tjsonSchema: deriveObjectSchema(fields, valueObjects, codecLookup, valueSets),\n\t\tvalidationLevel: \"strict\",\n\t\tvalidationAction: \"error\"\n\t});\n}\nfunction derivePolymorphicJsonSchema(baseFields, discriminatorField, variants, valueObjects, codecLookup, valueSets) {\n\tconst baseSchema = deriveObjectSchema(baseFields, valueObjects, codecLookup, valueSets);\n\tconst baseProperties = isRecord(baseSchema[\"properties\"]) ? baseSchema[\"properties\"] : {};\n\tconst oneOf = [];\n\tfor (const variant of variants) {\n\t\tconst variantOnlyFields = {};\n\t\tfor (const [name, field] of Object.entries(variant.fields)) if (!(name in baseFields)) variantOnlyFields[name] = field;\n\t\tconst variantProperties = {};\n\t\tconst variantRequired = [discriminatorField];\n\t\tfor (const [name, field] of Object.entries(variantOnlyFields)) {\n\t\t\tconst schema = fieldToBsonSchema(field, valueObjects, codecLookup, valueSets);\n\t\t\tif (schema) {\n\t\t\t\tvariantProperties[name] = schema;\n\t\t\t\tif (!field.nullable) variantRequired.push(name);\n\t\t\t}\n\t\t}\n\t\tconst entry = {\n\t\t\tproperties: {\n\t\t\t\t...baseProperties,\n\t\t\t\t[discriminatorField]: { enum: [variant.discriminatorValue] },\n\t\t\t\t...variantProperties\n\t\t\t},\n\t\t\trequired: variantRequired.sort(),\n\t\t\tadditionalProperties: false\n\t\t};\n\t\toneOf.push(entry);\n\t}\n\tconst jsonSchema = { ...baseSchema };\n\tdelete jsonSchema[\"additionalProperties\"];\n\tif (oneOf.length > 0) jsonSchema[\"oneOf\"] = oneOf;\n\treturn new MongoValidator({\n\t\tjsonSchema,\n\t\tvalidationLevel: \"strict\",\n\t\tvalidationAction: \"error\"\n\t});\n}\n//#endregion\n//#region src/psl-helpers.ts\nfunction getPositionalArgument(attr, index = 0) {\n\treturn attr.args.filter((arg) => arg.kind === \"positional\")[index]?.value;\n}\nfunction getNamedArgument(attr, name) {\n\treturn attr.args.find((a) => a.kind === \"named\" && a.name === name)?.value;\n}\nfunction parseFieldList(value) {\n\tconst inner = value.replace(/^\\[/, \"\").replace(/\\]$/, \"\").trim();\n\tif (inner.length === 0) return [];\n\treturn splitTopLevel(inner).map((s) => s.trim());\n}\nfunction parseIndexFieldList(value) {\n\treturn parseFieldList(value).map(parseIndexFieldSegment);\n}\nfunction parseIndexFieldSegment(segment) {\n\tconst wildcardMatch = segment.match(/^wildcard\\(\\s*(.*?)\\s*\\)$/);\n\tif (wildcardMatch) {\n\t\tconst scope = wildcardMatch[1] ?? \"\";\n\t\treturn {\n\t\t\tname: scope.length > 0 ? `${scope}.$**` : \"$**\",\n\t\t\tisWildcard: true\n\t\t};\n\t}\n\tconst modifierMatch = segment.match(/^(\\w+)\\(\\s*sort:\\s*(\\w+)\\s*\\)$/);\n\tif (modifierMatch) return {\n\t\tname: modifierMatch[1] ?? segment,\n\t\tisWildcard: false,\n\t\tdirection: modifierMatch[2] === \"Desc\" ? -1 : 1\n\t};\n\treturn {\n\t\tname: segment,\n\t\tisWildcard: false\n\t};\n}\nfunction splitTopLevel(input) {\n\tconst parts = [];\n\tlet depth = 0;\n\tlet start = 0;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst ch = input[i];\n\t\tif (ch === \"(\" || ch === \"[\" || ch === \"{\") depth++;\n\t\telse if (ch === \")\" || ch === \"]\" || ch === \"}\") depth = Math.max(0, depth - 1);\n\t\telse if (ch === \",\" && depth === 0) {\n\t\t\tparts.push(input.slice(start, i));\n\t\t\tstart = i + 1;\n\t\t}\n\t}\n\tparts.push(input.slice(start));\n\treturn parts;\n}\nfunction lowerFirst(value) {\n\tif (value.length === 0) return value;\n\treturn value[0]?.toLowerCase() + value.slice(1);\n}\nfunction getAttribute(attributes, name) {\n\treturn attributes.find((attr) => attr.name === name);\n}\nfunction getMapName(attributes) {\n\tconst mapAttr = getAttribute(attributes, \"map\");\n\tif (!mapAttr) return void 0;\n\tconst arg = mapAttr.args[0];\n\tif (!arg) return void 0;\n\treturn stripQuotes(arg.value);\n}\nfunction parseRelationAttribute(attributes) {\n\tconst relationAttr = getAttribute(attributes, \"relation\");\n\tif (!relationAttr) return void 0;\n\tlet relationName;\n\tlet fieldsArg;\n\tlet referencesArg;\n\tfor (const arg of relationAttr.args) if (arg.kind === \"positional\") relationName = stripQuotes(arg.value);\n\telse if (arg.name === \"name\") relationName = stripQuotes(arg.value);\n\telse if (arg.name === \"fields\") fieldsArg = arg;\n\telse if (arg.name === \"references\") referencesArg = arg;\n\tconst fields = fieldsArg ? parseFieldList(fieldsArg.value) : void 0;\n\tconst references = referencesArg ? parseFieldList(referencesArg.value) : void 0;\n\treturn {\n\t\t...ifDefined(\"relationName\", relationName),\n\t\t...ifDefined(\"fields\", fields),\n\t\t...ifDefined(\"references\", references)\n\t};\n}\nfunction stripQuotes(value) {\n\tif (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) return value.slice(1, -1);\n\treturn value;\n}\n//#endregion\n//#region src/interpreter.ts\n/**\n* Encode an authored enum value to its codec-encoded JSON form via the codec resolved by id from the\n* contract's codec lookup, so a non-identity `encodeJson` (permitted by the `mongoCodec` factory) is\n* respected. Matches the TS builder's `encodeEnumValue`: the lookup is always threaded in production,\n* and a codecId the lookup cannot resolve is a hard error — the enum uses a codec that is not part of\n* the contract's pack stack.\n*/\nfunction encodeEnumValue(value, codecId, codecLookup) {\n\tconst codec = codecLookup.get(codecId);\n\tif (!codec) throw errorEnumCodecNotInPackStack({ codecId });\n\treturn codec.encodeJson(value);\n}\n/**\n* Mongo's PSL surface binds the database from the connection string, so every\n* explicit namespace block is invalid, including `namespace unbound { … }`.\n*/\nfunction validateNamespaceBlocksForMongoTarget(input) {\n\tfor (const namespace of input.namespaces) input.diagnostics.push({\n\t\tcode: \"PSL_UNSUPPORTED_NAMESPACE_BLOCK\",\n\t\tmessage: `Mongo does not support \\`namespace ${namespace.name} { … }\\` blocks (the database is bound by the connection string; declare models at the document top level instead).`,\n\t\tsourceId: input.sourceId,\n\t\tspan: nodePslSpan(namespace.node.syntax, input.sourceFile)\n\t});\n}\nfunction fkRelationPairKey(declaringModel, targetModel) {\n\treturn `${declaringModel}::${targetModel}`;\n}\nfunction resolveFieldMappings(model) {\n\tconst pslNameToMapped = /* @__PURE__ */ new Map();\n\tfor (const field of Object.values(model.fields)) {\n\t\tconst mapped = getMapName(field.attributes) ?? field.name;\n\t\tpslNameToMapped.set(field.name, mapped);\n\t}\n\treturn { pslNameToMapped };\n}\nfunction resolveCollectionName(model) {\n\treturn getMapName(model.attributes) ?? lowerFirst(model.name);\n}\nfunction mongoCrossRef(modelName) {\n\treturn crossRef(modelName, UNBOUND_NAMESPACE_ID);\n}\nfunction collectPolymorphismDeclarations(models, sourceId, diagnostics) {\n\tconst discriminatorDeclarations = /* @__PURE__ */ new Map();\n\tconst baseDeclarations = /* @__PURE__ */ new Map();\n\tfor (const model of models) for (const attr of model.attributes) {\n\t\tif (attr.name === \"discriminator\") {\n\t\t\tconst fieldName = getPositionalArgument(attr);\n\t\t\tif (!fieldName) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_ATTRIBUTE_ARGUMENT\",\n\t\t\t\t\tmessage: `Model \"${model.name}\" @@discriminator requires a field name argument`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: attr.span\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst discField = model.fields[fieldName];\n\t\t\tif (discField && discField.typeName !== \"String\") {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_ATTRIBUTE_ARGUMENT\",\n\t\t\t\t\tmessage: `Discriminator field \"${fieldName}\" on model \"${model.name}\" must be of type String, but is \"${discField.typeName}\"`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: attr.span\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdiscriminatorDeclarations.set(model.name, {\n\t\t\t\tfieldName,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t}\n\t\tif (attr.name === \"base\") {\n\t\t\tconst baseName = getPositionalArgument(attr, 0);\n\t\t\tconst rawValue = getPositionalArgument(attr, 1);\n\t\t\tif (!baseName || !rawValue) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_ATTRIBUTE_ARGUMENT\",\n\t\t\t\t\tmessage: `Model \"${model.name}\" @@base requires two arguments: base model name and discriminator value`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: attr.span\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst value = parseQuotedStringLiteral(rawValue);\n\t\t\tif (value === void 0) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_ATTRIBUTE_ARGUMENT\",\n\t\t\t\t\tmessage: `Model \"${model.name}\" @@base discriminator value must be a quoted string literal`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: attr.span\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst collectionName = resolveCollectionName(model);\n\t\t\tbaseDeclarations.set(model.name, {\n\t\t\t\tbaseName,\n\t\t\t\tvalue,\n\t\t\t\tcollectionName,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t}\n\t}\n\treturn {\n\t\tdiscriminatorDeclarations,\n\t\tbaseDeclarations\n\t};\n}\nfunction resolvePolymorphism(input) {\n\tconst { discriminatorDeclarations, baseDeclarations, modelNames, sourceId, allModels: allModelViews, indexSpans, modelIndexesByName } = input;\n\tlet patched = input.models;\n\tlet roots = input.roots;\n\tlet collections = input.collections;\n\tconst diagnostics = [];\n\tfor (const [modelName, decl] of discriminatorDeclarations) {\n\t\tif (baseDeclarations.has(modelName)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_DISCRIMINATOR_AND_BASE\",\n\t\t\t\tmessage: `Model \"${modelName}\" cannot have both @@discriminator and @@base`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: decl.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst model = patched[modelName];\n\t\tif (!model) continue;\n\t\tconst modelView = allModelViews.find((m) => m.name === modelName);\n\t\tconst mappedDiscriminatorField = modelView ? resolveFieldMappings(modelView).pslNameToMapped.get(decl.fieldName) ?? decl.fieldName : decl.fieldName;\n\t\tif (!Object.hasOwn(model.fields, mappedDiscriminatorField)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_DISCRIMINATOR_FIELD_NOT_FOUND\",\n\t\t\t\tmessage: `Discriminator field \"${decl.fieldName}\" is not a field on model \"${modelName}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: decl.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst variants = {};\n\t\tfor (const [variantName, baseDecl] of baseDeclarations) {\n\t\t\tif (baseDecl.baseName !== modelName) continue;\n\t\t\tvariants[variantName] = { value: baseDecl.value };\n\t\t}\n\t\tif (Object.keys(variants).length === 0) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_ORPHANED_DISCRIMINATOR\",\n\t\t\t\tmessage: `Model \"${modelName}\" has @@discriminator but no variant models declare @@base(${modelName}, ...)`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: decl.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tpatched = {\n\t\t\t...patched,\n\t\t\t[modelName]: {\n\t\t\t\t...model,\n\t\t\t\tdiscriminator: { field: mappedDiscriminatorField },\n\t\t\t\tvariants\n\t\t\t}\n\t\t};\n\t}\n\tfor (const [variantName, baseDecl] of baseDeclarations) {\n\t\tif (!modelNames.has(baseDecl.baseName)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_BASE_TARGET_NOT_FOUND\",\n\t\t\t\tmessage: `Model \"${variantName}\" @@base references non-existent model \"${baseDecl.baseName}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: baseDecl.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (!discriminatorDeclarations.has(baseDecl.baseName)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_ORPHANED_BASE\",\n\t\t\t\tmessage: `Model \"${variantName}\" declares @@base(${baseDecl.baseName}, ...) but \"${baseDecl.baseName}\" has no @@discriminator`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: baseDecl.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (discriminatorDeclarations.has(variantName)) continue;\n\t\tconst baseModel = patched[baseDecl.baseName];\n\t\tconst variantModelView = allModelViews.find((m) => m.name === variantName);\n\t\tif (!variantModelView) continue;\n\t\tif (getMapName(variantModelView.attributes) !== void 0 && baseModel && baseDecl.collectionName !== baseModel.storage.collection) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_MONGO_VARIANT_SEPARATE_COLLECTION\",\n\t\t\t\tmessage: `Mongo variant \"${variantName}\" cannot use a different collection than its base \"${baseDecl.baseName}\". Mongo only supports single-collection polymorphism.`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: baseDecl.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst baseCollection = baseModel?.storage.collection ?? baseDecl.collectionName;\n\t\tconst variantModel = patched[variantName];\n\t\tif (variantModel) patched = {\n\t\t\t...patched,\n\t\t\t[variantName]: {\n\t\t\t\t...variantModel,\n\t\t\t\tbase: mongoCrossRef(baseDecl.baseName),\n\t\t\t\tstorage: { collection: baseCollection }\n\t\t\t}\n\t\t};\n\t\tconst variantCollectionName = resolveCollectionName(variantModelView);\n\t\tif (roots[variantCollectionName]?.model === variantName) if (variantCollectionName === baseCollection && baseModel) roots = {\n\t\t\t...roots,\n\t\t\t[variantCollectionName]: mongoCrossRef(baseDecl.baseName)\n\t\t};\n\t\telse roots = Object.fromEntries(Object.entries(roots).filter(([key]) => key !== variantCollectionName));\n\t\tconst variantOwnIndexes = modelIndexesByName.get(variantName) ?? [];\n\t\tconst baseColl = collections[baseCollection];\n\t\tconst discriminatorField = patched[baseDecl.baseName]?.discriminator?.field;\n\t\tconst scopedVariantIndexes = [];\n\t\tif (discriminatorField) for (const idx of variantOwnIndexes) {\n\t\t\tconst result = applyPolymorphicScopeToMongoIndex(idx, {\n\t\t\t\tdiscriminatorField,\n\t\t\t\tdiscriminatorValue: baseDecl.value\n\t\t\t});\n\t\t\tif (result.kind === \"conflict\") {\n\t\t\t\tconst span = indexSpans.get(idx) ?? baseDecl.span;\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\t\tmessage: `Variant \"${variantName}\" index conflicts with discriminator scope: ${result.reason}`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (result.index !== idx) indexSpans.set(result.index, indexSpans.get(idx) ?? baseDecl.span);\n\t\t\tscopedVariantIndexes.push(result.index);\n\t\t}\n\t\telse scopedVariantIndexes.push(...variantOwnIndexes);\n\t\tif (variantCollectionName !== baseCollection) {\n\t\t\tconst filtered = Object.fromEntries(Object.entries(collections).filter(([key]) => key !== variantCollectionName));\n\t\t\tif (scopedVariantIndexes.length > 0 && baseColl) {\n\t\t\t\tconst baseIndexes = baseColl[\"indexes\"] ?? [];\n\t\t\t\tcollections = {\n\t\t\t\t\t...filtered,\n\t\t\t\t\t[baseCollection]: {\n\t\t\t\t\t\t...baseColl,\n\t\t\t\t\t\tindexes: [...baseIndexes, ...scopedVariantIndexes]\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} else collections = filtered;\n\t\t} else if (baseColl) {\n\t\t\tconst existingIndexes = baseColl[\"indexes\"] ?? [];\n\t\t\tconst variantIndexSet = new Set(variantOwnIndexes);\n\t\t\tconst withoutUnscopedVariants = existingIndexes.filter((idx) => !variantIndexSet.has(idx));\n\t\t\tconst mergedIndexes = [...withoutUnscopedVariants];\n\t\t\tfor (const idx of scopedVariantIndexes) {\n\t\t\t\tconst idxKey = canonicalJson(idx);\n\t\t\t\tif (!withoutUnscopedVariants.some((existing) => canonicalJson(existing) === idxKey)) mergedIndexes.push(idx);\n\t\t\t}\n\t\t\tif (mergedIndexes.length !== existingIndexes.length || mergedIndexes.some((idx, i) => idx !== existingIndexes[i])) {\n\t\t\t\tconst next = { ...baseColl };\n\t\t\t\tif (mergedIndexes.length > 0) next[\"indexes\"] = mergedIndexes;\n\t\t\t\telse delete next[\"indexes\"];\n\t\t\t\tcollections = {\n\t\t\t\t\t...collections,\n\t\t\t\t\t[baseCollection]: next\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\tmodels: patched,\n\t\troots,\n\t\tcollections,\n\t\tdiagnostics\n\t};\n}\nfunction canonicalJson(value) {\n\tif (Array.isArray(value)) return `[${value.map(canonicalJson).join(\",\")}]`;\n\tif (value && typeof value === \"object\") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(\",\")}}`;\n\treturn JSON.stringify(value);\n}\nfunction parseIndexDirection(raw) {\n\tif (!raw) return 1;\n\tconst stripped = raw.replace(/^[\"']/, \"\").replace(/[\"']$/, \"\");\n\tconst num = Number(stripped);\n\tif (num === 1 || num === -1) return num;\n\tif ([\n\t\t\"text\",\n\t\t\"2dsphere\",\n\t\t\"2d\",\n\t\t\"hashed\"\n\t].includes(stripped)) return stripped;\n\treturn 1;\n}\nfunction parseNumericArg(raw) {\n\tif (!raw) return void 0;\n\tconst n = Number(raw);\n\treturn Number.isFinite(n) ? n : void 0;\n}\nfunction parseBooleanArg(raw) {\n\tif (raw === \"true\") return true;\n\tif (raw === \"false\") return false;\n}\nfunction parseJsonArg(raw) {\n\tif (!raw) return void 0;\n\tconst stripped = raw.replace(/^[\"']/, \"\").replace(/[\"']$/, \"\").replace(/\\\\\"/g, \"\\\"\");\n\ttry {\n\t\tconst parsed = JSON.parse(stripped);\n\t\tif (typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed)) return parsed;\n\t} catch {}\n}\nfunction parseCollation(attr) {\n\tconst locale = stripQuotesHelper(getNamedArgument(attr, \"collationLocale\"));\n\tif (!locale) return getNamedArgument(attr, \"collationStrength\") != null || getNamedArgument(attr, \"collationCaseLevel\") != null || getNamedArgument(attr, \"collationCaseFirst\") != null || getNamedArgument(attr, \"collationNumericOrdering\") != null || getNamedArgument(attr, \"collationAlternate\") != null || getNamedArgument(attr, \"collationMaxVariable\") != null || getNamedArgument(attr, \"collationBackwards\") != null || getNamedArgument(attr, \"collationNormalization\") != null ? null : void 0;\n\tconst collation = { locale };\n\tconst strength = parseNumericArg(getNamedArgument(attr, \"collationStrength\"));\n\tif (strength != null) collation.strength = strength;\n\tconst caseLevel = parseBooleanArg(getNamedArgument(attr, \"collationCaseLevel\"));\n\tif (caseLevel != null) collation.caseLevel = caseLevel;\n\tconst caseFirst = stripQuotesHelper(getNamedArgument(attr, \"collationCaseFirst\"));\n\tif (caseFirst != null) collation.caseFirst = caseFirst;\n\tconst numericOrdering = parseBooleanArg(getNamedArgument(attr, \"collationNumericOrdering\"));\n\tif (numericOrdering != null) collation.numericOrdering = numericOrdering;\n\tconst alternate = stripQuotesHelper(getNamedArgument(attr, \"collationAlternate\"));\n\tif (alternate != null) collation.alternate = alternate;\n\tconst maxVariable = stripQuotesHelper(getNamedArgument(attr, \"collationMaxVariable\"));\n\tif (maxVariable != null) collation.maxVariable = maxVariable;\n\tconst backwards = parseBooleanArg(getNamedArgument(attr, \"collationBackwards\"));\n\tif (backwards != null) collation.backwards = backwards;\n\tconst normalization = parseBooleanArg(getNamedArgument(attr, \"collationNormalization\"));\n\tif (normalization != null) collation.normalization = normalization;\n\treturn collation;\n}\nfunction stripQuotesHelper(raw) {\n\tif (!raw) return void 0;\n\treturn raw.replace(/^[\"']/, \"\").replace(/[\"']$/, \"\");\n}\nfunction parseProjectionList(raw, value) {\n\tif (!raw) return void 0;\n\tconst inner = raw.replace(/^[\"']/, \"\").replace(/[\"']$/, \"\").replace(/^\\[/, \"\").replace(/\\]$/, \"\").trim();\n\tif (inner.length === 0) return void 0;\n\tconst fields = inner.split(\",\").map((s) => s.trim()).filter((s) => s.length > 0);\n\tconst result = {};\n\tfor (const f of fields) result[f] = value;\n\treturn result;\n}\nfunction collectIndexes(pslModel, fieldMappings, modelNames, sourceId, diagnostics, indexSpans) {\n\tconst indexes = [];\n\tlet textIndexCount = 0;\n\tconst indexableFieldNames = /* @__PURE__ */ new Set();\n\tfor (const f of Object.values(pslModel.fields)) {\n\t\tif (modelNames.has(f.typeName)) continue;\n\t\tindexableFieldNames.add(f.name);\n\t}\n\tfor (const field of Object.values(pslModel.fields)) {\n\t\tif (modelNames.has(field.typeName)) continue;\n\t\tconst uniqueAttr = getAttribute(field.attributes, \"unique\");\n\t\tif (!uniqueAttr) continue;\n\t\tconst fieldUniqueIndex = new MongoIndex({\n\t\t\tkeys: [{\n\t\t\t\tfield: fieldMappings.pslNameToMapped.get(field.name) ?? field.name,\n\t\t\t\tdirection: 1\n\t\t\t}],\n\t\t\tunique: true\n\t\t});\n\t\tindexes.push(fieldUniqueIndex);\n\t\tindexSpans.set(fieldUniqueIndex, uniqueAttr.span);\n\t}\n\tfor (const attr of pslModel.attributes) {\n\t\tconst isIndex = attr.name === \"index\";\n\t\tconst isUnique = attr.name === \"unique\";\n\t\tconst isTextIndex = attr.name === \"textIndex\";\n\t\tif (!isIndex && !isUnique && !isTextIndex) continue;\n\t\tconst fieldsArg = getPositionalArgument(attr, 0);\n\t\tif (!fieldsArg) continue;\n\t\tconst parsedFields = parseIndexFieldList(fieldsArg);\n\t\tif (parsedFields.length === 0) continue;\n\t\tconst hasWildcard = parsedFields.some((f) => f.isWildcard);\n\t\tif (parsedFields.filter((f) => f.isWildcard).length > 1) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"An index can contain at most one wildcard() field\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (isUnique && hasWildcard) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"Unique indexes cannot use wildcard() fields\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (isTextIndex) {\n\t\t\ttextIndexCount++;\n\t\t\tif (textIndexCount > 1) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\t\tmessage: `Only one @@textIndex is allowed per collection (model \"${pslModel.name}\")`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: attr.span\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (hasWildcard) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\t\tmessage: \"wildcard() fields cannot be combined with type: hashed/2dsphere/2d or @@textIndex\",\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: attr.span\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tconst typeArg = getNamedArgument(attr, \"type\");\n\t\tconst defaultDirection = isTextIndex ? \"text\" : parseIndexDirection(typeArg);\n\t\tif (hasWildcard && typeof defaultDirection === \"string\" && [\n\t\t\t\"hashed\",\n\t\t\t\"2dsphere\",\n\t\t\t\"2d\"\n\t\t].includes(defaultDirection)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: `wildcard() fields cannot be combined with type: ${defaultDirection}`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (defaultDirection === \"hashed\" && parsedFields.length > 1) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"Hashed indexes must have exactly one field\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tlet missingField;\n\t\tfor (const pf of parsedFields) {\n\t\t\tlet fieldNameForLookup;\n\t\t\tif (pf.isWildcard) {\n\t\t\t\tconst wildcardMatch = pf.name.match(/^(.+)\\.\\$\\*\\*$/);\n\t\t\t\tfieldNameForLookup = wildcardMatch ? wildcardMatch[1] : void 0;\n\t\t\t} else fieldNameForLookup = pf.name;\n\t\t\tif (fieldNameForLookup === void 0 || fieldNameForLookup.length === 0) continue;\n\t\t\tif (!indexableFieldNames.has(fieldNameForLookup)) {\n\t\t\t\tmissingField = fieldNameForLookup;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (missingField !== void 0) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INDEX_FIELD_NOT_FOUND\",\n\t\t\t\tmessage: `Index on model \"${pslModel.name}\" references unknown field \"${missingField}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst keys = parsedFields.map((pf) => {\n\t\t\treturn {\n\t\t\t\tfield: pf.isWildcard ? pf.name.replace(/^(.+)\\.\\$\\*\\*$/, (_, prefix) => {\n\t\t\t\t\tconst mapped = fieldMappings.pslNameToMapped.get(prefix);\n\t\t\t\t\treturn mapped ? `${mapped}.$**` : `${prefix}.$**`;\n\t\t\t\t}) : fieldMappings.pslNameToMapped.get(pf.name) ?? pf.name,\n\t\t\t\tdirection: pf.direction != null ? pf.direction : defaultDirection\n\t\t\t};\n\t\t});\n\t\tconst unique = isUnique ? true : void 0;\n\t\tconst sparse = isTextIndex ? void 0 : parseBooleanArg(getNamedArgument(attr, \"sparse\"));\n\t\tconst expireAfterSeconds = isTextIndex ? void 0 : parseNumericArg(getNamedArgument(attr, \"expireAfterSeconds\"));\n\t\tif (hasWildcard && expireAfterSeconds != null) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"expireAfterSeconds cannot be combined with wildcard() fields\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst partialFilterExpression = parseJsonArg(getNamedArgument(attr, \"filter\"));\n\t\tconst includeArg = getNamedArgument(attr, \"include\");\n\t\tconst excludeArg = getNamedArgument(attr, \"exclude\");\n\t\tif (includeArg != null && excludeArg != null) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"Cannot specify both include and exclude on the same index\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif ((includeArg != null || excludeArg != null) && !hasWildcard) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"include/exclude options are only valid when the index contains a wildcard() field\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst wildcardProjection = includeArg != null ? parseProjectionList(includeArg, 1) : excludeArg != null ? parseProjectionList(excludeArg, 0) : void 0;\n\t\tconst collation = parseCollation(attr);\n\t\tif (collation === null) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_INDEX\",\n\t\t\t\tmessage: \"collationLocale is required when using collation options\",\n\t\t\t\tsourceId,\n\t\t\t\tspan: attr.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst rawWeights = parseJsonArg(getNamedArgument(attr, \"weights\"));\n\t\tlet weights;\n\t\tif (rawWeights) {\n\t\t\tweights = {};\n\t\t\tfor (const [k, v] of Object.entries(rawWeights)) if (typeof v === \"number\") weights[k] = v;\n\t\t}\n\t\tconst default_language = stripQuotesHelper(isTextIndex ? getNamedArgument(attr, \"language\") : getNamedArgument(attr, \"default_language\"));\n\t\tconst language_override = stripQuotesHelper(getNamedArgument(attr, \"languageOverride\"));\n\t\tconst index = new MongoIndex({\n\t\t\tkeys,\n\t\t\t...unique != null && { unique },\n\t\t\t...sparse != null && { sparse },\n\t\t\t...expireAfterSeconds != null && { expireAfterSeconds },\n\t\t\t...partialFilterExpression != null && { partialFilterExpression },\n\t\t\t...wildcardProjection != null && { wildcardProjection },\n\t\t\t...collation != null && { collation },\n\t\t\t...weights != null && { weights },\n\t\t\t...default_language != null && { default_language },\n\t\t\t...language_override != null && { language_override }\n\t\t});\n\t\tindexes.push(index);\n\t\tindexSpans.set(index, attr.span);\n\t}\n\treturn indexes;\n}\nfunction isRelationField(field, modelNames) {\n\treturn modelNames.has(field.typeName);\n}\nconst MONGO_OBJECT_ID_PSL_TYPE = \"ObjectId\";\nfunction resolveFieldCodecId(field, scalarTypeCodecIds) {\n\treturn scalarTypeCodecIds.get(field.typeName);\n}\nfunction resolveNonRelationField(field, ownerName, compositeTypeNames, scalarTypeCodecIds, codecIdByEnumName, sourceId, diagnostics) {\n\tif (compositeTypeNames.has(field.typeName)) {\n\t\tconst result = {\n\t\t\ttype: {\n\t\t\t\tkind: \"valueObject\",\n\t\t\t\tname: field.typeName\n\t\t\t},\n\t\t\tnullable: field.optional\n\t\t};\n\t\treturn field.list ? {\n\t\t\t...result,\n\t\t\tmany: true\n\t\t} : result;\n\t}\n\tconst enumCodecId = codecIdByEnumName.get(field.typeName);\n\tif (enumCodecId !== void 0) {\n\t\tconst valueSet = {\n\t\t\tplane: \"domain\",\n\t\t\tentityKind: \"enum\",\n\t\t\tnamespaceId: UNBOUND_NAMESPACE_ID,\n\t\t\tentityName: field.typeName\n\t\t};\n\t\tconst result = {\n\t\t\ttype: {\n\t\t\t\tkind: \"scalar\",\n\t\t\t\tcodecId: enumCodecId\n\t\t\t},\n\t\t\tnullable: field.optional,\n\t\t\tvalueSet\n\t\t};\n\t\treturn field.list ? {\n\t\t\t...result,\n\t\t\tmany: true\n\t\t} : result;\n\t}\n\tif (field.malformedType) return;\n\tconst codecId = resolveFieldCodecId(field, scalarTypeCodecIds);\n\tif (!codecId) {\n\t\tdiagnostics.push({\n\t\t\tcode: \"PSL_UNSUPPORTED_FIELD_TYPE\",\n\t\t\tmessage: `Field \"${ownerName}.${field.name}\" type \"${field.typeName}\" is not supported in Mongo PSL interpreter`,\n\t\t\tsourceId,\n\t\t\tspan: field.span\n\t\t});\n\t\treturn;\n\t}\n\tconst result = {\n\t\ttype: {\n\t\t\tkind: \"scalar\",\n\t\t\tcodecId\n\t\t},\n\t\tnullable: field.optional\n\t};\n\treturn field.list ? {\n\t\t...result,\n\t\tmany: true\n\t} : result;\n}\nfunction processEnumDeclarations(input) {\n\tconst builtEnums = {};\n\tif (input.enumBlocks.length === 0) return builtEnums;\n\tconst enumDescriptor = input.authoringContributions?.entityTypes?.[\"enum\"] !== void 0 && isAuthoringEntityTypeDescriptor(input.authoringContributions.entityTypes[\"enum\"]) ? input.authoringContributions.entityTypes[\"enum\"] : void 0;\n\tif (!enumDescriptor) {\n\t\tfor (const decl of input.enumBlocks) input.diagnostics.push({\n\t\t\tcode: \"PSL_ENUM_MISSING_FACTORY\",\n\t\t\tmessage: `enum \"${decl.name}\" requires an \"enum\" entityType factory in the active authoring contributions`,\n\t\t\tsourceId: input.sourceId,\n\t\t\tspan: decl.span\n\t\t});\n\t\treturn builtEnums;\n\t}\n\tfor (const decl of input.enumBlocks) {\n\t\tconst handle = instantiateAuthoringEntityType(\"enum\", enumDescriptor, [decl], input.entityContext);\n\t\tif (handle === void 0 || handle === null) continue;\n\t\tbuiltEnums[decl.name] = {\n\t\t\tcodecId: handle.codecId,\n\t\t\tmembers: handle.enumMembers.map((m) => ({\n\t\t\t\tname: m.name,\n\t\t\t\tvalue: blindCast(m.value)\n\t\t\t}))\n\t\t};\n\t}\n\treturn builtEnums;\n}\nfunction interpretPslDocumentToMongoContract(input) {\n\tconst { symbolTable, sourceFile, scalarTypeCodecIds, codecLookup } = input;\n\tconst sourceId = input.sourceId;\n\tconst diagnostics = [...input.seedDiagnostics ?? []];\n\tconst topLevel = symbolTable.topLevel;\n\tvalidateNamespaceBlocksForMongoTarget({\n\t\tnamespaces: Object.values(topLevel.namespaces),\n\t\tsourceId,\n\t\tsourceFile,\n\t\tdiagnostics\n\t});\n\tconst allModels = Object.values(topLevel.models);\n\tconst allCompositeTypes = Object.values(topLevel.compositeTypes);\n\tconst modelNames = new Set(allModels.map((m) => m.name));\n\tconst compositeTypeNames = new Set(allCompositeTypes.map((ct) => ct.name));\n\tconst builtEnums = processEnumDeclarations({\n\t\tenumBlocks: Object.values(topLevel.blocks).filter((b) => b.keyword === \"enum\").map((b) => b.block),\n\t\tsourceId,\n\t\tauthoringContributions: input.authoringContributions,\n\t\tentityContext: {\n\t\t\tfamily: \"mongo\",\n\t\t\ttarget: \"mongo\",\n\t\t\t...ifDefined(\"enumInferenceCodecs\", input.enumInferenceCodecs),\n\t\t\t...ifDefined(\"codecLookup\", codecLookup),\n\t\t\tsourceId,\n\t\t\tdiagnostics: { push: (d) => {\n\t\t\t\tdiagnostics.push(blindCast(d));\n\t\t\t} }\n\t\t},\n\t\tdiagnostics\n\t});\n\tconst codecIdByEnumName = new Map(Object.entries(builtEnums).map(([name, e]) => [name, e.codecId]));\n\tconst models = {};\n\tconst collections = {};\n\tconst roots = {};\n\tconst allFkRelations = [];\n\tconst indexSpans = /* @__PURE__ */ new Map();\n\tconst modelIndexesByName = /* @__PURE__ */ new Map();\n\tconst backrelationCandidates = [];\n\tfor (const pslModel of allModels) {\n\t\tconst collectionName = resolveCollectionName(pslModel);\n\t\tconst fieldMappings = resolveFieldMappings(pslModel);\n\t\tconst fields = {};\n\t\tconst relations = {};\n\t\tfor (const field of Object.values(pslModel.fields)) {\n\t\t\tif (isRelationField(field, modelNames)) {\n\t\t\t\tconst relation = parseRelationAttribute(field.attributes);\n\t\t\t\tif (field.list || !(relation?.fields && relation?.references)) {\n\t\t\t\t\tbackrelationCandidates.push({\n\t\t\t\t\t\tmodelName: pslModel.name,\n\t\t\t\t\t\tfieldName: field.name,\n\t\t\t\t\t\ttargetModelName: field.typeName,\n\t\t\t\t\t\t...ifDefined(\"relationName\", relation?.relationName),\n\t\t\t\t\t\tcardinality: field.list ? \"1:N\" : \"1:1\",\n\t\t\t\t\t\tfield\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (relation?.fields && relation?.references) {\n\t\t\t\t\tconst localMapped = relation.fields.map((f) => fieldMappings.pslNameToMapped.get(f) ?? f);\n\t\t\t\t\tconst targetModel = allModels.find((m) => m.name === field.typeName);\n\t\t\t\t\tconst targetFieldMappings = targetModel ? resolveFieldMappings(targetModel) : void 0;\n\t\t\t\t\tconst targetMapped = relation.references.map((f) => targetFieldMappings?.pslNameToMapped.get(f) ?? f);\n\t\t\t\t\trelations[field.name] = {\n\t\t\t\t\t\tto: mongoCrossRef(field.typeName),\n\t\t\t\t\t\tcardinality: \"N:1\",\n\t\t\t\t\t\ton: {\n\t\t\t\t\t\t\tlocalFields: localMapped,\n\t\t\t\t\t\t\ttargetFields: targetMapped\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tallFkRelations.push({\n\t\t\t\t\t\tdeclaringModel: pslModel.name,\n\t\t\t\t\t\tfieldName: field.name,\n\t\t\t\t\t\ttargetModel: field.typeName,\n\t\t\t\t\t\t...ifDefined(\"relationName\", relation.relationName),\n\t\t\t\t\t\tlocalFields: localMapped,\n\t\t\t\t\t\ttargetFields: targetMapped\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst resolved = resolveNonRelationField(field, pslModel.name, compositeTypeNames, scalarTypeCodecIds, codecIdByEnumName, sourceId, diagnostics);\n\t\t\tif (!resolved) continue;\n\t\t\tconst mappedName = fieldMappings.pslNameToMapped.get(field.name) ?? field.name;\n\t\t\tfields[mappedName] = resolved;\n\t\t}\n\t\tconst isVariantModel = pslModel.attributes.some((attr) => attr.name === \"base\");\n\t\tconst hasIdField = Object.values(pslModel.fields).some((f) => getAttribute(f.attributes, \"id\") !== void 0);\n\t\tif (!isVariantModel) if (!hasIdField) diagnostics.push({\n\t\t\tcode: \"PSL_MISSING_ID_FIELD\",\n\t\t\tmessage: `Model \"${pslModel.name}\" has no field with @id attribute. Every model must have exactly one @id field.`,\n\t\t\tsourceId\n\t\t});\n\t\telse {\n\t\t\tconst objectIdCodecId = scalarTypeCodecIds.get(MONGO_OBJECT_ID_PSL_TYPE);\n\t\t\tconst idField = fields[\"_id\"];\n\t\t\tif (!(idField !== void 0 && idField.type.kind === \"scalar\" && objectIdCodecId !== void 0 && idField.type.codecId === objectIdCodecId)) diagnostics.push({\n\t\t\t\tcode: \"PSL_MONGO_ID_REQUIRED\",\n\t\t\t\tmessage: `Model \"${pslModel.name}\" must declare an _id field of type ObjectId (e.g. \\`id ObjectId @id @map(\"_id\")\\`).`,\n\t\t\t\tsourceId\n\t\t\t});\n\t\t}\n\t\tmodels[pslModel.name] = {\n\t\t\tfields,\n\t\t\trelations,\n\t\t\tstorage: { collection: collectionName }\n\t\t};\n\t\tconst modelIndexes = collectIndexes(pslModel, fieldMappings, modelNames, sourceId, diagnostics, indexSpans);\n\t\tmodelIndexesByName.set(pslModel.name, modelIndexes);\n\t\tconst existingColl = collections[collectionName];\n\t\tif (existingColl && modelIndexes.length > 0) collections[collectionName] = { indexes: [...existingColl[\"indexes\"] ?? [], ...modelIndexes] };\n\t\telse if (!existingColl) collections[collectionName] = modelIndexes.length > 0 ? { indexes: modelIndexes } : {};\n\t\troots[collectionName] = mongoCrossRef(pslModel.name);\n\t}\n\tconst valueObjects = {};\n\tfor (const compositeType of allCompositeTypes) {\n\t\tconst fields = {};\n\t\tfor (const field of Object.values(compositeType.fields)) {\n\t\t\tconst resolved = resolveNonRelationField(field, compositeType.name, compositeTypeNames, scalarTypeCodecIds, codecIdByEnumName, sourceId, diagnostics);\n\t\t\tif (!resolved) continue;\n\t\t\tfields[field.name] = resolved;\n\t\t}\n\t\tvalueObjects[compositeType.name] = { fields };\n\t}\n\tconst fkRelationsByPair = /* @__PURE__ */ new Map();\n\tfor (const fk of allFkRelations) {\n\t\tconst key = fkRelationPairKey(fk.declaringModel, fk.targetModel);\n\t\tconst existing = fkRelationsByPair.get(key);\n\t\tif (existing) existing.push(fk);\n\t\telse fkRelationsByPair.set(key, [fk]);\n\t}\n\tfor (const candidate of backrelationCandidates) {\n\t\tconst pairKey = fkRelationPairKey(candidate.targetModelName, candidate.modelName);\n\t\tconst pairMatches = fkRelationsByPair.get(pairKey) ?? [];\n\t\tconst matches = candidate.relationName ? pairMatches.filter((r) => r.relationName === candidate.relationName) : [...pairMatches];\n\t\tif (matches.length === 0) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_ORPHANED_BACKRELATION\",\n\t\t\t\tmessage: `Backrelation list field \"${candidate.modelName}.${candidate.fieldName}\" has no matching FK-side relation on model \"${candidate.targetModelName}\". Add @relation(fields: [...], references: [...]) on the FK-side relation or use an explicit join model for many-to-many.`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: candidate.field.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (matches.length > 1) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"PSL_AMBIGUOUS_BACKRELATION\",\n\t\t\t\tmessage: `Backrelation list field \"${candidate.modelName}.${candidate.fieldName}\" matches multiple FK-side relations on model \"${candidate.targetModelName}\". Add @relation(\"...\") to both sides to disambiguate.`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: candidate.field.span\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst fk = matches[0];\n\t\tif (!fk) continue;\n\t\tconst modelEntry = models[candidate.modelName];\n\t\tif (!modelEntry) continue;\n\t\tmodelEntry.relations[candidate.fieldName] = {\n\t\t\tto: mongoCrossRef(candidate.targetModelName),\n\t\t\tcardinality: candidate.cardinality,\n\t\t\ton: {\n\t\t\t\tlocalFields: fk.targetFields,\n\t\t\t\ttargetFields: fk.localFields\n\t\t\t}\n\t\t};\n\t}\n\tconst { discriminatorDeclarations, baseDeclarations } = collectPolymorphismDeclarations(allModels, sourceId, diagnostics);\n\tconst polyResult = resolvePolymorphism({\n\t\tmodels,\n\t\troots,\n\t\tcollections,\n\t\tallModels,\n\t\tdiscriminatorDeclarations,\n\t\tbaseDeclarations,\n\t\tmodelNames,\n\t\tindexSpans,\n\t\tmodelIndexesByName,\n\t\tsourceId\n\t});\n\tif (diagnostics.length > 0 || polyResult.diagnostics.length > 0) return notOk({\n\t\tsummary: \"PSL to Mongo contract interpretation failed\",\n\t\tdiagnostics: [...diagnostics, ...polyResult.diagnostics]\n\t});\n\tconst resolvedModels = polyResult.models;\n\tconst resolvedCollections = polyResult.collections;\n\tconst storageValueSets = {};\n\tconst enumEntries = Object.entries(builtEnums);\n\tif (enumEntries.length > 0) {\n\t\tassertDefined(codecLookup, \"Mongo PSL interpretation requires a codec lookup to encode enum values\");\n\t\tfor (const [enumName, builtEnum] of enumEntries) storageValueSets[enumName] = {\n\t\t\tkind: \"valueSet\",\n\t\t\tvalues: builtEnum.members.map((m) => encodeEnumValue(m.value, builtEnum.codecId, codecLookup))\n\t\t};\n\t}\n\tfor (const [, modelEntry] of Object.entries(resolvedModels)) {\n\t\tif (modelEntry.base) continue;\n\t\tconst coll = resolvedCollections[modelEntry.storage.collection];\n\t\tif (!coll) continue;\n\t\tif (modelEntry.discriminator && modelEntry.variants) {\n\t\t\tconst variantEntries = Object.entries(modelEntry.variants).map(([variantName, { value }]) => ({\n\t\t\t\tdiscriminatorValue: value,\n\t\t\t\tfields: resolvedModels[variantName]?.fields ?? {}\n\t\t\t}));\n\t\t\tcoll[\"validator\"] = derivePolymorphicJsonSchema(modelEntry.fields, modelEntry.discriminator.field, variantEntries, valueObjects, codecLookup, storageValueSets);\n\t\t} else coll[\"validator\"] = deriveJsonSchema(modelEntry.fields, valueObjects, codecLookup, storageValueSets);\n\t}\n\tconst target = \"mongo\";\n\tconst targetFamily = \"mongo\";\n\tconst collectionInputs = {};\n\tfor (const [name, coll] of Object.entries(resolvedCollections)) {\n\t\tconst raw = {};\n\t\tif (coll[\"indexes\"] != null) raw[\"indexes\"] = coll[\"indexes\"];\n\t\tif (coll[\"validator\"] != null) raw[\"validator\"] = coll[\"validator\"];\n\t\tif (coll[\"options\"] != null) raw[\"options\"] = coll[\"options\"];\n\t\tcollectionInputs[name] = blindCast(raw);\n\t}\n\tconst unboundNamespace = buildMongoNamespace({\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tentries: {\n\t\t\tcollection: collectionInputs,\n\t\t\t...Object.keys(storageValueSets).length > 0 ? { valueSet: storageValueSets } : {}\n\t\t}\n\t});\n\tconst storage = new MongoStorage({\n\t\tstorageHash: computeStorageHash({\n\t\t\ttarget,\n\t\t\ttargetFamily,\n\t\t\tstorage: { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\t\t\tid: UNBOUND_NAMESPACE_ID,\n\t\t\t\tentries: {\n\t\t\t\t\tcollection: unboundNamespace.entries.collection,\n\t\t\t\t\t...unboundNamespace.entries.valueSet !== void 0 ? { valueSet: unboundNamespace.entries.valueSet } : {}\n\t\t\t\t}\n\t\t\t} } },\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t}),\n\t\tnamespaces: { [UNBOUND_NAMESPACE_ID]: unboundNamespace }\n\t});\n\tconst capabilities = {};\n\tconst hasEnums = Object.keys(builtEnums).length > 0;\n\treturn ok({\n\t\ttargetFamily,\n\t\ttarget,\n\t\troots: polyResult.roots,\n\t\tdomain: { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\t\tmodels: polyResult.models,\n\t\t\t...Object.keys(valueObjects).length > 0 ? { valueObjects } : {},\n\t\t\t...hasEnums ? { enum: builtEnums } : {}\n\t\t} } },\n\t\tstorage,\n\t\textensions: {},\n\t\tcapabilities,\n\t\tprofileHash: computeProfileHash({\n\t\t\ttarget,\n\t\t\ttargetFamily,\n\t\t\tcapabilities\n\t\t}),\n\t\tmeta: {}\n\t});\n}\n//#endregion\nexport { deriveJsonSchema as n, derivePolymorphicJsonSchema as r, interpretPslDocumentToMongoContract as t };\n\n//# sourceMappingURL=interpreter-BxbUTQ3k.mjs.map"],"mappings":";;;;;;;;;;;;;;AAaA,SAAS,gBAAgB,SAAS,aAAa;CAC9C,OAAO,aAAa,eAAe,OAAO,CAAC,GAAG;AAC/C;AACA,SAAS,kBAAkB,OAAO,cAAc,aAAa,WAAW;CACvE,IAAI,MAAM,KAAK,SAAS,UAAU;EACjC,MAAM,WAAW,gBAAgB,MAAM,KAAK,SAAS,WAAW;EAChE,IAAI,CAAC,UAAU,OAAO,KAAK;EAC3B,MAAM,aAAa,MAAM,aAAa,KAAK,IAAI,YAAY,MAAM,SAAS,WAAW,EAAE,UAAU,OAAO;EACxG,IAAI,UAAU,SAAS,MAAM,MAAM;GAClC,MAAM,QAAQ,EAAE,SAAS;GACzB,IAAI,YAAY,MAAM,UAAU;GAChC,OAAO;IACN,UAAU;IACV;GACD;EACD;EACA,IAAI,MAAM,UAAU;GACnB,MAAM,IAAI,EAAE,UAAU,CAAC,QAAQ,QAAQ,EAAE;GACzC,IAAI,YAAY,EAAE,UAAU,CAAC,GAAG,YAAY,IAAI;GAChD,OAAO;EACR;EACA,MAAM,IAAI,EAAE,SAAS;EACrB,IAAI,YAAY,EAAE,UAAU;EAC5B,OAAO;CACR;CACA,IAAI,MAAM,KAAK,SAAS,eAAe;EACtC,MAAM,KAAK,e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,EAAE,aAAa,IAAI,CAAC;GAC9D,GAAG,WAAW,EAAE,MAAM,WAAW,IAAI,CAAC;EACvC,EAAE,EAAE;EACJ;EACA,YAAY,CAAC;EACb;EACA,aAAa,mBAAmB;GAC/B;GACA;GACA;EACD,CAAC;EACD,MAAM,CAAC;CACR,CAAC;AACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { C as MongoContract, v as MongoCollection } from "./mongo-value-set-tNn9-pun-dJYx_rVD.mjs";
|
|
2
|
+
import { s as MongoStorage } from "./index-Cd2zLiU6.mjs";
|
|
3
|
+
import "./mongo-contract-view-AnejqfrQ-BaCFT0xm.mjs";
|
|
4
|
+
import { ControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
5
|
+
import { Type } from "arktype";
|
|
6
|
+
import { AnyEntityKindDescriptor, Namespace } from "@prisma/orm-framework/components/ir";
|
|
7
|
+
import { ContractSerializer, SchemaDiffIssue, SchemaVerifier, SchemaVerifyOptions, SchemaVerifyResult } from "@prisma/orm-framework/components/control";
|
|
8
|
+
import { JsonObject } from "@prisma/orm-framework/utils/json";
|
|
9
|
+
//#region ../../../2-mongo-family/9-family/dist/ir.d.mts
|
|
10
|
+
//#region src/core/ir/mongo-contract-serializer-base.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Mongo family `ContractSerializer` abstract base. Owns the family-shared
|
|
13
|
+
* deserialization pipeline:
|
|
14
|
+
*
|
|
15
|
+
* 1. Structural validation against the Mongo contract arktype schema
|
|
16
|
+
* (`MongoContractSchema`).
|
|
17
|
+
* 2. Framework-shared domain validation (`validateContractDomain`).
|
|
18
|
+
* 3. Family-shared storage validation (`validateMongoStorage`).
|
|
19
|
+
*
|
|
20
|
+
* The validated value is handed to the target via the
|
|
21
|
+
* `constructTargetContract` hook, which wraps the plain-JSON shape in
|
|
22
|
+
* the family-layer `MongoStorage` class instance (carrying the
|
|
23
|
+
* target-supplied `namespaces` map). Targets that need to add
|
|
24
|
+
* structural checks beyond the family default can override
|
|
25
|
+
* `parseMongoContractStructure`.
|
|
26
|
+
*
|
|
27
|
+
* Default `serializeContract` is identity over the contract — Mongo
|
|
28
|
+
* target classes carry JSON-clean fields by construction, so the value
|
|
29
|
+
* can be `JSON.stringify`'d directly. Targets that need on-the-way-out
|
|
30
|
+
* canonicalization override `serializeContract`.
|
|
31
|
+
*/
|
|
32
|
+
declare abstract class MongoContractSerializerBase<TContract> implements ContractSerializer<TContract> {
|
|
33
|
+
private readonly contractSchema;
|
|
34
|
+
private readonly entryKinds;
|
|
35
|
+
constructor(validatorFragments?: ReadonlyMap<string, Type<unknown>>, packEntityKinds?: readonly AnyEntityKindDescriptor[]);
|
|
36
|
+
deserializeContract<T extends TContract = TContract>(json: unknown): T;
|
|
37
|
+
serializeContract(contract: TContract): JsonObject;
|
|
38
|
+
/**
|
|
39
|
+
* Preserve empty `collections` maps and per-collection payloads. Mongo
|
|
40
|
+
* collections legitimately serialize empty (a declared collection with no
|
|
41
|
+
* schema is valid); SQL tables never do — that asymmetry lives here rather
|
|
42
|
+
* than in the family-agnostic canonicalizer.
|
|
43
|
+
*/
|
|
44
|
+
shouldPreserveEmpty: import("@prisma/orm-framework/contract/hashing").PreserveEmptyPredicate;
|
|
45
|
+
/**
|
|
46
|
+
* Family-shared structural validation: parse against the Mongo
|
|
47
|
+
* contract arktype schema, then run framework-shared domain + Mongo
|
|
48
|
+
* family storage checks, then hydrate the validated tree into Mongo
|
|
49
|
+
* Contract IR class instances. Targets can override to add
|
|
50
|
+
* target-specific structural checks; most targets accept the family
|
|
51
|
+
* default.
|
|
52
|
+
*
|
|
53
|
+
* The returned `MongoContract` carries class instances under
|
|
54
|
+
* `storage.namespaces[namespaceId].entries.collection[collectionName]` (each value is a
|
|
55
|
+
* `MongoCollection`, with nested `MongoIndex` / `MongoValidator` /
|
|
56
|
+
* `MongoCollectionOptions` constructed by the `MongoCollection` constructor).
|
|
57
|
+
* The rest of the contract envelope (models, valueObjects, capabilities, …)
|
|
58
|
+
* remains in plain-JSON form; those IR layers are handled by sibling
|
|
59
|
+
* subsystems and don't sit behind this SPI.
|
|
60
|
+
*/
|
|
61
|
+
protected parseMongoContractStructure(json: unknown): MongoContract;
|
|
62
|
+
/**
|
|
63
|
+
* Walk a structurally-validated Mongo contract and hydrate each namespace's
|
|
64
|
+
* entries via the registered entity-kind descriptors. Unknown kinds throw (fail-closed),
|
|
65
|
+
* preserving the existing Mongo serializer semantics.
|
|
66
|
+
*/
|
|
67
|
+
protected hydrateMongoContract(contract: MongoContract): MongoContract;
|
|
68
|
+
/**
|
|
69
|
+
* Target-specific class construction from the validated structural
|
|
70
|
+
* data. The target wraps the contract envelope in the family-layer
|
|
71
|
+
* `MongoStorage` class instance, supplying the `namespaces` map
|
|
72
|
+
* (target concretions like `MongoTargetUnboundDatabase`). The
|
|
73
|
+
* leaf collection / index shapes are already family-layer IR-class
|
|
74
|
+
* instances after the hydration walk above.
|
|
75
|
+
*/
|
|
76
|
+
protected abstract constructTargetContract(validated: MongoContract): TContract;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/core/ir/mongo-contract-serializer.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Default Mongo family `ContractSerializer` concretion. Inherits the
|
|
82
|
+
* Mongo-shared deserialization pipeline (structural validation +
|
|
83
|
+
* collection-level hydration) and falls through `constructTargetContract`
|
|
84
|
+
* with the validated `MongoContract` shape. Family-level call sites
|
|
85
|
+
* (family-instance methods, family-layer tests that don't reach into
|
|
86
|
+
* a target descriptor) instantiate this directly; targets with their
|
|
87
|
+
* own storage concretion (`target-mongo`'s `MongoTargetContractSerializer`)
|
|
88
|
+
* override `constructTargetContract` to wrap the storage shape.
|
|
89
|
+
*/
|
|
90
|
+
declare class MongoContractSerializer extends MongoContractSerializerBase<MongoContract> {
|
|
91
|
+
protected constructTargetContract(validated: MongoContract): MongoContract;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/core/ir/mongo-schema-verifier-base.d.ts
|
|
95
|
+
/**
|
|
96
|
+
* Mongo family `SchemaVerifier` abstract base. Commits the Mongo family
|
|
97
|
+
* to namespace-keyed verification: the family-shared walk iterates
|
|
98
|
+
* `storage.namespaces` in sorted order and dispatches per-namespace
|
|
99
|
+
* through the protected `verifyNamespace` hook, then aggregates
|
|
100
|
+
* target-extension issues from `verifyTargetExtensions`.
|
|
101
|
+
*
|
|
102
|
+
* Per-element diff work (collection / index / validator comparisons)
|
|
103
|
+
* lives on the target inside `verifyNamespace`. The family's structural
|
|
104
|
+
* commitment is "verification is namespaced"; the target's commitment is
|
|
105
|
+
* "verification of a given namespace's collections is the existing
|
|
106
|
+
* diff/canonicalize pipeline". The split keeps target-mongo's
|
|
107
|
+
* introspection-side helpers (`contractToMongoSchemaIR`,
|
|
108
|
+
* `canonicalizeSchemasForVerification`, `diffMongoSchemas`) in the target
|
|
109
|
+
* layer where they belong, while the family base owns the iteration
|
|
110
|
+
* scaffolding that makes namespaces a first-class verifier concept.
|
|
111
|
+
*
|
|
112
|
+
* Target-specific issue kinds (Atlas-only, future RLS-equivalents)
|
|
113
|
+
* surface through `verifyTargetExtensions`; that hook returns the empty
|
|
114
|
+
* list when no extensions exist over the Mongo family alphabet.
|
|
115
|
+
*/
|
|
116
|
+
declare abstract class MongoSchemaVerifierBase<TContract extends {
|
|
117
|
+
readonly storage: MongoStorage;
|
|
118
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
119
|
+
}, TSchema> implements SchemaVerifier<TContract, TSchema> {
|
|
120
|
+
verifySchema(options: SchemaVerifyOptions<TContract, TSchema>): SchemaVerifyResult;
|
|
121
|
+
protected effectiveCollectionControlPolicy(contract: TContract, collection: MongoCollection | undefined): ControlPolicy;
|
|
122
|
+
protected collectionControlPolicyForName(contract: TContract, collectionName: string): ControlPolicy;
|
|
123
|
+
protected verifyCommonMongoSchema(options: SchemaVerifyOptions<TContract, TSchema>): readonly SchemaDiffIssue[];
|
|
124
|
+
/**
|
|
125
|
+
* Per-namespace verification hook. Receives the namespace metadata plus
|
|
126
|
+
* the full contract + schema pair; the target's implementation owns the
|
|
127
|
+
* per-collection diff using its existing introspection-side helpers.
|
|
128
|
+
* Slice the schema by namespace at the call site (or compute the full
|
|
129
|
+
* diff once and dispatch per namespace) — the family base does not
|
|
130
|
+
* prescribe the per-namespace shape.
|
|
131
|
+
*/
|
|
132
|
+
protected abstract verifyNamespace(options: {
|
|
133
|
+
readonly contract: TContract;
|
|
134
|
+
readonly schema: TSchema;
|
|
135
|
+
readonly namespaceId: string;
|
|
136
|
+
readonly namespace: Namespace;
|
|
137
|
+
}): readonly SchemaDiffIssue[];
|
|
138
|
+
/**
|
|
139
|
+
* Target-specific extensions — Atlas-only kinds, target-only
|
|
140
|
+
* namespace-mismatch issues that don't fit the family-shared walk.
|
|
141
|
+
* Returns the empty list when the target ships no extensions.
|
|
142
|
+
*/
|
|
143
|
+
protected abstract verifyTargetExtensions(options: SchemaVerifyOptions<TContract, TSchema>): readonly SchemaDiffIssue[];
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { MongoContractSerializerBase as n, MongoSchemaVerifierBase as r, MongoContractSerializer as t };
|
|
147
|
+
//# sourceMappingURL=ir-CQrenTYt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir-CQrenTYt.d.mts","names":[],"sources":["../../../../2-mongo-family/9-family/dist/ir.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA6BuB,4BAA4B,sBAAsB,mBAAmB;mBACzE;mBACA;EACjB,YAAY,qBAAqB,oBAAoB,gBAAgB,2BAA2B;EAChG,oBAAoB,UAAU,YAAY,WAAW,gBAAgB;EACrE,kBAAkB,UAAU,YAAY;;;;;;;EAOxC,0DAA0D;;;;;;;;;;;;;;;;;YAiBhD,4BAA4B,gBAAgB;;;;;;YAM5C,qBAAqB,UAAU,gBAAgB;;;;;;;;;qBAStC,wBAAwB,WAAW,gBAAgB;;;;;;;;;;;;;;cAc1D,gCAAgC,4BAA4B;YAC9D,wBAAwB,WAAW,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;uBAyBxC,wBAAwB;WACpC,SAAS;WACT,uBAAuB;GAC/B,oBAAoB,eAAe,WAAW;EAC/C,aAAa,SAAS,oBAAoB,WAAW,WAAW;YACtD,iCAAiC,UAAU,WAAW,YAAY,8BAA8B;YAChG,+BAA+B,UAAU,WAAW,yBAAyB;YAC7E,wBAAwB,SAAS,oBAAoB,WAAW,oBAAoB;;;;;;;;;qBAS3E,gBAAgB;aACxB,UAAU;aACV,QAAQ;aACR;aACA,WAAW;eACT;;;;;;qBAMM,uBAAuB,SAAS,oBAAoB,WAAW,oBAAoB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { effectiveControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
2
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
3
|
+
//#region ../../../2-mongo-family/9-family/dist/ir.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Mongo family `SchemaVerifier` abstract base. Commits the Mongo family
|
|
6
|
+
* to namespace-keyed verification: the family-shared walk iterates
|
|
7
|
+
* `storage.namespaces` in sorted order and dispatches per-namespace
|
|
8
|
+
* through the protected `verifyNamespace` hook, then aggregates
|
|
9
|
+
* target-extension issues from `verifyTargetExtensions`.
|
|
10
|
+
*
|
|
11
|
+
* Per-element diff work (collection / index / validator comparisons)
|
|
12
|
+
* lives on the target inside `verifyNamespace`. The family's structural
|
|
13
|
+
* commitment is "verification is namespaced"; the target's commitment is
|
|
14
|
+
* "verification of a given namespace's collections is the existing
|
|
15
|
+
* diff/canonicalize pipeline". The split keeps target-mongo's
|
|
16
|
+
* introspection-side helpers (`contractToMongoSchemaIR`,
|
|
17
|
+
* `canonicalizeSchemasForVerification`, `diffMongoSchemas`) in the target
|
|
18
|
+
* layer where they belong, while the family base owns the iteration
|
|
19
|
+
* scaffolding that makes namespaces a first-class verifier concept.
|
|
20
|
+
*
|
|
21
|
+
* Target-specific issue kinds (Atlas-only, future RLS-equivalents)
|
|
22
|
+
* surface through `verifyTargetExtensions`; that hook returns the empty
|
|
23
|
+
* list when no extensions exist over the Mongo family alphabet.
|
|
24
|
+
*/
|
|
25
|
+
var MongoSchemaVerifierBase = class {
|
|
26
|
+
verifySchema(options) {
|
|
27
|
+
const issues = [];
|
|
28
|
+
issues.push(...this.verifyCommonMongoSchema(options));
|
|
29
|
+
issues.push(...this.verifyTargetExtensions(options));
|
|
30
|
+
return {
|
|
31
|
+
ok: issues.length === 0,
|
|
32
|
+
issues
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
effectiveCollectionControlPolicy(contract, collection) {
|
|
36
|
+
return effectiveControlPolicy(collection?.control, contract.defaultControlPolicy);
|
|
37
|
+
}
|
|
38
|
+
collectionControlPolicyForName(contract, collectionName) {
|
|
39
|
+
const collection = contract.storage.namespaces[UNBOUND_NAMESPACE_ID]?.entries.collection?.[collectionName];
|
|
40
|
+
return this.effectiveCollectionControlPolicy(contract, collection);
|
|
41
|
+
}
|
|
42
|
+
verifyCommonMongoSchema(options) {
|
|
43
|
+
const issues = [];
|
|
44
|
+
const { namespaces } = options.contract.storage;
|
|
45
|
+
const namespaceIds = Object.keys(namespaces).sort();
|
|
46
|
+
for (const namespaceId of namespaceIds) {
|
|
47
|
+
const namespace = namespaces[namespaceId];
|
|
48
|
+
if (!namespace) continue;
|
|
49
|
+
issues.push(...this.verifyNamespace({
|
|
50
|
+
contract: options.contract,
|
|
51
|
+
schema: options.schema,
|
|
52
|
+
namespaceId,
|
|
53
|
+
namespace
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
return issues;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { MongoSchemaVerifierBase as t };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=ir-Ch2aPr7a.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir-Ch2aPr7a.mjs","names":[],"sources":["../../../../2-mongo-family/9-family/dist/ir.mjs"],"sourcesContent":["import { n as MongoContractSerializerBase, t as MongoContractSerializer } from \"./mongo-contract-serializer-Cx7Fae8e.mjs\";\nimport { t as MongoContractView } from \"./mongo-contract-view-rcWzby6f.mjs\";\nimport { effectiveControlPolicy } from \"@internal/contract/types\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\n//#region src/core/ir/mongo-schema-verifier-base.ts\n/**\n* Mongo family `SchemaVerifier` abstract base. Commits the Mongo family\n* to namespace-keyed verification: the family-shared walk iterates\n* `storage.namespaces` in sorted order and dispatches per-namespace\n* through the protected `verifyNamespace` hook, then aggregates\n* target-extension issues from `verifyTargetExtensions`.\n*\n* Per-element diff work (collection / index / validator comparisons)\n* lives on the target inside `verifyNamespace`. The family's structural\n* commitment is \"verification is namespaced\"; the target's commitment is\n* \"verification of a given namespace's collections is the existing\n* diff/canonicalize pipeline\". The split keeps target-mongo's\n* introspection-side helpers (`contractToMongoSchemaIR`,\n* `canonicalizeSchemasForVerification`, `diffMongoSchemas`) in the target\n* layer where they belong, while the family base owns the iteration\n* scaffolding that makes namespaces a first-class verifier concept.\n*\n* Target-specific issue kinds (Atlas-only, future RLS-equivalents)\n* surface through `verifyTargetExtensions`; that hook returns the empty\n* list when no extensions exist over the Mongo family alphabet.\n*/\nvar MongoSchemaVerifierBase = class {\n\tverifySchema(options) {\n\t\tconst issues = [];\n\t\tissues.push(...this.verifyCommonMongoSchema(options));\n\t\tissues.push(...this.verifyTargetExtensions(options));\n\t\treturn {\n\t\t\tok: issues.length === 0,\n\t\t\tissues\n\t\t};\n\t}\n\teffectiveCollectionControlPolicy(contract, collection) {\n\t\treturn effectiveControlPolicy(collection?.control, contract.defaultControlPolicy);\n\t}\n\tcollectionControlPolicyForName(contract, collectionName) {\n\t\tconst collection = contract.storage.namespaces[UNBOUND_NAMESPACE_ID]?.entries.collection?.[collectionName];\n\t\treturn this.effectiveCollectionControlPolicy(contract, collection);\n\t}\n\tverifyCommonMongoSchema(options) {\n\t\tconst issues = [];\n\t\tconst { namespaces } = options.contract.storage;\n\t\tconst namespaceIds = Object.keys(namespaces).sort();\n\t\tfor (const namespaceId of namespaceIds) {\n\t\t\tconst namespace = namespaces[namespaceId];\n\t\t\tif (!namespace) continue;\n\t\t\tissues.push(...this.verifyNamespace({\n\t\t\t\tcontract: options.contract,\n\t\t\t\tschema: options.schema,\n\t\t\t\tnamespaceId,\n\t\t\t\tnamespace\n\t\t\t}));\n\t\t}\n\t\treturn issues;\n\t}\n};\n//#endregion\nexport { MongoContractSerializer, MongoContractSerializerBase, MongoContractView, MongoSchemaVerifierBase };\n\n//# sourceMappingURL=ir.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAI,0BAA0B,MAAM;CACnC,aAAa,SAAS;EACrB,MAAM,SAAS,CAAC;EAChB,OAAO,KAAK,GAAG,KAAK,wBAAwB,OAAO,CAAC;EACpD,OAAO,KAAK,GAAG,KAAK,uBAAuB,OAAO,CAAC;EACnD,OAAO;GACN,IAAI,OAAO,WAAW;GACtB;EACD;CACD;CACA,iCAAiC,UAAU,YAAY;EACtD,OAAO,uBAAuB,YAAY,SAAS,SAAS,oBAAoB;CACjF;CACA,+BAA+B,UAAU,gBAAgB;EACxD,MAAM,aAAa,SAAS,QAAQ,WAAW,qBAAqB,EAAE,QAAQ,aAAa;EAC3F,OAAO,KAAK,iCAAiC,UAAU,UAAU;CAClE;CACA,wBAAwB,SAAS;EAChC,MAAM,SAAS,CAAC;EAChB,MAAM,EAAE,eAAe,QAAQ,SAAS;EACxC,MAAM,eAAe,OAAO,KAAK,UAAU,CAAC,CAAC,KAAK;EAClD,KAAK,MAAM,eAAe,cAAc;GACvC,MAAM,YAAY,WAAW;GAC7B,IAAI,CAAC,WAAW;GAChB,OAAO,KAAK,GAAG,KAAK,gBAAgB;IACnC,UAAU,QAAQ;IAClB,QAAQ,QAAQ;IAChB;IACA;GACD,CAAC,CAAC;EACH;EACA,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { C as MongoContract } from "./mongo-value-set-tNn9-pun-dJYx_rVD.mjs";
|
|
2
|
+
import "./index-Cd2zLiU6.mjs";
|
|
3
|
+
import { t as MongoContractView$1 } from "./mongo-contract-view-AnejqfrQ-BaCFT0xm.mjs";
|
|
4
|
+
import { r as AnyMongoMigrationOperation } from "./control-C7-kthr1.mjs";
|
|
5
|
+
import { Migration } from "@prisma/orm-toolchain/migration-tools/migration";
|
|
6
|
+
//#region ../../../2-mongo-family/9-family/dist/migration.d.mts
|
|
7
|
+
//#region src/core/mongo-migration.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Family-owned base class for Mongo migrations.
|
|
10
|
+
*
|
|
11
|
+
* Provides the fixed `targetId = 'mongo'` so that user-authored migrations
|
|
12
|
+
* and renderer-generated scaffolds (e.g. the output of
|
|
13
|
+
* `renderCallsToTypeScript`) inherit it directly and don't have to re-declare
|
|
14
|
+
* the abstract `targetId` member from `Migration`.
|
|
15
|
+
*
|
|
16
|
+
* The operation type parameter is `AnyMongoMigrationOperation` — the union
|
|
17
|
+
* of DDL-shaped `MongoMigrationPlanOperation` and `MongoDataTransformOperation` —
|
|
18
|
+
* so subclasses can return a mix of schema operations (e.g. `createIndex`,
|
|
19
|
+
* `setValidation`) and data-transform operations (e.g. `dataTransform`).
|
|
20
|
+
* Mirrors the generic parameter used by `PlannerProducedMongoMigration`.
|
|
21
|
+
*
|
|
22
|
+
* Binds the framework base's `Start` / `End` contract generics so a subclass
|
|
23
|
+
* that assigns its snapshot-store `contract.json` imports to
|
|
24
|
+
* `startContractJson` / `endContractJson` gets fully-typed view accessors:
|
|
25
|
+
* `this.endContract` is a `MongoContractView<End>`
|
|
26
|
+
* (and `this.startContract` a `MongoContractView<Start> | null`), built lazily
|
|
27
|
+
* from those JSON fields via the shared `MigrationContractViews` helper. The
|
|
28
|
+
* framework base derives `describe()` from the same JSON. View getters live on
|
|
29
|
+
* the family base (not the framework base) because `MongoContractView`'s shape
|
|
30
|
+
* is Mongo-specific.
|
|
31
|
+
*/
|
|
32
|
+
declare abstract class MongoMigration<Start extends MongoContract = MongoContract, End extends MongoContract = MongoContract> extends Migration<AnyMongoMigrationOperation, string, string, Start, End> {
|
|
33
|
+
#private;
|
|
34
|
+
readonly targetId: "mongo";
|
|
35
|
+
/**
|
|
36
|
+
* The typed, namespace-unwrapped view over this migration's end-state
|
|
37
|
+
* contract — `this.endContract.collection.<name>.validator`, etc. Throws if
|
|
38
|
+
* no `endContractJson` was provided (a `describe()`-overriding migration
|
|
39
|
+
* with no contract has no view to expose).
|
|
40
|
+
*/
|
|
41
|
+
get endContract(): MongoContractView$1<End>;
|
|
42
|
+
/**
|
|
43
|
+
* The typed view over this migration's start-state contract, or `null` for
|
|
44
|
+
* a baseline migration (no `startContractJson`).
|
|
45
|
+
*/
|
|
46
|
+
get startContract(): MongoContractView$1<Start> | null;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { MongoMigration as t };
|
|
50
|
+
//# sourceMappingURL=migration-CNDQv5yB.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-CNDQv5yB.d.mts","names":[],"sources":["../../../../2-mongo-family/9-family/dist/migration.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA6BuB,eAAe,cAAc,gBAAgB,eAAe,YAAY,gBAAgB,uBAAuB,UAAU,4CAA4C,OAAO;;WAExL;;;;;;;MAOL,eAAe,oBAAoB;;;;;MAKnC,iBAAiB,oBAAoB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { t as MongoContractView$1 } from "./mongo-contract-view-rcWzby6f-wRBCUnBt.mjs";
|
|
2
|
+
import { Migration, MigrationContractViews } from "@prisma/orm-toolchain/migration-tools/migration";
|
|
3
|
+
//#region ../../../2-mongo-family/9-family/dist/migration.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Family-owned base class for Mongo migrations.
|
|
6
|
+
*
|
|
7
|
+
* Provides the fixed `targetId = 'mongo'` so that user-authored migrations
|
|
8
|
+
* and renderer-generated scaffolds (e.g. the output of
|
|
9
|
+
* `renderCallsToTypeScript`) inherit it directly and don't have to re-declare
|
|
10
|
+
* the abstract `targetId` member from `Migration`.
|
|
11
|
+
*
|
|
12
|
+
* The operation type parameter is `AnyMongoMigrationOperation` — the union
|
|
13
|
+
* of DDL-shaped `MongoMigrationPlanOperation` and `MongoDataTransformOperation` —
|
|
14
|
+
* so subclasses can return a mix of schema operations (e.g. `createIndex`,
|
|
15
|
+
* `setValidation`) and data-transform operations (e.g. `dataTransform`).
|
|
16
|
+
* Mirrors the generic parameter used by `PlannerProducedMongoMigration`.
|
|
17
|
+
*
|
|
18
|
+
* Binds the framework base's `Start` / `End` contract generics so a subclass
|
|
19
|
+
* that assigns its snapshot-store `contract.json` imports to
|
|
20
|
+
* `startContractJson` / `endContractJson` gets fully-typed view accessors:
|
|
21
|
+
* `this.endContract` is a `MongoContractView<End>`
|
|
22
|
+
* (and `this.startContract` a `MongoContractView<Start> | null`), built lazily
|
|
23
|
+
* from those JSON fields via the shared `MigrationContractViews` helper. The
|
|
24
|
+
* framework base derives `describe()` from the same JSON. View getters live on
|
|
25
|
+
* the family base (not the framework base) because `MongoContractView`'s shape
|
|
26
|
+
* is Mongo-specific.
|
|
27
|
+
*/
|
|
28
|
+
var MongoMigration = class extends Migration {
|
|
29
|
+
targetId = "mongo";
|
|
30
|
+
#endView = new MigrationContractViews(this, "MongoMigration", (json) => MongoContractView$1.fromJson(json));
|
|
31
|
+
#startView = new MigrationContractViews(this, "MongoMigration", (json) => MongoContractView$1.fromJson(json));
|
|
32
|
+
/**
|
|
33
|
+
* The typed, namespace-unwrapped view over this migration's end-state
|
|
34
|
+
* contract — `this.endContract.collection.<name>.validator`, etc. Throws if
|
|
35
|
+
* no `endContractJson` was provided (a `describe()`-overriding migration
|
|
36
|
+
* with no contract has no view to expose).
|
|
37
|
+
*/
|
|
38
|
+
get endContract() {
|
|
39
|
+
return this.#endView.endContract;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The typed view over this migration's start-state contract, or `null` for
|
|
43
|
+
* a baseline migration (no `startContractJson`).
|
|
44
|
+
*/
|
|
45
|
+
get startContract() {
|
|
46
|
+
return this.#startView.startContract;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { MongoMigration as t };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=migration-dcM7u4HG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-dcM7u4HG.mjs","names":["MongoContractView","#endView","#startView"],"sources":["../../../../2-mongo-family/9-family/dist/migration.mjs"],"sourcesContent":["import { t as MongoContractView } from \"./mongo-contract-view-rcWzby6f.mjs\";\nimport { Migration, MigrationContractViews } from \"@internal/migration-tools/migration\";\n//#region src/core/mongo-migration.ts\n/**\n* Family-owned base class for Mongo migrations.\n*\n* Provides the fixed `targetId = 'mongo'` so that user-authored migrations\n* and renderer-generated scaffolds (e.g. the output of\n* `renderCallsToTypeScript`) inherit it directly and don't have to re-declare\n* the abstract `targetId` member from `Migration`.\n*\n* The operation type parameter is `AnyMongoMigrationOperation` — the union\n* of DDL-shaped `MongoMigrationPlanOperation` and `MongoDataTransformOperation` —\n* so subclasses can return a mix of schema operations (e.g. `createIndex`,\n* `setValidation`) and data-transform operations (e.g. `dataTransform`).\n* Mirrors the generic parameter used by `PlannerProducedMongoMigration`.\n*\n* Binds the framework base's `Start` / `End` contract generics so a subclass\n* that assigns its snapshot-store `contract.json` imports to\n* `startContractJson` / `endContractJson` gets fully-typed view accessors:\n* `this.endContract` is a `MongoContractView<End>`\n* (and `this.startContract` a `MongoContractView<Start> | null`), built lazily\n* from those JSON fields via the shared `MigrationContractViews` helper. The\n* framework base derives `describe()` from the same JSON. View getters live on\n* the family base (not the framework base) because `MongoContractView`'s shape\n* is Mongo-specific.\n*/\nvar MongoMigration = class extends Migration {\n\ttargetId = \"mongo\";\n\t#endView = new MigrationContractViews(this, \"MongoMigration\", (json) => MongoContractView.fromJson(json));\n\t#startView = new MigrationContractViews(this, \"MongoMigration\", (json) => MongoContractView.fromJson(json));\n\t/**\n\t* The typed, namespace-unwrapped view over this migration's end-state\n\t* contract — `this.endContract.collection.<name>.validator`, etc. Throws if\n\t* no `endContractJson` was provided (a `describe()`-overriding migration\n\t* with no contract has no view to expose).\n\t*/\n\tget endContract() {\n\t\treturn this.#endView.endContract;\n\t}\n\t/**\n\t* The typed view over this migration's start-state contract, or `null` for\n\t* a baseline migration (no `startContractJson`).\n\t*/\n\tget startContract() {\n\t\treturn this.#startView.startContract;\n\t}\n};\n//#endregion\nexport { MongoMigration as Migration };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAI,iBAAiB,cAAc,UAAU;CAC5C,WAAW;CACX,WAAW,IAAI,uBAAuB,MAAM,mBAAmB,SAASA,oBAAkB,SAAS,IAAI,CAAC;CACxG,aAAa,IAAI,uBAAuB,MAAM,mBAAmB,SAASA,oBAAkB,SAAS,IAAI,CAAC;;;;;;;CAO1G,IAAI,cAAc;EACjB,OAAO,KAAKC,SAAS;CACtB;;;;;CAKA,IAAI,gBAAgB;EACnB,OAAO,KAAKC,WAAW;CACxB;AACD"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { a as MongoContractSchema, m as createMongoContractSchema, p as composeMongoEntityKinds } from "./entity-kinds-B4KNTF8z-DPIuUuuB.mjs";
|
|
2
|
+
import { u as validateMongoStorage } from "./dist-DHrEJnhK.mjs";
|
|
3
|
+
import { t as mongoContractCanonicalizationHooks } from "./canonicalization-hooks-DF3Z6sjO.mjs";
|
|
4
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
5
|
+
import { type } from "arktype";
|
|
6
|
+
import { hydrateNamespaceEntities } from "@prisma/orm-framework/components/ir";
|
|
7
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
8
|
+
import { validateContractDomain } from "@prisma/orm-framework/contract/validate-domain";
|
|
9
|
+
//#region ../../../2-mongo-family/9-family/dist/mongo-contract-serializer-Cx7Fae8e.mjs
|
|
10
|
+
/**
|
|
11
|
+
* Mongo family `ContractSerializer` abstract base. Owns the family-shared
|
|
12
|
+
* deserialization pipeline:
|
|
13
|
+
*
|
|
14
|
+
* 1. Structural validation against the Mongo contract arktype schema
|
|
15
|
+
* (`MongoContractSchema`).
|
|
16
|
+
* 2. Framework-shared domain validation (`validateContractDomain`).
|
|
17
|
+
* 3. Family-shared storage validation (`validateMongoStorage`).
|
|
18
|
+
*
|
|
19
|
+
* The validated value is handed to the target via the
|
|
20
|
+
* `constructTargetContract` hook, which wraps the plain-JSON shape in
|
|
21
|
+
* the family-layer `MongoStorage` class instance (carrying the
|
|
22
|
+
* target-supplied `namespaces` map). Targets that need to add
|
|
23
|
+
* structural checks beyond the family default can override
|
|
24
|
+
* `parseMongoContractStructure`.
|
|
25
|
+
*
|
|
26
|
+
* Default `serializeContract` is identity over the contract — Mongo
|
|
27
|
+
* target classes carry JSON-clean fields by construction, so the value
|
|
28
|
+
* can be `JSON.stringify`'d directly. Targets that need on-the-way-out
|
|
29
|
+
* canonicalization override `serializeContract`.
|
|
30
|
+
*/
|
|
31
|
+
var MongoContractSerializerBase = class {
|
|
32
|
+
contractSchema;
|
|
33
|
+
entryKinds;
|
|
34
|
+
constructor(validatorFragments, packEntityKinds = []) {
|
|
35
|
+
this.entryKinds = composeMongoEntityKinds(packEntityKinds);
|
|
36
|
+
this.contractSchema = validatorFragments !== void 0 && validatorFragments.size > 0 ? createMongoContractSchema(validatorFragments) : void 0;
|
|
37
|
+
}
|
|
38
|
+
deserializeContract(json) {
|
|
39
|
+
const validated = this.parseMongoContractStructure(json);
|
|
40
|
+
return this.constructTargetContract(validated);
|
|
41
|
+
}
|
|
42
|
+
serializeContract(contract) {
|
|
43
|
+
return contract;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Preserve empty `collections` maps and per-collection payloads. Mongo
|
|
47
|
+
* collections legitimately serialize empty (a declared collection with no
|
|
48
|
+
* schema is valid); SQL tables never do — that asymmetry lives here rather
|
|
49
|
+
* than in the family-agnostic canonicalizer.
|
|
50
|
+
*/
|
|
51
|
+
shouldPreserveEmpty = mongoContractCanonicalizationHooks.shouldPreserveEmpty;
|
|
52
|
+
/**
|
|
53
|
+
* Family-shared structural validation: parse against the Mongo
|
|
54
|
+
* contract arktype schema, then run framework-shared domain + Mongo
|
|
55
|
+
* family storage checks, then hydrate the validated tree into Mongo
|
|
56
|
+
* Contract IR class instances. Targets can override to add
|
|
57
|
+
* target-specific structural checks; most targets accept the family
|
|
58
|
+
* default.
|
|
59
|
+
*
|
|
60
|
+
* The returned `MongoContract` carries class instances under
|
|
61
|
+
* `storage.namespaces[namespaceId].entries.collection[collectionName]` (each value is a
|
|
62
|
+
* `MongoCollection`, with nested `MongoIndex` / `MongoValidator` /
|
|
63
|
+
* `MongoCollectionOptions` constructed by the `MongoCollection` constructor).
|
|
64
|
+
* The rest of the contract envelope (models, valueObjects, capabilities, …)
|
|
65
|
+
* remains in plain-JSON form; those IR layers are handled by sibling
|
|
66
|
+
* subsystems and don't sit behind this SPI.
|
|
67
|
+
*/
|
|
68
|
+
parseMongoContractStructure(json) {
|
|
69
|
+
const parsed = (this.contractSchema ?? MongoContractSchema)(json);
|
|
70
|
+
if (parsed instanceof type.errors) throw structuredError("CONTRACT.VALIDATION_FAILED", `Contract structural validation failed: ${parsed.summary}`);
|
|
71
|
+
const validatedShape = parsed;
|
|
72
|
+
const hydratedContract = this.hydrateMongoContract(validatedShape);
|
|
73
|
+
validateContractDomain(hydratedContract);
|
|
74
|
+
validateMongoStorage(hydratedContract);
|
|
75
|
+
return hydratedContract;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Walk a structurally-validated Mongo contract and hydrate each namespace's
|
|
79
|
+
* entries via the registered entity-kind descriptors. Unknown kinds throw (fail-closed),
|
|
80
|
+
* preserving the existing Mongo serializer semantics.
|
|
81
|
+
*/
|
|
82
|
+
hydrateMongoContract(contract) {
|
|
83
|
+
const rawNamespaces = contract.storage.namespaces;
|
|
84
|
+
const hydratedNamespaces = Object.fromEntries(Object.entries(rawNamespaces).map(([nsId, nsEnvelope]) => {
|
|
85
|
+
const hydratedEntries = hydrateNamespaceEntities(blindCast(nsEnvelope.entries), this.entryKinds, "fail", nsId);
|
|
86
|
+
return [nsId, {
|
|
87
|
+
...nsEnvelope,
|
|
88
|
+
id: nsEnvelope.id,
|
|
89
|
+
entries: blindCast(hydratedEntries)
|
|
90
|
+
}];
|
|
91
|
+
}));
|
|
92
|
+
return {
|
|
93
|
+
...contract,
|
|
94
|
+
storage: {
|
|
95
|
+
...contract.storage,
|
|
96
|
+
namespaces: hydratedNamespaces
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Default Mongo family `ContractSerializer` concretion. Inherits the
|
|
103
|
+
* Mongo-shared deserialization pipeline (structural validation +
|
|
104
|
+
* collection-level hydration) and falls through `constructTargetContract`
|
|
105
|
+
* with the validated `MongoContract` shape. Family-level call sites
|
|
106
|
+
* (family-instance methods, family-layer tests that don't reach into
|
|
107
|
+
* a target descriptor) instantiate this directly; targets with their
|
|
108
|
+
* own storage concretion (`target-mongo`'s `MongoTargetContractSerializer`)
|
|
109
|
+
* override `constructTargetContract` to wrap the storage shape.
|
|
110
|
+
*/
|
|
111
|
+
var MongoContractSerializer = class extends MongoContractSerializerBase {
|
|
112
|
+
constructTargetContract(validated) {
|
|
113
|
+
return validated;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { MongoContractSerializerBase as n, MongoContractSerializer as t };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map
|