@prisma/orm-toolchain 8.0.0-rc.17-dev.6 → 8.0.0-rc.17-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.
package/dist/cli.mjs CHANGED
@@ -6944,7 +6944,7 @@ const lspCommand = defineServerCommand({
6944
6944
  } },
6945
6945
  handler: async (args, io) => {
6946
6946
  const exitCode = await withoutClientProcessIdInArgv(async () => {
6947
- const { startServer } = await import("./exports-8j3KNNBj.mjs");
6947
+ const { startServer } = await import("./exports-BGdqNkGF.mjs");
6948
6948
  return startServer({
6949
6949
  stdin: io.stdin,
6950
6950
  stdout: io.stdout,
@@ -9,7 +9,7 @@ import { readFileSync, statSync } from "node:fs";
9
9
  import { fileURLToPath, pathToFileURL } from "node:url";
10
10
  import { normalize as normalize$1 } from "node:path";
11
11
  import { format, resolveFormatOptions } from "@prisma/orm-framework/psl-parser/format";
12
- import { EMPTY_DATA_TYPES, assembleAttributeSpecs, blockSpecFactoryOf, buildSymbolTable, createBinder, entityReference, findBlockDescriptor, isNamespaceLike, isPrismaNextSchema, isPslIdentifier, matchesSelector, memberEntries, renameLegacyDirective, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
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
15
  import { ArrayLiteralAst, AttributeArgAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, PathExprAst, PslSources, StringLiteralExprAst, SyntaxNode, SyntaxToken, TaggedLiteralExprAst, TypesBlockAst, any, isTrivia, nonTriviaSibling, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
@@ -930,7 +930,10 @@ function argumentRootGrammar(owner, source) {
930
930
  function blockValueGrammar(owner, source) {
931
931
  const descriptor = findBlockDescriptor(source.pslBlockDescriptors, owner.blockKeyword);
932
932
  if (descriptor === void 0) return void 0;
933
- const spec = blockSpecFactoryOf(descriptor)({ symbols: source.symbolTable });
933
+ const spec = blockSpecFactoryOf(descriptor)(blockSpecContext({
934
+ symbols: source.symbolTable,
935
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
936
+ }));
934
937
  if (spec.mode === "map") return spec.value.type;
935
938
  return Object.hasOwn(spec.parameters, owner.key) ? spec.parameters[owner.key]?.type : void 0;
936
939
  }
@@ -941,7 +944,10 @@ function attributeSpecResolver(context, source) {
941
944
  return (name) => {
942
945
  const factory = descriptor?.attributes?.[name];
943
946
  if (factory === void 0) return void 0;
944
- return blindCast(factory)({ symbols: source.symbolTable });
947
+ return blindCast(factory)(blockSpecContext({
948
+ symbols: source.symbolTable,
949
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
950
+ }));
945
951
  };
946
952
  }
947
953
  case "model": {
@@ -952,7 +958,7 @@ function attributeSpecResolver(context, source) {
952
958
  const specContext = {
953
959
  symbols: source.symbolTable,
954
960
  model,
955
- controlMutationDefaults: source.controlMutationDefaults,
961
+ defaultFunctionRegistry: source.controlMutationDefaults.defaultFunctionRegistry,
956
962
  dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
957
963
  };
958
964
  return (name) => specs.model[name]?.(specContext);
@@ -967,7 +973,7 @@ function attributeSpecResolver(context, source) {
967
973
  const specContext = {
968
974
  symbols: source.symbolTable,
969
975
  model,
970
- controlMutationDefaults: source.controlMutationDefaults,
976
+ defaultFunctionRegistry: source.controlMutationDefaults.defaultFunctionRegistry,
971
977
  dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
972
978
  };
973
979
  const node = typeReferenceNode(field);
@@ -1012,8 +1018,13 @@ function requiredArguments(signature) {
1012
1018
  }])];
1013
1019
  }
1014
1020
  function requiredArgumentSnippet(argument, tabStop) {
1015
- if (argument.kind === "positional") return argSnippetPlaceholder(argument.argument.type.kind, tabStop, argument.argument.key);
1016
- return `${argument.key}: ${argSnippetPlaceholder(argument.type.kind, tabStop, argument.key)}`;
1021
+ if (argument.kind === "positional") return argumentPlaceholder(argument.argument.type, tabStop, argument.argument.key);
1022
+ return `${argument.key}: ${argumentPlaceholder(argument.type, tabStop, argument.key)}`;
1023
+ }
1024
+ function argumentPlaceholder(type, tabStop, key) {
1025
+ const tag = type.kind === "dataTypeValue" ? type.tags[0] : void 0;
1026
+ if (tag !== void 0) return `${tag}\`\${${tabStop.toString()}:${key}}\``;
1027
+ return argSnippetPlaceholder(type.kind, tabStop, key);
1017
1028
  }
1018
1029
  function argSnippetPlaceholder(kind, tabStop, key) {
1019
1030
  const placeholder = `\${${tabStop.toString()}:${key}}`;
@@ -1205,7 +1216,7 @@ function valueItems(input, type, syntax, qualifier) {
1205
1216
  }
1206
1217
  if (syntax === "functionName") return [];
1207
1218
  if (qualifier !== void 0) return qualifiedItems(input, type, qualifier);
1208
- if (type.kind === "taggedLiteral") return type.tags.map((tag) => ({
1219
+ if (type.kind === "taggedLiteral" || type.kind === "dataTypeValue") return type.tags.map((tag) => ({
1209
1220
  ...completionItem(input, tag, input.clientSupportsSnippets ? `${tag}\`$1\`` : tag, CompletionItemKind.Value, input.clientSupportsSnippets),
1210
1221
  detail: type.documentation
1211
1222
  }));
@@ -1221,7 +1232,6 @@ function valueItems(input, type, syntax, qualifier) {
1221
1232
  selector: type.expected,
1222
1233
  namespaces: true
1223
1234
  });
1224
- case "dataTypeValue":
1225
1235
  case "list":
1226
1236
  case "record":
1227
1237
  case "int":
@@ -1431,7 +1441,7 @@ function provideDeclarationKeywordCompletionItems(context, sourceFile, source, c
1431
1441
  }));
1432
1442
  }
1433
1443
  function declarationKeywordCandidates(scope, source) {
1434
- return [...scope === "namespace" ? namespaceNativeDeclarationKeywords : documentNativeDeclarationKeywords, ...genericBlockDeclarationKeywordCandidates(source.pslBlockDescriptors, source.symbolTable)];
1444
+ return [...scope === "namespace" ? namespaceNativeDeclarationKeywords : documentNativeDeclarationKeywords, ...genericBlockDeclarationKeywordCandidates(source.pslBlockDescriptors, source.symbolTable, source.dataTypes ?? EMPTY_DATA_TYPES)];
1435
1445
  }
1436
1446
  function nativeDeclarationKeyword(label, insertText, snippetText, documentation) {
1437
1447
  return {
@@ -1443,14 +1453,17 @@ function nativeDeclarationKeyword(label, insertText, snippetText, documentation)
1443
1453
  kind: CompletionItemKind.Keyword
1444
1454
  };
1445
1455
  }
1446
- function genericBlockDeclarationKeywordCandidates(descriptors, symbols) {
1456
+ function genericBlockDeclarationKeywordCandidates(descriptors, symbols, dataTypes) {
1447
1457
  return descriptorBlockKeywords(descriptors).map((keyword) => {
1448
1458
  const descriptor = findBlockDescriptor(descriptors, keyword);
1449
1459
  return {
1450
1460
  category: "genericBlock",
1451
1461
  label: keyword,
1452
1462
  insertText: `${keyword} `,
1453
- snippetText: genericBlockSnippet(keyword, descriptor === void 0 ? void 0 : blockSpecFactoryOf(descriptor)({ symbols })),
1463
+ snippetText: genericBlockSnippet(keyword, descriptor === void 0 ? void 0 : blockSpecFactoryOf(descriptor)(blockSpecContext({
1464
+ symbols,
1465
+ dataTypes
1466
+ }))),
1454
1467
  detail: descriptor?.documentation || "Generic block keyword",
1455
1468
  kind: CompletionItemKind.Keyword
1456
1469
  };
@@ -1492,7 +1505,10 @@ function declarationKeywordSortText(candidate) {
1492
1505
  function provideGenericBlockKeyCompletionItems(context, sourceFile, source, capabilities) {
1493
1506
  const descriptor = findBlockDescriptor(source.pslBlockDescriptors, context.blockKeyword);
1494
1507
  if (descriptor === void 0) return [];
1495
- const spec = blockSpecFactoryOf(descriptor)({ symbols: source.symbolTable });
1508
+ const spec = blockSpecFactoryOf(descriptor)(blockSpecContext({
1509
+ symbols: source.symbolTable,
1510
+ dataTypes: source.dataTypes ?? EMPTY_DATA_TYPES
1511
+ }));
1496
1512
  if (spec.mode !== "struct") return [];
1497
1513
  const existing = existingGenericBlockParameterNames(context.block, context.offset);
1498
1514
  const hasEquals = editedKeyHasEquals(context.block, context.offset);
@@ -2651,7 +2667,13 @@ function collectExpression(expression, source, tokens, context = {}) {
2651
2667
  }
2652
2668
  return;
2653
2669
  }
2654
- if (expression instanceof TaggedLiteralExprAst) return;
2670
+ if (expression instanceof TaggedLiteralExprAst) {
2671
+ const tag = expression.tag();
2672
+ addIdentifier(tag?.namespace(), "namespace", tokens);
2673
+ addIdentifier(tag?.identifier(), "keyword", tokens);
2674
+ addToken(expression.literal()?.token(), "string", tokens);
2675
+ return;
2676
+ }
2655
2677
  if (expression instanceof PathExprAst) {
2656
2678
  collectMemberPath(expression, source, tokens);
2657
2679
  return;
@@ -3767,4 +3789,4 @@ function startServer(streams) {
3767
3789
  //#endregion
3768
3790
  export { startServer };
3769
3791
 
3770
- //# sourceMappingURL=exports-8j3KNNBj.mjs.map
3792
+ //# sourceMappingURL=exports-BGdqNkGF.mjs.map