@prisma/orm-framework 8.0.0-rc.14-dev.18 → 8.0.0-rc.14-dev.20

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.
Files changed (29) hide show
  1. package/dist/{ast-helpers-2XRnkQEO-BxG5qx3Q.mjs → ast-helpers-CzydMPdh-Mi0SrZRa.mjs} +41 -3
  2. package/dist/{ast-helpers-2XRnkQEO-BxG5qx3Q.mjs.map → ast-helpers-CzydMPdh-Mi0SrZRa.mjs.map} +1 -1
  3. package/dist/{binder-CQGFQCuK-DrdVszQh.d.mts → binder-CGmSEQPU-Bn32vwiq.d.mts} +7 -4
  4. package/dist/binder-CGmSEQPU-Bn32vwiq.d.mts.map +1 -0
  5. package/dist/{declarations-C0VwsVFX-BcP1Nyv4.mjs → declarations-DDT0hm5r-BAMLVwKx.mjs} +24 -5
  6. package/dist/declarations-DDT0hm5r-BAMLVwKx.mjs.map +1 -0
  7. package/dist/{parse-DqMTVHCw-DqqgVEUq.d.mts → parse-eSQ_clQv-Dd2RdJRb.d.mts} +20 -9
  8. package/dist/parse-eSQ_clQv-Dd2RdJRb.d.mts.map +1 -0
  9. package/dist/{parse-EvT3Ac9q-B0Nxq52v.mjs → parse-ymgXJUnk-CYMEjkGC.mjs} +61 -21
  10. package/dist/parse-ymgXJUnk-CYMEjkGC.mjs.map +1 -0
  11. package/dist/psl-parser.d.mts +11 -12
  12. package/dist/psl-parser.d.mts.map +1 -1
  13. package/dist/psl-parser.mjs +122 -68
  14. package/dist/psl-parser.mjs.map +1 -1
  15. package/dist/psl-parser__format.mjs +3 -3
  16. package/dist/psl-parser__format.mjs.map +1 -1
  17. package/dist/psl-parser__interpret.d.mts +2 -2
  18. package/dist/psl-parser__interpret.mjs +1 -1
  19. package/dist/psl-parser__interpret.mjs.map +1 -1
  20. package/dist/psl-parser__syntax.d.mts +2 -2
  21. package/dist/psl-parser__syntax.mjs +3 -3
  22. package/dist/psl-parser__syntax.mjs.map +1 -1
  23. package/dist/{resolve-GE34dgM6-D33m6YEw.mjs → resolve-C8PUf8zv-QAvnPhCt.mjs} +3 -3
  24. package/dist/{resolve-GE34dgM6-D33m6YEw.mjs.map → resolve-C8PUf8zv-QAvnPhCt.mjs.map} +1 -1
  25. package/package.json +15 -15
  26. package/dist/binder-CQGFQCuK-DrdVszQh.d.mts.map +0 -1
  27. package/dist/declarations-C0VwsVFX-BcP1Nyv4.mjs.map +0 -1
  28. package/dist/parse-DqMTVHCw-DqqgVEUq.d.mts.map +0 -1
  29. package/dist/parse-EvT3Ac9q-B0Nxq52v.mjs.map +0 -1
@@ -4,9 +4,9 @@ import { a as or, i as okVoid, n as notOk, r as ok, t as and } from "./result-8O
4
4
  import { b as isAuthoringModelAttributeDescriptor, x as isAuthoringPslBlockDescriptor } from "./temporal-presets-DzBBD4St-BaL1QaZ7.mjs";
5
5
  import { a as flatPslModels, c as namespacePslExtensionBlocks } from "./psl-ast-CyvE6CR-.mjs";
6
6
  import { n as isPslIdentifier } from "./tokenizer-BMz7z2KR-J0yZ4im3.mjs";
7
- import { C as TaggedLiteralExprAst, S as StringLiteralExprAst, T as TypesBlockAst, _ as NumberLiteralExprAst, a as CompositeTypeDeclarationAst, d as IdentifierAst, g as NamespaceDeclarationAst, i as BooleanLiteralExprAst, l as FunctionCallAst, m as ModelDeclarationAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, y as ObjectLiteralExprAst } from "./declarations-C0VwsVFX-BcP1Nyv4.mjs";
8
- import { a as mapPslDiagnostics, c as readResolvedAttributes, i as keywordPslSpan, l as readResolvedConstructorCall, n as diagnosticFromSpan, o as nodePslSpan, r as diagnosticSource, s as readResolvedAttribute, t as createPslDiagnosticCollector } from "./resolve-GE34dgM6-D33m6YEw.mjs";
9
- //#region ../../../1-framework/2-authoring/psl-parser/dist/symbol-table-0DYRY2eQ.mjs
7
+ import { C as TaggedLiteralExprAst, S as StringLiteralExprAst, T as TypesBlockAst, _ as NumberLiteralExprAst, a as CompositeTypeDeclarationAst, b as PathExprAst, d as IdentifierAst, g as NamespaceDeclarationAst, i as BooleanLiteralExprAst, l as FunctionCallAst, m as ModelDeclarationAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, y as ObjectLiteralExprAst } from "./declarations-DDT0hm5r-BAMLVwKx.mjs";
8
+ import { a as mapPslDiagnostics, c as readResolvedAttributes, i as keywordPslSpan, l as readResolvedConstructorCall, n as diagnosticFromSpan, o as nodePslSpan, r as diagnosticSource, s as readResolvedAttribute, t as createPslDiagnosticCollector } from "./resolve-C8PUf8zv-QAvnPhCt.mjs";
9
+ //#region ../../../1-framework/2-authoring/psl-parser/dist/symbol-table-DDQTCCCB.mjs
10
10
  function* modelAttributeDescriptors(namespace) {
11
11
  for (const value of Object.values(namespace)) {
12
12
  if (isAuthoringModelAttributeDescriptor(value)) {
@@ -37,6 +37,57 @@ function resolveDescribeUnresolvedType(pslDiagnostics) {
37
37
  if (pslDiagnostics?.describeUnresolvedType === void 0) return;
38
38
  return blindCast(pslDiagnostics.describeUnresolvedType);
39
39
  }
40
+ function writtenEntityReference(node) {
41
+ const name = IdentifierAst.cast(node)?.name();
42
+ if (name !== void 0) return {
43
+ namespace: void 0,
44
+ name
45
+ };
46
+ const path = PathExprAst.cast(node)?.path();
47
+ if (path === void 0 || path.length !== 2) return void 0;
48
+ const [namespace, member] = path;
49
+ return namespace === void 0 || member === void 0 ? void 0 : {
50
+ namespace,
51
+ name: member
52
+ };
53
+ }
54
+ function describeWrittenEntityReference(reference) {
55
+ return reference.namespace === void 0 ? reference.name : `${reference.namespace}.${reference.name}`;
56
+ }
57
+ const references = /* @__PURE__ */ new WeakMap();
58
+ function entityReference(resolution) {
59
+ switch (resolution.kind) {
60
+ case "model":
61
+ case "compositeType":
62
+ case "namedType":
63
+ case "block": return interned(resolution.symbol, resolution.namespace);
64
+ default: return;
65
+ }
66
+ }
67
+ function interned(declaration, namespace) {
68
+ const existing = references.get(declaration);
69
+ if (existing !== void 0) return existing;
70
+ const reference = {
71
+ declaration,
72
+ namespace
73
+ };
74
+ references.set(declaration, reference);
75
+ return reference;
76
+ }
77
+ function matchesSelector(reference, expected) {
78
+ const declaration = reference.declaration;
79
+ if (declaration.kind !== expected.kind) return false;
80
+ return expected.kind !== "block" || declaration.kind === "block" && declaration.keyword === expected.keyword;
81
+ }
82
+ function describeResolution(resolution) {
83
+ switch (resolution.kind) {
84
+ case "block": return resolution.symbol.keyword;
85
+ case "contributedType": return "scalar type";
86
+ case "crossSpace": return "cross-space reference";
87
+ case "unresolved": return "unresolved name";
88
+ default: return resolution.kind;
89
+ }
90
+ }
40
91
  function blockSpecFactoryOf(descriptor) {
41
92
  return blindCast(descriptor.spec);
42
93
  }
@@ -293,11 +344,22 @@ function walkEntities(symbolTable, stack, binder, visit) {
293
344
  for (const entity of Object.values(topLevel.compositeTypes)) visit(entity);
294
345
  for (const namespace of Object.values(topLevel.namespaces)) {
295
346
  stack.push(binder.scopeAt(namespace.declarations[0].node.syntax));
296
- for (const entity of Object.values(namespace.models)) visit(entity);
297
- for (const entity of Object.values(namespace.compositeTypes)) visit(entity);
347
+ for (const entity of Object.values(namespace.models)) visit(entity, namespace);
348
+ for (const entity of Object.values(namespace.compositeTypes)) visit(entity, namespace);
298
349
  stack.pop();
299
350
  }
300
351
  }
352
+ function declarationResolution(entity, namespace) {
353
+ return entity.kind === "model" ? {
354
+ kind: "model",
355
+ symbol: entity,
356
+ ...namespace === void 0 ? {} : { namespace }
357
+ } : {
358
+ kind: "compositeType",
359
+ symbol: entity,
360
+ ...namespace === void 0 ? {} : { namespace }
361
+ };
362
+ }
301
363
  function createBinder(input) {
302
364
  const { symbolTable, sources, context } = input;
303
365
  const contributions = context.authoringContributions;
@@ -331,24 +393,51 @@ function bind(options) {
331
393
  const baseScope = namedTypeBaseScope(symbolTable.topLevel, contributed);
332
394
  for (const symbol of Object.values(symbolTable.topLevel.namedTypes)) {
333
395
  declarations.set(symbol.node.syntax, symbol);
396
+ const declaredName = symbol.node.name()?.syntax;
397
+ if (declaredName !== void 0) references.set(declaredName, {
398
+ kind: "namedType",
399
+ symbol
400
+ });
334
401
  const name = symbol.node.typeAnnotation()?.name();
335
402
  const outcome = resolveTypeReference(name, baseScope);
336
403
  if (name === void 0 || outcome === void 0) continue;
337
404
  references.set(name.syntax, outcome.resolution);
338
405
  }
339
- for (const symbol of Object.values(symbolTable.topLevel.blocks)) declarations.set(symbol.node.syntax, symbol);
406
+ for (const symbol of Object.values(symbolTable.topLevel.blocks)) {
407
+ declarations.set(symbol.node.syntax, symbol);
408
+ const declaredName = symbol.node.name()?.syntax;
409
+ if (declaredName !== void 0) references.set(declaredName, {
410
+ kind: "block",
411
+ symbol
412
+ });
413
+ }
340
414
  for (const namespace of Object.values(symbolTable.topLevel.namespaces)) {
341
415
  const scope = namespaceScope(namespace, document);
342
416
  for (const declaration of namespace.declarations) {
343
417
  declarations.set(declaration.node.syntax, namespace);
344
418
  scopes.set(declaration.node.syntax, scope);
345
419
  }
346
- for (const symbol of Object.values(namespace.blocks)) declarations.set(symbol.node.syntax, symbol);
420
+ for (const symbol of Object.values(namespace.blocks)) {
421
+ declarations.set(symbol.node.syntax, symbol);
422
+ const declaredName = symbol.node.name()?.syntax;
423
+ if (declaredName !== void 0) references.set(declaredName, {
424
+ kind: "block",
425
+ symbol,
426
+ namespace
427
+ });
428
+ }
347
429
  }
348
- walkEntities(symbolTable, stack, binder, (entity) => {
430
+ walkEntities(symbolTable, stack, binder, (entity, namespace) => {
349
431
  declarations.set(entity.node.syntax, entity);
432
+ const declaredName = entity.node.name()?.syntax;
433
+ if (declaredName !== void 0) references.set(declaredName, declarationResolution(entity, namespace));
350
434
  for (const field of Object.values(entity.fields)) {
351
435
  declarations.set(field.node.syntax, field);
436
+ const fieldName = field.node.name()?.syntax;
437
+ if (fieldName !== void 0) references.set(fieldName, {
438
+ kind: "field",
439
+ symbol: field
440
+ });
352
441
  const node = typeReferenceNode(field);
353
442
  if (node === void 0) continue;
354
443
  const outcome = resolveTypeReference(field.node.typeAnnotation()?.name(), stack.current(), (written) => describeUnresolvedType?.({
@@ -431,10 +520,7 @@ function bind(options) {
431
520
  function bindBlock(block, ctx) {
432
521
  const descriptor = findBlockDescriptor(ctx.pslBlockDescriptors, block.keyword);
433
522
  if (descriptor === void 0) return;
434
- const spec = blockSpecFactoryOf(descriptor)({
435
- symbols: ctx.symbolTable,
436
- block
437
- });
523
+ const spec = blockSpecFactoryOf(descriptor)({ symbols: ctx.symbolTable });
438
524
  for (const entry of block.node.entries()) {
439
525
  const key = entry.key()?.name();
440
526
  if (key === void 0) continue;
@@ -448,10 +534,7 @@ function bindBlock(block, ctx) {
448
534
  for (const attribute of readResolvedAttributes(block.node.attributes(), ctx.sources)) {
449
535
  const factory = attributeSpecs[attribute.name];
450
536
  if (factory === void 0) continue;
451
- bindArguments(attribute, blindCast(factory)({
452
- symbols: ctx.symbolTable,
453
- block
454
- }), ctx);
537
+ bindArguments(attribute, blindCast(factory)({ symbols: ctx.symbolTable }), ctx);
455
538
  }
456
539
  }
457
540
  function bindExpression(rule, expression, ctx, modelContext) {
@@ -527,14 +610,14 @@ function tryBindExpression(rule, expression, ctx, modelContext) {
527
610
  }
528
611
  case "entityRef": {
529
612
  const node = expression.syntax;
530
- const name = IdentifierAst.cast(node)?.name();
531
- if (name === void 0) return {
613
+ const written = writtenEntityReference(node);
614
+ if (written === void 0) return {
532
615
  matched: false,
533
616
  references,
534
617
  diagnostics
535
618
  };
536
619
  const failures = [];
537
- const resolution = resolveEntity(name, node, {
620
+ const resolution = resolveEntity(written, node, {
538
621
  ...ctx,
539
622
  diagnostics: failures
540
623
  });
@@ -683,15 +766,23 @@ function targetFields(target) {
683
766
  if (target === void 0) return void 0;
684
767
  if (target.kind === "model" || target.kind === "compositeType") return target.symbol.fields;
685
768
  }
686
- function resolveEntity(name, node, ctx) {
687
- const found = ctx.scope.lookup(name);
769
+ function resolveEntity(written, node, ctx) {
770
+ const found = written.namespace === void 0 ? ctx.scope.lookup(written.name) : qualifiedMember(written.namespace, written.name, ctx.scope);
688
771
  if (found === void 0) {
689
- report(`Cannot find entity "${name}"`, node, ctx, "entity");
772
+ const name = describeWrittenEntityReference(written);
773
+ if (written.name !== "") report(`Cannot find entity "${name}"`, node, ctx, "entity");
690
774
  return {
691
775
  kind: "unresolved",
692
776
  name
693
777
  };
694
778
  }
779
+ if ("badQualifier" in found) {
780
+ report(found.badQualifier, node, ctx, "entity");
781
+ return {
782
+ kind: "unresolved",
783
+ name: found.qualifier
784
+ };
785
+ }
695
786
  return found;
696
787
  }
697
788
  function report(message, node, ctx, reference) {
@@ -1032,40 +1123,6 @@ function bool() {
1032
1123
  }
1033
1124
  };
1034
1125
  }
1035
- const references = /* @__PURE__ */ new WeakMap();
1036
- function entityReference(resolution) {
1037
- switch (resolution.kind) {
1038
- case "model":
1039
- case "compositeType":
1040
- case "namedType":
1041
- case "block": return interned(resolution.symbol, resolution.namespace);
1042
- default: return;
1043
- }
1044
- }
1045
- function interned(declaration, namespace) {
1046
- const existing = references.get(declaration);
1047
- if (existing !== void 0) return existing;
1048
- const reference = {
1049
- declaration,
1050
- namespace
1051
- };
1052
- references.set(declaration, reference);
1053
- return reference;
1054
- }
1055
- function matchesSelector(reference, expected) {
1056
- const declaration = reference.declaration;
1057
- if (declaration.kind !== expected.kind) return false;
1058
- return expected.kind !== "block" || declaration.kind === "block" && declaration.keyword === expected.keyword;
1059
- }
1060
- function describeResolution(resolution) {
1061
- switch (resolution.kind) {
1062
- case "block": return resolution.symbol.keyword;
1063
- case "contributedType": return "scalar type";
1064
- case "crossSpace": return "cross-space reference";
1065
- case "unresolved": return "unresolved name";
1066
- default: return resolution.kind;
1067
- }
1068
- }
1069
1126
  function entityRef(expected) {
1070
1127
  const label = `${expected.kind === "block" ? expected.keyword : expected.kind} reference`;
1071
1128
  return {
@@ -1073,8 +1130,9 @@ function entityRef(expected) {
1073
1130
  label,
1074
1131
  expected,
1075
1132
  parse: (arg, ctx) => {
1076
- const name = IdentifierAst.cast(arg.syntax)?.name();
1077
- if (name === void 0) return notOk([leafDiagnostic(ctx, arg, `Expected ${label}`)]);
1133
+ const written = writtenEntityReference(arg.syntax);
1134
+ if (written === void 0) return notOk([leafDiagnostic(ctx, arg, `Expected ${label}`)]);
1135
+ const name = describeWrittenEntityReference(written);
1078
1136
  const resolution = ctx.binder.symbolForNode(arg.syntax);
1079
1137
  if (resolution === void 0 || resolution.kind === "unresolved") return notOk([]);
1080
1138
  const reference = entityReference(resolution);
@@ -1556,7 +1614,8 @@ function interpretExtensionBlock(input) {
1556
1614
  const ctx = {
1557
1615
  sources,
1558
1616
  symbols,
1559
- binder
1617
+ binder,
1618
+ selfBlock: block
1560
1619
  };
1561
1620
  const entries = spec.mode === "struct" ? interpretStructBlock(block, spec, ctx) : interpretMapBlock(block, spec, ctx);
1562
1621
  const diagnostics = [...entries.diagnostics];
@@ -1698,14 +1757,12 @@ function interpretExtensionBlockAttributes(input) {
1698
1757
  continue;
1699
1758
  }
1700
1759
  seenNames.add(name);
1701
- const spec = blindCast(declared[name])({
1702
- symbols,
1703
- block
1704
- });
1760
+ const spec = blindCast(declared[name])({ symbols });
1705
1761
  const result = interpretAttribute(attribute, spec, {
1706
1762
  sources,
1707
1763
  symbols,
1708
- binder
1764
+ binder,
1765
+ selfBlock: block
1709
1766
  });
1710
1767
  if (result.ok) {
1711
1768
  const argSpans = Object.create(null);
@@ -1744,10 +1801,7 @@ function interpretExtensionBlocks(input) {
1744
1801
  const parsed = interpretExtensionBlock({
1745
1802
  block,
1746
1803
  descriptor,
1747
- spec: blockSpecFactoryOf(descriptor)({
1748
- symbols: symbolTable,
1749
- block
1750
- }),
1804
+ spec: blockSpecFactoryOf(descriptor)({ symbols: symbolTable }),
1751
1805
  symbols: symbolTable,
1752
1806
  sources,
1753
1807
  binder