@prisma/orm-toolchain 8.0.0-rc.18-dev.41 → 8.0.0-rc.18-dev.43

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
@@ -6960,7 +6960,7 @@ const lspCommand = defineServerCommand({
6960
6960
  } },
6961
6961
  handler: async (args, io) => {
6962
6962
  const exitCode = await withoutClientProcessIdInArgv(async () => {
6963
- const { startServer } = await import("./exports-DeD-nbF3.mjs");
6963
+ const { startServer } = await import("./exports-DfhvwKY6.mjs");
6964
6964
  return startServer({
6965
6965
  stdin: io.stdin,
6966
6966
  stdout: io.stdout,
@@ -17,7 +17,8 @@ import { CompletionItemKind, CompletionItemTag, ConnectionError, ConnectionError
17
17
  import { TextDocument } from "vscode-languageserver-textdocument";
18
18
  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";
19
19
  import { hasPslInterpreter } from "@prisma/orm-framework/psl-parser/interpret";
20
- import { isAuthoringPslBlockDescriptor } from "@prisma/orm-framework/components/authoring";
20
+ import { admittedTags, describeAdmittedForms, isAuthoringPslBlockDescriptor } from "@prisma/orm-framework/components/authoring";
21
+ import { dataTypeId } from "@prisma/orm-framework/components/codec";
21
22
  import { ProposedFeatures as ProposedFeatures$1, StreamMessageReader, StreamMessageWriter, createConnection as createConnection$1, createProtocolConnection } from "vscode-languageserver/node";
22
23
  import { Console } from "node:console";
23
24
  import { Readable, Writable } from "node:stream";
@@ -1052,7 +1053,7 @@ function cursorIdentifier(at, offset) {
1052
1053
  function requiredArgumentsSnippet(signature) {
1053
1054
  return requiredArguments(signature).map((argument, index) => requiredArgumentSnippet(argument, index + 1)).join(", ");
1054
1055
  }
1055
- function typeConstructorSnippet(name, descriptor) {
1056
+ function typeConstructorSnippet(name, descriptor, dataTypes) {
1056
1057
  const args = descriptor.args ?? [];
1057
1058
  const reference = descriptor.kind === "typeConstructor" ? descriptor.entityRefArg : void 0;
1058
1059
  const count = Math.max(args.length, (reference?.index ?? -1) + 1);
@@ -1062,8 +1063,9 @@ function typeConstructorSnippet(name, descriptor) {
1062
1063
  if (index === reference?.index) values.push(argSnippetPlaceholder("identifier", values.length + 1, reference.entityKind));
1063
1064
  else if (arg !== void 0 && arg.optional !== true) {
1064
1065
  const key = arg.name ?? `arg${index + 1}`;
1065
- const placeholder = argSnippetPlaceholder(arg.kind === "string" || arg.kind === "stringArray" ? "str" : arg.kind === "object" ? "record" : "identifier", values.length + 1, key);
1066
- values.push(arg.kind === "stringArray" ? `[${placeholder}]` : placeholder);
1066
+ const tabStop = values.length + 1;
1067
+ const [tag] = arg.kind === "value" ? admittedTags(dataTypes, dataTypeId(arg.dataType)) : [];
1068
+ values.push(tag !== void 0 ? taggedPlaceholder(tag, tabStop, key) : argSnippetPlaceholder(arg.kind === "object" ? "record" : "identifier", tabStop, key));
1067
1069
  }
1068
1070
  }
1069
1071
  return `${name}(${values.join(", ") || (count > 0 ? "${1:}" : "")})`;
@@ -1086,9 +1088,12 @@ function requiredArgumentSnippet(argument, tabStop) {
1086
1088
  }
1087
1089
  function argumentPlaceholder(type, tabStop, key) {
1088
1090
  const tag = type.kind === "dataTypeValue" ? type.tags[0] : void 0;
1089
- if (tag !== void 0) return `${tag}\`\${${tabStop.toString()}:${key}}\``;
1091
+ if (tag !== void 0) return taggedPlaceholder(tag, tabStop, key);
1090
1092
  return argSnippetPlaceholder(type.kind, tabStop, key);
1091
1093
  }
1094
+ function taggedPlaceholder(tag, tabStop, key) {
1095
+ return `${tag}\`\${${tabStop.toString()}:${key}}\``;
1096
+ }
1092
1097
  function argSnippetPlaceholder(kind, tabStop, key) {
1093
1098
  const placeholder = `\${${tabStop.toString()}:${key}}`;
1094
1099
  if (kind === "str") return `"${placeholder}"`;
@@ -1103,7 +1108,7 @@ function refinesScalarType(symbol, binder) {
1103
1108
  const node = typeReferenceNode(symbol);
1104
1109
  return !symbol.isConstructor && symbol.node.typeAnnotation()?.name()?.namespace() === void 0 && node !== void 0 && binder.symbolForNode(node)?.kind === "contributedType";
1105
1110
  }
1106
- function scopeCompletionItems(entries, binder, range, capabilities, selection) {
1111
+ function scopeCompletionItems(entries, binder, dataTypes, range, capabilities, selection) {
1107
1112
  const items = [];
1108
1113
  for (const [name, resolution] of entries) {
1109
1114
  if (selection !== void 0 && "offers" in selection) {
@@ -1154,7 +1159,7 @@ function scopeCompletionItems(entries, binder, range, capabilities, selection) {
1154
1159
  if (callable) {
1155
1160
  item.textEdit = {
1156
1161
  range,
1157
- newText: capabilities.clientSupportsSnippets ? typeConstructorSnippet(name, descriptor) : `${name}()`
1162
+ newText: capabilities.clientSupportsSnippets ? typeConstructorSnippet(name, descriptor, dataTypes) : `${name}()`
1158
1163
  };
1159
1164
  if (capabilities.clientSupportsSnippets) item.insertTextFormat = InsertTextFormat.Snippet;
1160
1165
  }
@@ -1327,7 +1332,7 @@ function qualifiedItems(input, type, qualifier) {
1327
1332
  });
1328
1333
  }
1329
1334
  function entityItems(input, entries, selection) {
1330
- return scopeCompletionItems(entries, input.binder, {
1335
+ return scopeCompletionItems(entries, input.binder, EMPTY_DATA_TYPES, {
1331
1336
  start: input.sourceFile.positionAt(input.context.replacementStartOffset),
1332
1337
  end: input.sourceFile.positionAt(input.context.replacementEndOffset)
1333
1338
  }, input, selection);
@@ -1649,7 +1654,7 @@ function existingGenericBlockParameterNames(block, cursorOffset, source) {
1649
1654
  return names;
1650
1655
  }
1651
1656
  function provideModelTypeCompletionItems(context, sourceFile, source, capabilities) {
1652
- return scopeCompletionItems(source.binder.scopeAt(context.field.syntax).entries(), source.binder, {
1657
+ return scopeCompletionItems(source.binder.scopeAt(context.field.syntax).entries(), source.binder, source.dataTypes ?? EMPTY_DATA_TYPES, {
1653
1658
  start: sourceFile.positionAt(context.replacementStartOffset),
1654
1659
  end: sourceFile.positionAt(context.offset)
1655
1660
  }, capabilities);
@@ -1680,7 +1685,7 @@ function provideMixinInclusionCompletionItems(context, sourceFile, source, capab
1680
1685
  const entries = [];
1681
1686
  for (const entry of visible) if (entry[1].kind === "mixin" || entry[1].kind === "namespace") entries.push(entry);
1682
1687
  const included = includedMixins(block, context.inclusion, source);
1683
- return scopeCompletionItems(entries, source.binder, {
1688
+ return scopeCompletionItems(entries, source.binder, source.dataTypes ?? EMPTY_DATA_TYPES, {
1684
1689
  start: sourceFile.positionAt(context.replacementStartOffset),
1685
1690
  end: sourceFile.positionAt(context.offset)
1686
1691
  }, capabilities, {
@@ -1691,7 +1696,7 @@ function provideMixinInclusionCompletionItems(context, sourceFile, source, capab
1691
1696
  function provideNamespaceMemberCompletionItems(context, sourceFile, source, capabilities) {
1692
1697
  if (context.space !== void 0) return [];
1693
1698
  const qualifier = source.binder.scopeAt(context.field.syntax).lookup(context.namespace);
1694
- return scopeCompletionItems(qualifier !== void 0 && isNamespaceLike(qualifier) ? memberEntries(qualifier) : [], source.binder, {
1699
+ return scopeCompletionItems(qualifier !== void 0 && isNamespaceLike(qualifier) ? memberEntries(qualifier) : [], source.binder, source.dataTypes ?? EMPTY_DATA_TYPES, {
1695
1700
  start: sourceFile.positionAt(context.replacementStartOffset),
1696
1701
  end: sourceFile.positionAt(context.offset)
1697
1702
  }, capabilities);
@@ -2068,7 +2073,7 @@ function providePslHover(input) {
2068
2073
  const offset = input.sourceFile.offsetAt(input.position);
2069
2074
  const token = identTokenAt(input.document.syntax, offset);
2070
2075
  if (token === void 0) return null;
2071
- const value = hoverValueAt(input.binder, token, input.pslBlockDescriptors);
2076
+ const value = hoverValueAt(input, token);
2072
2077
  if (value === void 0) return null;
2073
2078
  return {
2074
2079
  contents: {
@@ -2081,10 +2086,10 @@ function providePslHover(input) {
2081
2086
  }
2082
2087
  };
2083
2088
  }
2084
- function hoverValueAt(binder, token, pslBlockDescriptors) {
2085
- const result = resolveHoverResult(binder, token);
2086
- if (result !== void 0) return renderHoverResult(result);
2087
- return blockKeywordDocumentationAt(token, pslBlockDescriptors);
2089
+ function hoverValueAt(input, token) {
2090
+ const result = resolveHoverResult(input.binder, token);
2091
+ if (result !== void 0) return renderHoverResult(result, input.dataTypes);
2092
+ return blockKeywordDocumentationAt(token, input.pslBlockDescriptors);
2088
2093
  }
2089
2094
  function resolveHoverResult(binder, token) {
2090
2095
  const resolution = resolvedNodeAt(token, binder)?.resolution;
@@ -2125,11 +2130,11 @@ function resolveHoverResult(binder, token) {
2125
2130
  default: return;
2126
2131
  }
2127
2132
  }
2128
- function renderHoverResult(result) {
2133
+ function renderHoverResult(result, dataTypes) {
2129
2134
  if (result.kind === "entity") return renderEntityContent(result.symbol);
2130
2135
  if (result.kind === "namespace") return renderNamespaceContent(result.symbol);
2131
2136
  if (result.kind === "attribute") return renderAttributeContent(result.symbol);
2132
- if (result.kind === "contributedType") return renderContributedTypeContent(result.symbol);
2137
+ if (result.kind === "contributedType") return renderContributedTypeContent(result.symbol, dataTypes);
2133
2138
  if (result.kind === "parameter") return renderParameterContent(result.symbol);
2134
2139
  if (result.kind === "function") return renderFunctionContent(result.symbol);
2135
2140
  return renderConstantContent(result.symbol);
@@ -2158,10 +2163,10 @@ function renderAttributeContent(symbol) {
2158
2163
  "```"
2159
2164
  ].join("\n"), symbol.spec.documentation);
2160
2165
  }
2161
- function renderContributedTypeContent(symbol) {
2166
+ function renderContributedTypeContent(symbol, dataTypes) {
2162
2167
  return withDocumentation([
2163
2168
  "```prisma",
2164
- renderContributedTypeLabel(symbol),
2169
+ renderContributedTypeLabel(symbol, dataTypes),
2165
2170
  "```"
2166
2171
  ].join("\n"), symbol.descriptor.kind === "typeConstructor" ? symbol.descriptor.documentation : void 0);
2167
2172
  }
@@ -2191,19 +2196,17 @@ function renderConstantContent(symbol) {
2191
2196
  function withDocumentation(fence, documentation) {
2192
2197
  return documentation === void 0 || documentation === "" ? fence : `${fence}\n\n${documentation}`;
2193
2198
  }
2194
- function renderContributedTypeLabel(symbol) {
2199
+ function renderContributedTypeLabel(symbol, dataTypes) {
2195
2200
  const path = symbol.path.join(".");
2196
2201
  const args = symbol.descriptor.args ?? [];
2197
2202
  if (args.length === 0) return path;
2198
2203
  return `${path}(${args.map((arg, index) => {
2199
- return `${arg.name ?? `arg${index + 1}`}${arg.optional === true ? "?" : ""}: ${argumentTypeLabel(arg)}`;
2204
+ return `${arg.name ?? `arg${index + 1}`}${arg.optional === true ? "?" : ""}: ${argumentTypeLabel(arg, dataTypes)}`;
2200
2205
  }).join(", ")})`;
2201
2206
  }
2202
- function argumentTypeLabel(arg) {
2203
- if (arg.kind === "string") return "string";
2204
- if (arg.kind === "boolean") return "boolean";
2207
+ function argumentTypeLabel(arg, dataTypes) {
2208
+ if (arg.kind === "value") return describeAdmittedForms(dataTypes, dataTypeId(arg.dataType));
2205
2209
  if (arg.kind === "number") return "number";
2206
- if (arg.kind === "stringArray") return "string[]";
2207
2210
  if (arg.kind === "object") return "object";
2208
2211
  return arg.values.map((value) => `'${value}'`).join(" | ");
2209
2212
  }
@@ -2241,7 +2244,6 @@ function binderContextFromStack(stack) {
2241
2244
  model: {},
2242
2245
  field: {}
2243
2246
  },
2244
- textDataTypes: [],
2245
2247
  dataTypes: {}
2246
2248
  },
2247
2249
  controlMutationDefaults: { defaultFunctionRegistry: stack.controlMutationDefaults?.defaultFunctionRegistry ?? /* @__PURE__ */ new Map() },
@@ -3051,7 +3053,8 @@ var Project = class {
3051
3053
  sourceFile: document.sourceFile,
3052
3054
  position,
3053
3055
  binder: data.artifacts.binder(),
3054
- pslBlockDescriptors: data.controlStack.pslBlockDescriptors
3056
+ pslBlockDescriptors: data.controlStack.pslBlockDescriptors,
3057
+ dataTypes: data.controlStack.dataTypes ?? EMPTY_DATA_TYPES
3055
3058
  });
3056
3059
  } catch {
3057
3060
  return null;
@@ -3961,4 +3964,4 @@ function startServer(streams) {
3961
3964
  //#endregion
3962
3965
  export { startServer };
3963
3966
 
3964
- //# sourceMappingURL=exports-DeD-nbF3.mjs.map
3967
+ //# sourceMappingURL=exports-DfhvwKY6.mjs.map