@prisma/orm-family-sql 8.0.0-rc.12-dev.6 → 8.0.0-rc.12-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { n as checkSqlDefaultBody } from "./validators-CR2v1106.mjs";
2
2
  import { o as extractCodecControlHooks } from "./schema-verify-CrvQZ5V8-BfrNHJbX.mjs";
3
3
  import { a as temporalStringAuthoringPresets, i as temporalCodecPresetWithPrecision, n as temporalAuthoringPresets, o as timestampNowControlDescriptor, r as temporalCodecPreset, t as TIMESTAMP_NOW_GENERATOR_ID } from "./timestamp-now-generator-CVrEeaJp-Bt_PHBSf.mjs";
4
- import { _ as plannerSuccess, a as buildNativeTypeExpander, b as sqlDefaultLiteralTagEntry, c as controlPolicyForCall, d as detectDestructiveChanges, f as detectTableNameCaseChanges, g as plannerFailure, h as planFieldEventOperations, i as assembleAuthoringContributions, l as control_default, m as partitionIssuesByControlPolicy, n as PSL_INVALID_DEFAULT_SQL, o as contractNamespaceToSchemaIR, p as partitionCallsByControlPolicy, r as TABLE_NAME_CASE_CHANGED_CODE, s as contractToSchemaIR, t as INIT_ADDITIVE_POLICY, u as createMigrationPlan, v as runnerFailure, y as runnerSuccess } from "./control-3ACchVAO.mjs";
4
+ import { _ as plannerSuccess, a as buildNativeTypeExpander, b as sqlDefaultLiteralTagEntry, c as controlPolicyForCall, d as detectDestructiveChanges, f as detectTableNameCaseChanges, g as plannerFailure, h as planFieldEventOperations, i as assembleAuthoringContributions, l as control_default, m as partitionIssuesByControlPolicy, n as PSL_INVALID_DEFAULT_SQL, o as contractNamespaceToSchemaIR, p as partitionCallsByControlPolicy, r as TABLE_NAME_CASE_CHANGED_CODE, s as contractToSchemaIR, t as INIT_ADDITIVE_POLICY, u as createMigrationPlan, v as runnerFailure, y as runnerSuccess } from "./control-BjvN-a2_.mjs";
5
5
  export { INIT_ADDITIVE_POLICY, PSL_INVALID_DEFAULT_SQL, TABLE_NAME_CASE_CHANGED_CODE, TIMESTAMP_NOW_GENERATOR_ID, assembleAuthoringContributions, buildNativeTypeExpander, checkSqlDefaultBody, contractNamespaceToSchemaIR, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, control_default as default, detectDestructiveChanges, detectTableNameCaseChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, sqlDefaultLiteralTagEntry, temporalAuthoringPresets, temporalCodecPreset, temporalCodecPresetWithPrecision, temporalStringAuthoringPresets, timestampNowControlDescriptor };
@@ -1,4 +1,4 @@
1
- import { c as sqlAttributeSpecs } from "./sql-attribute-specs-BjCzXYcO-Cj8SS3iE.mjs";
1
+ import { u as sqlAttributeSpecs } from "./sql-attribute-specs-DH3Yxb21-CZV-L28L.mjs";
2
2
  import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringTypes, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringFieldPresets } from "./authoring-type-constructors-C1ogrr_x-B9lfq5gm.mjs";
3
3
  //#region ../../../2-sql/9-family/dist/pack.mjs
4
4
  const sqlFamilyPack = {
@@ -1,7 +1,7 @@
1
1
  import { n as isAuthoredIndexInput } from "./index-naming-Cj1Anq-T-w1JL7-EM.mjs";
2
2
  import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
3
3
  import { n as buildSqlContractFromDefinition } from "./derived-checks-6WZKIUxH-CWip2UN5.mjs";
4
- import { a as interpretFieldAttribute, c as sqlAttributeSpecs, i as findModelAttributeNode, n as fieldSpecContext, o as interpretModelAttribute, r as findFieldAttributeNode, s as lowerDefaultFunctionWithRegistry, t as PSL_CHECK_ON_STI_VARIANT } from "./sql-attribute-specs-BjCzXYcO-Cj8SS3iE.mjs";
4
+ import { a as findModelAttributeNode, c as lowerDefaultFunctionWithRegistry, i as findFieldAttributeNode, l as modelAttributeSpecsFrom, n as createSqlBinder, o as interpretFieldAttribute, r as fieldSpecContext, s as interpretModelAttribute, t as PSL_CHECK_ON_STI_VARIANT, u as sqlAttributeSpecs } from "./sql-attribute-specs-DH3Yxb21-CZV-L28L.mjs";
5
5
  import { t as defaultTableName } from "./default-table-name-BfFY8qYR-lHNcVmY5.mjs";
6
6
  import { isStructuredError, structuredError } from "@prisma/orm-framework/utils/structured-error";
7
7
  import { hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, isDataTypeLoweringEntry, loweringEntryKey, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
@@ -17,7 +17,7 @@ import { describeTaggedLiteralFailure } from "@prisma/orm-framework/components/c
17
17
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
18
18
  import { createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, keywordPslSpan, nodePslSpan } from "@prisma/orm-framework/psl-parser";
19
19
  import { consumeInvalidFkPairing, fkRelationPairKey, requiredOneToOneBackrelationDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
20
- //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-Cs1cxg-E.mjs
20
+ //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-CYD009gd.mjs
21
21
  function contractError(code, message, options) {
22
22
  return structuredError(code, message, options);
23
23
  }
@@ -721,8 +721,8 @@ function checkUncomposedNamespace(attributeName, composedExtensions, context) {
721
721
  *
722
722
  * The `data` payload carries the missing namespace so machine consumers (agents, IDE extensions, CLI auto-fix) don't have to parse the prose.
723
723
  */
724
- function reportUncomposedNamespace(input) {
725
- input.diagnostics.push({
724
+ function uncomposedNamespaceDiagnostic(input) {
725
+ return {
726
726
  code: "PSL_EXTENSION_NAMESPACE_NOT_COMPOSED",
727
727
  message: `${input.subjectLabel} uses unrecognized namespace "${input.namespace}". Add extension pack "${input.namespace}" to extensions in prisma.config.ts.`,
728
728
  ...input.source.at(input.span),
@@ -730,7 +730,15 @@ function reportUncomposedNamespace(input) {
730
730
  namespace: input.namespace,
731
731
  suggestedPack: input.namespace
732
732
  }
733
- });
733
+ };
734
+ }
735
+ function reportUncomposedNamespace(input) {
736
+ input.diagnostics.push(uncomposedNamespaceDiagnostic({
737
+ subjectLabel: input.subjectLabel,
738
+ namespace: input.namespace,
739
+ source: input.source,
740
+ span: input.span
741
+ }));
734
742
  }
735
743
  /**
736
744
  * Pushes the canonical `PSL_UNKNOWN_FIELD_PRESET` diagnostic when a typoed preset name is referenced inside a registered field-preset namespace. The `data` payload exposes the namespace and full helper path so machine consumers (agents, IDE extensions) don't have to parse the prose.
@@ -1095,6 +1103,7 @@ function lowerDefaultForField(input) {
1095
1103
  model: input.model,
1096
1104
  field: input.field,
1097
1105
  sources: input.sources,
1106
+ binder: input.binder,
1098
1107
  diagnostics: input.diagnostics
1099
1108
  });
1100
1109
  if (interpreted === void 0) return {};
@@ -1268,6 +1277,7 @@ function lowerEnumDefaultForField(input) {
1268
1277
  model,
1269
1278
  field,
1270
1279
  sources: input.sources,
1280
+ binder: input.binder,
1271
1281
  diagnostics
1272
1282
  });
1273
1283
  if (interpreted === void 0) return {};
@@ -1292,41 +1302,50 @@ const REMOVED_ATTRIBUTE_RULES = /* @__PURE__ */ new Map([["updatedAt", {
1292
1302
  const overlap = [...REMOVED_ATTRIBUTE_RULES.keys()].filter((name) => Object.hasOwn(sqlAttributeSpecs.field, name));
1293
1303
  if (overlap.length > 0) throw new InternalError(`Registered SQL field attributes and REMOVED_ATTRIBUTE_RULES must not overlap. Names in both: ${overlap.join(", ")}`);
1294
1304
  }
1295
- function validateFieldAttributes(input) {
1296
- for (const attribute of input.field.attributes) {
1297
- if (Object.hasOwn(sqlAttributeSpecs.field, attribute.name)) continue;
1298
- if (attribute.name.startsWith("db.")) {
1299
- input.diagnostics.push({
1300
- code: "PSL_UNSUPPORTED_FIELD_ATTRIBUTE",
1301
- message: formatDbAttributeMigrationMessage(attribute),
1302
- ...diagnosticSource(input.sources, input.field.node.syntax).at(attribute.span)
1303
- });
1304
- continue;
1305
- }
1306
- const uncomposedNamespace = checkUncomposedNamespace(attribute.name, input.composedExtensions, {
1307
- familyId: input.familyId,
1308
- targetId: input.targetId,
1309
- authoringContributions: input.authoringContributions
1310
- });
1311
- if (uncomposedNamespace) {
1312
- reportUncomposedNamespace({
1313
- subjectLabel: `Attribute "@${attribute.name}"`,
1305
+ function describeUnsupportedSqlAttribute(input) {
1306
+ const namespaceContext = {
1307
+ ...ifDefined("familyId", input.familyId),
1308
+ ...ifDefined("targetId", input.targetId),
1309
+ authoringContributions: input.authoringContributions
1310
+ };
1311
+ return ({ attribute, level, owner, field }) => {
1312
+ if (level === "model") {
1313
+ const source = diagnosticSource(input.sources, owner.node.syntax);
1314
+ const uncomposedNamespace = checkUncomposedNamespace(attribute.name, input.composedExtensions, namespaceContext);
1315
+ if (uncomposedNamespace) return uncomposedNamespaceDiagnostic({
1316
+ subjectLabel: `Attribute "@@${attribute.name}"`,
1314
1317
  namespace: uncomposedNamespace,
1315
- source: diagnosticSource(input.sources, input.field.node.syntax),
1316
- span: attribute.span,
1317
- diagnostics: input.diagnostics
1318
+ source,
1319
+ span: attribute.span
1318
1320
  });
1319
- continue;
1321
+ return {
1322
+ code: "PSL_UNSUPPORTED_MODEL_ATTRIBUTE",
1323
+ message: `Model "${owner.name}" uses unsupported attribute "@@${attribute.name}"`,
1324
+ ...source.at(attribute.span)
1325
+ };
1320
1326
  }
1321
- const baseMessage = `Field "${input.model.name}.${input.field.name}" uses unsupported attribute "@${attribute.name}"`;
1322
- const removedRule = REMOVED_ATTRIBUTE_RULES.get(attribute.name);
1323
- const message = removedRule && !removedRule.suppressWhen(input.field) ? `${baseMessage}. ${removedRule.hint}` : baseMessage;
1324
- input.diagnostics.push({
1327
+ if (field === void 0) return void 0;
1328
+ const source = diagnosticSource(input.sources, field.node.syntax);
1329
+ if (attribute.name.startsWith("db.")) return {
1325
1330
  code: "PSL_UNSUPPORTED_FIELD_ATTRIBUTE",
1326
- message,
1327
- ...diagnosticSource(input.sources, input.field.node.syntax).at(attribute.span)
1331
+ message: formatDbAttributeMigrationMessage(attribute),
1332
+ ...source.at(attribute.span)
1333
+ };
1334
+ const uncomposedNamespace = checkUncomposedNamespace(attribute.name, input.composedExtensions, namespaceContext);
1335
+ if (uncomposedNamespace) return uncomposedNamespaceDiagnostic({
1336
+ subjectLabel: `Attribute "@${attribute.name}"`,
1337
+ namespace: uncomposedNamespace,
1338
+ source,
1339
+ span: attribute.span
1328
1340
  });
1329
- }
1341
+ const baseMessage = `Field "${owner.name}.${field.name}" uses unsupported attribute "@${attribute.name}"`;
1342
+ const removedRule = REMOVED_ATTRIBUTE_RULES.get(attribute.name);
1343
+ return {
1344
+ code: "PSL_UNSUPPORTED_FIELD_ATTRIBUTE",
1345
+ message: removedRule && !removedRule.suppressWhen(field) ? `${baseMessage}. ${removedRule.hint}` : baseMessage,
1346
+ ...source.at(attribute.span)
1347
+ };
1348
+ };
1330
1349
  }
1331
1350
  function extractFieldConstraintNames(input) {
1332
1351
  const idAttribute = getAttribute(input.field.attributes, "id");
@@ -1339,6 +1358,7 @@ function extractFieldConstraintNames(input) {
1339
1358
  model: input.model,
1340
1359
  field: input.field,
1341
1360
  sources: input.sources,
1361
+ binder: input.binder,
1342
1362
  diagnostics: input.diagnostics
1343
1363
  })?.map;
1344
1364
  const uniqueNode = findFieldAttributeNode(input.field, "unique");
@@ -1353,6 +1373,7 @@ function extractFieldConstraintNames(input) {
1353
1373
  model: input.model,
1354
1374
  field: input.field,
1355
1375
  sources: input.sources,
1376
+ binder: input.binder,
1356
1377
  diagnostics: input.diagnostics
1357
1378
  })?.map
1358
1379
  };
@@ -1374,6 +1395,7 @@ function lowerNoCheckForField(input) {
1374
1395
  model: input.model,
1375
1396
  field: input.field,
1376
1397
  sources: input.sources,
1398
+ binder: input.binder,
1377
1399
  diagnostics: input.diagnostics
1378
1400
  });
1379
1401
  if (interpreted === void 0) return void 0;
@@ -1406,7 +1428,7 @@ function lowerNoCheckForField(input) {
1406
1428
  return [...authored].sort();
1407
1429
  }
1408
1430
  function collectResolvedFields(input) {
1409
- const { model, symbolTable, mapping, enumTypeDescriptors, namedTypeDescriptors, modelNames, compositeTypeNames, composedExtensions, authoringContributions, familyId, targetId, defaultFunctionRegistry, dataTypeSupport, generatorDescriptorById, diagnostics, sources, scalarColumnDescriptors, enumHandles, capabilities, namespaceId, namespaceExtensionEntities, codecLookup } = input;
1431
+ const { model, symbolTable, mapping, enumTypeDescriptors, namedTypeDescriptors, modelNames, compositeTypeNames, composedExtensions, authoringContributions, binder, familyId, targetId, defaultFunctionRegistry, dataTypeSupport, generatorDescriptorById, diagnostics, sources, scalarColumnDescriptors, enumHandles, capabilities, namespaceId, namespaceExtensionEntities, codecLookup } = input;
1410
1432
  const resolvedFields = [];
1411
1433
  const valueObjectStorageTypeName = authoringContributions?.valueObjectStorageType;
1412
1434
  const declaredControlPolicy = getAttribute(model.attributes, "control")?.args.find((arg) => arg.kind === "positional")?.value.trim();
@@ -1415,16 +1437,6 @@ function collectResolvedFields(input) {
1415
1437
  const source = diagnosticSource(sources, field.node.syntax);
1416
1438
  const isModelField = modelNames.has(field.typeName);
1417
1439
  if (field.list && isModelField) continue;
1418
- validateFieldAttributes({
1419
- model,
1420
- field,
1421
- composedExtensions,
1422
- authoringContributions,
1423
- diagnostics,
1424
- sources,
1425
- familyId,
1426
- targetId
1427
- });
1428
1440
  const relationAttribute = getAttribute(field.attributes, "relation");
1429
1441
  if (isModelField && relationAttribute) continue;
1430
1442
  if (field.typeContractSpaceId !== void 0 && relationAttribute) continue;
@@ -1436,6 +1448,7 @@ function collectResolvedFields(input) {
1436
1448
  let presetContributions;
1437
1449
  const resolveInput = {
1438
1450
  field,
1451
+ binder,
1439
1452
  enumTypeDescriptors,
1440
1453
  namedTypeDescriptors,
1441
1454
  scalarColumnDescriptors,
@@ -1518,6 +1531,7 @@ function collectResolvedFields(input) {
1518
1531
  model,
1519
1532
  symbolTable,
1520
1533
  sources: input.sources,
1534
+ binder: input.binder,
1521
1535
  enumHandle,
1522
1536
  defaultFunctionRegistry,
1523
1537
  dataTypeSupport,
@@ -1529,6 +1543,7 @@ function collectResolvedFields(input) {
1529
1543
  model,
1530
1544
  symbolTable,
1531
1545
  sources: input.sources,
1546
+ binder: input.binder,
1532
1547
  columnDescriptor: descriptor,
1533
1548
  generatorDescriptorById,
1534
1549
  defaultFunctionRegistry,
@@ -1569,6 +1584,7 @@ function collectResolvedFields(input) {
1569
1584
  model,
1570
1585
  field,
1571
1586
  sources: input.sources,
1587
+ binder: input.binder,
1572
1588
  diagnostics
1573
1589
  });
1574
1590
  let isIdField = Boolean(idAttribute);
@@ -1603,6 +1619,7 @@ function collectResolvedFields(input) {
1603
1619
  model,
1604
1620
  field,
1605
1621
  sources: input.sources,
1622
+ binder: input.binder,
1606
1623
  isListField: isListField && !isValueObjectField,
1607
1624
  isDomainEnum: enumHandle !== void 0,
1608
1625
  diagnostics
@@ -1626,7 +1643,7 @@ function collectResolvedFields(input) {
1626
1643
  }
1627
1644
  return resolvedFields;
1628
1645
  }
1629
- function buildModelMappings(symbols, modelEntries, defaultNamespaceId, diagnostics, sources) {
1646
+ function buildModelMappings(symbols, modelEntries, defaultNamespaceId, diagnostics, sources, binder) {
1630
1647
  const result = /* @__PURE__ */ new Map();
1631
1648
  for (const { model, namespaceId } of modelEntries) {
1632
1649
  const mapNode = findModelAttributeNode(model, "map");
@@ -1636,6 +1653,7 @@ function buildModelMappings(symbols, modelEntries, defaultNamespaceId, diagnosti
1636
1653
  spec: sqlAttributeSpecs.model.map(),
1637
1654
  model,
1638
1655
  sources,
1656
+ binder,
1639
1657
  diagnostics
1640
1658
  })?.name ?? defaultTableName(model.name);
1641
1659
  const fieldColumns = /* @__PURE__ */ new Map();
@@ -1647,6 +1665,7 @@ function buildModelMappings(symbols, modelEntries, defaultNamespaceId, diagnosti
1647
1665
  spec: sqlAttributeSpecs.field.map(),
1648
1666
  model,
1649
1667
  field,
1668
+ binder,
1650
1669
  sources,
1651
1670
  diagnostics
1652
1671
  })?.name ?? field.name;
@@ -1807,14 +1826,6 @@ const REFERENTIAL_ACTION_MAP = {
1807
1826
  function normalizeReferentialAction(actionToken) {
1808
1827
  return REFERENTIAL_ACTION_MAP[actionToken];
1809
1828
  }
1810
- function resolveReferencedModel(symbols, field) {
1811
- const topLevel = symbols.topLevel.models[field.typeName];
1812
- if (topLevel !== void 0) return topLevel;
1813
- for (const namespace of Object.values(symbols.topLevel.namespaces)) {
1814
- const model = namespace.models[field.typeName];
1815
- if (model !== void 0) return model;
1816
- }
1817
- }
1818
1829
  function interpretRelationAttribute(input) {
1819
1830
  const node = findFieldAttributeNode(input.field, "relation");
1820
1831
  if (node === void 0) return void 0;
@@ -1825,8 +1836,8 @@ function interpretRelationAttribute(input) {
1825
1836
  model: input.selfModel,
1826
1837
  field: input.field,
1827
1838
  sources: input.sources,
1828
- diagnostics: input.diagnostics,
1829
- resolveReferencedModel: () => resolveReferencedModel(input.symbols, input.field)
1839
+ binder: input.binder,
1840
+ diagnostics: input.diagnostics
1830
1841
  });
1831
1842
  }
1832
1843
  function indexFkRelations(input) {
@@ -2500,6 +2511,7 @@ function buildModelNodeFromPsl(input) {
2500
2511
  generatorDescriptorById: input.generatorDescriptorById,
2501
2512
  diagnostics,
2502
2513
  sources: input.sources,
2514
+ binder: input.binder,
2503
2515
  scalarColumnDescriptors: input.scalarColumnDescriptors,
2504
2516
  ...ifDefined("enumHandles", input.enumHandles),
2505
2517
  capabilities: input.capabilities,
@@ -2533,6 +2545,7 @@ function buildModelNodeFromPsl(input) {
2533
2545
  modelName: model.name,
2534
2546
  field,
2535
2547
  sources: input.sources,
2548
+ binder: input.binder,
2536
2549
  composedExtensions: input.composedExtensions,
2537
2550
  authoringContributions: input.authoringContributions,
2538
2551
  diagnostics,
@@ -2546,6 +2559,7 @@ function buildModelNodeFromPsl(input) {
2546
2559
  field,
2547
2560
  symbols: input.symbolTable,
2548
2561
  sources: input.sources,
2562
+ binder: input.binder,
2549
2563
  diagnostics
2550
2564
  });
2551
2565
  if (!parsedRelation) continue;
@@ -2590,29 +2604,7 @@ function buildModelNodeFromPsl(input) {
2590
2604
  const foreignKeyNodes = [];
2591
2605
  const modelAttributeNodes = Array.from(model.node.attributes());
2592
2606
  for (const [attributeIndex, modelAttribute] of model.attributes.entries()) {
2593
- if (!Object.hasOwn(sqlAttributeSpecs.model, modelAttribute.name) && !input.modelAttributesByName.has(modelAttribute.name)) {
2594
- const uncomposedNamespace = checkUncomposedNamespace(modelAttribute.name, input.composedExtensions, {
2595
- familyId: input.familyId,
2596
- targetId: input.targetId,
2597
- authoringContributions: input.authoringContributions
2598
- });
2599
- if (uncomposedNamespace) {
2600
- reportUncomposedNamespace({
2601
- subjectLabel: `Attribute "@@${modelAttribute.name}"`,
2602
- namespace: uncomposedNamespace,
2603
- source,
2604
- span: modelAttribute.span,
2605
- diagnostics
2606
- });
2607
- continue;
2608
- }
2609
- diagnostics.push({
2610
- code: "PSL_UNSUPPORTED_MODEL_ATTRIBUTE",
2611
- message: `Model "${model.name}" uses unsupported attribute "@@${modelAttribute.name}"`,
2612
- ...source.at(modelAttribute.span)
2613
- });
2614
- continue;
2615
- }
2607
+ if (!Object.hasOwn(sqlAttributeSpecs.model, modelAttribute.name) && !input.modelAttributesByName.has(modelAttribute.name)) continue;
2616
2608
  if (modelAttribute.name === "map") continue;
2617
2609
  if (modelAttribute.name === "discriminator" || modelAttribute.name === "base") continue;
2618
2610
  if (modelAttribute.name === "control") {
@@ -2634,6 +2626,7 @@ function buildModelNodeFromPsl(input) {
2634
2626
  model,
2635
2627
  symbols: input.symbolTable,
2636
2628
  sources: input.sources,
2629
+ binder: input.binder,
2637
2630
  diagnostics
2638
2631
  });
2639
2632
  if (parsed !== void 0) controlPolicy = parsed.policy;
@@ -2666,6 +2659,7 @@ function buildModelNodeFromPsl(input) {
2666
2659
  model,
2667
2660
  symbols: input.symbolTable,
2668
2661
  sources: input.sources,
2662
+ binder: input.binder,
2669
2663
  diagnostics
2670
2664
  });
2671
2665
  if (parsed === void 0) continue;
@@ -2705,6 +2699,7 @@ function buildModelNodeFromPsl(input) {
2705
2699
  model,
2706
2700
  symbols: input.symbolTable,
2707
2701
  sources: input.sources,
2702
+ binder: input.binder,
2708
2703
  diagnostics
2709
2704
  });
2710
2705
  if (parsed === void 0) continue;
@@ -2733,6 +2728,7 @@ function buildModelNodeFromPsl(input) {
2733
2728
  model,
2734
2729
  symbols: input.symbolTable,
2735
2730
  sources: input.sources,
2731
+ binder: input.binder,
2736
2732
  diagnostics
2737
2733
  });
2738
2734
  if (parsed === void 0) continue;
@@ -2779,6 +2775,7 @@ function buildModelNodeFromPsl(input) {
2779
2775
  model,
2780
2776
  symbols: input.symbolTable,
2781
2777
  sources: input.sources,
2778
+ binder: input.binder,
2782
2779
  diagnostics
2783
2780
  });
2784
2781
  if (parsed === void 0) continue;
@@ -2803,9 +2800,11 @@ function buildModelNodeFromPsl(input) {
2803
2800
  declaredContributedModelAttributes.add(modelAttribute.name);
2804
2801
  const node = modelAttributeNodes[attributeIndex];
2805
2802
  if (node === void 0) continue;
2803
+ const specFactory = input.contributedModelAttributeSpecs[contributedModelAttribute.attribute];
2804
+ if (specFactory === void 0) continue;
2806
2805
  const parsed = interpretModelAttribute({
2807
2806
  node,
2808
- spec: blindCast(contributedModelAttribute.spec)({
2807
+ spec: specFactory({
2809
2808
  symbols: input.symbolTable,
2810
2809
  model,
2811
2810
  controlMutationDefaults: {
@@ -2816,6 +2815,7 @@ function buildModelNodeFromPsl(input) {
2816
2815
  model,
2817
2816
  symbols: input.symbolTable,
2818
2817
  sources: input.sources,
2818
+ binder: input.binder,
2819
2819
  diagnostics
2820
2820
  });
2821
2821
  if (parsed === void 0) continue;
@@ -2881,6 +2881,7 @@ function buildModelNodeFromPsl(input) {
2881
2881
  field: relationAttribute.field,
2882
2882
  symbols: input.symbolTable,
2883
2883
  sources: input.sources,
2884
+ binder: input.binder,
2884
2885
  diagnostics
2885
2886
  });
2886
2887
  if (!parsedRelation) continue;
@@ -2989,6 +2990,7 @@ function buildModelNodeFromPsl(input) {
2989
2990
  field: relationAttribute.field,
2990
2991
  symbols: input.symbolTable,
2991
2992
  sources: input.sources,
2993
+ binder: input.binder,
2992
2994
  diagnostics
2993
2995
  });
2994
2996
  if (!parsedRelation) continue;
@@ -3204,7 +3206,7 @@ function patchModelDomainFields(models, modelResolvedFields) {
3204
3206
  }
3205
3207
  return patched;
3206
3208
  }
3207
- function collectPolymorphismDeclarations(identities, symbols, sources, diagnostics) {
3209
+ function collectPolymorphismDeclarations(identities, symbols, sources, binder, diagnostics) {
3208
3210
  const discriminatorDeclarations = /* @__PURE__ */ new Map();
3209
3211
  const baseDeclarations = /* @__PURE__ */ new Map();
3210
3212
  for (const { model, key } of identities.values()) {
@@ -3217,6 +3219,7 @@ function collectPolymorphismDeclarations(identities, symbols, sources, diagnosti
3217
3219
  spec: sqlAttributeSpecs.model.discriminator(),
3218
3220
  model,
3219
3221
  sources,
3222
+ binder,
3220
3223
  diagnostics
3221
3224
  });
3222
3225
  if (parsed !== void 0) {
@@ -3242,6 +3245,7 @@ function collectPolymorphismDeclarations(identities, symbols, sources, diagnosti
3242
3245
  spec: sqlAttributeSpecs.model.base(),
3243
3246
  model,
3244
3247
  sources,
3248
+ binder,
3245
3249
  diagnostics
3246
3250
  });
3247
3251
  if (parsed !== void 0) {
@@ -3500,6 +3504,13 @@ function stripStorageOnlyDomainFields(model, fieldNames) {
3500
3504
  }
3501
3505
  };
3502
3506
  }
3507
+ function voicedAsUncomposedNamespace(diagnostic, composedExtensions, context) {
3508
+ const data = diagnostic.data;
3509
+ if (data?.["reference"] !== "type") return false;
3510
+ const name = data["name"];
3511
+ if (typeof name !== "string") return false;
3512
+ return checkUncomposedNamespace(name, composedExtensions, context) !== void 0;
3513
+ }
3503
3514
  function interpretPslDocumentToSqlContract(input) {
3504
3515
  if (!input.target) throw new InternalError("PSL interpretation requires an explicit target context from composition.");
3505
3516
  if (!input.scalarColumnDescriptors) throw new InternalError("PSL interpretation requires composed scalar type descriptors.");
@@ -3507,6 +3518,32 @@ function interpretPslDocumentToSqlContract(input) {
3507
3518
  assertDefined(anchorDocument, "interpretPslDocumentToSqlContract requires at least one document");
3508
3519
  const source = diagnosticSource(input.sources, anchorDocument.syntax);
3509
3520
  const diagnostics = createPslDiagnosticCollector(input.sources);
3521
+ const composedExtensionNames = new Set(input.composedExtensions ?? []);
3522
+ const modelAttributesByName = buildModelAttributesByName(input.authoringContributions);
3523
+ const contributedModelSpecs = modelAttributeSpecsFrom(modelAttributesByName);
3524
+ const { binder, diagnostics: binderDiagnostics } = createSqlBinder({
3525
+ symbolTable: input.symbolTable,
3526
+ sources: input.sources,
3527
+ authoringContributions: input.authoringContributions,
3528
+ controlMutationDefaults: {
3529
+ defaultFunctionRegistry: input.controlMutationDefaults?.defaultFunctionRegistry ?? /* @__PURE__ */ new Map(),
3530
+ dataTypeEntries: input.authoringContributions?.dataTypes ?? {}
3531
+ },
3532
+ scalarColumnDescriptors: input.scalarColumnDescriptors,
3533
+ contributedModelAttributeSpecs: contributedModelSpecs,
3534
+ describeUnsupportedAttribute: describeUnsupportedSqlAttribute({
3535
+ composedExtensions: composedExtensionNames,
3536
+ authoringContributions: input.authoringContributions,
3537
+ sources: input.sources,
3538
+ familyId: input.target.familyId,
3539
+ targetId: input.target.targetId
3540
+ })
3541
+ });
3542
+ diagnostics.push(...binderDiagnostics.filter((diagnostic) => !voicedAsUncomposedNamespace(diagnostic, composedExtensionNames, {
3543
+ familyId: "sql",
3544
+ targetId: input.target.targetId,
3545
+ authoringContributions: input.authoringContributions
3546
+ })));
3510
3547
  const { topLevel } = input.symbolTable;
3511
3548
  const namespaceSymbols = Object.values(topLevel.namespaces);
3512
3549
  validateNamespaceBlocksForSqlTarget({
@@ -3514,6 +3551,7 @@ function interpretPslDocumentToSqlContract(input) {
3514
3551
  targetId: input.target.targetId,
3515
3552
  source,
3516
3553
  sources: input.sources,
3554
+ binder,
3517
3555
  diagnostics
3518
3556
  });
3519
3557
  validateBlockModelAttributeRequirements({
@@ -3606,7 +3644,6 @@ function interpretPslDocumentToSqlContract(input) {
3606
3644
  const validEnumHandles = { ...enumResult.enumHandles };
3607
3645
  const enumHandlesByName = new Map(Object.entries(validEnumHandles));
3608
3646
  const entityTypesByDiscriminator = buildEntityTypesByDiscriminator(input.authoringContributions);
3609
- const modelAttributesByName = buildModelAttributesByName(input.authoringContributions);
3610
3647
  const authoringWarnings = [];
3611
3648
  const extensionEntityContext = {
3612
3649
  family: input.target.familyId,
@@ -3619,7 +3656,7 @@ function interpretPslDocumentToSqlContract(input) {
3619
3656
  } },
3620
3657
  warnings: authoringWarnings
3621
3658
  };
3622
- const earlyModelMappingsByCoordinate = buildModelMappings(input.symbolTable, modelEntries, defaultNamespaceId, createPslDiagnosticCollector(input.sources), input.sources);
3659
+ const earlyModelMappingsByCoordinate = buildModelMappings(input.symbolTable, modelEntries, defaultNamespaceId, createPslDiagnosticCollector(input.sources), input.sources, binder);
3623
3660
  const composedPslBlockDescriptors = input.authoringContributions?.pslBlockDescriptors ?? {};
3624
3661
  const namespaceExtensionEntities = /* @__PURE__ */ new Map();
3625
3662
  const mergeNamespaceExtensionEntities = (nsId, entities, blocks) => {
@@ -3692,7 +3729,7 @@ function interpretPslDocumentToSqlContract(input) {
3692
3729
  diagnostics
3693
3730
  });
3694
3731
  const storageTypes = { ...namedTypeResult.storageTypes };
3695
- const modelMappingsByCoordinate = buildModelMappings(input.symbolTable, modelEntries, defaultNamespaceId, diagnostics, input.sources);
3732
+ const modelMappingsByCoordinate = buildModelMappings(input.symbolTable, modelEntries, defaultNamespaceId, diagnostics, input.sources, binder);
3696
3733
  const modelMappings = /* @__PURE__ */ new Map();
3697
3734
  for (const mapping of modelMappingsByCoordinate.values()) modelMappings.set(mapping.model.name, mapping);
3698
3735
  const modelNodes = [];
@@ -3725,6 +3762,7 @@ function interpretPslDocumentToSqlContract(input) {
3725
3762
  generatorDescriptorById,
3726
3763
  scalarColumnDescriptors: input.scalarColumnDescriptors,
3727
3764
  sources: input.sources,
3765
+ binder,
3728
3766
  symbolTable: input.symbolTable,
3729
3767
  diagnostics,
3730
3768
  modelNamespaceIds,
@@ -3733,6 +3771,7 @@ function interpretPslDocumentToSqlContract(input) {
3733
3771
  ...namespaceExtensionEntities.size > 0 ? { namespaceExtensionEntities } : {},
3734
3772
  ...ifDefined("codecLookup", input.codecLookup),
3735
3773
  modelAttributesByName,
3774
+ contributedModelAttributeSpecs: contributedModelSpecs,
3736
3775
  defaultNamespaceId
3737
3776
  });
3738
3777
  modelNodes.push(namespaceId !== void 0 ? {
@@ -3790,7 +3829,7 @@ function interpretPslDocumentToSqlContract(input) {
3790
3829
  namespaceId: resolvedNamespaceId,
3791
3830
  key: modelCoordinateKey(resolvedNamespaceId, model.name)
3792
3831
  }];
3793
- })), input.symbolTable, input.sources, diagnostics);
3832
+ })), input.symbolTable, input.sources, binder, diagnostics);
3794
3833
  const stiVariantKeys = /* @__PURE__ */ new Set();
3795
3834
  for (const variantKey of baseDeclarations.keys()) if (!(modelMappingsByCoordinate.get(variantKey)?.model.attributes.some((attr) => attr.name === "map") ?? false)) stiVariantKeys.add(variantKey);
3796
3835
  for (const variantKey of stiVariantKeys) {
@@ -3820,7 +3859,8 @@ function interpretPslDocumentToSqlContract(input) {
3820
3859
  targetId: input.target.targetId,
3821
3860
  authoringContributions: input.authoringContributions,
3822
3861
  diagnostics,
3823
- sources: input.sources
3862
+ sources: input.sources,
3863
+ binder
3824
3864
  });
3825
3865
  if (diagnostics.length > 0 || (input.seedDiagnostics?.length ?? 0) > 0) return notOk({
3826
3866
  summary: "PSL to SQL contract interpretation failed",
@@ -3893,4 +3933,4 @@ function interpretPslDocumentToSqlContract(input) {
3893
3933
  //#endregion
3894
3934
  export { interpretPslDocumentToSqlContract as a, resolveFieldTypeDescriptor as c, indexFkRelations as i, buildEntityTypesByDiscriminator as n, normalizeReferentialAction as o, entryForTag as r, readDataTypeDefault as s, applyBackrelationCandidates as t };
3895
3935
 
3896
- //# sourceMappingURL=interpreter-Cs1cxg-E-N_DDfih-.mjs.map
3936
+ //# sourceMappingURL=interpreter-CYD009gd-DK-SbljF.mjs.map