@prisma/orm-framework 8.0.0-rc.17-dev.41 → 8.0.0-rc.17-dev.42

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 (33) hide show
  1. package/dist/{binder-C54tCWu0-C66Qu7Oy.d.mts → binder-Eeh-nJsx-BkT5IXHe.d.mts} +15 -18
  2. package/dist/binder-Eeh-nJsx-BkT5IXHe.d.mts.map +1 -0
  3. package/dist/components.d.mts +1 -1
  4. package/dist/components__control.d.mts +1 -1
  5. package/dist/{config-types-ChGfgO0H.d.mts → config-types-DnfvNRK4.d.mts} +3 -2
  6. package/dist/config-types-DnfvNRK4.d.mts.map +1 -0
  7. package/dist/config.d.mts +1 -1
  8. package/dist/config__config-types.d.mts +1 -1
  9. package/dist/{control-rWaFpiNP.d.mts → control-510XVXM6.d.mts} +2 -1
  10. package/dist/{control-rWaFpiNP.d.mts.map → control-510XVXM6.d.mts.map} +1 -1
  11. package/dist/control-BdigmuMj.d.mts +1 -0
  12. package/dist/{control-C11hV6zc-CyU5mC4U.d.mts → control-C11hV6zc-CEHP41aJ.d.mts} +2 -2
  13. package/dist/{control-C11hV6zc-CyU5mC4U.d.mts.map → control-C11hV6zc-CEHP41aJ.d.mts.map} +1 -1
  14. package/dist/errors.d.mts +4 -4
  15. package/dist/errors__control.d.mts +2 -2
  16. package/dist/errors__execution.d.mts +1 -1
  17. package/dist/errors__migration.d.mts +1 -1
  18. package/dist/{execution-Dwe5KeZR.d.mts → execution-CQlE9CHq.d.mts} +3 -3
  19. package/dist/{execution-Dwe5KeZR.d.mts.map → execution-CQlE9CHq.d.mts.map} +1 -1
  20. package/dist/{migration-mo8np4v0.d.mts → migration-CFOAAVqQ.d.mts} +2 -2
  21. package/dist/{migration-mo8np4v0.d.mts.map → migration-CFOAAVqQ.d.mts.map} +1 -1
  22. package/dist/{parse-CJtBvEYy-DSJkhfVG.d.mts → parse-CJtBvEYy-CBkiQrF-.d.mts} +2 -2
  23. package/dist/{parse-CJtBvEYy-DSJkhfVG.d.mts.map → parse-CJtBvEYy-CBkiQrF-.d.mts.map} +1 -1
  24. package/dist/psl-parser.d.mts +4 -4
  25. package/dist/psl-parser.mjs +78 -90
  26. package/dist/psl-parser.mjs.map +1 -1
  27. package/dist/psl-parser__format.d.mts +1 -1
  28. package/dist/psl-parser__interpret.d.mts +3 -3
  29. package/dist/psl-parser__syntax.d.mts +1 -1
  30. package/package.json +15 -15
  31. package/dist/binder-C54tCWu0-C66Qu7Oy.d.mts.map +0 -1
  32. package/dist/config-types-ChGfgO0H.d.mts.map +0 -1
  33. package/dist/control-n_yMh33m.d.mts +0 -1
@@ -3,13 +3,14 @@ import { t as InternalError } from "./internal-error-ChGYPVpq-DhUD05u0.mjs";
3
3
  import { a as or, i as okVoid, n as notOk, r as ok, t as and } from "./result-8OXF26MN.mjs";
4
4
  import { r as createDataTypeLookup } from "./data-type-4xQlxYB5-DD158cOq.mjs";
5
5
  import { S as isAuthoringPslBlockDescriptor, f as describeTaggedLiteralFailure, x as isAuthoringModelAttributeDescriptor } from "./temporal-presets-DEyPX8qQ-Bz4DdZ8v.mjs";
6
+ import { r as UNBOUND_NAMESPACE_ID } from "./namespace-VUH2dgnS-By5y75h9.mjs";
6
7
  import { a as describeExpected, b as tagForm, i as describeAdmittedForms, n as admittedTags, o as describeRefusal, p as exactRewrite, r as castTypedValue, t as admittedForms, y as readWrittenValue } from "./authoring-axlemDvs.mjs";
7
- import { a as flatPslModels, c as namespacePslExtensionBlocks } from "./psl-ast-CyvE6CR-.mjs";
8
+ import { a as flatPslModels, c as namespacePslExtensionBlocks, n as UNBOUND_PSL_NAMESPACE_NAME } from "./psl-ast-CyvE6CR-.mjs";
8
9
  import { l as printSyntax } from "./ast-helpers-CzydMPdh-Mi0SrZRa.mjs";
9
10
  import { n as isPslIdentifier } from "./tokenizer-C-GTKKjR-B1vOzJy0.mjs";
10
11
  import { D as TypesBlockAst, S as PathExprAst, T as TaggedLiteralExprAst, a as CompositeTypeDeclarationAst, c as FieldDeclarationAst, d as IdentifierAst, f as KeyValuePairAst, g as ModelDeclarationAst, h as ModelAttributeAst, i as BooleanLiteralExprAst, l as FunctionCallAst, p as MixinDeclarationAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, v as NamespaceDeclarationAst, w as StringLiteralExprAst, x as ObjectLiteralExprAst, y as NumberLiteralExprAst } from "./declarations-DuSbyF44-Bee8mK-C.mjs";
11
12
  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";
12
- //#region ../../../1-framework/2-authoring/psl-parser/dist/binder-DNpvbbBT.mjs
13
+ //#region ../../../1-framework/2-authoring/psl-parser/dist/binder-C1D2hDgY.mjs
13
14
  function* modelAttributeDescriptors(namespace) {
14
15
  for (const value of Object.values(namespace)) {
15
16
  if (isAuthoringModelAttributeDescriptor(value)) {
@@ -219,6 +220,15 @@ function findBlockDescriptor(descriptors, keyword) {
219
220
  if (nested !== void 0) return nested;
220
221
  }
221
222
  }
223
+ function namespaceIdOfPslName(name) {
224
+ return name === "unbound" ? UNBOUND_NAMESPACE_ID : name;
225
+ }
226
+ function pslNameOfNamespaceId(id) {
227
+ return id === "__unbound__" ? UNBOUND_PSL_NAMESPACE_NAME : id;
228
+ }
229
+ function pslNamesOfNamespaceId(id) {
230
+ return id === "__unbound__" ? [UNBOUND_PSL_NAMESPACE_NAME, UNBOUND_NAMESPACE_ID] : [id];
231
+ }
222
232
  function* recordNames(...records) {
223
233
  for (const record of records) yield* Object.keys(record);
224
234
  }
@@ -288,48 +298,31 @@ var ContributedScope = class extends Scope {
288
298
  }
289
299
  };
290
300
  var DocumentScope = class extends Scope {
291
- #records;
292
- constructor(records, parent) {
301
+ #symbols;
302
+ constructor(symbols, parent) {
293
303
  super(parent);
294
- this.#records = records;
304
+ this.#symbols = symbols;
295
305
  }
296
306
  lookup(name) {
297
- const records = this.#records;
298
- const model = records.models[name];
299
- if (model !== void 0) return {
300
- kind: "model",
301
- symbol: model
302
- };
303
- const compositeType = records.compositeTypes[name];
304
- if (compositeType !== void 0) return {
305
- kind: "compositeType",
306
- symbol: compositeType
307
- };
308
- const namedType = records.namedTypes[name];
307
+ const { defaultNamespace, namedTypes, namespaces } = this.#symbols;
308
+ const member = namespaceMember(defaultNamespace, name);
309
+ if (member !== void 0) return member;
310
+ const namedType = namedTypes[name];
309
311
  if (namedType !== void 0) return {
310
312
  kind: "namedType",
311
313
  symbol: namedType
312
314
  };
313
- const block = records.blocks[name];
314
- if (block !== void 0) return {
315
- kind: "block",
316
- symbol: block
317
- };
318
- const mixin = records.mixins[name];
319
- if (mixin !== void 0) return {
320
- kind: "mixin",
321
- symbol: mixin
322
- };
323
- const namespace = records.namespaces[name];
315
+ const namespace = namespaces[namespaceIdOfPslName(name)];
324
316
  if (namespace !== void 0) return {
325
317
  kind: "namespace",
326
318
  symbol: namespace
327
319
  };
328
320
  return this.parent?.lookup(name);
329
321
  }
330
- ownNames() {
331
- const records = this.#records;
332
- return recordNames(records.models, records.compositeTypes, records.namedTypes, records.blocks, records.mixins, records.namespaces);
322
+ *ownNames() {
323
+ const { defaultNamespace, namedTypes, namespaces } = this.#symbols;
324
+ yield* recordNames(defaultNamespace.models, defaultNamespace.compositeTypes, namedTypes, defaultNamespace.blocks, defaultNamespace.mixins);
325
+ for (const namespace of Object.values(namespaces)) yield namespace.name;
333
326
  }
334
327
  };
335
328
  var NamespaceScope = class extends Scope {
@@ -349,12 +342,12 @@ var NamespaceScope = class extends Scope {
349
342
  function contributedScope(registry) {
350
343
  return new ContributedScope(registry);
351
344
  }
352
- function documentScope(records, parent) {
353
- return new DocumentScope(records, parent);
345
+ function documentScope(symbols, parent) {
346
+ return new DocumentScope(symbols, parent);
354
347
  }
355
- function namedTypeBaseScope(records, parent) {
348
+ function namedTypeBaseScope(symbols, parent) {
356
349
  return new DocumentScope({
357
- ...records,
350
+ ...symbols,
358
351
  namedTypes: {}
359
352
  }, parent);
360
353
  }
@@ -383,7 +376,7 @@ function lookupMember(qualifier, name) {
383
376
  * should consume first-wins symbols rather than re-emitting duplicate diagnostics.
384
377
  */
385
378
  function buildSymbolTable(options) {
386
- const { documents, sources } = options;
379
+ const { documents, sources, defaultNamespaceId } = options;
387
380
  const diagnostics = [];
388
381
  const namespaces = Object.create(null);
389
382
  const namedTypes = Object.create(null);
@@ -391,7 +384,18 @@ function buildSymbolTable(options) {
391
384
  const models = Object.create(null);
392
385
  const compositeTypes = Object.create(null);
393
386
  const mixins = Object.create(null);
394
- const topLevelNames = /* @__PURE__ */ new Set();
387
+ const topLevelNames = new Set(pslNamesOfNamespaceId(defaultNamespaceId));
388
+ const defaultNamespace = {
389
+ kind: "namespace",
390
+ id: defaultNamespaceId,
391
+ name: pslNameOfNamespaceId(defaultNamespaceId),
392
+ declarations: [],
393
+ models,
394
+ compositeTypes,
395
+ blocks,
396
+ mixins
397
+ };
398
+ namespaces[defaultNamespaceId] = defaultNamespace;
395
399
  for (const document of documents) {
396
400
  const sourceFile = sources.sourceFileFor(document.syntax);
397
401
  const claim = (taken, name) => {
@@ -425,13 +429,16 @@ function buildSymbolTable(options) {
425
429
  } else if (declaration instanceof NamespaceDeclarationAst) {
426
430
  const declaredName = declaration.name()?.name();
427
431
  if (declaredName === void 0) continue;
428
- let namespace = namespaces[declaredName];
432
+ const id = namespaceIdOfPslName(declaredName);
433
+ let namespace = namespaces[id];
429
434
  if (namespace === void 0) {
430
- const name = claim(topLevelNames, declaration.name());
431
- if (name === void 0) continue;
435
+ const names = pslNamesOfNamespaceId(id);
436
+ if (claim(names.some((name) => topLevelNames.has(name)) ? new Set(names) : topLevelNames, declaration.name()) === void 0) continue;
437
+ for (const name of names) topLevelNames.add(name);
432
438
  namespace = {
433
439
  kind: "namespace",
434
- name,
440
+ id,
441
+ name: pslNameOfNamespaceId(id),
435
442
  declarations: [{
436
443
  node: declaration,
437
444
  span: nodePslSpan(declaration.syntax, sources)
@@ -441,12 +448,12 @@ function buildSymbolTable(options) {
441
448
  blocks: Object.create(null),
442
449
  mixins: Object.create(null)
443
450
  };
444
- namespaces[name] = namespace;
451
+ namespaces[id] = namespace;
445
452
  } else namespace.declarations.push({
446
453
  node: declaration,
447
454
  span: nodePslSpan(declaration.syntax, sources)
448
455
  });
449
- extendNamespace(namespace, declaration, diagnostics, sources);
456
+ extendNamespace(namespace, declaration, diagnostics, sources, namespace === defaultNamespace ? topLevelNames : /* @__PURE__ */ new Set());
450
457
  } else if (declaration instanceof TypesBlockAst) for (const binding of declaration.declarations()) {
451
458
  const name = claim(topLevelNames, binding.name());
452
459
  if (name === void 0) continue;
@@ -461,14 +468,11 @@ function buildSymbolTable(options) {
461
468
  }
462
469
  }
463
470
  return {
464
- symbolTable: { topLevel: {
471
+ symbolTable: {
472
+ defaultNamespace,
465
473
  namespaces,
466
- namedTypes,
467
- blocks,
468
- models,
469
- compositeTypes,
470
- mixins
471
- } },
474
+ namedTypes
475
+ },
472
476
  diagnostics
473
477
  };
474
478
  }
@@ -518,12 +522,12 @@ function buildMixin(name, node, sources, diagnostics) {
518
522
  attributes: readResolvedAttributes(node.attributes(), sources)
519
523
  };
520
524
  }
521
- function extendNamespace(namespace, node, diagnostics, sources) {
525
+ function extendNamespace(namespace, node, diagnostics, sources, documentNames) {
522
526
  const { models, compositeTypes, blocks, mixins } = namespace;
523
527
  for (const member of node.declarations()) {
524
528
  const memberName = member.name()?.name();
525
529
  if (memberName === void 0) continue;
526
- if (Object.hasOwn(models, memberName) || Object.hasOwn(compositeTypes, memberName) || Object.hasOwn(blocks, memberName) || Object.hasOwn(mixins, memberName)) {
530
+ if (Object.hasOwn(models, memberName) || Object.hasOwn(compositeTypes, memberName) || Object.hasOwn(blocks, memberName) || Object.hasOwn(mixins, memberName) || documentNames.has(memberName)) {
527
531
  const range = nameRange(member.name(), sources);
528
532
  if (range) diagnostics.push({
529
533
  code: "PSL_DUPLICATE_DECLARATION",
@@ -533,6 +537,7 @@ function extendNamespace(namespace, node, diagnostics, sources) {
533
537
  });
534
538
  continue;
535
539
  }
540
+ documentNames.add(memberName);
536
541
  if (member instanceof ModelDeclarationAst) models[memberName] = buildModel(memberName, member, sources, diagnostics);
537
542
  else if (member instanceof CompositeTypeDeclarationAst) compositeTypes[memberName] = buildCompositeType(memberName, member, sources, diagnostics);
538
543
  else if (member instanceof GenericBlockDeclarationAst) blocks[memberName] = buildBlock(memberName, member, sources);
@@ -540,9 +545,8 @@ function extendNamespace(namespace, node, diagnostics, sources) {
540
545
  }
541
546
  }
542
547
  function placeMixinMembers(input) {
543
- const { topLevel } = input.symbolTable;
544
548
  const diagnostics = [];
545
- for (const records of [topLevel, ...Object.values(topLevel.namespaces)]) {
549
+ for (const records of Object.values(input.symbolTable.namespaces)) {
546
550
  for (const symbol of Object.values(records.models)) placeFields(symbol, input, diagnostics);
547
551
  for (const symbol of Object.values(records.compositeTypes)) placeFields(symbol, input, diagnostics);
548
552
  for (const symbol of Object.values(records.blocks)) placeEntries(symbol, input, diagnostics);
@@ -779,17 +783,16 @@ function hasFields(mixin) {
779
783
  return FIELD_MIXIN_KEYWORDS.has(mixin.keyword);
780
784
  }
781
785
  function walkFieldOwners(symbolTable, stack, binder, visit) {
782
- const { topLevel } = symbolTable;
783
786
  const visitAll = (records, namespace) => {
784
787
  for (const entity of Object.values(records.models)) visit(entity, namespace);
785
788
  for (const entity of Object.values(records.compositeTypes)) visit(entity, namespace);
786
789
  for (const mixin of Object.values(records.mixins)) if (hasFields(mixin)) visit(mixin, namespace);
787
790
  };
788
- visitAll(topLevel);
789
- for (const namespace of Object.values(topLevel.namespaces)) {
790
- stack.push(binder.scopeAt(namespace.declarations[0].node.syntax));
791
+ for (const namespace of Object.values(symbolTable.namespaces)) {
792
+ const [declaration] = namespace.declarations;
793
+ if (declaration !== void 0) stack.push(binder.scopeAt(declaration.node.syntax));
791
794
  visitAll(namespace, namespace);
792
- stack.pop();
795
+ if (declaration !== void 0) stack.pop();
793
796
  }
794
797
  }
795
798
  function isWrittenIn(member, holder) {
@@ -805,11 +808,11 @@ function declarationResolution(entity, namespace) {
805
808
  return entity.kind === "model" ? {
806
809
  kind: "model",
807
810
  symbol: entity,
808
- ...namespace === void 0 ? {} : { namespace }
811
+ namespace
809
812
  } : {
810
813
  kind: "compositeType",
811
814
  symbol: entity,
812
- ...namespace === void 0 ? {} : { namespace }
815
+ namespace
813
816
  };
814
817
  }
815
818
  function createBinder(input) {
@@ -833,15 +836,15 @@ function bind(options) {
833
836
  const { sources, symbolTable, contributedTypes, attributeSpecs, defaultFunctionRegistry, dataTypes, describeUnsupportedAttribute, describeUnresolvedType } = options;
834
837
  const pslBlockDescriptors = options.pslBlockDescriptors ?? {};
835
838
  const contributed = contributedScope(contributedTypeScope(contributedTypes));
836
- const document = documentScope(symbolTable.topLevel, contributed);
839
+ const document = documentScope(symbolTable, contributed);
837
840
  const stack = new ScopeStack(document);
838
841
  const scopes = /* @__PURE__ */ new WeakMap();
839
842
  const declarations = /* @__PURE__ */ new WeakMap();
840
843
  const references = /* @__PURE__ */ new WeakMap();
841
844
  const diagnostics = [];
842
845
  const binder = new PslBinder(declarations, references, document, scopes);
843
- const baseScope = namedTypeBaseScope(symbolTable.topLevel, contributed);
844
- for (const symbol of Object.values(symbolTable.topLevel.namedTypes)) {
846
+ const baseScope = namedTypeBaseScope(symbolTable, contributed);
847
+ for (const symbol of Object.values(symbolTable.namedTypes)) {
845
848
  declarations.set(symbol.node.syntax, symbol);
846
849
  const declaredName = symbol.node.name()?.syntax;
847
850
  if (declaredName !== void 0) references.set(declaredName, {
@@ -859,24 +862,8 @@ function bind(options) {
859
862
  diagnostics
860
863
  });
861
864
  }
862
- for (const symbol of Object.values(symbolTable.topLevel.blocks)) {
863
- declarations.set(symbol.node.syntax, symbol);
864
- const declaredName = symbol.node.name()?.syntax;
865
- if (declaredName !== void 0) references.set(declaredName, {
866
- kind: "block",
867
- symbol
868
- });
869
- }
870
- for (const symbol of Object.values(symbolTable.topLevel.mixins)) {
871
- declarations.set(symbol.node.syntax, symbol);
872
- const declaredName = symbol.node.name()?.syntax;
873
- if (declaredName !== void 0) references.set(declaredName, {
874
- kind: "mixin",
875
- symbol
876
- });
877
- }
878
- for (const namespace of Object.values(symbolTable.topLevel.namespaces)) {
879
- const scope = namespaceScope(namespace, document);
865
+ for (const namespace of Object.values(symbolTable.namespaces)) {
866
+ const scope = namespace === symbolTable.defaultNamespace ? document : namespaceScope(namespace, document);
880
867
  for (const declaration of namespace.declarations) {
881
868
  declarations.set(declaration.node.syntax, namespace);
882
869
  scopes.set(declaration.node.syntax, scope);
@@ -912,8 +899,10 @@ function bind(options) {
912
899
  diagnostics,
913
900
  included
914
901
  };
915
- bindInclusions(symbolTable.topLevel, document, inclusionContext);
916
- for (const namespace of Object.values(symbolTable.topLevel.namespaces)) bindInclusions(namespace, binder.scopeAt(namespace.declarations[0].node.syntax), inclusionContext);
902
+ for (const namespace of Object.values(symbolTable.namespaces)) {
903
+ const [declaration] = namespace.declarations;
904
+ bindInclusions(namespace, declaration === void 0 ? document : binder.scopeAt(declaration.node.syntax), inclusionContext);
905
+ }
917
906
  diagnostics.push(...placeMixinMembers({
918
907
  symbolTable,
919
908
  sources,
@@ -1014,11 +1003,11 @@ function bind(options) {
1014
1003
  }, context);
1015
1004
  for (const mixin of Object.values(records.mixins)) if (!hasFields(mixin)) bindBlock(mixin, context);
1016
1005
  };
1017
- bindBlocks(symbolTable.topLevel);
1018
- for (const namespace of Object.values(symbolTable.topLevel.namespaces)) {
1019
- stack.push(binder.scopeAt(namespace.declarations[0].node.syntax));
1006
+ for (const namespace of Object.values(symbolTable.namespaces)) {
1007
+ const [declaration] = namespace.declarations;
1008
+ if (declaration !== void 0) stack.push(binder.scopeAt(declaration.node.syntax));
1020
1009
  bindBlocks(namespace);
1021
- stack.pop();
1010
+ if (declaration !== void 0) stack.pop();
1022
1011
  }
1023
1012
  return {
1024
1013
  binder,
@@ -2394,8 +2383,7 @@ function interpretExtensionBlocks(input) {
2394
2383
  const { symbolTable, sources, pslBlockDescriptors, binder, dataTypes } = input;
2395
2384
  const parsedBlocks = /* @__PURE__ */ new Map();
2396
2385
  const diagnostics = [];
2397
- const scopes = [symbolTable.topLevel, ...Object.values(symbolTable.topLevel.namespaces)];
2398
- for (const scope of scopes) for (const block of Object.values(scope.blocks)) {
2386
+ for (const namespace of Object.values(symbolTable.namespaces)) for (const block of Object.values(namespace.blocks)) {
2399
2387
  const descriptor = findBlockDescriptor(pslBlockDescriptors, block.keyword);
2400
2388
  if (descriptor === void 0) continue;
2401
2389
  const parsed = interpretExtensionBlock({