@prisma/orm-toolchain 8.0.0-rc.17-dev.37 → 8.0.0-rc.17-dev.39

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/{aggregate-C0Kci0iw.mjs → aggregate-CJjYCgNP.mjs} +6 -2
  2. package/dist/aggregate-CJjYCgNP.mjs.map +1 -0
  3. package/dist/{aggregate-C23h_Ybm.d.mts → aggregate-MAVa_CD0.d.mts} +6 -2
  4. package/dist/{aggregate-C23h_Ybm.d.mts.map → aggregate-MAVa_CD0.d.mts.map} +1 -1
  5. package/dist/{caught-errors-DUV-u8yQ-DuPp394m.mjs → caught-errors-olsx_RBn-Cg0ilJtv.mjs} +133 -8
  6. package/dist/caught-errors-olsx_RBn-Cg0ilJtv.mjs.map +1 -0
  7. package/dist/cli.mjs +369 -94
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/cli__control-api.d.mts +14 -9
  10. package/dist/cli__control-api.d.mts.map +1 -1
  11. package/dist/cli__control-api.mjs +2 -2
  12. package/dist/cli__control-api__testing.d.mts +1 -1
  13. package/dist/cli__control-api__testing.mjs +1 -0
  14. package/dist/cli__control-api__testing.mjs.map +1 -1
  15. package/dist/cli__migration-cli.mjs +2 -2
  16. package/dist/cli__migration-cli.mjs.map +1 -1
  17. package/dist/{db-sign-DvCsMwUF-D5UIkRXD.d.mts → db-sign-D90hPxFE-B-YLAvFQ.d.mts} +77 -22
  18. package/dist/db-sign-D90hPxFE-B-YLAvFQ.d.mts.map +1 -0
  19. package/dist/{exports-D21BYJ-P.mjs → exports-D-0yFZ8f.mjs} +207 -94
  20. package/dist/exports-D-0yFZ8f.mjs.map +1 -0
  21. package/dist/migration-tools.d.mts +1 -1
  22. package/dist/migration-tools.mjs +1 -1
  23. package/dist/migration-tools__aggregate.d.mts +1 -1
  24. package/dist/migration-tools__aggregate.mjs +1 -1
  25. package/dist/{ref-BITTabCb-DT5r3Y3B.mjs → ref-BMhPu-wB-DU1LW2lb.mjs} +439 -160
  26. package/dist/ref-BMhPu-wB-DU1LW2lb.mjs.map +1 -0
  27. package/dist/vite-plugin-contract-emit.mjs +1 -1
  28. package/package.json +12 -12
  29. package/dist/aggregate-C0Kci0iw.mjs.map +0 -1
  30. package/dist/caught-errors-DUV-u8yQ-DuPp394m.mjs.map +0 -1
  31. package/dist/db-sign-DvCsMwUF-D5UIkRXD.d.mts.map +0 -1
  32. package/dist/exports-D21BYJ-P.mjs.map +0 -1
  33. package/dist/ref-BITTabCb-DT5r3Y3B.mjs.map +0 -1
@@ -12,7 +12,7 @@ import { format, resolveFormatOptions } from "@prisma/orm-framework/psl-parser/f
12
12
  import { EMPTY_DATA_TYPES, assembleAttributeSpecs, blockSpecContext, blockSpecFactoryOf, buildSymbolTable, createBinder, entityReference, findBlockDescriptor, isNamespaceLike, isPrismaNextSchema, isPslIdentifier, matchesSelector, memberEntries, renameLegacyDirective, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
13
13
  import { CompletionItemKind, CompletionItemTag, ConnectionError, ConnectionErrors, DiagnosticSeverity, DidChangeWatchedFilesNotification, DocumentDiagnosticReportKind, FoldingRangeKind, InsertTextFormat, LSPErrorCodes, MarkupKind, ProposedFeatures, RegistrationRequest, ResponseError, SemanticTokenModifiers, SemanticTokenTypes, TextDocumentSyncKind, createConnection } from "vscode-languageserver";
14
14
  import { TextDocument } from "vscode-languageserver-textdocument";
15
- import { ArrayLiteralAst, AttributeArgAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, MixinDeclarationAst, MixinInclusionAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, PathExprAst, PslSources, StringLiteralExprAst, SyntaxNode, SyntaxToken, TaggedLiteralExprAst, TypesBlockAst, any, isTrivia, nonTriviaSibling, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
15
+ import { ArrayLiteralAst, AttributeArgAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, MixinDeclarationAst, MixinInclusionAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, PathExprAst, PslSources, StringLiteralExprAst, SyntaxNode, SyntaxToken, TaggedLiteralExprAst, TypesBlockAst, any, filterChildren, isTrivia, nonTriviaSibling, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
16
16
  import { hasPslInterpreter } from "@prisma/orm-framework/psl-parser/interpret";
17
17
  import { isAuthoringPslBlockDescriptor } from "@prisma/orm-framework/components/authoring";
18
18
  import { ProposedFeatures as ProposedFeatures$1, StreamMessageReader, StreamMessageWriter, createConnection as createConnection$1, createProtocolConnection } from "vscode-languageserver/node";
@@ -367,6 +367,97 @@ function resolveInterpretation(config, stack, inputs) {
367
367
  }
368
368
  };
369
369
  }
370
+ const FIELD_BLOCK_KEYWORDS$1 = /* @__PURE__ */ new Set(["model", "type"]);
371
+ function castModelBlock(node) {
372
+ const model = ModelDeclarationAst.cast(node);
373
+ if (model !== void 0) return model;
374
+ const mixin = MixinDeclarationAst.cast(node);
375
+ return mixin?.keyword()?.text === "model" ? mixin : void 0;
376
+ }
377
+ function castFieldBlock(node) {
378
+ const block = ModelDeclarationAst.cast(node) ?? CompositeTypeDeclarationAst.cast(node);
379
+ if (block !== void 0) return block;
380
+ const mixin = MixinDeclarationAst.cast(node);
381
+ return FIELD_BLOCK_KEYWORDS$1.has(mixin?.keyword()?.text ?? "") ? mixin : void 0;
382
+ }
383
+ function castEntryBlock(node) {
384
+ const block = GenericBlockDeclarationAst.cast(node);
385
+ if (block !== void 0) return block;
386
+ const mixin = MixinDeclarationAst.cast(node);
387
+ const keyword = mixin?.keyword()?.text;
388
+ return keyword !== void 0 && !FIELD_BLOCK_KEYWORDS$1.has(keyword) ? mixin : void 0;
389
+ }
390
+ function argumentRootGrammar(owner, source) {
391
+ switch (owner.ownerKind) {
392
+ case "field":
393
+ case "model":
394
+ case "block": return attributeSpecResolver(owner, source)(owner.attributeName);
395
+ case "blockValue": return blockValueGrammar(owner, source);
396
+ }
397
+ }
398
+ function blockValueGrammar(owner, source) {
399
+ const descriptor = findBlockDescriptor(source.pslBlockDescriptors, owner.blockKeyword);
400
+ if (descriptor === void 0) return void 0;
401
+ const spec = blockSpecFactoryOf(descriptor)(blockSpecContext({
402
+ symbols: source.symbolTable,
403
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
404
+ }));
405
+ if (spec.mode === "map") return spec.value.type;
406
+ return Object.hasOwn(spec.parameters, owner.key) ? spec.parameters[owner.key]?.type : void 0;
407
+ }
408
+ function attributeSpecResolver(context, source) {
409
+ switch (context.ownerKind) {
410
+ case "block": {
411
+ const descriptor = findBlockDescriptor(source.pslBlockDescriptors, context.blockKeyword);
412
+ return (name) => {
413
+ const factory = descriptor?.attributes?.[name];
414
+ if (factory === void 0) return void 0;
415
+ return blindCast(factory)(blockSpecContext({
416
+ symbols: source.symbolTable,
417
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
418
+ }));
419
+ };
420
+ }
421
+ case "model": {
422
+ if (source.authoringContributions === void 0) return () => void 0;
423
+ const model = fieldSpecModel(source.binder.declaredSymbol(context.model.syntax));
424
+ if (model === void 0 || source.controlMutationDefaults === void 0) return () => void 0;
425
+ const specs = assembleAttributeSpecs(source.authoringContributions);
426
+ const specContext = {
427
+ symbols: source.symbolTable,
428
+ model,
429
+ defaultFunctionRegistry: source.controlMutationDefaults.defaultFunctionRegistry,
430
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
431
+ };
432
+ return (name) => specs.model[name]?.(specContext);
433
+ }
434
+ case "field": {
435
+ if (source.authoringContributions === void 0) return () => void 0;
436
+ const model = fieldSpecModel(source.binder.declaredSymbol(context.model.syntax));
437
+ if (model === void 0 || source.controlMutationDefaults === void 0) return () => void 0;
438
+ const field = source.binder.declaredSymbol(context.field.syntax);
439
+ if (field?.kind !== "field") return () => void 0;
440
+ const specs = assembleAttributeSpecs(source.authoringContributions);
441
+ const specContext = {
442
+ symbols: source.symbolTable,
443
+ model,
444
+ defaultFunctionRegistry: source.controlMutationDefaults.defaultFunctionRegistry,
445
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
446
+ };
447
+ const node = typeReferenceNode(field);
448
+ const typeResolution = node === void 0 ? void 0 : source.binder.symbolForNode(node);
449
+ return (name) => specs.field[name]?.({
450
+ ...specContext,
451
+ field,
452
+ typeResolution
453
+ });
454
+ }
455
+ }
456
+ }
457
+ function fieldSpecModel(symbol) {
458
+ if (symbol?.kind === "model") return symbol;
459
+ return symbol?.kind === "mixin" && symbol.keyword === "model" ? symbol : void 0;
460
+ }
370
461
  function locateAttributeSyntax(input) {
371
462
  const offset = input.sourceFile.offsetAt(input.position);
372
463
  const at = input.document.syntax.tokenAtOffset(offset);
@@ -455,6 +546,12 @@ function classifyPslCompletionContext(input) {
455
546
  };
456
547
  const attributeContext = classifyFieldAttribute(attributeClassifierInput) ?? classifyGenericBlockAttribute(attributeClassifierInput) ?? classifyModelAttribute(attributeClassifierInput);
457
548
  if (attributeContext !== void 0) return attributeContext;
549
+ const inclusionContext = classifyMixinInclusion({
550
+ node: precedingNode,
551
+ offset,
552
+ replacementStartOffset
553
+ });
554
+ if (inclusionContext !== void 0) return inclusionContext;
458
555
  const declarationKeywordContext = classifyDeclarationKeyword({
459
556
  node: precedingNode,
460
557
  offset,
@@ -470,7 +567,7 @@ function classifyPslCompletionContext(input) {
470
567
  if (genericBlockContext !== void 0) return genericBlockContext;
471
568
  const field = fieldForTypeSlot(precedingNode);
472
569
  if (field === void 0) return UNSUPPORTED;
473
- if (field.syntax.findAncestor(any(ModelDeclarationAst.cast, CompositeTypeDeclarationAst.cast)) === void 0) return UNSUPPORTED;
570
+ if (field.syntax.findAncestor(castFieldBlock) === void 0) return UNSUPPORTED;
474
571
  return classifyModelFieldType({
475
572
  field,
476
573
  offset,
@@ -555,7 +652,7 @@ function classifyTypePosition(name, field, offset, fieldName, replacementStartOf
555
652
  replacementStartOffset
556
653
  };
557
654
  }
558
- const declarationCast = any(ModelDeclarationAst.cast, CompositeTypeDeclarationAst.cast, TypesBlockAst.cast, GenericBlockDeclarationAst.cast, NamespaceDeclarationAst.cast);
655
+ const declarationCast = any(ModelDeclarationAst.cast, CompositeTypeDeclarationAst.cast, TypesBlockAst.cast, GenericBlockDeclarationAst.cast, MixinDeclarationAst.cast, NamespaceDeclarationAst.cast);
559
656
  function classifyDeclarationKeyword(input) {
560
657
  const precedingDeclaration = input.node?.findAncestor(declarationCast);
561
658
  const namespace = input.node?.findAncestor(NamespaceDeclarationAst.cast);
@@ -575,7 +672,7 @@ function classifyDeclarationKeyword(input) {
575
672
  * declarations, or when the cursor sits past its closing `}`.
576
673
  */
577
674
  function canCompleteDeclaration(precedingDeclaration, offset, inNamespaceBody) {
578
- if (precedingDeclaration.lbrace() === void 0 && (precedingDeclaration instanceof TypesBlockAst || precedingDeclaration.name() === void 0)) return true;
675
+ if (precedingDeclaration.lbrace() === void 0 && !(precedingDeclaration instanceof MixinDeclarationAst) && (precedingDeclaration instanceof TypesBlockAst || precedingDeclaration.name() === void 0)) return true;
579
676
  if (precedingDeclaration instanceof NamespaceDeclarationAst && inNamespaceBody) return true;
580
677
  const rbrace = precedingDeclaration.rbrace();
581
678
  return rbrace !== void 0 && offset >= rbrace.endOffset;
@@ -592,7 +689,7 @@ function classifyFieldAttribute(input) {
592
689
  const attribute = input.node?.findAncestor(FieldAttributeAst.cast);
593
690
  if (attribute === void 0 || !isWithinAttributeOrOpenArguments(attribute, input.offset)) return;
594
691
  const field = attribute.syntax.findAncestor(FieldDeclarationAst.cast);
595
- const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
692
+ const model = attribute.syntax.findAncestor(castModelBlock);
596
693
  if (field === void 0 || model === void 0) return UNSUPPORTED;
597
694
  const owner = {
598
695
  ownerKind: "field",
@@ -629,7 +726,7 @@ function classifyFieldAttribute(input) {
629
726
  }
630
727
  function classifyGenericBlockAttribute(input) {
631
728
  const attribute = activeModelAttribute(input);
632
- const block = attribute?.syntax.findAncestor(GenericBlockDeclarationAst.cast);
729
+ const block = attribute?.syntax.findAncestor(castEntryBlock);
633
730
  if (attribute === void 0 || block === void 0) return;
634
731
  const blockKeyword = block.keyword()?.text;
635
732
  if (blockKeyword === void 0 || blockKeyword.length === 0) return UNSUPPORTED;
@@ -669,7 +766,7 @@ function classifyGenericBlockAttribute(input) {
669
766
  function classifyModelAttribute(input) {
670
767
  const attribute = activeModelAttribute(input);
671
768
  if (attribute === void 0) return;
672
- const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
769
+ const model = attribute.syntax.findAncestor(castModelBlock);
673
770
  if (model === void 0) return;
674
771
  const owner = {
675
772
  ownerKind: "model",
@@ -840,7 +937,7 @@ function followsSeparator(cursor, kinds) {
840
937
  }
841
938
  function classifyGenericBlockParameter(input) {
842
939
  const node = input.at.leftBiased()?.parent;
843
- const block = node?.findAncestor(GenericBlockDeclarationAst.cast);
940
+ const block = node?.findAncestor(castEntryBlock);
844
941
  if (block === void 0) return;
845
942
  if (hasUnsupportedAncestor(node)) return UNSUPPORTED;
846
943
  if (!blockBodyContainsOffset(block, input.offset)) return UNSUPPORTED;
@@ -906,6 +1003,26 @@ function isAfterEquals(pair, offset) {
906
1003
  function hasUnsupportedAncestor(node) {
907
1004
  return node?.findAncestor(any(AttributeArgListAst.cast, FieldAttributeAst.cast, ModelAttributeAst.cast)) !== void 0;
908
1005
  }
1006
+ function classifyMixinInclusion(input) {
1007
+ const { offset, replacementStartOffset } = input;
1008
+ const inclusion = input.node?.findAncestor(MixinInclusionAst.cast);
1009
+ if (inclusion === void 0 || inclusion.syntax.isOutside(offset)) return void 0;
1010
+ const name = inclusion.name();
1011
+ if (name?.colon() !== void 0) return void 0;
1012
+ const position = {
1013
+ kind: "mixinInclusion",
1014
+ offset,
1015
+ replacementStartOffset,
1016
+ inclusion
1017
+ };
1018
+ const dot = name?.dot();
1019
+ if (name === void 0 || dot === void 0 || offset <= dot.offset) return position;
1020
+ const namespace = name.namespace()?.name();
1021
+ return namespace === void 0 || name.isOverQualified() ? UNSUPPORTED : {
1022
+ ...position,
1023
+ namespace
1024
+ };
1025
+ }
909
1026
  /** The significant token preceding the cursor — the in-progress edit identifier
910
1027
  * is skipped, so the result is the token the classifier anchors on. */
911
1028
  function precedingToken(at, edit) {
@@ -919,77 +1036,6 @@ function cursorIdentifier(at, offset) {
919
1036
  const left = at.leftBiased();
920
1037
  if (left?.kind === "Ident" && left.endOffset === offset) return left;
921
1038
  }
922
- function argumentRootGrammar(owner, source) {
923
- switch (owner.ownerKind) {
924
- case "field":
925
- case "model":
926
- case "block": return attributeSpecResolver(owner, source)(owner.attributeName);
927
- case "blockValue": return blockValueGrammar(owner, source);
928
- }
929
- }
930
- function blockValueGrammar(owner, source) {
931
- const descriptor = findBlockDescriptor(source.pslBlockDescriptors, owner.blockKeyword);
932
- if (descriptor === void 0) return void 0;
933
- const spec = blockSpecFactoryOf(descriptor)(blockSpecContext({
934
- symbols: source.symbolTable,
935
- dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
936
- }));
937
- if (spec.mode === "map") return spec.value.type;
938
- return Object.hasOwn(spec.parameters, owner.key) ? spec.parameters[owner.key]?.type : void 0;
939
- }
940
- function attributeSpecResolver(context, source) {
941
- switch (context.ownerKind) {
942
- case "block": {
943
- const descriptor = findBlockDescriptor(source.pslBlockDescriptors, context.blockKeyword);
944
- return (name) => {
945
- const factory = descriptor?.attributes?.[name];
946
- if (factory === void 0) return void 0;
947
- return blindCast(factory)(blockSpecContext({
948
- symbols: source.symbolTable,
949
- dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
950
- }));
951
- };
952
- }
953
- case "model": {
954
- if (source.authoringContributions === void 0) return () => void 0;
955
- const model = source.binder.declaredSymbol(context.model.syntax);
956
- if (model?.kind !== "model" || source.controlMutationDefaults === void 0) return () => void 0;
957
- const specs = assembleAttributeSpecs(source.authoringContributions);
958
- const specContext = {
959
- symbols: source.symbolTable,
960
- model,
961
- defaultFunctionRegistry: source.controlMutationDefaults.defaultFunctionRegistry,
962
- dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
963
- };
964
- return (name) => specs.model[name]?.(specContext);
965
- }
966
- case "field": {
967
- if (source.authoringContributions === void 0) return () => void 0;
968
- const model = fieldSpecModel(source.binder.declaredSymbol(context.model.syntax));
969
- if (model === void 0 || source.controlMutationDefaults === void 0) return () => void 0;
970
- const field = source.binder.declaredSymbol(context.field.syntax);
971
- if (field?.kind !== "field") return () => void 0;
972
- const specs = assembleAttributeSpecs(source.authoringContributions);
973
- const specContext = {
974
- symbols: source.symbolTable,
975
- model,
976
- defaultFunctionRegistry: source.controlMutationDefaults.defaultFunctionRegistry,
977
- dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
978
- };
979
- const node = typeReferenceNode(field);
980
- const typeResolution = node === void 0 ? void 0 : source.binder.symbolForNode(node);
981
- return (name) => specs.field[name]?.({
982
- ...specContext,
983
- field,
984
- typeResolution
985
- });
986
- }
987
- }
988
- }
989
- function fieldSpecModel(symbol) {
990
- if (symbol?.kind === "model") return symbol;
991
- return symbol?.kind === "mixin" && symbol.keyword === "model" ? symbol : void 0;
992
- }
993
1039
  function requiredArgumentsSnippet(signature) {
994
1040
  return requiredArguments(signature).map((argument, index) => requiredArgumentSnippet(argument, index + 1)).join(", ");
995
1041
  }
@@ -1047,7 +1093,9 @@ function refinesScalarType(symbol, binder) {
1047
1093
  function scopeCompletionItems(entries, binder, range, capabilities, selection) {
1048
1094
  const items = [];
1049
1095
  for (const [name, resolution] of entries) {
1050
- if (selection !== void 0) {
1096
+ if (selection !== void 0 && "offers" in selection) {
1097
+ if (!offersMixin(resolution, selection)) continue;
1098
+ } else if (selection !== void 0) {
1051
1099
  if (!offersEntity(resolution, selection)) continue;
1052
1100
  } else if (resolution.kind === "block" || resolution.kind === "mixin") continue;
1053
1101
  const item = {
@@ -1109,11 +1157,21 @@ function scopeCompletionItems(entries, binder, range, capabilities, selection) {
1109
1157
  item.kind = resolution.symbol.keyword === "enum" ? CompletionItemKind.Enum : CompletionItemKind.Keyword;
1110
1158
  item.detail = resolution.symbol.keyword;
1111
1159
  break;
1160
+ case "mixin":
1161
+ item.kind = CompletionItemKind.Interface;
1162
+ item.detail = `${resolution.symbol.keyword} mixin`;
1163
+ break;
1112
1164
  }
1113
1165
  items.push(item);
1114
1166
  }
1115
1167
  return items;
1116
1168
  }
1169
+ function offersMixin(resolution, selection) {
1170
+ if (resolution.kind === "mixin") return selection.offers(resolution.symbol);
1171
+ if (resolution.kind !== "namespace" || !selection.namespaces) return false;
1172
+ for (const [, member] of memberEntries(resolution)) if (member.kind === "mixin" && selection.offers(member.symbol)) return true;
1173
+ return false;
1174
+ }
1117
1175
  function offersEntity(resolution, selection) {
1118
1176
  if (isNamespaceLike(resolution)) {
1119
1177
  if (!selection.namespaces) return false;
@@ -1128,8 +1186,8 @@ function matchesEntity(resolution, selector) {
1128
1186
  }
1129
1187
  function localFieldNames(context, binder) {
1130
1188
  if (context.ownerKind === "block" || context.ownerKind === "blockValue") return [];
1131
- const model = binder.declaredSymbol(context.model.syntax);
1132
- return scalarFieldNames(model?.kind === "model" ? model : void 0, binder);
1189
+ const owner = binder.declaredSymbol(context.model.syntax);
1190
+ return scalarFieldNames(owner?.kind === "model" || owner?.kind === "mixin" && owner.keyword === "model" ? owner : void 0, binder);
1133
1191
  }
1134
1192
  function referencedFieldNames(context, binder) {
1135
1193
  if (context.ownerKind !== "field") return [];
@@ -1299,7 +1357,10 @@ const declarationKeywordCategoryOrder = {
1299
1357
  };
1300
1358
  const nameSnippetPlaceholder = "${1:Name}";
1301
1359
  const namespaceSnippetPlaceholder = "${1:name}";
1302
- const namespaceNativeDeclarationKeywords = [nativeDeclarationKeyword("model", "model ", `model ${nameSnippetPlaceholder} {\n \${0:// Fields}\n}`, "Defines a data model."), nativeDeclarationKeyword("type", "type ", `type ${nameSnippetPlaceholder} {\n \${0:// Fields}\n}`, "Defines a reusable composite type.")];
1360
+ const fieldsBodySnippet = "${0:// Fields}";
1361
+ const blockBodySnippet = "${0:// Block keys and attributes}";
1362
+ const keywordsWithoutMixins = /* @__PURE__ */ new Set(["namespace", "types"]);
1363
+ const namespaceNativeDeclarationKeywords = [nativeDeclarationKeyword("model", "model ", `model ${nameSnippetPlaceholder} {\n ${fieldsBodySnippet}\n}`, "Defines a data model."), nativeDeclarationKeyword("type", "type ", `type ${nameSnippetPlaceholder} {\n ${fieldsBodySnippet}\n}`, "Defines a reusable composite type.")];
1303
1364
  const documentNativeDeclarationKeywords = [
1304
1365
  ...namespaceNativeDeclarationKeywords,
1305
1366
  nativeDeclarationKeyword("types", "types ", "types {\n ${0:// Type aliases}\n}", "Defines reusable named types."),
@@ -1362,6 +1423,7 @@ function providePslCompletionItems(input) {
1362
1423
  clientSupportsSnippets: input.clientSupportsSnippets,
1363
1424
  clientSupportsTriggerSuggestCommand: input.clientSupportsTriggerSuggestCommand === true
1364
1425
  });
1426
+ case "mixinInclusion": return provideMixinInclusionCompletionItems(context, input.sourceFile, input.candidates, input);
1365
1427
  case "modelType": return provideModelTypeCompletionItems(context, input.sourceFile, input.candidates, input);
1366
1428
  case "namespaceMember": return provideNamespaceMemberCompletionItems(context, input.sourceFile, input.candidates, input);
1367
1429
  }
@@ -1445,7 +1507,21 @@ function provideDeclarationKeywordCompletionItems(context, sourceFile, source, c
1445
1507
  }));
1446
1508
  }
1447
1509
  function declarationKeywordCandidates(scope, source) {
1448
- return [...scope === "namespace" ? namespaceNativeDeclarationKeywords : documentNativeDeclarationKeywords, ...genericBlockDeclarationKeywordCandidates(source.pslBlockDescriptors, source.symbolTable, source.dataTypes ?? EMPTY_DATA_TYPES)];
1510
+ const nativeCandidates = scope === "namespace" ? namespaceNativeDeclarationKeywords : documentNativeDeclarationKeywords;
1511
+ const genericBlockCandidates = genericBlockDeclarationKeywordCandidates(source.pslBlockDescriptors, source.symbolTable, source.dataTypes ?? EMPTY_DATA_TYPES);
1512
+ return [...nativeCandidates.flatMap((candidate) => withMixinDeclaration(candidate, fieldsBodySnippet)), ...genericBlockCandidates.flatMap((candidate) => withMixinDeclaration(candidate, blockBodySnippet))];
1513
+ }
1514
+ function withMixinDeclaration(candidate, bodySnippet) {
1515
+ if (keywordsWithoutMixins.has(candidate.label)) return [candidate];
1516
+ const label = `${candidate.label} mixin`;
1517
+ return [candidate, {
1518
+ category: candidate.category,
1519
+ label,
1520
+ insertText: `${label} `,
1521
+ snippetText: `${label} ${nameSnippetPlaceholder} {\n ${bodySnippet}\n}`,
1522
+ detail: `Declares a mixin for ${candidate.label} blocks.`,
1523
+ kind: candidate.kind
1524
+ }];
1449
1525
  }
1450
1526
  function nativeDeclarationKeyword(label, insertText, snippetText, documentation) {
1451
1527
  return {
@@ -1478,7 +1554,7 @@ function genericBlockSnippet(keyword, spec) {
1478
1554
  const placeholder = `\${${index + 2}:${name}}`;
1479
1555
  return ` ${name} = ${parameter.type.kind === "list" ? `[${placeholder}]` : placeholder}`;
1480
1556
  });
1481
- const cursor = lines.length === 0 ? "${0:// Block keys and attributes}" : "$0";
1557
+ const cursor = lines.length === 0 ? blockBodySnippet : "$0";
1482
1558
  return [
1483
1559
  `${keyword} ${nameSnippetPlaceholder} {`,
1484
1560
  ...lines,
@@ -1514,7 +1590,7 @@ function provideGenericBlockKeyCompletionItems(context, sourceFile, source, capa
1514
1590
  dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
1515
1591
  }));
1516
1592
  if (spec.mode !== "struct") return [];
1517
- const existing = existingGenericBlockParameterNames(context.block, context.offset);
1593
+ const existing = existingGenericBlockParameterNames(context.block, context.offset, source);
1518
1594
  const hasEquals = editedKeyHasEquals(context.block, context.offset);
1519
1595
  const replacementRange = {
1520
1596
  start: sourceFile.positionAt(context.replacementStartOffset),
@@ -1545,9 +1621,11 @@ function editedKeyHasEquals(block, cursorOffset) {
1545
1621
  for (const entry of block.entries()) if (!entry.syntax.isOutside(cursorOffset)) return entry.equals() !== void 0;
1546
1622
  return false;
1547
1623
  }
1548
- function existingGenericBlockParameterNames(block, cursorOffset) {
1624
+ function existingGenericBlockParameterNames(block, cursorOffset, source) {
1549
1625
  const names = /* @__PURE__ */ new Set();
1550
- for (const entry of block.entries()) {
1626
+ const symbol = source.binder.declaredSymbol(block.syntax);
1627
+ const entries = symbol?.kind === "block" || symbol?.kind === "mixin" ? symbol.entries : block.entries();
1628
+ for (const entry of entries) {
1551
1629
  if (!entry.syntax.isOutside(cursorOffset)) continue;
1552
1630
  const name = entry.key()?.name();
1553
1631
  if (name !== void 0) names.add(name);
@@ -1560,6 +1638,40 @@ function provideModelTypeCompletionItems(context, sourceFile, source, capabiliti
1560
1638
  end: sourceFile.positionAt(context.offset)
1561
1639
  }, capabilities);
1562
1640
  }
1641
+ function includingBlockKeyword(block) {
1642
+ if (ModelDeclarationAst.cast(block) !== void 0) return "model";
1643
+ if (CompositeTypeDeclarationAst.cast(block) !== void 0) return "type";
1644
+ return GenericBlockDeclarationAst.cast(block)?.keyword()?.text;
1645
+ }
1646
+ function includedMixins(block, except, source) {
1647
+ const included = /* @__PURE__ */ new Set();
1648
+ for (const inclusion of filterChildren(block, MixinInclusionAst.cast)) {
1649
+ if (inclusion.syntax === except.syntax) continue;
1650
+ const name = inclusion.name();
1651
+ const resolution = name === void 0 ? void 0 : source.binder.symbolForNode(name.syntax);
1652
+ if (resolution?.kind === "mixin") included.add(resolution.symbol);
1653
+ }
1654
+ return included;
1655
+ }
1656
+ function provideMixinInclusionCompletionItems(context, sourceFile, source, capabilities) {
1657
+ const block = context.inclusion.syntax.parent;
1658
+ const keyword = block === void 0 ? void 0 : includingBlockKeyword(block);
1659
+ if (block === void 0 || keyword === void 0) return [];
1660
+ const scope = source.binder.scopeAt(block);
1661
+ const namespaceId = context.namespace;
1662
+ const qualifier = namespaceId === void 0 ? void 0 : scope.lookup(namespaceId);
1663
+ const visible = namespaceId === void 0 ? scope.entries() : qualifier !== void 0 && isNamespaceLike(qualifier) ? memberEntries(qualifier) : [];
1664
+ const entries = [];
1665
+ for (const entry of visible) if (entry[1].kind === "mixin" || entry[1].kind === "namespace") entries.push(entry);
1666
+ const included = includedMixins(block, context.inclusion, source);
1667
+ return scopeCompletionItems(entries, source.binder, {
1668
+ start: sourceFile.positionAt(context.replacementStartOffset),
1669
+ end: sourceFile.positionAt(context.offset)
1670
+ }, capabilities, {
1671
+ offers: (mixin) => mixin.keyword === keyword && !included.has(mixin),
1672
+ namespaces: namespaceId === void 0
1673
+ });
1674
+ }
1563
1675
  function provideNamespaceMemberCompletionItems(context, sourceFile, source, capabilities) {
1564
1676
  if (context.space !== void 0) return [];
1565
1677
  const qualifier = source.binder.scopeAt(context.field.syntax).lookup(context.namespace);
@@ -1718,7 +1830,7 @@ function blockValueSignatureContext(input) {
1718
1830
  const pair = preceding?.parent.findAncestor(KeyValuePairAst.cast);
1719
1831
  const equals = pair?.equals();
1720
1832
  if (pair === void 0 || equals === void 0 || offset <= equals.offset) return void 0;
1721
- const block = pair.syntax.findAncestor(GenericBlockDeclarationAst.cast);
1833
+ const block = pair.syntax.findAncestor(castEntryBlock);
1722
1834
  const blockKeyword = block?.keyword()?.text;
1723
1835
  const key = pair.key()?.name();
1724
1836
  if (block === void 0 || blockKeyword === void 0 || key === void 0) return void 0;
@@ -1737,14 +1849,14 @@ function blockValueSignatureContext(input) {
1737
1849
  function signatureOwner(attribute) {
1738
1850
  if (attribute instanceof FieldAttributeAst) {
1739
1851
  const field = attribute.syntax.findAncestor(FieldDeclarationAst.cast);
1740
- const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
1852
+ const model = attribute.syntax.findAncestor(castModelBlock);
1741
1853
  return field === void 0 || model === void 0 ? void 0 : {
1742
1854
  ownerKind: "field",
1743
1855
  field,
1744
1856
  model
1745
1857
  };
1746
1858
  }
1747
- const block = attribute.syntax.findAncestor(GenericBlockDeclarationAst.cast);
1859
+ const block = attribute.syntax.findAncestor(castEntryBlock);
1748
1860
  if (block !== void 0) {
1749
1861
  const blockKeyword = block.keyword()?.text;
1750
1862
  return blockKeyword === void 0 || blockKeyword.length === 0 ? void 0 : {
@@ -1753,7 +1865,7 @@ function signatureOwner(attribute) {
1753
1865
  blockKeyword
1754
1866
  };
1755
1867
  }
1756
- const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
1868
+ const model = attribute.syntax.findAncestor(castModelBlock);
1757
1869
  return model === void 0 ? void 0 : {
1758
1870
  ownerKind: "model",
1759
1871
  model
@@ -3466,7 +3578,8 @@ function createServerOn(connection) {
3466
3578
  "(",
3467
3579
  "{",
3468
3580
  ":",
3469
- ","
3581
+ ",",
3582
+ "+"
3470
3583
  ] },
3471
3584
  signatureHelpProvider: { triggerCharacters: ["(", ","] },
3472
3585
  hoverProvider: true,
@@ -3818,4 +3931,4 @@ function startServer(streams) {
3818
3931
  //#endregion
3819
3932
  export { startServer };
3820
3933
 
3821
- //# sourceMappingURL=exports-D21BYJ-P.mjs.map
3934
+ //# sourceMappingURL=exports-D-0yFZ8f.mjs.map