@prisma/orm-family-sql 8.0.0-rc.11-dev.32 → 8.0.0-rc.11-dev.34
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/dist/{authoring-type-constructors-C1ogrr_x-BziNu7gs.mjs → authoring-type-constructors-C1ogrr_x-V3OpvQTx.mjs} +2 -2
- package/dist/{authoring-type-constructors-C1ogrr_x-BziNu7gs.mjs.map → authoring-type-constructors-C1ogrr_x-V3OpvQTx.mjs.map} +1 -1
- package/dist/{contract-builder-C8uKThYB.d.mts → contract-builder-BnirYYsD.d.mts} +5 -5
- package/dist/{contract-builder-C8uKThYB.d.mts.map → contract-builder-BnirYYsD.d.mts.map} +1 -1
- package/dist/{contract-builder-CkT67-Wq.mjs → contract-builder-W6jqU1qo.mjs} +7 -7
- package/dist/contract-builder-W6jqU1qo.mjs.map +1 -0
- package/dist/contract-prisma7__provider.mjs +58 -44
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +6 -6
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +2 -2
- package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +11 -20
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +1 -1
- package/dist/contract-ts.mjs +1 -1
- package/dist/contract-ts__contract-builder.d.mts +1 -1
- package/dist/contract-ts__contract-builder.mjs +1 -1
- package/dist/{control-dqbsNN69.mjs → control-liGaqQ0q.mjs} +27 -28
- package/dist/control-liGaqQ0q.mjs.map +1 -0
- package/dist/diff-B16bL_IR.mjs.map +1 -1
- package/dist/family.mjs +5 -5
- package/dist/family__control.mjs +2 -2
- package/dist/family__diff.mjs +1 -1
- package/dist/family__ir.mjs +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/family__verify.mjs +1 -1
- package/dist/{interpreter-9Ru2E-MH-CQdWmnh8.mjs → interpreter-C8N5eRW1-LGv-WI9y.mjs} +280 -336
- package/dist/interpreter-C8N5eRW1-LGv-WI9y.mjs.map +1 -0
- package/dist/ir-I-xciGUH.mjs.map +1 -1
- package/dist/{psl-infer-DyRJ8dw6.mjs → psl-infer-CsCbcmXS.mjs} +4 -2
- package/dist/psl-infer-CsCbcmXS.mjs.map +1 -0
- package/dist/{schema-verify-C_PEdlAr-CmXrFuW1.mjs → schema-verify-CrvQZ5V8-BfrNHJbX.mjs} +3 -3
- package/dist/schema-verify-CrvQZ5V8-BfrNHJbX.mjs.map +1 -0
- package/dist/{sql-attribute-specs-CHSP1wKs-D5T2TZQ8.mjs → sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs} +11 -16
- package/dist/sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs.map +1 -0
- package/dist/{sql-contract-serializer-Bxu4a5oQ-CNy5ONMn.mjs → sql-contract-serializer-C4HbCKFe-BD1Fx4JX.mjs} +6 -6
- package/dist/sql-contract-serializer-C4HbCKFe-BD1Fx4JX.mjs.map +1 -0
- package/dist/{verify-ChiDeTk8-HEewdjrM.mjs → verify-BVk5bjdH-BXgGLM2U.mjs} +6 -5
- package/dist/verify-BVk5bjdH-BXgGLM2U.mjs.map +1 -0
- package/package.json +18 -18
- package/dist/contract-builder-CkT67-Wq.mjs.map +0 -1
- package/dist/control-dqbsNN69.mjs.map +0 -1
- package/dist/interpreter-9Ru2E-MH-CQdWmnh8.mjs.map +0 -1
- package/dist/psl-infer-DyRJ8dw6.mjs.map +0 -1
- package/dist/schema-verify-C_PEdlAr-CmXrFuW1.mjs.map +0 -1
- package/dist/sql-attribute-specs-CHSP1wKs-D5T2TZQ8.mjs.map +0 -1
- package/dist/sql-contract-serializer-Bxu4a5oQ-CNy5ONMn.mjs.map +0 -1
- package/dist/verify-ChiDeTk8-HEewdjrM.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-verify-C_PEdlAr-CmXrFuW1.mjs","names":[],"sources":["../../../../2-sql/9-family/dist/schema-verify-C_PEdlAr.mjs"],"sourcesContent":["import { blindCast } from \"@internal/utils/casts\";\nimport { assertUniqueCodecOwner, dispositionForCategory, issueOutcome } from \"@internal/framework-components/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { effectiveControlPolicy } from \"@internal/contract/types\";\nimport { isStorageTypeInstance } from \"@internal/sql-contract/types\";\n//#region src/core/assembly.ts\nfunction hasCodecControlHooks(descriptor) {\n\tif (typeof descriptor !== \"object\" || descriptor === null) return false;\n\tconst hooks = descriptor.types?.codecTypes?.controlPlaneHooks;\n\treturn hooks !== null && hooks !== void 0 && typeof hooks === \"object\";\n}\nfunction extractCodecControlHooks(descriptors) {\n\tconst hooks = /* @__PURE__ */ new Map();\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const descriptor of descriptors) {\n\t\tif (typeof descriptor !== \"object\" || descriptor === null) continue;\n\t\tif (!hasCodecControlHooks(descriptor)) continue;\n\t\tconst controlPlaneHooks = descriptor.types.codecTypes.controlPlaneHooks;\n\t\tfor (const [codecId, hook] of Object.entries(controlPlaneHooks)) {\n\t\t\tassertUniqueCodecOwner({\n\t\t\t\tcodecId,\n\t\t\t\towners,\n\t\t\t\tdescriptorId: descriptor.id,\n\t\t\t\tentityLabel: \"control hooks\",\n\t\t\t\tentityOwnershipLabel: \"owner\"\n\t\t\t});\n\t\t\thooks.set(codecId, hook);\n\t\t\towners.set(codecId, descriptor.id);\n\t\t}\n\t}\n\treturn hooks;\n}\n//#endregion\n//#region src/core/diff/verifier-disposition.ts\n/**\n* Classifies a codec `verifyType` hook finding into the target-neutral\n* categories the framework grades. A storage type is a named type instance\n* (e.g. a native enum); the only shape divergence it can carry is a change\n* to its value set, so a paired mismatch always classifies as `valueDrift`.\n*/\nfunction classifyStorageTypeDiffIssue(issue) {\n\tif (issueOutcome(issue) === \"not-found\") return \"declaredMissing\";\n\tif (issueOutcome(issue) === \"not-expected\") return \"extraAuxiliary\";\n\treturn \"valueDrift\";\n}\nfunction verifierDisposition(controlPolicy, issue) {\n\treturn dispositionForCategory(controlPolicy, classifyStorageTypeDiffIssue(issue));\n}\n//#endregion\n//#region src/core/diff/schema-verify.ts\nfunction issueNode(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\tif (node === void 0) return void 0;\n\treturn blindCast(node);\n}\n/**\n* Resolves an issue's framework-neutral {@link DiffSubjectGranularity} on\n* demand, from the issue's node's `nodeKind` via the target-provided\n* `granularityOf` map. The node carries only its `nodeKind` identity, never a\n* classification, and nothing is stamped onto the issue — every consumer\n* (the family verdict below, the framework aggregate's unclaimed-elements\n* sweep via {@link import('@internal/framework-components/control').SchemaSubjectClassifierCapable})\n* calls this the same way, resolved by the family/target that owns the node\n* vocabulary. `undefined` for an issue with no node.\n*/\nfunction classifyDiffSubjectGranularity(issue, granularityOf) {\n\tconst node = issueNode(issue);\n\treturn node === void 0 ? void 0 : granularityOf(node.nodeKind);\n}\n/**\n* Resolves an issue's storage `entityKind` on demand, from the issue's\n* node's `nodeKind` via the target-provided `entityKindOf` map — the sibling\n* of {@link classifyDiffSubjectGranularity}, called the same way by the same\n* consumers (via\n* {@link import('@internal/framework-components/control').SchemaSubjectClassifierCapable}).\n* `undefined` for an issue with no node, or for a node kind with no storage\n* entity of its own.\n*/\nfunction classifyDiffEntityKind(issue, entityKindOf) {\n\tconst node = issueNode(issue);\n\treturn node === void 0 ? void 0 : entityKindOf(node.nodeKind);\n}\n/**\n* Re-keys the legacy `classifySqlVerifierIssueKind` category mapping on the\n* issue's {@link DiffSubjectGranularity} (resolved via `granularityOf`) + the\n* issue reason. The vocabulary maps one-to-one: an undeclared live entity or\n* namespace is `extraTopLevelObject`, an undeclared live field\n* `extraNestedElement`, undeclared auxiliaries (constraints, indexes,\n* defaults) and structural leaves (policies) `extraAuxiliary`; every paired\n* divergence is `declaredIncompatible`; anything the database lacks is\n* `declaredMissing`.\n* `granularityOf` is the target's classifier, so target and extension node\n* kinds classify without the family importing them.\n*/\nfunction classifySqlDiffIssue(issue, granularityOf) {\n\tif (issueOutcome(issue) === \"not-found\") return \"declaredMissing\";\n\tif (issueOutcome(issue) === \"not-expected\") {\n\t\tconst granularity = classifyDiffSubjectGranularity(issue, granularityOf);\n\t\tif (granularity === \"entity\" || granularity === \"namespace\") return \"extraTopLevelObject\";\n\t\tif (granularity === \"field\") return \"extraNestedElement\";\n\t\treturn \"extraAuxiliary\";\n\t}\n\treturn \"declaredIncompatible\";\n}\n/**\n* Whether a `not-expected` issue is a strict-mode-only finding. The legacy\n* walk detected every relational extra (namespaces, entities, fields, and\n* their auxiliaries) only under `--strict`; the structural diff (roots, RLS\n* policies, roles) was never strict-gated — its extras fail in both modes.\n* Keyed on the issue's granularity, resolved via `granularityOf`.\n*/\nfunction isStrictOnlyExtra(issue, granularityOf) {\n\tconst granularity = classifyDiffSubjectGranularity(issue, granularityOf);\n\treturn granularity === \"namespace\" || granularity === \"entity\" || granularity === \"field\" || granularity === \"auxiliary\";\n}\n/**\n* Applies the two consumer filters to a diff issue list: strict gating\n* (relational `not-expected` findings drop in lenient mode) and\n* control-policy disposition (each surviving issue grades against its\n* subject table's effective policy; suppressed issues drop, `observed`\n* subjects warn). The verify verdict is `failures.length === 0`.\n*/\nfunction computeSqlDiffVerdict(input) {\n\tconst failures = [];\n\tconst warnings = [];\n\tfor (const issue of input.issues) {\n\t\tif (!input.strict && issueOutcome(issue) === \"not-expected\" && isStrictOnlyExtra(issue, input.granularityOf)) continue;\n\t\tconst disposition = dispositionForCategory(effectiveControlPolicy(input.resolveControlPolicy(issue), input.defaultControlPolicy), classifySqlDiffIssue(issue, input.granularityOf));\n\t\tif (disposition === \"suppress\") continue;\n\t\tif (disposition === \"warn\") {\n\t\t\twarnings.push(issue);\n\t\t\tcontinue;\n\t\t}\n\t\tfailures.push(issue);\n\t}\n\treturn {\n\t\tfailures,\n\t\twarnings\n\t};\n}\nfunction computeStorageTypeVerdict(input) {\n\tconst failures = [];\n\tconst warnings = [];\n\tconst policy = effectiveControlPolicy(void 0, input.contract.defaultControlPolicy);\n\tfor (const pair of input.namespacePairs) {\n\t\tif (pair.actual === void 0) continue;\n\t\tfor (const [typeName, typeInstance] of Object.entries(input.contract.storage.types ?? {})) {\n\t\t\tif (!isStorageTypeInstance(typeInstance)) continue;\n\t\t\tconst hook = input.codecHooks.get(typeInstance.codecId);\n\t\t\tif (!hook?.verifyType) continue;\n\t\t\tconst typeIssues = hook.verifyType({\n\t\t\t\ttypeName,\n\t\t\t\ttypeInstance,\n\t\t\t\tschema: pair.actual\n\t\t\t});\n\t\t\tfor (const issue of typeIssues) {\n\t\t\t\tconst disposition = verifierDisposition(policy, issue);\n\t\t\t\tif (disposition === \"suppress\") continue;\n\t\t\t\tif (disposition === \"warn\") {\n\t\t\t\t\twarnings.push(issue);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfailures.push(issue);\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\tfailures,\n\t\twarnings\n\t};\n}\n/**\n* THE SQL schema verify: runs the target's full-tree node diff, grades it\n* through the family's post-diff filters (strict gating + control-policy\n* disposition) plus the codec `verifyType` hook findings, and wraps the\n* verdict in the issue-based result envelope. `ok` holds exactly when both\n* issue lists are empty — the lists carry the verdict's failures.\n*/\nfunction verifySqlSchemaByDiff(input) {\n\tconst startTime = Date.now();\n\tconst verdictDiff = input.diffSchema({\n\t\tcontract: input.contract,\n\t\tschema: input.schema,\n\t\tframeworkComponents: input.frameworkComponents\n\t});\n\tconst diffVerdict = computeSqlDiffVerdict({\n\t\tissues: verdictDiff.issues,\n\t\tresolveControlPolicy: verdictDiff.resolveControlPolicy,\n\t\tstrict: input.strict,\n\t\tdefaultControlPolicy: input.contract.defaultControlPolicy,\n\t\tgranularityOf: input.granularityOf\n\t});\n\tconst storageTypeVerdict = computeStorageTypeVerdict({\n\t\tcontract: input.contract,\n\t\tnamespacePairs: verdictDiff.namespacePairs,\n\t\tcodecHooks: extractCodecControlHooks(input.frameworkComponents)\n\t});\n\tconst failCount = diffVerdict.failures.length + storageTypeVerdict.failures.length;\n\tconst ok = failCount === 0;\n\tconst profileHash = \"profileHash\" in input.contract && typeof input.contract.profileHash === \"string\" ? input.contract.profileHash : void 0;\n\treturn {\n\t\tok,\n\t\t...ok ? {} : { code: \"CONTRACT.SCHEMA_VERIFICATION_FAILED\" },\n\t\tsummary: ok ? \"Database schema satisfies contract\" : `Database schema does not satisfy contract (${failCount} failure${failCount === 1 ? \"\" : \"s\"})`,\n\t\tcontract: {\n\t\t\tstorageHash: input.contract.storage.storageHash,\n\t\t\t...ifDefined(\"profileHash\", profileHash)\n\t\t},\n\t\ttarget: {\n\t\t\texpected: input.contract.target,\n\t\t\tactual: input.contract.target\n\t\t},\n\t\tschema: {\n\t\t\tissues: [...diffVerdict.failures, ...storageTypeVerdict.failures],\n\t\t\twarnings: { issues: [...diffVerdict.warnings, ...storageTypeVerdict.warnings] }\n\t\t},\n\t\tmeta: { strict: input.strict },\n\t\ttimings: { total: Date.now() - startTime }\n\t};\n}\n//#endregion\nexport { computeStorageTypeVerdict as a, computeSqlDiffVerdict as i, classifyDiffSubjectGranularity as n, verifySqlSchemaByDiff as o, classifySqlDiffIssue as r, extractCodecControlHooks as s, classifyDiffEntityKind as t };\n\n//# sourceMappingURL=schema-verify-C_PEdlAr.mjs.map"],"mappings":";;;;;;AAMA,SAAS,qBAAqB,YAAY;CACzC,IAAI,OAAO,eAAe,YAAY,eAAe,MAAM,OAAO;CAClE,MAAM,QAAQ,WAAW,OAAO,YAAY;CAC5C,OAAO,UAAU,QAAQ,UAAU,KAAK,KAAK,OAAO,UAAU;AAC/D;AACA,SAAS,yBAAyB,aAAa;CAC9C,MAAM,wBAAwB,IAAI,IAAI;CACtC,MAAM,yBAAyB,IAAI,IAAI;CACvC,KAAK,MAAM,cAAc,aAAa;EACrC,IAAI,O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AAO,KAAK,IAAI,IAAI,UAAU;CAC1C;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sql-attribute-specs-CHSP1wKs-D5T2TZQ8.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-CHSP1wKs.mjs"],"sourcesContent":["import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str, taggedLiteral } from \"@internal/psl-parser\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { notOk } from \"@internal/utils/result\";\n//#region src/sql-attribute-specs.ts\nfunction findModelAttributeNode(model, name) {\n\tfor (const attribute of model.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;\n}\nfunction findFieldAttributeNode(field, name) {\n\tfor (const attribute of field.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;\n}\nfunction buildModelAttributeCtx(input) {\n\treturn {\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel\n\t};\n}\nfunction buildFieldAttributeCtx(input) {\n\treturn {\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel,\n\t\tresolveReferencedModel: input.resolveReferencedModel ?? (() => void 0),\n\t\tfield: input.field\n\t};\n}\nfunction interpretModelAttribute(input) {\n\tconst result = interpretAttribute(input.node, input.spec, buildModelAttributeCtx({\n\t\tselfModel: input.model,\n\t\tsourceFile: input.sourceFile,\n\t\tsourceId: input.sourceId\n\t}));\n\tif (!result.ok) {\n\t\tfor (const failure of result.failure) input.diagnostics.push(failure);\n\t\treturn;\n\t}\n\treturn result.value;\n}\nfunction interpretFieldAttribute(input) {\n\tconst result = interpretAttribute(input.node, input.spec, buildFieldAttributeCtx({\n\t\tselfModel: input.model,\n\t\tfield: input.field,\n\t\tsourceFile: input.sourceFile,\n\t\tsourceId: input.sourceId,\n\t\tresolveReferencedModel: input.resolveReferencedModel\n\t}));\n\tif (!result.ok) {\n\t\tfor (const failure of result.failure) input.diagnostics.push(failure);\n\t\treturn;\n\t}\n\treturn result.value;\n}\nfunction validateMappedName(value, ctx, attributeNode) {\n\treturn value.name === \"\" ? [leafDiagnostic(ctx, attributeNode, \"Mapped name must not be empty\")] : [];\n}\nconst mapModelSpec = modelAttribute(\"map\", {\n\tdocumentation: \"Maps this model to a database table name.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str(),\n\t\tdocumentation: \"The nonempty database table name.\"\n\t}],\n\trefine: validateMappedName\n});\nconst mapFieldSpec = fieldAttribute(\"map\", {\n\tdocumentation: \"Maps this field to a database column name.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str(),\n\t\tdocumentation: \"The nonempty database column name.\"\n\t}],\n\trefine: validateMappedName\n});\nfunction scalarDefaultArms(isList, registries) {\n\tconst literal = () => oneOf(str(), numLiteral(), bool());\n\tconst tagEntries = [...registries.defaultLiteralTagRegistry];\n\tconst tagArms = tagEntries.length > 0 ? [taggedLiteral(tagEntries.map(([tag]) => tag), { documentation: [...new Set(tagEntries.map(([, entry]) => entry.documentation))].join(\" \") })] : [];\n\tconst funcArms = [...registries.defaultFunctionRegistry.entries()].map(([name, entry]) => funcCall(name, blindCast(entry.signature)));\n\treturn isList ? [\n\t\tlist(literal()),\n\t\t...funcArms,\n\t\t...tagArms\n\t] : [\n\t\tstr(),\n\t\tnumLiteral(),\n\t\tbool(),\n\t\t...funcArms,\n\t\t...tagArms\n\t];\n}\nfunction noEnumMember() {\n\treturn {\n\t\tkind: \"rejecting\",\n\t\tlabel: \"enum member\",\n\t\tmessage: \"Enum declares no members\",\n\t\tparse: (arg, ctx) => notOk([leafDiagnostic(ctx, arg, \"Enum declares no members\")])\n\t};\n}\nfunction enumMemberNames(ctx) {\n\tconst block = (ctx.field.typeNamespaceId === void 0 ? ctx.symbols.topLevel : ctx.symbols.topLevel.namespaces[ctx.field.typeNamespaceId])?.blocks[ctx.field.typeName];\n\tif (block === void 0 || block.keyword !== \"enum\") return void 0;\n\treturn Object.keys(block.block.parameters);\n}\nfunction enumDefaultArms(members, enumName) {\n\tconst [first, ...rest] = members;\n\tif (first === void 0) return [noEnumMember()];\n\tconst member = (name) => identifier(name, { documentation: `The \\`${name}\\` member of enum \\`${enumName}\\`.` });\n\treturn [member(first), ...rest.map(member)];\n}\nfunction defaultFieldSpec(ctx) {\n\tconst members = enumMemberNames(ctx);\n\treturn fieldAttribute(\"default\", {\n\t\tdocumentation: \"Supplies a default value when this field is omitted from a mutation.\",\n\t\tpositional: [{\n\t\t\tkey: \"value\",\n\t\t\ttype: oneOf(...members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members, ctx.field.typeName)),\n\t\t\tdocumentation: \"A literal, enum member, or registered default function compatible with this field.\"\n\t\t}]\n\t});\n}\nconst idFieldSpec = fieldAttribute(\"id\", {\n\tdocumentation: \"Makes this field the primary key of the table.\",\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database primary-key constraint name.\"\n\t} }\n});\nconst uniqueFieldSpec = fieldAttribute(\"unique\", {\n\tdocumentation: \"Requires values in this field to be unique.\",\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database unique-constraint name.\"\n\t} }\n});\nconst noCheckKindArgument = () => oneOf(identifier(\"membership\", { documentation: \"Waives the generated check that values belong to the declared domain enum.\" }), identifier(\"elementNotNull\", { documentation: \"Waives the generated check that scalar-list elements are non-null.\" }));\n/**\n* `@noCheck` waives generated CHECK constraints on one column: bare for every\n* kind the column's shape derives, or naming concrete kinds. Two optional\n* positional slots cover the whole kind vocabulary; a third argument is\n* necessarily a duplicate and fails as excess arity.\n*/\nconst noCheckFieldSpec = fieldAttribute(\"noCheck\", {\n\tdocumentation: \"Waives generated CHECK constraints for this column. With no arguments, waives every generated kind.\",\n\tpositional: [{\n\t\tkey: \"first\",\n\t\ttype: optional(noCheckKindArgument()),\n\t\tdocumentation: \"The first generated check kind to waive: `membership` or `elementNotNull`.\"\n\t}, {\n\t\tkey: \"second\",\n\t\ttype: optional(noCheckKindArgument()),\n\t\tdocumentation: \"A second, distinct generated check kind to waive.\"\n\t}],\n\trefine: (value, ctx, attributeNode) => {\n\t\tif (value.first !== void 0 && value.first === value.second) return [leafDiagnostic(ctx, attributeNode, \"`@noCheck` names the same kind twice\")];\n\t\treturn [];\n\t}\n});\nconst idModelSpec = modelAttribute(\"id\", {\n\tdocumentation: \"Declares a compound primary key for this table.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t}),\n\t\tdocumentation: \"The ordered, nonempty list of distinct primary-key fields.\"\n\t}],\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database primary-key constraint name.\"\n\t} }\n});\nconst uniqueModelSpec = modelAttribute(\"unique\", {\n\tdocumentation: \"Requires the combination of these fields to be unique.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t}),\n\t\tdocumentation: \"The ordered, nonempty list of distinct fields in the unique constraint.\"\n\t}],\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database unique-constraint name.\"\n\t} }\n});\nconst PSL_INDEX_FIELDS_XOR_EXPRESSION = \"PSL_INDEX_FIELDS_XOR_EXPRESSION\";\nconst PSL_INDEX_EXPRESSION_REQUIRES_NAME = \"PSL_INDEX_EXPRESSION_REQUIRES_NAME\";\nconst PSL_INDEX_NAME_XOR_MAP = \"PSL_INDEX_NAME_XOR_MAP\";\nconst indexModelSpec = modelAttribute(\"index\", {\n\tdocumentation: \"Declares a database index over fields or a SQL expression, optionally restricted by a predicate.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: optional(list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t})),\n\t\tdocumentation: \"The ordered list of distinct indexed fields. Mutually exclusive with `expression`.\"\n\t}],\n\tnamed: {\n\t\texpression: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The SQL index expression. Requires `name` or `map` and cannot be combined with a fields list.\"\n\t\t},\n\t\twhere: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The SQL predicate restricting rows included in a partial index.\"\n\t\t},\n\t\tunique: {\n\t\t\ttype: optional(bool()),\n\t\t\tdocumentation: \"Whether the index enforces uniqueness.\"\n\t\t},\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The index name. Mutually exclusive with `map`.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database index name. Mutually exclusive with `name`.\"\n\t\t},\n\t\ttype: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The target-specific index access method.\"\n\t\t},\n\t\toptions: {\n\t\t\ttype: optional(record(str())),\n\t\t\tdocumentation: \"Target-specific index options. Requires an explicit `type`.\"\n\t\t}\n\t},\n\trefine: (value, ctx, attributeNode) => {\n\t\tconst diagnostics = [];\n\t\tif (value.fields === void 0 === (value.expression === void 0)) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` requires exactly one of a fields list or an `expression` argument\", PSL_INDEX_FIELDS_XOR_EXPRESSION));\n\t\tif (value.expression !== void 0 && value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` with an `expression` argument requires a `name` or `map` argument (a default name cannot be derived from an expression)\", PSL_INDEX_EXPRESSION_REQUIRES_NAME));\n\t\tif (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` takes at most one of `name` and `map`\", PSL_INDEX_NAME_XOR_MAP));\n\t\tif (value.options !== void 0 && value.type === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` options argument requires a type argument\"));\n\t\treturn diagnostics;\n\t}\n});\nconst PSL_CHECK_REQUIRES_NAME_OR_MAP = \"PSL_CHECK_REQUIRES_NAME_OR_MAP\";\nconst PSL_CHECK_NAME_XOR_MAP = \"PSL_CHECK_NAME_XOR_MAP\";\nconst PSL_CHECK_EXPRESSION_EMPTY = \"PSL_CHECK_EXPRESSION_EMPTY\";\n/**\n* A single-table-inheritance variant (`@@base` with no own `@@map`) shares\n* its base model's storage table and has no table of its own to declare a\n* check on — raised from {@link interpretPslDocumentToSqlContract}, not from\n* this spec's own `refine`, because the rule needs the model's `@@base`\n* declaration, which a single attribute's `refine` cannot see.\n*/\nconst PSL_CHECK_ON_STI_VARIANT = \"PSL_CHECK_ON_STI_VARIANT\";\nconst checkModelSpec = modelAttribute(\"check\", {\n\tdocumentation: \"Declares a named database CHECK constraint on this table.\",\n\tnamed: {\n\t\texpression: {\n\t\t\ttype: str(),\n\t\t\tdocumentation: \"The nonempty SQL predicate checked for each row.\"\n\t\t},\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The constraint name. Exactly one of `name` and `map` is required.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database constraint name. Exactly one of `name` and `map` is required.\"\n\t\t}\n\t},\n\trefine: (value, ctx, attributeNode) => {\n\t\tconst diagnostics = [];\n\t\tif (value.expression.trim().length === 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@check` expression must not be empty — an empty predicate is not a constraint\", PSL_CHECK_EXPRESSION_EMPTY));\n\t\tif (value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@check` requires a `name` or `map` argument (a default name cannot be derived — a check has no column tuple to name itself after)\", PSL_CHECK_REQUIRES_NAME_OR_MAP));\n\t\tif (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@check` takes at most one of `name` and `map`\", PSL_CHECK_NAME_XOR_MAP));\n\t\treturn diagnostics;\n\t}\n});\nconst controlModelSpec = modelAttribute(\"control\", {\n\tdocumentation: \"Sets how schema management treats this model’s storage.\",\n\tpositional: [{\n\t\tkey: \"policy\",\n\t\tdocumentation: \"The storage control policy: `managed`, `tolerated`, `external`, or `observed`.\",\n\t\ttype: oneOf(identifier(\"managed\", { documentation: \"Verifies the declared shape strictly and allows migrations to create, alter, or drop the storage object.\" }), identifier(\"tolerated\", { documentation: \"Verifies declared columns while allowing extra columns. Migrations may create missing storage, but never alter or drop existing storage.\" }), identifier(\"external\", { documentation: \"Verifies declared storage without creating, altering, or dropping it.\" }), identifier(\"observed\", { documentation: \"Reports storage differences as warnings rather than verification failures and never emits migration operations.\" }))\n\t}]\n});\nconst discriminatorModelSpec = modelAttribute(\"discriminator\", {\n\tdocumentation: \"Selects the field that identifies inheritance variants of this model.\",\n\tpositional: [{\n\t\tkey: \"field\",\n\t\ttype: fieldRef(),\n\t\tdocumentation: \"The discriminator field on this model.\"\n\t}]\n});\nconst baseModelSpec = modelAttribute(\"base\", {\n\tdocumentation: \"Declares this model as a variant of a base model.\",\n\tpositional: [{\n\t\tkey: \"base\",\n\t\ttype: entityRef(),\n\t\tdocumentation: \"The base model to inherit from.\"\n\t}, {\n\t\tkey: \"value\",\n\t\ttype: str(),\n\t\tdocumentation: \"The discriminator value identifying this variant.\"\n\t}]\n});\nfunction relationAttributeSpan(ctx) {\n\tconst node = findFieldAttributeNode(ctx.field, \"relation\");\n\tif (node !== void 0) return nodePslSpan(node.syntax, ctx.sourceFile);\n\treturn ctx.field.span;\n}\nfunction relationInvariants(parsed, ctx) {\n\tif (parsed.fields !== void 0 !== (parsed.references !== void 0)) return [{\n\t\tcode: \"PSL_INVALID_ATTRIBUTE_SYNTAX\",\n\t\tmessage: `Relation field \"${ctx.selfModel.name}.${ctx.field.name}\" requires fields and references arguments`,\n\t\tsourceId: ctx.sourceId,\n\t\tspan: relationAttributeSpan(ctx)\n\t}];\n\treturn [];\n}\nconst referentialActionArgument = () => oneOf(identifier(\"NoAction\", { documentation: \"Rejects a change that would violate the foreign key when the constraint is checked; checking may be deferred when supported and configured.\" }), identifier(\"Restrict\", { documentation: \"Rejects deleting or updating a referenced row while referencing rows remain, without deferring the check.\" }), identifier(\"Cascade\", { documentation: \"Propagates deletion or key updates of a referenced row to its referencing rows.\" }), identifier(\"SetNull\", { documentation: \"Sets referencing foreign-key fields to null when the referenced row is deleted or its key changes. The fields must allow null.\" }), identifier(\"SetDefault\", { documentation: \"Sets referencing foreign-key fields to their defaults when the referenced row is deleted or its key changes. The resulting values must satisfy the foreign key.\" }));\nconst relationFieldSpec = fieldAttribute(\"relation\", {\n\tdocumentation: \"Defines the relation name, foreign-key fields, and referential actions for this relation.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The relation name used to pair both sides. May also be supplied by name.\"\n\t}],\n\tnamed: {\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The relation name used to pair both sides. Cannot also be supplied positionally.\"\n\t\t},\n\t\tfields: {\n\t\t\ttype: optional(list(fieldRef(), {\n\t\t\t\tallowEmpty: false,\n\t\t\t\tunique: true\n\t\t\t})),\n\t\t\tdocumentation: \"The ordered local foreign-key fields. Must be supplied together with `references`.\"\n\t\t},\n\t\treferences: {\n\t\t\ttype: optional(list(referencedFieldRef(), {\n\t\t\t\tallowEmpty: false,\n\t\t\t\tunique: true\n\t\t\t})),\n\t\t\tdocumentation: \"The corresponding fields on the referenced model. Must be supplied together with `fields`.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database foreign-key constraint name.\"\n\t\t},\n\t\tonDelete: {\n\t\t\ttype: optional(referentialActionArgument()),\n\t\t\tdocumentation: \"The referential action when a referenced row is deleted.\"\n\t\t},\n\t\tonUpdate: {\n\t\t\ttype: optional(referentialActionArgument()),\n\t\t\tdocumentation: \"The referential action when a referenced key is updated.\"\n\t\t},\n\t\tindex: {\n\t\t\ttype: optional(bool()),\n\t\t\tdocumentation: \"Whether to create an index for the relation’s foreign-key fields.\"\n\t\t}\n\t},\n\trefine: relationInvariants\n});\nfunction fieldSpecContext(input) {\n\treturn {\n\t\tsymbols: input.symbols,\n\t\tmodel: input.model,\n\t\tfield: input.field,\n\t\tcontrolMutationDefaults: input.controlMutationDefaults\n\t};\n}\nconst sqlAttributeSpecs = {\n\tmodel: {\n\t\tmap: () => mapModelSpec,\n\t\tid: () => idModelSpec,\n\t\tunique: () => uniqueModelSpec,\n\t\tindex: () => indexModelSpec,\n\t\tcheck: () => checkModelSpec,\n\t\tcontrol: () => controlModelSpec,\n\t\tdiscriminator: () => discriminatorModelSpec,\n\t\tbase: () => baseModelSpec\n\t},\n\tfield: {\n\t\tmap: () => mapFieldSpec,\n\t\tid: () => idFieldSpec,\n\t\tunique: () => uniqueFieldSpec,\n\t\tnoCheck: () => noCheckFieldSpec,\n\t\trelation: () => relationFieldSpec,\n\t\tdefault: defaultFieldSpec\n\t}\n};\n//#endregion\nexport { interpretFieldAttribute as a, findModelAttributeNode as i, fieldSpecContext as n, interpretModelAttribute as o, findFieldAttributeNode as r, sqlAttributeSpecs as s, PSL_CHECK_ON_STI_VARIANT as t };\n\n//# sourceMappingURL=sql-attribute-specs-CHSP1wKs.mjs.map"],"mappings":";;;;AAIA,SAAS,uBAAuB,OAAO,MAAM;CAC5C,KAAK,MAAM,aAAa,MAAM,KAAK,WAAW,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE,aAAa,IAAI,MAAM,MAAM,OAAO;AAC5G;AACA,SAAS,uBAAuB,OAAO,MAAM;CAC5C,KAAK,MAAM,aAAa,MAAM,KAAK,WAAW,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE,aAAa,IAAI,MAAM,MAAM,OAAO;AAC5G;AACA,SAAS,uBAAuB,OAAO;CACtC,OAAO;EACN,UAAU,MAAM;EAChB,YAA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AS,IAAI,CAAC;EACpB,eAAe;CAChB,CAAC;CACD,OAAO;EACN,MAAM;GACL,MAAM,SAAS,IAAI,CAAC;GACpB,eAAe;EAChB;EACA,QAAQ;GACP,MAAM,SAAS,KAAK,SAAS,GAAG;IAC/B,YAAY;IACZ,QAAQ;GACT,CAAC,CAAC;GACF,eAAe;EAChB;EACA,YAAY;GACX,MAAM,SAAS,KAAK,mBAAmB,GAAG;IACzC,YAAY;IACZ,QAAQ;GACT,CAAC,CAAC;GACF,eAAe;EAChB;EACA,KAAK;GACJ,MAAM,SAAS,IAAI,CAAC;GACpB,eAAe;EAChB;EACA,UAAU;GACT,MAAM,SAAS,0BAA0B,CAAC;GAC1C,eAAe;EAChB;EACA,UAAU;GACT,MAAM,SAAS,0BAA0B,CAAC;GAC1C,eAAe;EAChB;EACA,OAAO;GACN,MAAM,SAAS,KAAK,CAAC;GACrB,eAAe;EAChB;CACD;CACA,QAAQ;AACT,CAAC;AACD,SAAS,iBAAiB,OAAO;CAChC,OAAO;EACN,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO,MAAM;EACb,yBAAyB,MAAM;CAChC;AACD;AACA,MAAM,oBAAoB;CACzB,OAAO;EACN,WAAW;EACX,UAAU;EACV,cAAc;EACd,aAAa;EACb,aAAa;EACb,eAAe;EACf,qBAAqB;EACrB,YAAY;CACb;CACA,OAAO;EACN,WAAW;EACX,UAAU;EACV,cAAc;EACd,eAAe;EACf,gBAAgB;EAChB,SAAS;CACV;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sql-contract-serializer-Bxu4a5oQ-CNy5ONMn.mjs","names":[],"sources":["../../../../2-sql/9-family/dist/sql-contract-serializer-Bxu4a5oQ.mjs"],"sourcesContent":["import { t as sqlFamilyError } from \"./errors-B5g0xWro.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { hydrateNamespaceEntities } from \"@internal/framework-components/ir\";\nimport { sqlContractCanonicalizationHooks } from \"@internal/sql-contract/canonicalization-hooks\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { SqlStorage, isMaterializedSqlNamespace } from \"@internal/sql-contract/types\";\nimport { ContractValidationError } from \"@internal/contract/contract-validation-error\";\nimport { isPlainRecord as isPlainRecord$1 } from \"@internal/contract/is-plain-record\";\nimport { withDerivedToOneRelationNullability } from \"@internal/contract-authoring\";\nimport { composeSqlEntityKinds } from \"@internal/sql-contract/entity-kinds\";\nimport { createSqlContractSchema, resolveSqlToOneRelationStorage, validateSqlContractFully } from \"@internal/sql-contract/validators\";\nimport { type } from \"arktype\";\n//#region src/core/ir/sql-contract-serializer-base.ts\nconst NamespaceRawSchema = type({\n\tid: \"string\",\n\t\"kind?\": \"string\",\n\tentries: type({ \"+\": \"ignore\" })\n});\n/**\n* A `contract.json` written before to-one relations recorded `nullable` (rc.9 and earlier)\n* loads with the flag derived from storage: nullable when any local FK column is nullable or\n* cannot be resolved.\n*/\nfunction withSqlToOneRelationNullability(contract) {\n\tconst domain = withDerivedToOneRelationNullability(contract.domain, ({ model, relation }) => {\n\t\tconst { ownsForeignKey, columns } = resolveSqlToOneRelationStorage(contract, blindCast(model.storage), relation);\n\t\treturn {\n\t\t\townsReference: ownsForeignKey,\n\t\t\tlocalFieldNullability: columns.map((column) => column.nullable)\n\t\t};\n\t});\n\treturn {\n\t\t...contract,\n\t\tdomain\n\t};\n}\n/**\n* SQL family `ContractSerializer` abstract base. Carries the SQL-shared\n* deserialization pipeline:\n*\n* 1. `parseSqlContractStructure` validates the on-disk JSON envelope\n* against the SQL contract arktype schema (`validateSqlContractFully`)\n* and returns the validated flat-data shape.\n* 2. `hydrateSqlStorage` walks the validated `storage` subtree and\n* constructs the family-shared SQL Contract IR class hierarchy\n* (`SqlStorage` -> `StorageTable` -> `StorageColumn` / `PrimaryKey`\n* / …). The rest of the contract envelope is JSON-clean primitive\n* data and passes through unchanged.\n* 3. `constructTargetContract` is the target-specific extension hook;\n* defaults to identity. Targets that need to attach target-only\n* fields (e.g. target-specific derived storage fields) override it.\n*\n* Default `serializeContract` is identity over the contract — concrete\n* SQL targets ship JSON-clean class instances, so the contract value\n* can be stringified directly. The non-enumerable family-level `kind`\n* discriminator on `SqlNode` instances stays out of the persisted\n* envelope automatically. Targets that need to canonicalize on the way\n* out (key ordering, dropping computed-only fields) override\n* `serializeContract` directly.\n*/\nvar SqlContractSerializerBase = class {\n\tentityHydrationRegistry;\n\tcontractSchema;\n\tentryKinds;\n\tconstructor(entityHydrationRegistry = /* @__PURE__ */ new Map(), packEntityKinds = []) {\n\t\tthis.entityHydrationRegistry = entityHydrationRegistry;\n\t\tthis.entryKinds = composeSqlEntityKinds(packEntityKinds);\n\t\tthis.contractSchema = packEntityKinds.length > 0 ? createSqlContractSchema(this.entryKinds) : void 0;\n\t}\n\tdeserializeContract(json) {\n\t\tconst validated = withSqlToOneRelationNullability(this.parseSqlContractStructure(json));\n\t\tconst hydrated = this.hydrateSqlStorage(validated);\n\t\treturn this.constructTargetContract(hydrated);\n\t}\n\tserializeContract(contract) {\n\t\treturn contract;\n\t}\n\tshouldPreserveEmpty = sqlContractCanonicalizationHooks.shouldPreserveEmpty;\n\tsortStorage = sqlContractCanonicalizationHooks.sortStorage;\n\tparseSqlContractStructure(json) {\n\t\treturn validateSqlContractFully(json, this.contractSchema !== void 0 ? { contractSchema: this.contractSchema } : void 0);\n\t}\n\thydrateSqlStorage(validated) {\n\t\tconst types = validated.storage.types;\n\t\tconst hydratedTypes = types !== void 0 ? Object.fromEntries(Object.entries(types).map(([name, entry]) => [name, this.hydrateStorageTypeEntry(entry)])) : void 0;\n\t\tconst rawNamespaces = validated.storage.namespaces;\n\t\tif (rawNamespaces === void 0) throw new ContractValidationError(\"Contract storage.namespaces is required after structural validation\", \"structural\");\n\t\tconst hydratedNamespaces = this.hydrateSqlNamespaceMap(blindCast(rawNamespaces));\n\t\treturn {\n\t\t\t...validated,\n\t\t\tstorage: new SqlStorage({\n\t\t\t\tstorageHash: validated.storage.storageHash,\n\t\t\t\t...ifDefined(\"types\", hydratedTypes),\n\t\t\t\tnamespaces: blindCast(hydratedNamespaces)\n\t\t\t})\n\t\t};\n\t}\n\thydrateSqlNamespaceMap(namespaces) {\n\t\treturn Object.fromEntries(Object.entries(namespaces).map(([nsId, namespaceEntryRaw]) => {\n\t\t\tconst namespaceHydrated = this.hydrateSqlNamespaceEntry(nsId, namespaceEntryRaw);\n\t\t\tif (!isMaterializedSqlNamespace(namespaceHydrated)) throw sqlFamilyError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Target serializer bug: hydrateSqlNamespaceEntry for namespace \"${nsId}\" returned a non-NamespaceBase value. Override hydrateSqlNamespaceEntry to produce a target namespace concretion.`, {\n\t\t\t\twhy: \"The target contract serializer hydrated a namespace into a value that is not a materialized namespace concretion.\",\n\t\t\t\tfix: \"Fix the target package: its hydrateSqlNamespaceEntry override must return a target namespace concretion.\",\n\t\t\t\tmeta: { namespaceId: nsId }\n\t\t\t});\n\t\t\treturn [nsId, namespaceHydrated];\n\t\t}));\n\t}\n\thydrateSqlNamespaceEntry(nsId, raw) {\n\t\tconst id = typeof raw[\"id\"] === \"string\" ? raw[\"id\"] : nsId;\n\t\tconst parsed = NamespaceRawSchema({\n\t\t\t...raw,\n\t\t\tid\n\t\t});\n\t\tif (parsed instanceof type.errors) throw new ContractValidationError(`Namespace hydration failed: ${parsed.map((p) => p.message).join(\"; \")}`, \"structural\");\n\t\tconst entriesRaw = parsed.entries;\n\t\tconst rawEntriesMap = isPlainRecord$1(entriesRaw) ? entriesRaw : {};\n\t\tconst entriesInput = {};\n\t\tfor (const [key, innerMap] of Object.entries(rawEntriesMap)) entriesInput[key] = isPlainRecord$1(innerMap) ? innerMap : Object.freeze({});\n\t\tconst entriesOutput = hydrateNamespaceEntities(entriesInput, this.entryKinds, \"fail\", id);\n\t\tif (!Object.hasOwn(entriesOutput, \"table\")) entriesOutput[\"table\"] = {};\n\t\treturn blindCast({\n\t\t\tid,\n\t\t\tentries: entriesOutput\n\t\t});\n\t}\n\thydrateStorageTypeEntry(entry) {\n\t\tif (typeof entry !== \"object\" || entry === null) return entry;\n\t\tconst kind = entry.kind;\n\t\tif (typeof kind !== \"string\") return entry;\n\t\tconst factory = this.entityHydrationRegistry.get(kind);\n\t\tif (factory === void 0) return entry;\n\t\treturn blindCast(factory(entry));\n\t}\n\tconstructTargetContract(hydrated) {\n\t\treturn hydrated;\n\t}\n\t/**\n\t* Serializes a namespace's `entries` dict by walking every enumerable\n\t* kind — no kind is named here, mirroring the generic hydrate walk in\n\t* `hydrateSqlNamespaceEntry` above. `table` is the SQL family's one\n\t* universal base kind (every namespace carries it), so it is always\n\t* emitted, even when empty; every other kind — target- or\n\t* pack-contributed — is emitted only when it holds at least one entry.\n\t* A kind carried non-enumerable on `entries` is excluded here for free,\n\t* since `Object.entries` honors enumerability.\n\t*/\n\tserializeNamespaceEntries(entries) {\n\t\tconst out = { table: this.serializeEntries(entries[\"table\"] ?? {}) };\n\t\tfor (const [kind, record] of Object.entries(entries)) {\n\t\t\tif (kind === \"table\" || record == null || Object.keys(record).length === 0) continue;\n\t\t\tout[kind] = this.serializeEntries(record);\n\t\t}\n\t\treturn out;\n\t}\n\tserializeEntries(entries) {\n\t\tconst out = {};\n\t\tfor (const [name, entry] of Object.entries(entries)) out[name] = this.serializeJsonObject(entry);\n\t\treturn out;\n\t}\n\tserializeJsonObject(value) {\n\t\treturn blindCast(this.serializeJsonValue(value));\n\t}\n\tserializeJsonValue(value) {\n\t\treturn blindCast(JSON.parse(JSON.stringify(value)));\n\t}\n};\n//#endregion\n//#region src/core/ir/sql-contract-serializer.ts\n/**\n* Default SQL family `ContractSerializer` concretion. Inherits the\n* full SQL-shared deserialization pipeline (structural validation +\n* IR-class hydration) without pack-registered `storage.types`\n* hydration factories — targets that emit polymorphic JSON outside the\n* codec-typed envelope wire a target-specific subclass with a populated\n* registry (see Postgres). Family-level call sites instantiate this\n* default directly when no target serializer is supplied.\n*\n* Because this serializer has no target concretion, deserialization of\n* contracts that include namespace entries from JSON will throw unless\n* the caller provides pre-hydrated `NamespaceBase` instances. Production\n* paths always supply a target-specific serializer.\n*/\nvar SqlContractSerializer = class extends SqlContractSerializerBase {\n\tconstructor() {\n\t\tsuper(/* @__PURE__ */ new Map());\n\t}\n};\n//#endregion\nexport { SqlContractSerializerBase as n, SqlContractSerializer as t };\n\n//# sourceMappingURL=sql-contract-serializer-Bxu4a5oQ.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,qBAAqB,KAAK;CAC/B,IAAI;CACJ,SAAS;CACT,SAAS,KAAK,EAAE,KAAK,SAAS,CAAC;AAChC,CAAC;;;;;;AAMD,SAAS,gCAAgC,UAAU;CAClD,MAAM,SAAS,oCAAoC,SAAS,SAAS,EAAE,OAAO,eAAe;EAC5F,MAAM,EAAE,gBAAgB,YAAY,+BAA+B,UAAU,UAAU,MAAM,OAAO,GAAG,QAAQ;EAC/G,OAAO;GACN,eAAe;GACf,uBAAuB,QAAQ,KAAK,WAAW,OAAO,QAAQ;EAC/D;CACD,CAAC;CACD,OAAO;EACN,GAAG;EACH;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAI,4BAA4B,MAAM;CACrC;CACA;CACA;CACA,YAAY,0CAA0C,IAAI,IAAI,GAAG,kBAAkB,CAAC,GAAG;EACtF,KAAK,0BAA0B;EAC/B,KAAK,aAAa,sBAAsB,eAAe;EACvD,KAAK,iBAAiB,gBAAgB,SAAS,IAAI,wBAAwB,KAAK,UAAU,IAAI,KAAK;CACpG;CACA,oBAAoB,MAAM;EACzB,MAAM,YAAY,gCAAgC,KAAK,0BAA0B,IAAI,CAAC;EACtF,MAAM,WAAW,KAAK,kBAAkB,SAAS;EACjD,OAAO,KAAK,wBAAwB,QAAQ;CAC7C;CACA,kBAAkB,UAAU;EAC3B,OAAO;CACR;CACA,sBAAsB,iCAAiC;CACvD,cAAc,iCAAiC;CAC/C,0BAA0B,MAAM;EAC/B,OAAO,yBAAyB,MAAM,KAA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B,OAAO;EACzB,OAAO,UAAU,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;CACnD;AACD;;;;;;;;;;;;;;;AAiBA,IAAI,wBAAwB,cAAc,0BAA0B;CACnE,cAAc;EACb,sBAAsB,IAAI,IAAI,CAAC;CAChC;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verify-ChiDeTk8-HEewdjrM.mjs","names":[],"sources":["../../../../2-sql/9-family/dist/verify-ChiDeTk8.mjs"],"sourcesContent":["import { t as sqlFamilyError } from \"./errors-B5g0xWro.mjs\";\nimport { type } from \"arktype\";\n//#region src/core/verify.ts\nconst MetaSchema = type({ \"[string]\": \"unknown\" });\nfunction parseMeta(meta) {\n\tif (meta === null || meta === void 0) return {};\n\tlet parsed;\n\tif (typeof meta === \"string\") try {\n\t\tparsed = JSON.parse(meta);\n\t} catch {\n\t\treturn {};\n\t}\n\telse parsed = meta;\n\tconst result = MetaSchema(parsed);\n\tif (result instanceof type.errors) return {};\n\treturn result;\n}\n/**\n* SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;\n* Postgres uses `jsonb` and returns an already-parsed value. Normalize both\n* here so `ContractMarkerRecord.contractJson` is always the structured form.\n*/\nfunction parseContractJson(value) {\n\tif (value === null || value === void 0) return null;\n\tif (typeof value !== \"string\") return value;\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn null;\n\t}\n}\nconst ContractMarkerRowSchema = type({\n\tcore_hash: \"string\",\n\tprofile_hash: \"string\",\n\t\"contract_json?\": \"unknown | null\",\n\t\"canonical_version?\": \"number | null\",\n\t\"updated_at?\": \"Date | string\",\n\t\"app_tag?\": \"string | null\",\n\t\"meta?\": \"unknown | null\",\n\tinvariants: type(\"string\").array()\n});\n/**\n* Parses a contract marker row from database query result.\n* This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).\n*/\nfunction parseContractMarkerRow(row) {\n\tconst result = ContractMarkerRowSchema(row);\n\tif (result instanceof type.errors) {\n\t\tconst messages = result.map((p) => p.message).join(\"; \");\n\t\tthrow sqlFamilyError(\"CONTRACT.MARKER_ROW_CORRUPT\", `Invalid contract marker row: ${messages}`, {\n\t\t\twhy: \"The contract marker row read from the database does not match the expected marker shape.\",\n\t\t\tfix: \"Re-sign the database with `prisma db sign`, or repair the marker table.\",\n\t\t\tnextActions: [{\n\t\t\t\tkind: \"run-command\",\n\t\t\t\tlabel: \"Re-sign the database\",\n\t\t\t\tcommand: \"{bin} db sign\"\n\t\t\t}, {\n\t\t\t\tkind: \"user-choice\",\n\t\t\t\tlabel: \"Repair the marker table by hand\",\n\t\t\t\treason: messages\n\t\t\t}],\n\t\t\tmeta: { issues: messages }\n\t\t});\n\t}\n\tconst updatedAt = result.updated_at ? result.updated_at instanceof Date ? result.updated_at : new Date(result.updated_at) : /* @__PURE__ */ new Date();\n\treturn {\n\t\tstorageHash: result.core_hash,\n\t\tprofileHash: result.profile_hash,\n\t\tcontractJson: parseContractJson(result.contract_json),\n\t\tcanonicalVersion: result.canonical_version ?? null,\n\t\tupdatedAt,\n\t\tappTag: result.app_tag ?? null,\n\t\tmeta: parseMeta(result.meta),\n\t\tinvariants: result.invariants\n\t};\n}\n/**\n* Collects supported codec type IDs from adapter and extension manifests.\n* Returns a sorted, unique array of type IDs that are declared in the manifests.\n* This enables coverage checks by comparing contract column types against supported types.\n*\n* Note: This extracts type IDs from manifest type imports, not from runtime codec registries.\n* The manifests declare which codec types are available, but the actual type IDs\n* are defined in the codec-types TypeScript modules that are imported.\n*\n* For MVP, we return an empty array since extracting type IDs from TypeScript modules\n* would require runtime evaluation or static analysis. This can be enhanced later.\n*/\nfunction collectSupportedCodecTypeIds(descriptors) {\n\treturn [];\n}\n//#endregion\nexport { parseContractMarkerRow as n, collectSupportedCodecTypeIds as t };\n\n//# sourceMappingURL=verify-ChiDeTk8.mjs.map"],"mappings":";;;AAGA,MAAM,aAAa,KAAK,EAAE,YAAY,UAAU,CAAC;AACjD,SAAS,UAAU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