@prisma-next/sql-contract-psl 0.3.0-dev.146 → 0.3.0-dev.162

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.
@@ -23,7 +23,6 @@ import type {
23
23
  PslField,
24
24
  PslModel,
25
25
  PslNamedTypeDeclaration,
26
- PslSpan,
27
26
  } from '@prisma-next/psl-parser';
28
27
  import type { StorageTypeInstance } from '@prisma-next/sql-contract/types';
29
28
  import {
@@ -51,10 +50,13 @@ import {
51
50
  } from './psl-attribute-parsing';
52
51
  import type { ColumnDescriptor } from './psl-column-resolution';
53
52
  import {
53
+ checkUncomposedNamespace,
54
54
  getAuthoringTypeConstructor,
55
- parsePgvectorLength,
56
- resolveColumnDescriptor,
55
+ instantiatePslTypeConstructor,
56
+ reportUncomposedNamespace,
57
57
  resolveDbNativeTypeAttribute,
58
+ resolveFieldTypeDescriptor,
59
+ resolvePslTypeConstructorDescriptor,
58
60
  toNamedTypeFieldDescriptor,
59
61
  } from './psl-column-resolution';
60
62
  import {
@@ -109,13 +111,25 @@ function buildComposedExtensionPackRefs(
109
111
  );
110
112
  }
111
113
 
112
- function hasSameSpan(a: PslSpan, b: ContractSourceDiagnosticSpan): boolean {
113
- return (
114
- a.start.offset === b.start.offset &&
115
- a.end.offset === b.end.offset &&
116
- a.start.line === b.start.line &&
117
- a.end.line === b.end.line
118
- );
114
+ function diagnosticDedupKey(diagnostic: ContractSourceDiagnostic): string {
115
+ const span = diagnostic.span;
116
+ const spanKey = span
117
+ ? `${span.start.offset}:${span.end.offset}:${span.start.line}:${span.end.line}`
118
+ : '';
119
+ return `${diagnostic.code}\u0000${diagnostic.sourceId}\u0000${spanKey}\u0000${diagnostic.message}`;
120
+ }
121
+
122
+ function dedupeDiagnostics(
123
+ diagnostics: readonly ContractSourceDiagnostic[],
124
+ ): ContractSourceDiagnostic[] {
125
+ const seen = new Map<string, ContractSourceDiagnostic>();
126
+ for (const diagnostic of diagnostics) {
127
+ const key = diagnosticDedupKey(diagnostic);
128
+ if (!seen.has(key)) {
129
+ seen.set(key, diagnostic);
130
+ }
131
+ }
132
+ return [...seen.values()];
119
133
  }
120
134
 
121
135
  function compareStrings(left: string, right: string): -1 | 0 | 1 {
@@ -194,112 +208,178 @@ interface ResolveNamedTypeDeclarationsInput {
194
208
  readonly enumTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
195
209
  readonly scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
196
210
  readonly composedExtensions: ReadonlySet<string>;
197
- readonly pgvectorVectorConstructor: AuthoringTypeConstructorDescriptor | undefined;
211
+ readonly familyId: string;
212
+ readonly targetId: string;
213
+ readonly authoringContributions: AuthoringContributions | undefined;
198
214
  readonly diagnostics: ContractSourceDiagnostic[];
199
215
  }
200
216
 
201
- function resolveNamedTypeDeclarations(input: ResolveNamedTypeDeclarationsInput): {
202
- readonly storageTypes: Record<string, StorageTypeInstance>;
203
- readonly namedTypeDescriptors: Map<string, ColumnDescriptor>;
204
- readonly namedTypeBaseTypes: Map<string, string>;
217
+ function validateNamedTypeAttributes(input: {
218
+ readonly declaration: PslNamedTypeDeclaration;
219
+ readonly sourceId: string;
220
+ readonly diagnostics: ContractSourceDiagnostic[];
221
+ readonly composedExtensions: ReadonlySet<string>;
222
+ readonly allowDbNativeType: boolean;
223
+ readonly familyId: string;
224
+ readonly targetId: string;
225
+ }): {
226
+ readonly dbNativeTypeAttribute: PslAttribute | undefined;
227
+ readonly hasUnsupportedNamedTypeAttribute: boolean;
205
228
  } {
206
- const storageTypes: Record<string, StorageTypeInstance> = {};
207
- const namedTypeDescriptors = new Map<string, ColumnDescriptor>();
208
- const namedTypeBaseTypes = new Map<string, string>();
229
+ const dbNativeTypeAttributes = input.allowDbNativeType
230
+ ? input.declaration.attributes.filter((attribute) => attribute.name.startsWith('db.'))
231
+ : [];
232
+ const [dbNativeTypeAttribute, ...extraDbNativeTypeAttributes] = dbNativeTypeAttributes;
233
+ let hasUnsupportedNamedTypeAttribute = false;
234
+
235
+ for (const extra of extraDbNativeTypeAttributes) {
236
+ input.diagnostics.push({
237
+ code: 'PSL_INVALID_ATTRIBUTE_ARGUMENT',
238
+ message: `Named type "${input.declaration.name}" can declare at most one @db.* attribute`,
239
+ sourceId: input.sourceId,
240
+ span: extra.span,
241
+ });
242
+ hasUnsupportedNamedTypeAttribute = true;
243
+ }
209
244
 
210
- for (const declaration of input.declarations) {
211
- const baseDescriptor =
212
- input.enumTypeDescriptors.get(declaration.baseType) ??
213
- input.scalarTypeDescriptors.get(declaration.baseType);
214
- if (!baseDescriptor) {
215
- input.diagnostics.push({
216
- code: 'PSL_UNSUPPORTED_NAMED_TYPE_BASE',
217
- message: `Named type "${declaration.name}" references unsupported base type "${declaration.baseType}"`,
218
- sourceId: input.sourceId,
219
- span: declaration.span,
220
- });
245
+ for (const attribute of input.declaration.attributes) {
246
+ if (input.allowDbNativeType && attribute.name.startsWith('db.')) {
221
247
  continue;
222
248
  }
223
- namedTypeBaseTypes.set(declaration.name, declaration.baseType);
224
249
 
225
- const pgvectorAttribute = getAttribute(declaration.attributes, 'pgvector.column');
226
- const dbNativeTypeAttribute = declaration.attributes.find((attribute) =>
227
- attribute.name.startsWith('db.'),
228
- );
229
- const unsupportedNamedTypeAttribute = declaration.attributes.find(
230
- (attribute) => attribute.name !== 'pgvector.column' && !attribute.name.startsWith('db.'),
231
- );
232
- if (unsupportedNamedTypeAttribute) {
233
- input.diagnostics.push({
234
- code: 'PSL_UNSUPPORTED_NAMED_TYPE_ATTRIBUTE',
235
- message: `Named type "${declaration.name}" uses unsupported attribute "${unsupportedNamedTypeAttribute.name}"`,
250
+ const uncomposedNamespace = checkUncomposedNamespace(attribute.name, input.composedExtensions, {
251
+ familyId: input.familyId,
252
+ targetId: input.targetId,
253
+ });
254
+ if (uncomposedNamespace) {
255
+ reportUncomposedNamespace({
256
+ subjectLabel: `Attribute "@${attribute.name}"`,
257
+ namespace: uncomposedNamespace,
236
258
  sourceId: input.sourceId,
237
- span: unsupportedNamedTypeAttribute.span,
259
+ span: attribute.span,
260
+ diagnostics: input.diagnostics,
238
261
  });
262
+ hasUnsupportedNamedTypeAttribute = true;
239
263
  continue;
240
264
  }
241
265
 
242
- if (pgvectorAttribute && dbNativeTypeAttribute) {
243
- input.diagnostics.push({
244
- code: 'PSL_UNSUPPORTED_NAMED_TYPE_ATTRIBUTE',
245
- message: `Named type "${declaration.name}" cannot combine @pgvector.column with @${dbNativeTypeAttribute.name}.`,
266
+ input.diagnostics.push({
267
+ code: 'PSL_UNSUPPORTED_NAMED_TYPE_ATTRIBUTE',
268
+ message: `Named type "${input.declaration.name}" uses unsupported attribute "${attribute.name}"`,
269
+ sourceId: input.sourceId,
270
+ span: attribute.span,
271
+ });
272
+ hasUnsupportedNamedTypeAttribute = true;
273
+ }
274
+
275
+ return { dbNativeTypeAttribute, hasUnsupportedNamedTypeAttribute };
276
+ }
277
+
278
+ function resolveNamedTypeDeclarations(input: ResolveNamedTypeDeclarationsInput): {
279
+ readonly storageTypes: Record<string, StorageTypeInstance>;
280
+ readonly namedTypeDescriptors: Map<string, ColumnDescriptor>;
281
+ } {
282
+ const storageTypes: Record<string, StorageTypeInstance> = {};
283
+ const namedTypeDescriptors = new Map<string, ColumnDescriptor>();
284
+
285
+ for (const declaration of input.declarations) {
286
+ if (declaration.typeConstructor) {
287
+ const { hasUnsupportedNamedTypeAttribute } = validateNamedTypeAttributes({
288
+ declaration,
246
289
  sourceId: input.sourceId,
247
- span: dbNativeTypeAttribute.span,
290
+ diagnostics: input.diagnostics,
291
+ composedExtensions: input.composedExtensions,
292
+ allowDbNativeType: false,
293
+ familyId: input.familyId,
294
+ targetId: input.targetId,
248
295
  });
249
- continue;
250
- }
251
-
252
- if (pgvectorAttribute) {
253
- if (!input.composedExtensions.has('pgvector')) {
254
- input.diagnostics.push({
255
- code: 'PSL_EXTENSION_NAMESPACE_NOT_COMPOSED',
256
- message:
257
- 'Attribute "@pgvector.column" uses unrecognized namespace "pgvector". Add extension pack "pgvector" to extensionPacks in prisma-next.config.ts.',
258
- sourceId: input.sourceId,
259
- span: pgvectorAttribute.span,
260
- });
296
+ if (hasUnsupportedNamedTypeAttribute) {
261
297
  continue;
262
298
  }
263
- if (declaration.baseType !== 'Bytes') {
264
- input.diagnostics.push({
265
- code: 'PSL_INVALID_ATTRIBUTE_ARGUMENT',
266
- message: `Named type "${declaration.name}" uses @pgvector.column on unsupported base type "${declaration.baseType}"`,
267
- sourceId: input.sourceId,
268
- span: pgvectorAttribute.span,
269
- });
299
+
300
+ const helperPath = declaration.typeConstructor.path.join('.');
301
+ const typeConstructor = resolvePslTypeConstructorDescriptor({
302
+ call: declaration.typeConstructor,
303
+ authoringContributions: input.authoringContributions,
304
+ composedExtensions: input.composedExtensions,
305
+ familyId: input.familyId,
306
+ targetId: input.targetId,
307
+ diagnostics: input.diagnostics,
308
+ sourceId: input.sourceId,
309
+ unsupportedCode: 'PSL_UNSUPPORTED_NAMED_TYPE_CONSTRUCTOR',
310
+ unsupportedMessage: `Named type "${declaration.name}" references unsupported constructor "${helperPath}"`,
311
+ });
312
+ if (!typeConstructor) {
270
313
  continue;
271
314
  }
272
- const length = parsePgvectorLength({
273
- attribute: pgvectorAttribute,
315
+
316
+ const storageType = instantiatePslTypeConstructor({
317
+ call: declaration.typeConstructor,
318
+ descriptor: typeConstructor,
274
319
  diagnostics: input.diagnostics,
275
320
  sourceId: input.sourceId,
321
+ entityLabel: `Named type "${declaration.name}"`,
276
322
  });
277
- if (length === undefined) {
323
+ if (!storageType) {
278
324
  continue;
279
325
  }
280
- const pgvectorStorageType = input.pgvectorVectorConstructor
281
- ? instantiateAuthoringTypeConstructor(input.pgvectorVectorConstructor, [length])
282
- : {
283
- codecId: 'pg/vector@1',
284
- nativeType: 'vector',
285
- typeParams: { length },
286
- };
326
+
287
327
  namedTypeDescriptors.set(
288
328
  declaration.name,
289
- toNamedTypeFieldDescriptor(declaration.name, pgvectorStorageType),
329
+ toNamedTypeFieldDescriptor(declaration.name, storageType),
290
330
  );
291
331
  storageTypes[declaration.name] = {
292
- codecId: pgvectorStorageType.codecId,
293
- nativeType: pgvectorStorageType.nativeType,
294
- typeParams: pgvectorStorageType.typeParams ?? { length },
332
+ codecId: storageType.codecId,
333
+ nativeType: storageType.nativeType,
334
+ typeParams: storageType.typeParams ?? {},
295
335
  };
296
336
  continue;
297
337
  }
298
338
 
339
+ // Parser invariant: when typeConstructor is absent, baseType is defined.
340
+ // The check below narrows `baseType` for TypeScript and guards against a
341
+ // parser regression; it is unreachable under a correct parser.
342
+ if (declaration.baseType === undefined) {
343
+ input.diagnostics.push({
344
+ code: 'PSL_UNSUPPORTED_NAMED_TYPE_BASE',
345
+ message: `Named type "${declaration.name}" must declare a base type or constructor`,
346
+ sourceId: input.sourceId,
347
+ span: declaration.span,
348
+ });
349
+ continue;
350
+ }
351
+ const { baseType } = declaration;
352
+ const baseDescriptor =
353
+ input.enumTypeDescriptors.get(baseType) ?? input.scalarTypeDescriptors.get(baseType);
354
+ if (!baseDescriptor) {
355
+ input.diagnostics.push({
356
+ code: 'PSL_UNSUPPORTED_NAMED_TYPE_BASE',
357
+ message: `Named type "${declaration.name}" references unsupported base type "${baseType}"`,
358
+ sourceId: input.sourceId,
359
+ span: declaration.span,
360
+ });
361
+ continue;
362
+ }
363
+
364
+ const { dbNativeTypeAttribute, hasUnsupportedNamedTypeAttribute } = validateNamedTypeAttributes(
365
+ {
366
+ declaration,
367
+ sourceId: input.sourceId,
368
+ diagnostics: input.diagnostics,
369
+ composedExtensions: input.composedExtensions,
370
+ allowDbNativeType: true,
371
+ familyId: input.familyId,
372
+ targetId: input.targetId,
373
+ },
374
+ );
375
+ if (hasUnsupportedNamedTypeAttribute) {
376
+ continue;
377
+ }
378
+
299
379
  if (dbNativeTypeAttribute) {
300
380
  const descriptor = resolveDbNativeTypeAttribute({
301
381
  attribute: dbNativeTypeAttribute,
302
- baseType: declaration.baseType,
382
+ baseType,
303
383
  baseDescriptor,
304
384
  diagnostics: input.diagnostics,
305
385
  sourceId: input.sourceId,
@@ -329,7 +409,7 @@ function resolveNamedTypeDeclarations(input: ResolveNamedTypeDeclarationsInput):
329
409
  };
330
410
  }
331
411
 
332
- return { storageTypes, namedTypeDescriptors, namedTypeBaseTypes };
412
+ return { storageTypes, namedTypeDescriptors };
333
413
  }
334
414
 
335
415
  interface BuildModelNodeInput {
@@ -340,8 +420,9 @@ interface BuildModelNodeInput {
340
420
  readonly compositeTypeNames: ReadonlySet<string>;
341
421
  readonly enumTypeDescriptors: Map<string, ColumnDescriptor>;
342
422
  readonly namedTypeDescriptors: Map<string, ColumnDescriptor>;
343
- readonly namedTypeBaseTypes: Map<string, string>;
344
423
  readonly composedExtensions: Set<string>;
424
+ readonly familyId: string;
425
+ readonly targetId: string;
345
426
  readonly authoringContributions: AuthoringContributions | undefined;
346
427
  readonly defaultFunctionRegistry: ControlMutationDefaultRegistry;
347
428
  readonly generatorDescriptorById: ReadonlyMap<string, MutationDefaultGeneratorDescriptor>;
@@ -361,22 +442,23 @@ function buildModelNodeFromPsl(input: BuildModelNodeInput): BuildModelNodeResult
361
442
  const { model, mapping, sourceId, diagnostics } = input;
362
443
  const tableName = mapping.tableName;
363
444
 
364
- const resolvedFields = collectResolvedFields(
445
+ const resolvedFields = collectResolvedFields({
365
446
  model,
366
447
  mapping,
367
- input.enumTypeDescriptors,
368
- input.namedTypeDescriptors,
369
- input.namedTypeBaseTypes,
370
- input.modelNames,
371
- input.compositeTypeNames,
372
- input.composedExtensions,
373
- input.authoringContributions,
374
- input.defaultFunctionRegistry,
375
- input.generatorDescriptorById,
448
+ enumTypeDescriptors: input.enumTypeDescriptors,
449
+ namedTypeDescriptors: input.namedTypeDescriptors,
450
+ modelNames: input.modelNames,
451
+ compositeTypeNames: input.compositeTypeNames,
452
+ composedExtensions: input.composedExtensions,
453
+ authoringContributions: input.authoringContributions,
454
+ familyId: input.familyId,
455
+ targetId: input.targetId,
456
+ defaultFunctionRegistry: input.defaultFunctionRegistry,
457
+ generatorDescriptorById: input.generatorDescriptorById,
376
458
  diagnostics,
377
459
  sourceId,
378
- input.scalarTypeDescriptors,
379
- );
460
+ scalarTypeDescriptors: input.scalarTypeDescriptors,
461
+ });
380
462
 
381
463
  const primaryKeyFields = resolvedFields.filter((field) => field.isId);
382
464
  const primaryKeyColumns = primaryKeyFields.map((field) => field.columnName);
@@ -402,6 +484,8 @@ function buildModelNodeFromPsl(input: BuildModelNodeInput): BuildModelNodeResult
402
484
  sourceId,
403
485
  composedExtensions: input.composedExtensions,
404
486
  diagnostics,
487
+ familyId: input.familyId,
488
+ targetId: input.targetId,
405
489
  });
406
490
  const relationAttribute = getAttribute(field.attributes, 'relation');
407
491
  let relationName: string | undefined;
@@ -517,12 +601,18 @@ function buildModelNodeFromPsl(input: BuildModelNodeInput): BuildModelNodeResult
517
601
  }
518
602
  continue;
519
603
  }
520
- if (modelAttribute.name.startsWith('pgvector.') && !input.composedExtensions.has('pgvector')) {
521
- diagnostics.push({
522
- code: 'PSL_EXTENSION_NAMESPACE_NOT_COMPOSED',
523
- message: `Attribute "@@${modelAttribute.name}" uses unrecognized namespace "pgvector". Add extension pack "pgvector" to extensionPacks in prisma-next.config.ts.`,
604
+ const uncomposedNamespace = checkUncomposedNamespace(
605
+ modelAttribute.name,
606
+ input.composedExtensions,
607
+ { familyId: input.familyId, targetId: input.targetId },
608
+ );
609
+ if (uncomposedNamespace) {
610
+ reportUncomposedNamespace({
611
+ subjectLabel: `Attribute "@@${modelAttribute.name}"`,
612
+ namespace: uncomposedNamespace,
524
613
  sourceId,
525
614
  span: modelAttribute.span,
615
+ diagnostics,
526
616
  });
527
617
  continue;
528
618
  }
@@ -692,14 +782,32 @@ function buildModelNodeFromPsl(input: BuildModelNodeInput): BuildModelNodeResult
692
782
  };
693
783
  }
694
784
 
695
- function buildValueObjects(
696
- compositeTypes: readonly PslCompositeType[],
697
- enumTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>,
698
- namedTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>,
699
- scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>,
700
- diagnostics: ContractSourceDiagnostic[],
701
- sourceId: string,
702
- ): Record<string, ContractValueObject> {
785
+ interface BuildValueObjectsInput {
786
+ readonly compositeTypes: readonly PslCompositeType[];
787
+ readonly enumTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
788
+ readonly namedTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
789
+ readonly scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
790
+ readonly composedExtensions: ReadonlySet<string>;
791
+ readonly familyId: string;
792
+ readonly targetId: string;
793
+ readonly authoringContributions: AuthoringContributions | undefined;
794
+ readonly diagnostics: ContractSourceDiagnostic[];
795
+ readonly sourceId: string;
796
+ }
797
+
798
+ function buildValueObjects(input: BuildValueObjectsInput): Record<string, ContractValueObject> {
799
+ const {
800
+ compositeTypes,
801
+ enumTypeDescriptors,
802
+ namedTypeDescriptors,
803
+ scalarTypeDescriptors,
804
+ composedExtensions,
805
+ familyId,
806
+ targetId,
807
+ authoringContributions,
808
+ diagnostics,
809
+ sourceId,
810
+ } = input;
703
811
  const valueObjects: Record<string, ContractValueObject> = {};
704
812
  const compositeTypeNames = new Set(compositeTypes.map((ct) => ct.name));
705
813
 
@@ -714,25 +822,35 @@ function buildValueObjects(
714
822
  fields[field.name] = field.list ? { ...result, many: true } : result;
715
823
  continue;
716
824
  }
717
- const descriptor = resolveColumnDescriptor(
825
+ const resolved = resolveFieldTypeDescriptor({
718
826
  field,
719
- enumTypeDescriptors as Map<string, ColumnDescriptor>,
720
- namedTypeDescriptors as Map<string, ColumnDescriptor>,
827
+ enumTypeDescriptors,
828
+ namedTypeDescriptors,
721
829
  scalarTypeDescriptors,
722
- );
723
- if (!descriptor) {
724
- diagnostics.push({
725
- code: 'PSL_UNSUPPORTED_FIELD_TYPE',
726
- message: `Field "${compositeType.name}.${field.name}" type "${field.typeName}" is not supported`,
727
- sourceId,
728
- span: field.span,
729
- });
830
+ authoringContributions,
831
+ composedExtensions,
832
+ familyId,
833
+ targetId,
834
+ diagnostics,
835
+ sourceId,
836
+ entityLabel: `Field "${compositeType.name}.${field.name}"`,
837
+ });
838
+ if (!resolved.ok) {
839
+ if (!resolved.alreadyReported) {
840
+ diagnostics.push({
841
+ code: 'PSL_UNSUPPORTED_FIELD_TYPE',
842
+ message: `Field "${compositeType.name}.${field.name}" type "${field.typeName}" is not supported`,
843
+ sourceId,
844
+ span: field.span,
845
+ });
846
+ }
730
847
  continue;
731
848
  }
732
- fields[field.name] = {
849
+ const scalarField: ContractField = {
733
850
  nullable: field.optional,
734
- type: { kind: 'scalar', codecId: descriptor.codecId },
851
+ type: { kind: 'scalar', codecId: resolved.descriptor.codecId },
735
852
  };
853
+ fields[field.name] = field.list ? { ...scalarField, many: true } : scalarField;
736
854
  }
737
855
  valueObjects[compositeType.name] = { fields };
738
856
  }
@@ -1011,8 +1129,8 @@ export function interpretPslDocumentToSqlContract(
1011
1129
  const modelNames = new Set(models.map((model) => model.name));
1012
1130
  const compositeTypeNames = new Set(compositeTypes.map((ct) => ct.name));
1013
1131
  const composedExtensions = new Set(input.composedExtensionPacks ?? []);
1014
- const defaultFunctionRegistry =
1015
- input.controlMutationDefaults?.defaultFunctionRegistry ?? new Map<string, never>();
1132
+ const defaultFunctionRegistry: ControlMutationDefaultRegistry =
1133
+ input.controlMutationDefaults?.defaultFunctionRegistry ?? new Map();
1016
1134
  const generatorDescriptors = input.controlMutationDefaults?.generatorDescriptors ?? [];
1017
1135
  const generatorDescriptorById = new Map<string, MutationDefaultGeneratorDescriptor>();
1018
1136
  for (const descriptor of generatorDescriptors) {
@@ -1032,10 +1150,9 @@ export function interpretPslDocumentToSqlContract(
1032
1150
  enumTypeDescriptors: enumResult.enumTypeDescriptors,
1033
1151
  scalarTypeDescriptors: input.scalarTypeDescriptors,
1034
1152
  composedExtensions,
1035
- pgvectorVectorConstructor: getAuthoringTypeConstructor(input.authoringContributions, [
1036
- 'pgvector',
1037
- 'vector',
1038
- ]),
1153
+ familyId: input.target.familyId,
1154
+ targetId: input.target.targetId,
1155
+ authoringContributions: input.authoringContributions,
1039
1156
  diagnostics,
1040
1157
  });
1041
1158
 
@@ -1060,8 +1177,9 @@ export function interpretPslDocumentToSqlContract(
1060
1177
  compositeTypeNames,
1061
1178
  enumTypeDescriptors: enumResult.enumTypeDescriptors,
1062
1179
  namedTypeDescriptors: namedTypeResult.namedTypeDescriptors,
1063
- namedTypeBaseTypes: namedTypeResult.namedTypeBaseTypes,
1064
1180
  composedExtensions,
1181
+ familyId: input.target.familyId,
1182
+ targetId: input.target.targetId,
1065
1183
  authoringContributions: input.authoringContributions,
1066
1184
  defaultFunctionRegistry,
1067
1185
  generatorDescriptorById,
@@ -1090,22 +1208,23 @@ export function interpretPslDocumentToSqlContract(
1090
1208
  diagnostics,
1091
1209
  );
1092
1210
 
1093
- if (diagnostics.length > 0) {
1094
- const dedupedDiagnostics = diagnostics.filter(
1095
- (diagnostic, index, allDiagnostics) =>
1096
- allDiagnostics.findIndex(
1097
- (candidate) =>
1098
- candidate.code === diagnostic.code &&
1099
- candidate.message === diagnostic.message &&
1100
- candidate.sourceId === diagnostic.sourceId &&
1101
- ((candidate.span && diagnostic.span && hasSameSpan(candidate.span, diagnostic.span)) ||
1102
- (!candidate.span && !diagnostic.span)),
1103
- ) === index,
1104
- );
1211
+ const valueObjects = buildValueObjects({
1212
+ compositeTypes,
1213
+ enumTypeDescriptors: enumResult.enumTypeDescriptors,
1214
+ namedTypeDescriptors: namedTypeResult.namedTypeDescriptors,
1215
+ scalarTypeDescriptors: input.scalarTypeDescriptors,
1216
+ composedExtensions,
1217
+ familyId: input.target.familyId,
1218
+ targetId: input.target.targetId,
1219
+ authoringContributions: input.authoringContributions,
1220
+ diagnostics,
1221
+ sourceId,
1222
+ });
1105
1223
 
1224
+ if (diagnostics.length > 0) {
1106
1225
  return notOk({
1107
1226
  summary: 'PSL to SQL contract interpretation failed',
1108
- diagnostics: dedupedDiagnostics,
1227
+ diagnostics: dedupeDiagnostics(diagnostics),
1109
1228
  });
1110
1229
  }
1111
1230
 
@@ -1132,15 +1251,6 @@ export function interpretPslDocumentToSqlContract(
1132
1251
  })),
1133
1252
  });
1134
1253
 
1135
- const valueObjects = buildValueObjects(
1136
- compositeTypes,
1137
- enumResult.enumTypeDescriptors,
1138
- namedTypeResult.namedTypeDescriptors,
1139
- input.scalarTypeDescriptors,
1140
- diagnostics,
1141
- sourceId,
1142
- );
1143
-
1144
1254
  let patchedModels = patchModelDomainFields(
1145
1255
  contract.models as Record<string, ContractModel>,
1146
1256
  modelResolvedFields,