@prisma/orm-toolchain 8.0.0-rc.1-dev.46 → 8.0.0-rc.10
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/README.md +1 -5
- package/dist/{aggregate-CPZB020V.mjs → aggregate-B4HKshLQ.mjs} +10 -10
- package/dist/aggregate-B4HKshLQ.mjs.map +1 -0
- package/dist/{aggregate-DLUJLq5Y.d.mts → aggregate-D_eX4zoo.d.mts} +3 -3
- package/dist/{aggregate-DLUJLq5Y.d.mts.map → aggregate-D_eX4zoo.d.mts.map} +1 -1
- package/dist/cli-telemetry.d.mts +8 -7
- package/dist/cli-telemetry.d.mts.map +1 -1
- package/dist/cli-telemetry.mjs +22 -24
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.d.mts +2 -6
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +447 -430
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +20 -11
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__init-output.mjs +1 -1
- package/dist/cli__migration-cli.mjs +6 -6
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs} +3 -3
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map → contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs.map} +1 -1
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-verify-Yih5kWtB-B1kv76ec.d.mts} +5 -5
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts.map → db-verify-Yih5kWtB-B1kv76ec.d.mts.map} +1 -1
- package/dist/{domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs → domain-type-generation-CR9ECUau-DOlKbcaE.mjs} +20 -6
- package/dist/domain-type-generation-CR9ECUau-DOlKbcaE.mjs.map +1 -0
- package/dist/{domain-type-generation-PkAb39ob-Ct8AGqow.d.mts → domain-type-generation-X6-AaL1U-DHEoRf_y.d.mts} +14 -3
- package/dist/domain-type-generation-X6-AaL1U-DHEoRf_y.d.mts.map +1 -0
- package/dist/emitter.d.mts +2 -2
- package/dist/emitter.mjs +2 -2
- package/dist/emitter__domain-type-generation.d.mts +2 -2
- package/dist/emitter__domain-type-generation.mjs +2 -2
- package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-SoLLYLtw-DMxVbVs9.mjs} +9 -9
- package/dist/errors-SoLLYLtw-DMxVbVs9.mjs.map +1 -0
- package/dist/{exports-BZaG8_w_.mjs → exports-BXXeNWlj.mjs} +25 -47
- package/dist/exports-BXXeNWlj.mjs.map +1 -0
- package/dist/exports-CE6OD63o-4Qpqr2W7.mjs +398 -0
- package/dist/exports-CE6OD63o-4Qpqr2W7.mjs.map +1 -0
- package/dist/{exports-8ZUN43ve.mjs → exports-CYa2di3d.mjs} +382 -22
- package/dist/exports-CYa2di3d.mjs.map +1 -0
- package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs → graph-membership-DY1Onbc3-CwBd6wuB.mjs} +3 -3
- package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs.map → graph-membership-DY1Onbc3-CwBd6wuB.mjs.map} +1 -1
- package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
- package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
- package/dist/{import-roots-CNFBPAT1.mjs → import-roots-BHOrDJbI.mjs} +5 -5
- package/dist/import-roots-BHOrDJbI.mjs.map +1 -0
- package/dist/{index-Dgwl8Tzs.d.mts → index-D217lbiW.d.mts} +7 -3
- package/dist/index-D217lbiW.d.mts.map +1 -0
- package/dist/{index-DRs7L6N0.d.mts → index-u5RdrumF.d.mts} +2 -19
- package/dist/index-u5RdrumF.d.mts.map +1 -0
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-Cww4bv0v-BEiFxmbX.mjs} +3 -3
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-Cww4bv0v-BEiFxmbX.mjs.map} +1 -1
- package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-BmWQNxRP-DQqbcPsS.mjs} +5 -5
- package/dist/{io-635GlNx1-D3zrw2qu.mjs.map → io-BmWQNxRP-DQqbcPsS.mjs.map} +1 -1
- package/dist/{migration-hspPIEeV.mjs → migration-B9w-7dKe.mjs} +4 -4
- package/dist/{migration-hspPIEeV.mjs.map → migration-B9w-7dKe.mjs.map} +1 -1
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-CW4bMmTz-B5xFtFVB.mjs} +3 -3
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs.map → migration-graph-CW4bMmTz-B5xFtFVB.mjs.map} +1 -1
- package/dist/migration-tools.d.mts +3 -3
- package/dist/migration-tools.mjs +12 -12
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.d.mts +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.d.mts +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{output-CovTDY14-CUoAqLML.mjs → output-D83nTTpC-XlvN30yS.mjs} +4 -4
- package/dist/{output-CovTDY14-CUoAqLML.mjs.map → output-D83nTTpC-XlvN30yS.mjs.map} +1 -1
- package/dist/publish-surface.d.mts +1 -1
- package/dist/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.d.mts +1 -1
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/quick-reference-mongo.md +11 -11
- package/dist/quick-reference-postgres.md +10 -10
- package/dist/readme-mongo.md +6 -6
- package/dist/readme-postgres.md +6 -6
- package/dist/{ref-h6InR6dO-rGfl18Jv.mjs → ref-DcqFmceq-QaUjgZeM.mjs} +190 -87
- package/dist/ref-DcqFmceq-QaUjgZeM.mjs.map +1 -0
- package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-BWpwb8_b.mjs} +9 -2
- package/dist/ref-resolution-BWpwb8_b.mjs.map +1 -0
- package/dist/{ref-resolution-COGOSL57.d.mts → ref-resolution-CaHQJXE0.d.mts} +11 -1
- package/dist/ref-resolution-CaHQJXE0.d.mts.map +1 -0
- package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-BpSpzdYB-BcDelHGt.mjs} +9 -9
- package/dist/refs-BpSpzdYB-BcDelHGt.mjs.map +1 -0
- package/dist/{shells-C4HbRAr5.mjs → shells-BIdFZwUY.mjs} +1 -6
- package/dist/shells-BIdFZwUY.mjs.map +1 -0
- package/dist/{spaces-Dj65JrwZ.d.mts → spaces-B20bgxF9.d.mts} +2 -2
- package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-B20bgxF9.d.mts.map} +1 -1
- package/dist/{spaces-4qMOAYE9.mjs → spaces-BCZiAZQn.mjs} +7 -7
- package/dist/spaces-BCZiAZQn.mjs.map +1 -0
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs} +7 -7
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.d.mts +1 -1
- package/dist/vite-plugin-contract-emit.mjs +7 -7
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/aggregate-CPZB020V.mjs.map +0 -1
- package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +0 -1
- package/dist/domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs.map +0 -1
- package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
- package/dist/exports-8ZUN43ve.mjs.map +0 -1
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs +0 -160
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
- package/dist/exports-BZaG8_w_.mjs.map +0 -1
- package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
- package/dist/index-DRs7L6N0.d.mts.map +0 -1
- package/dist/index-Dgwl8Tzs.d.mts.map +0 -1
- package/dist/ref-h6InR6dO-rGfl18Jv.mjs.map +0 -1
- package/dist/ref-resolution-COGOSL57.d.mts.map +0 -1
- package/dist/ref-resolution-HeNBXW53.mjs.map +0 -1
- package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
- package/dist/shells-C4HbRAr5.mjs.map +0 -1
- package/dist/spaces-4qMOAYE9.mjs.map +0 -1
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { n as findNearestConfigPathForFile, o as requireConfigSections, r as loadConfig } from "./exports-
|
|
1
|
+
import { n as findNearestConfigPathForFile, o as requireConfigSections, r as loadConfig } from "./exports-BXXeNWlj.mjs";
|
|
2
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
2
3
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
3
4
|
import { CliStructuredError } from "@prisma/orm-framework/errors/control";
|
|
4
5
|
import { createControlStack } from "@prisma/orm-framework/components/control";
|
|
5
6
|
import { join } from "pathe";
|
|
6
|
-
import {
|
|
7
|
+
import { normalize as normalize$1 } from "node:path";
|
|
7
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
-
import {
|
|
9
|
+
import { format } from "@prisma/orm-framework/psl-parser/format";
|
|
10
|
+
import { CompletionItemKind, ConnectionError, ConnectionErrors, DiagnosticSeverity, DidChangeWatchedFilesNotification, DocumentDiagnosticReportKind, FoldingRangeKind, InsertTextFormat, ProposedFeatures, RegistrationRequest, SemanticTokenModifiers, SemanticTokenTypes, TextDocumentSyncKind, TextDocuments, createConnection } from "vscode-languageserver";
|
|
9
11
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
10
|
-
import { ArrayLiteralAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, StringLiteralExprAst, TypesBlockAst, any, filterChildren, findChildToken, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
|
|
12
|
+
import { ArrayLiteralAst, AttributeArgAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, StringLiteralExprAst, TypesBlockAst, any, filterChildren, findChildToken, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
|
|
11
13
|
import { isAuthoringPslBlockDescriptor } from "@prisma/orm-framework/components/authoring";
|
|
12
|
-
import { buildSymbolTable, findBlockDescriptor } from "@prisma/orm-framework/psl-parser";
|
|
14
|
+
import { assembleAttributeSpecs, buildSymbolTable, findBlockDescriptor } from "@prisma/orm-framework/psl-parser";
|
|
13
15
|
import { hasPslInterpreter } from "@prisma/orm-framework/psl-parser/interpret";
|
|
14
16
|
import { ProposedFeatures as ProposedFeatures$1, StreamMessageReader, StreamMessageWriter, createConnection as createConnection$1, createProtocolConnection } from "vscode-languageserver/node";
|
|
15
17
|
import { Console } from "node:console";
|
|
@@ -64,6 +66,13 @@ function classifyPslCompletionContext(input) {
|
|
|
64
66
|
const preceding = precedingToken(at, edit);
|
|
65
67
|
const precedingNode = preceding?.parent;
|
|
66
68
|
const replacementStartOffset = edit?.offset ?? offset;
|
|
69
|
+
const attributeClassifierInput = {
|
|
70
|
+
offset,
|
|
71
|
+
node: at.leftBiased()?.parent ?? at.rightBiased()?.parent,
|
|
72
|
+
replacementStartOffset
|
|
73
|
+
};
|
|
74
|
+
const attributeContext = classifyFieldAttribute(attributeClassifierInput) ?? classifyGenericBlockAttribute(attributeClassifierInput) ?? classifyModelAttribute(attributeClassifierInput);
|
|
75
|
+
if (attributeContext !== void 0) return attributeContext;
|
|
67
76
|
const declarationKeywordContext = classifyDeclarationKeyword({
|
|
68
77
|
node: precedingNode,
|
|
69
78
|
offset,
|
|
@@ -194,6 +203,113 @@ function blockBodyContainsOffset(block, offset) {
|
|
|
194
203
|
const bodyEnd = block.rbrace()?.offset ?? block.syntax.endOffset;
|
|
195
204
|
return offset >= bodyStart && offset <= bodyEnd;
|
|
196
205
|
}
|
|
206
|
+
function classifyFieldAttribute(input) {
|
|
207
|
+
const attribute = input.node?.findAncestor(FieldAttributeAst.cast);
|
|
208
|
+
if (attribute === void 0 || attribute.syntax.isOutside(input.offset)) return;
|
|
209
|
+
const field = attribute.syntax.findAncestor(FieldDeclarationAst.cast);
|
|
210
|
+
const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
|
|
211
|
+
if (field === void 0 || model === void 0) return UNSUPPORTED;
|
|
212
|
+
if (isAttributeNamePosition(attribute, input.offset)) return {
|
|
213
|
+
kind: "fieldAttributeName",
|
|
214
|
+
offset: input.offset,
|
|
215
|
+
replacementStartOffset: input.replacementStartOffset,
|
|
216
|
+
attribute,
|
|
217
|
+
field,
|
|
218
|
+
model
|
|
219
|
+
};
|
|
220
|
+
const attributeName = attributeNamedKeyName(attribute, input.offset);
|
|
221
|
+
if (attributeName === void 0) return UNSUPPORTED;
|
|
222
|
+
return {
|
|
223
|
+
kind: "fieldAttributeNamedKey",
|
|
224
|
+
offset: input.offset,
|
|
225
|
+
replacementStartOffset: input.replacementStartOffset,
|
|
226
|
+
attributeName,
|
|
227
|
+
attribute,
|
|
228
|
+
field,
|
|
229
|
+
model
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function classifyGenericBlockAttribute(input) {
|
|
233
|
+
const attribute = activeModelAttribute(input);
|
|
234
|
+
const block = attribute?.syntax.findAncestor(GenericBlockDeclarationAst.cast);
|
|
235
|
+
if (attribute === void 0 || block === void 0) return;
|
|
236
|
+
const blockKeyword = block.keyword()?.text;
|
|
237
|
+
if (blockKeyword === void 0 || blockKeyword.length === 0) return UNSUPPORTED;
|
|
238
|
+
if (isAttributeNamePosition(attribute, input.offset)) return {
|
|
239
|
+
kind: "blockAttributeName",
|
|
240
|
+
offset: input.offset,
|
|
241
|
+
replacementStartOffset: input.replacementStartOffset,
|
|
242
|
+
attribute,
|
|
243
|
+
block,
|
|
244
|
+
blockKeyword
|
|
245
|
+
};
|
|
246
|
+
const attributeName = attributeNamedKeyName(attribute, input.offset);
|
|
247
|
+
if (attributeName === void 0) return UNSUPPORTED;
|
|
248
|
+
return {
|
|
249
|
+
kind: "blockAttributeNamedKey",
|
|
250
|
+
offset: input.offset,
|
|
251
|
+
replacementStartOffset: input.replacementStartOffset,
|
|
252
|
+
attributeName,
|
|
253
|
+
attribute,
|
|
254
|
+
block,
|
|
255
|
+
blockKeyword
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function classifyModelAttribute(input) {
|
|
259
|
+
const attribute = activeModelAttribute(input);
|
|
260
|
+
if (attribute === void 0) return;
|
|
261
|
+
const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
|
|
262
|
+
if (model === void 0) return;
|
|
263
|
+
if (isAttributeNamePosition(attribute, input.offset)) return {
|
|
264
|
+
kind: "modelAttributeName",
|
|
265
|
+
offset: input.offset,
|
|
266
|
+
replacementStartOffset: input.replacementStartOffset,
|
|
267
|
+
attribute,
|
|
268
|
+
model
|
|
269
|
+
};
|
|
270
|
+
const attributeName = attributeNamedKeyName(attribute, input.offset);
|
|
271
|
+
if (attributeName === void 0) return UNSUPPORTED;
|
|
272
|
+
return {
|
|
273
|
+
kind: "modelAttributeNamedKey",
|
|
274
|
+
offset: input.offset,
|
|
275
|
+
replacementStartOffset: input.replacementStartOffset,
|
|
276
|
+
attributeName,
|
|
277
|
+
attribute,
|
|
278
|
+
model
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function activeModelAttribute(input) {
|
|
282
|
+
const attribute = input.node?.findAncestor(ModelAttributeAst.cast);
|
|
283
|
+
if (attribute === void 0 || attribute.syntax.isOutside(input.offset)) return;
|
|
284
|
+
return attribute;
|
|
285
|
+
}
|
|
286
|
+
function isAttributeNamePosition(attribute, offset) {
|
|
287
|
+
return !attribute.argList()?.syntax.isInside(offset);
|
|
288
|
+
}
|
|
289
|
+
function attributeNamedKeyName(attribute, offset) {
|
|
290
|
+
const argList = attribute.argList();
|
|
291
|
+
if (argList === void 0 || argList.syntax.isOutside(offset)) return;
|
|
292
|
+
const rparen = argList.rparen();
|
|
293
|
+
if (rparen !== void 0 && offset >= rparen.endOffset) return;
|
|
294
|
+
for (const arg of argList.args()) {
|
|
295
|
+
const colon = arg.colon();
|
|
296
|
+
if (colon !== void 0 && offset > colon.offset && offset >= arg.syntax.offset && offset <= arg.syntax.endOffset) return;
|
|
297
|
+
}
|
|
298
|
+
const token = attribute.syntax.tokenAtOffset(offset).leftBiased();
|
|
299
|
+
if (token?.kind === "Colon") return;
|
|
300
|
+
const node = token?.parent;
|
|
301
|
+
const activeArg = node?.findAncestor(AttributeArgAst.cast);
|
|
302
|
+
if (activeArg === void 0 && node?.kind !== "AttributeArgList") return;
|
|
303
|
+
if (activeArg !== void 0) {
|
|
304
|
+
const colon = activeArg.colon();
|
|
305
|
+
if (colon !== void 0 && offset > colon.offset) return;
|
|
306
|
+
const value = activeArg.value();
|
|
307
|
+
if (colon === void 0 && value !== void 0 && value.syntax.kind !== "Identifier" && value.syntax.isInside(offset)) return;
|
|
308
|
+
}
|
|
309
|
+
const attributeName = attribute.name()?.identifier()?.name();
|
|
310
|
+
if (attributeName === void 0) return;
|
|
311
|
+
return attributeName;
|
|
312
|
+
}
|
|
197
313
|
function classifyGenericBlockParameter(input) {
|
|
198
314
|
const node = input.at.leftBiased()?.parent;
|
|
199
315
|
const block = node?.findAncestor(GenericBlockDeclarationAst.cast);
|
|
@@ -282,12 +398,193 @@ function providePslCompletionItems(input) {
|
|
|
282
398
|
case "unsupported": return [];
|
|
283
399
|
case "spaceMember": return [];
|
|
284
400
|
case "genericBlockValue": return [];
|
|
401
|
+
case "fieldAttributeName":
|
|
402
|
+
case "modelAttributeName":
|
|
403
|
+
case "blockAttributeName": return provideAttributeNameCompletionItems(context, input.sourceFile, input.candidates, input.clientSupportsSnippets);
|
|
404
|
+
case "fieldAttributeNamedKey":
|
|
405
|
+
case "modelAttributeNamedKey":
|
|
406
|
+
case "blockAttributeNamedKey": return provideAttributeNamedKeyCompletionItems(context, input.sourceFile, input.candidates);
|
|
285
407
|
case "declarationKeyword": return provideDeclarationKeywordCompletionItems(context, input.sourceFile, input.candidates, input.clientSupportsSnippets);
|
|
286
408
|
case "genericBlockKey": return provideGenericBlockKeyCompletionItems(context, input.sourceFile, input.candidates);
|
|
287
409
|
case "modelType": return provideModelTypeCompletionItems(context, input.sourceFile, input.candidates);
|
|
288
410
|
case "namespaceMember": return provideNamespaceMemberCompletionItems(context, input.sourceFile, input.candidates);
|
|
289
411
|
}
|
|
290
412
|
}
|
|
413
|
+
function provideAttributeNameCompletionItems(context, sourceFile, source, clientSupportsSnippets) {
|
|
414
|
+
const names = attributeNames(context, source);
|
|
415
|
+
const replacementEndOffset = attributeNameReplacementEndOffset(context);
|
|
416
|
+
const replacementRange = {
|
|
417
|
+
start: sourceFile.positionAt(context.replacementStartOffset),
|
|
418
|
+
end: sourceFile.positionAt(replacementEndOffset)
|
|
419
|
+
};
|
|
420
|
+
const resolveSpec = attributeSpecResolver(context, source);
|
|
421
|
+
return names.map((name) => {
|
|
422
|
+
const newText = attributeNameEditText({
|
|
423
|
+
name,
|
|
424
|
+
spec: resolveSpec(name),
|
|
425
|
+
attribute: context.attribute,
|
|
426
|
+
clientSupportsSnippets
|
|
427
|
+
});
|
|
428
|
+
return {
|
|
429
|
+
label: name,
|
|
430
|
+
kind: CompletionItemKind.Function,
|
|
431
|
+
detail: "PSL attribute",
|
|
432
|
+
sortText: name,
|
|
433
|
+
filterText: name,
|
|
434
|
+
textEdit: {
|
|
435
|
+
range: replacementRange,
|
|
436
|
+
newText
|
|
437
|
+
},
|
|
438
|
+
...newText !== name ? { insertTextFormat: InsertTextFormat.Snippet } : {}
|
|
439
|
+
};
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function provideAttributeNamedKeyCompletionItems(context, sourceFile, source) {
|
|
443
|
+
const spec = attributeSpec(context, source);
|
|
444
|
+
if (spec === void 0) return [];
|
|
445
|
+
const existing = existingAttributeNamedKeys(context.attribute, context.offset);
|
|
446
|
+
const replacementRange = {
|
|
447
|
+
start: sourceFile.positionAt(context.replacementStartOffset),
|
|
448
|
+
end: sourceFile.positionAt(namedKeyReplacementEndOffset(context))
|
|
449
|
+
};
|
|
450
|
+
return Object.keys(spec.named).filter((name) => !existing.has(name)).map((name) => ({
|
|
451
|
+
label: name,
|
|
452
|
+
kind: CompletionItemKind.Property,
|
|
453
|
+
detail: "Attribute argument",
|
|
454
|
+
sortText: name,
|
|
455
|
+
filterText: name,
|
|
456
|
+
textEdit: {
|
|
457
|
+
range: replacementRange,
|
|
458
|
+
newText: name
|
|
459
|
+
}
|
|
460
|
+
}));
|
|
461
|
+
}
|
|
462
|
+
function attributeNames(context, source) {
|
|
463
|
+
switch (context.kind) {
|
|
464
|
+
case "blockAttributeName": {
|
|
465
|
+
const descriptor = findBlockDescriptor(source.pslBlockDescriptors, context.blockKeyword);
|
|
466
|
+
return sortedUnique(Object.keys(descriptor?.attributes ?? {}));
|
|
467
|
+
}
|
|
468
|
+
case "fieldAttributeName":
|
|
469
|
+
if (source.authoringContributions === void 0) return [];
|
|
470
|
+
return sortedUnique(Object.keys(assembleAttributeSpecs(source.authoringContributions).field));
|
|
471
|
+
case "modelAttributeName":
|
|
472
|
+
if (source.authoringContributions === void 0) return [];
|
|
473
|
+
return sortedUnique(Object.keys(assembleAttributeSpecs(source.authoringContributions).model));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function attributeNameEditText(input) {
|
|
477
|
+
if (!input.clientSupportsSnippets || input.spec === void 0 || input.attribute.argList() !== void 0) return input.name;
|
|
478
|
+
const required = requiredAttributeArguments(input.spec);
|
|
479
|
+
if (required.length === 0) return input.name;
|
|
480
|
+
return `${input.name}(${required.map((argument, index) => requiredAttributeArgumentSnippet(argument, index + 1)).join(", ")})`;
|
|
481
|
+
}
|
|
482
|
+
function requiredAttributeArguments(spec) {
|
|
483
|
+
const positionalKeys = new Set(spec.positional.map((argument) => argument.key));
|
|
484
|
+
return [...spec.positional.flatMap((argument) => isOptionalParam(argument.type) ? [] : [{
|
|
485
|
+
kind: "positional",
|
|
486
|
+
argument
|
|
487
|
+
}]), ...Object.entries(spec.named).flatMap(([key, type]) => positionalKeys.has(key) || isOptionalParam(type) ? [] : [{
|
|
488
|
+
kind: "named",
|
|
489
|
+
key,
|
|
490
|
+
type
|
|
491
|
+
}])];
|
|
492
|
+
}
|
|
493
|
+
function requiredAttributeArgumentSnippet(argument, tabStop) {
|
|
494
|
+
if (argument.kind === "positional") return argSnippetPlaceholder(argument.argument.type, tabStop);
|
|
495
|
+
return `${argument.key}: ${argSnippetPlaceholder(argument.type, tabStop)}`;
|
|
496
|
+
}
|
|
497
|
+
function argSnippetPlaceholder(param, tabStop) {
|
|
498
|
+
const placeholder = `\${${tabStop.toString()}:}`;
|
|
499
|
+
if (param.kind === "str") return `"${placeholder}"`;
|
|
500
|
+
if (param.kind === "list") return `[${placeholder}]`;
|
|
501
|
+
if (param.kind === "record") return `{ ${placeholder} }`;
|
|
502
|
+
return placeholder;
|
|
503
|
+
}
|
|
504
|
+
function isOptionalParam(param) {
|
|
505
|
+
return "optional" in param && param.optional === true;
|
|
506
|
+
}
|
|
507
|
+
function attributeNameReplacementEndOffset(context) {
|
|
508
|
+
return context.attribute.name()?.syntax.endOffset ?? context.offset;
|
|
509
|
+
}
|
|
510
|
+
function namedKeyReplacementEndOffset(context) {
|
|
511
|
+
const token = context.attribute.syntax.tokenAtOffset(context.offset).rightBiased();
|
|
512
|
+
if (token?.kind === "Ident" && token.offset <= context.offset) return token.endOffset;
|
|
513
|
+
return context.offset;
|
|
514
|
+
}
|
|
515
|
+
function attributeSpec(context, source) {
|
|
516
|
+
return attributeSpecForName(context, source, context.attributeName);
|
|
517
|
+
}
|
|
518
|
+
function attributeSpecForName(context, source, name) {
|
|
519
|
+
return attributeSpecResolver(context, source)(name);
|
|
520
|
+
}
|
|
521
|
+
function attributeSpecResolver(context, source) {
|
|
522
|
+
switch (context.kind) {
|
|
523
|
+
case "blockAttributeName":
|
|
524
|
+
case "blockAttributeNamedKey": {
|
|
525
|
+
const descriptor = findBlockDescriptor(source.pslBlockDescriptors, context.blockKeyword);
|
|
526
|
+
return (name) => {
|
|
527
|
+
const factory = descriptor?.attributes?.[name];
|
|
528
|
+
if (factory === void 0) return;
|
|
529
|
+
return blindCast(factory)();
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
case "modelAttributeName":
|
|
533
|
+
case "modelAttributeNamedKey": {
|
|
534
|
+
if (source.authoringContributions === void 0) return () => void 0;
|
|
535
|
+
const model = modelSymbolForNode(source.symbolTable, context.model);
|
|
536
|
+
if (model === void 0 || source.controlMutationDefaults === void 0) return () => void 0;
|
|
537
|
+
const specs = assembleAttributeSpecs(source.authoringContributions);
|
|
538
|
+
const specContext = {
|
|
539
|
+
symbols: source.symbolTable,
|
|
540
|
+
model,
|
|
541
|
+
controlMutationDefaults: source.controlMutationDefaults.defaultFunctionRegistry
|
|
542
|
+
};
|
|
543
|
+
return (name) => specs.model[name]?.(specContext);
|
|
544
|
+
}
|
|
545
|
+
case "fieldAttributeName":
|
|
546
|
+
case "fieldAttributeNamedKey": {
|
|
547
|
+
if (source.authoringContributions === void 0) return () => void 0;
|
|
548
|
+
const model = modelSymbolForNode(source.symbolTable, context.model);
|
|
549
|
+
if (model === void 0 || source.controlMutationDefaults === void 0) return () => void 0;
|
|
550
|
+
const field = fieldSymbolForNode(model, context.field);
|
|
551
|
+
if (field === void 0) return () => void 0;
|
|
552
|
+
const specs = assembleAttributeSpecs(source.authoringContributions);
|
|
553
|
+
const specContext = {
|
|
554
|
+
symbols: source.symbolTable,
|
|
555
|
+
model,
|
|
556
|
+
controlMutationDefaults: source.controlMutationDefaults.defaultFunctionRegistry
|
|
557
|
+
};
|
|
558
|
+
return (name) => specs.field[name]?.({
|
|
559
|
+
...specContext,
|
|
560
|
+
field
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function existingAttributeNamedKeys(attribute, cursorOffset) {
|
|
566
|
+
const names = /* @__PURE__ */ new Set();
|
|
567
|
+
for (const arg of attribute.argList()?.args() ?? []) {
|
|
568
|
+
if (!arg.syntax.isOutside(cursorOffset)) continue;
|
|
569
|
+
const name = arg.name()?.name();
|
|
570
|
+
if (name !== void 0) names.add(name);
|
|
571
|
+
}
|
|
572
|
+
return names;
|
|
573
|
+
}
|
|
574
|
+
function modelSymbolForNode(symbolTable, node) {
|
|
575
|
+
const topLevelMatch = Object.values(symbolTable.topLevel.models).find((model) => sameSyntax(model.node.syntax, node.syntax));
|
|
576
|
+
if (topLevelMatch !== void 0) return topLevelMatch;
|
|
577
|
+
for (const namespace of Object.values(symbolTable.topLevel.namespaces)) {
|
|
578
|
+
const namespaceMatch = Object.values(namespace.models).find((model) => sameSyntax(model.node.syntax, node.syntax));
|
|
579
|
+
if (namespaceMatch !== void 0) return namespaceMatch;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function fieldSymbolForNode(model, node) {
|
|
583
|
+
return Object.values(model.fields).find((field) => sameSyntax(field.node.syntax, node.syntax));
|
|
584
|
+
}
|
|
585
|
+
function sameSyntax(left, right) {
|
|
586
|
+
return left.offset === right.offset && left.endOffset === right.endOffset;
|
|
587
|
+
}
|
|
291
588
|
function provideDeclarationKeywordCompletionItems(context, sourceFile, source, clientSupportsSnippets) {
|
|
292
589
|
const replacementRange = {
|
|
293
590
|
start: sourceFile.positionAt(context.replacementStartOffset),
|
|
@@ -474,13 +771,43 @@ function hasPslInputs(config) {
|
|
|
474
771
|
return source?.format === "psl" && source.inputs !== void 0;
|
|
475
772
|
}
|
|
476
773
|
function resolveSchemaInputs(config) {
|
|
477
|
-
const
|
|
478
|
-
const
|
|
774
|
+
const uris = (hasPslInputs(config) ? config.contract?.source.inputs : void 0)?.map(configuredInputUri) ?? [];
|
|
775
|
+
const identities = new Set(uris.map(canonicalFileIdentity));
|
|
479
776
|
return {
|
|
480
|
-
includes: (uri) =>
|
|
777
|
+
includes: (uri) => identities.has(canonicalFileIdentity(uri)),
|
|
481
778
|
uris: () => uris
|
|
482
779
|
};
|
|
483
780
|
}
|
|
781
|
+
function configuredInputUri(input) {
|
|
782
|
+
if (isFileUri(input)) return input;
|
|
783
|
+
return pathToFileURL(input, { windows: isWindowsPlatform() }).toString();
|
|
784
|
+
}
|
|
785
|
+
function isFileUri(input) {
|
|
786
|
+
try {
|
|
787
|
+
return new URL(input).protocol === "file:";
|
|
788
|
+
} catch {
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
function canonicalFileIdentity(uri) {
|
|
793
|
+
let url;
|
|
794
|
+
try {
|
|
795
|
+
url = new URL(uri);
|
|
796
|
+
} catch {
|
|
797
|
+
return uri;
|
|
798
|
+
}
|
|
799
|
+
if (url.protocol !== "file:") return uri;
|
|
800
|
+
try {
|
|
801
|
+
const windows = isWindowsPlatform();
|
|
802
|
+
const filePath = normalize$1(fileURLToPath(url, { windows }));
|
|
803
|
+
return windows ? filePath.toLowerCase() : filePath;
|
|
804
|
+
} catch {
|
|
805
|
+
return uri;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function isWindowsPlatform() {
|
|
809
|
+
return process.platform === "win32";
|
|
810
|
+
}
|
|
484
811
|
const CONFIG_FILENAME = "prisma.config.ts";
|
|
485
812
|
const emptyPipelineInputs = {
|
|
486
813
|
scalarTypes: [],
|
|
@@ -518,7 +845,9 @@ async function resolveConfigInputs(configPath) {
|
|
|
518
845
|
function pipelineInputsFromStack(stack) {
|
|
519
846
|
return {
|
|
520
847
|
scalarTypes: [...stack.scalarTypes],
|
|
521
|
-
pslBlockDescriptors: stack.authoringContributions.pslBlockDescriptors
|
|
848
|
+
pslBlockDescriptors: stack.authoringContributions.pslBlockDescriptors,
|
|
849
|
+
authoringContributions: stack.authoringContributions,
|
|
850
|
+
...stack.controlMutationDefaults === void 0 ? {} : { controlMutationDefaults: stack.controlMutationDefaults }
|
|
522
851
|
};
|
|
523
852
|
}
|
|
524
853
|
function resolveInterpretation(config, stack, inputs) {
|
|
@@ -611,12 +940,27 @@ function guardCalls(target) {
|
|
|
611
940
|
return value;
|
|
612
941
|
} });
|
|
613
942
|
}
|
|
943
|
+
/**
|
|
944
|
+
* Whether an error says the connection is gone.
|
|
945
|
+
*
|
|
946
|
+
* The identity check is the fast path. It misses when the error comes from a
|
|
947
|
+
* second copy of `vscode-jsonrpc` in the dependency tree, whose
|
|
948
|
+
* `ConnectionError` is a different class carrying the same shape, so the code
|
|
949
|
+
* is what decides: `Closed`, `Disposed` and `AlreadyListening` are the whole
|
|
950
|
+
* range, and no other error jsonrpc throws carries a numeric `code` in it.
|
|
951
|
+
*/
|
|
952
|
+
function isConnectionGone(error) {
|
|
953
|
+
if (error instanceof ConnectionError) return true;
|
|
954
|
+
if (!(error instanceof Error) || !("code" in error)) return false;
|
|
955
|
+
const { code } = error;
|
|
956
|
+
return code === ConnectionErrors.Closed || code === ConnectionErrors.Disposed || code === ConnectionErrors.AlreadyListening;
|
|
957
|
+
}
|
|
614
958
|
function whileConnected(send) {
|
|
615
959
|
let sent;
|
|
616
960
|
try {
|
|
617
961
|
sent = send();
|
|
618
962
|
} catch (error) {
|
|
619
|
-
if (error
|
|
963
|
+
if (isConnectionGone(error)) return Promise.resolve(void 0);
|
|
620
964
|
throw error;
|
|
621
965
|
}
|
|
622
966
|
return isThenable(sent) ? sent.then(void 0, () => void 0) : sent;
|
|
@@ -644,6 +988,15 @@ function runPipeline(text, inputs) {
|
|
|
644
988
|
diagnostics: mapParseDiagnostics([...parseDiagnostics, ...symbolTableDiagnostics])
|
|
645
989
|
};
|
|
646
990
|
}
|
|
991
|
+
const DIRECTIVE = /^(\s*\/\/ *use +)(prisma-8|prisma-next)( *)(?!\S)/;
|
|
992
|
+
const LEGACY_NAME = "prisma-next";
|
|
993
|
+
function isPrismaNextSchema(text) {
|
|
994
|
+
return DIRECTIVE.test(text);
|
|
995
|
+
}
|
|
996
|
+
/** The document with the directive earlier releases wrote replaced by the current one. */
|
|
997
|
+
function renameLegacyDirective(text) {
|
|
998
|
+
return text.replace(DIRECTIVE, (whole, lead, name, trail) => name === LEGACY_NAME ? `${lead}prisma-8${trail}` : whole);
|
|
999
|
+
}
|
|
647
1000
|
/**
|
|
648
1001
|
* `null` (not a configured input) is distinct from a `DocumentDiagnostics` whose
|
|
649
1002
|
* `diagnostics` are `[]` (an input that parsed clean): the caller treats both as
|
|
@@ -651,7 +1004,7 @@ function runPipeline(text, inputs) {
|
|
|
651
1004
|
* diagnosing.
|
|
652
1005
|
*/
|
|
653
1006
|
function computeDocumentDiagnostics(uri, text, inputs, controlStack) {
|
|
654
|
-
if (!inputs.includes(uri)) return null;
|
|
1007
|
+
if (!inputs.includes(uri) || !isPrismaNextSchema(text)) return null;
|
|
655
1008
|
const { document, sourceFile, symbolTable, diagnostics } = runPipeline(text, controlStack);
|
|
656
1009
|
return {
|
|
657
1010
|
diagnostics,
|
|
@@ -714,7 +1067,7 @@ function createProjectArtifacts(options) {
|
|
|
714
1067
|
}).table;
|
|
715
1068
|
return symbolTable;
|
|
716
1069
|
}
|
|
717
|
-
throw new InternalError("invariant violated: project has no
|
|
1070
|
+
throw new InternalError("invariant violated: project has no readable configured input — callers must check document artifacts first");
|
|
718
1071
|
},
|
|
719
1072
|
documentChanged: drop,
|
|
720
1073
|
documentClosed: drop
|
|
@@ -1057,7 +1410,7 @@ function lastGoodProject(entry) {
|
|
|
1057
1410
|
if (entry === void 0 || entry.status === "failed") return;
|
|
1058
1411
|
return entry.status === "loaded" ? entry.project : entry.lastGood;
|
|
1059
1412
|
}
|
|
1060
|
-
const CONFIG_LOAD_FAILED_CODE = "
|
|
1413
|
+
const CONFIG_LOAD_FAILED_CODE = "PRISMA_CONFIG_LOAD_FAILED";
|
|
1061
1414
|
const semanticTokenSourceLimit = 1e5;
|
|
1062
1415
|
function createServer(connection) {
|
|
1063
1416
|
return createServerOn(guardedConnection(connection));
|
|
@@ -1201,7 +1554,7 @@ function createServerOn(connection) {
|
|
|
1201
1554
|
message: configFailureMessage(error),
|
|
1202
1555
|
code: CONFIG_LOAD_FAILED_CODE,
|
|
1203
1556
|
severity: DiagnosticSeverity.Error,
|
|
1204
|
-
source: "prisma
|
|
1557
|
+
source: "prisma"
|
|
1205
1558
|
}]
|
|
1206
1559
|
});
|
|
1207
1560
|
}
|
|
@@ -1268,12 +1621,13 @@ function createServerOn(connection) {
|
|
|
1268
1621
|
async function formatDocument(uri) {
|
|
1269
1622
|
const document = documents.get(uri);
|
|
1270
1623
|
if (document === void 0) return [];
|
|
1624
|
+
const source = document.getText();
|
|
1625
|
+
if (!isPrismaNextSchema(source)) return [];
|
|
1271
1626
|
const project = await resolveProjectForDocument(uri);
|
|
1272
1627
|
if (project === void 0) return [];
|
|
1273
|
-
const source = document.getText();
|
|
1274
1628
|
let formatted;
|
|
1275
1629
|
try {
|
|
1276
|
-
formatted = format(source, project.formatter);
|
|
1630
|
+
formatted = renameLegacyDirective(format(source, project.formatter));
|
|
1277
1631
|
} catch {
|
|
1278
1632
|
return [];
|
|
1279
1633
|
}
|
|
@@ -1321,7 +1675,9 @@ function createServerOn(connection) {
|
|
|
1321
1675
|
candidates: {
|
|
1322
1676
|
scalarTypes: project.controlStack.scalarTypes,
|
|
1323
1677
|
pslBlockDescriptors: project.controlStack.pslBlockDescriptors,
|
|
1324
|
-
symbolTable: project.artifacts.symbolTable()
|
|
1678
|
+
symbolTable: project.artifacts.symbolTable(),
|
|
1679
|
+
...project.controlStack.authoringContributions === void 0 ? {} : { authoringContributions: project.controlStack.authoringContributions },
|
|
1680
|
+
...project.controlStack.controlMutationDefaults === void 0 ? {} : { controlMutationDefaults: project.controlStack.controlMutationDefaults }
|
|
1325
1681
|
},
|
|
1326
1682
|
clientSupportsSnippets: clientCapabilities.completionSnippets
|
|
1327
1683
|
})];
|
|
@@ -1342,7 +1698,7 @@ function createServerOn(connection) {
|
|
|
1342
1698
|
full: true,
|
|
1343
1699
|
range: true
|
|
1344
1700
|
},
|
|
1345
|
-
completionProvider: { triggerCharacters: ["."] },
|
|
1701
|
+
completionProvider: { triggerCharacters: [".", "@"] },
|
|
1346
1702
|
...clientCapabilities.pullDiagnostics ? { diagnosticProvider: {
|
|
1347
1703
|
interFileDependencies: false,
|
|
1348
1704
|
workspaceDiagnostics: false
|
|
@@ -1355,7 +1711,7 @@ function createServerOn(connection) {
|
|
|
1355
1711
|
method: DidChangeWatchedFilesNotification.type.method,
|
|
1356
1712
|
registerOptions: { watchers: [{ globPattern: watchedConfigGlob }] }
|
|
1357
1713
|
}] });
|
|
1358
|
-
else logWarn("Client does not support dynamic file-watcher registration; Prisma
|
|
1714
|
+
else logWarn("Client does not support dynamic file-watcher registration; Prisma 8 config changes will not be picked up without a restart.");
|
|
1359
1715
|
});
|
|
1360
1716
|
connection.onDidChangeWatchedFiles(async (params) => {
|
|
1361
1717
|
const changedConfigPaths = configPathsFromWatchedChanges(params.changes.map((change) => filePathFromUri(change.uri)));
|
|
@@ -1431,7 +1787,11 @@ function createServerOn(connection) {
|
|
|
1431
1787
|
return {
|
|
1432
1788
|
dispose: () => connection.dispose(),
|
|
1433
1789
|
getDocumentAst: (uri) => artifactsForDocument(uri)?.document(uri),
|
|
1434
|
-
getProjectSymbolTable: (uri) =>
|
|
1790
|
+
getProjectSymbolTable: (uri) => {
|
|
1791
|
+
const artifacts = artifactsForDocument(uri);
|
|
1792
|
+
if (artifacts?.document(uri) === void 0) return;
|
|
1793
|
+
return artifacts.symbolTable();
|
|
1794
|
+
}
|
|
1435
1795
|
};
|
|
1436
1796
|
}
|
|
1437
1797
|
function emptySemanticTokens() {
|
|
@@ -1443,7 +1803,7 @@ function toDiagnostics(computed) {
|
|
|
1443
1803
|
message: diagnostic.message,
|
|
1444
1804
|
code: diagnostic.code,
|
|
1445
1805
|
severity: toLspSeverity(diagnostic.severity),
|
|
1446
|
-
source: "prisma
|
|
1806
|
+
source: "prisma"
|
|
1447
1807
|
}));
|
|
1448
1808
|
}
|
|
1449
1809
|
function toLspSeverity(severity) {
|
|
@@ -1731,4 +2091,4 @@ function startServer(streams) {
|
|
|
1731
2091
|
//#endregion
|
|
1732
2092
|
export { startServer };
|
|
1733
2093
|
|
|
1734
|
-
//# sourceMappingURL=exports-
|
|
2094
|
+
//# sourceMappingURL=exports-CYa2di3d.mjs.map
|