@prisma-next/sql-contract-ts 0.11.0-dev.3 → 0.11.0-dev.31
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/config-types.d.mts.map +1 -1
- package/dist/config-types.mjs.map +1 -1
- package/dist/contract-builder.d.mts +19 -17
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-builder.mjs +5 -5
- package/dist/contract-builder.mjs.map +1 -1
- package/package.json +10 -10
- package/src/build-contract.ts +20 -3
- package/src/contract-builder.ts +0 -10
- package/src/contract-definition.ts +1 -2
- package/src/contract-dsl.ts +0 -2
- package/src/contract-lowering.ts +0 -1
- package/src/contract-types.ts +31 -12
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-contract-ts",
|
|
3
|
-
"version": "0.11.0-dev.
|
|
3
|
+
"version": "0.11.0-dev.31",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "SQL-specific TypeScript contract authoring surface for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/config": "0.11.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.11.0-dev.
|
|
11
|
-
"@prisma-next/contract-authoring": "0.11.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.11.0-dev.
|
|
13
|
-
"@prisma-next/sql-contract": "0.11.0-dev.
|
|
14
|
-
"@prisma-next/utils": "0.11.0-dev.
|
|
9
|
+
"@prisma-next/config": "0.11.0-dev.31",
|
|
10
|
+
"@prisma-next/contract": "0.11.0-dev.31",
|
|
11
|
+
"@prisma-next/contract-authoring": "0.11.0-dev.31",
|
|
12
|
+
"@prisma-next/framework-components": "0.11.0-dev.31",
|
|
13
|
+
"@prisma-next/sql-contract": "0.11.0-dev.31",
|
|
14
|
+
"@prisma-next/utils": "0.11.0-dev.31",
|
|
15
15
|
"arktype": "^2.2.0",
|
|
16
16
|
"pathe": "^2.0.3",
|
|
17
17
|
"ts-toolbelt": "^9.6.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@prisma-next/test-utils": "0.11.0-dev.
|
|
21
|
-
"@prisma-next/tsconfig": "0.11.0-dev.
|
|
20
|
+
"@prisma-next/test-utils": "0.11.0-dev.31",
|
|
21
|
+
"@prisma-next/tsconfig": "0.11.0-dev.31",
|
|
22
22
|
"@types/pg": "8.20.0",
|
|
23
23
|
"pg": "8.20.0",
|
|
24
|
-
"@prisma-next/tsdown": "0.11.0-dev.
|
|
24
|
+
"@prisma-next/tsdown": "0.11.0-dev.31",
|
|
25
25
|
"tsdown": "0.22.0",
|
|
26
26
|
"typescript": "5.9.3",
|
|
27
27
|
"vitest": "4.1.6"
|
package/src/build-contract.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
type JsonValue,
|
|
17
17
|
type StorageHashBase,
|
|
18
18
|
} from '@prisma-next/contract/types';
|
|
19
|
+
import { type CapabilityMatrix, mergeCapabilityMatrices } from '@prisma-next/contract-authoring';
|
|
19
20
|
import type { CodecLookup } from '@prisma-next/framework-components/codec';
|
|
20
21
|
import { type Namespace, UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
|
|
21
22
|
import { validateIndexTypes } from '@prisma-next/sql-contract/index-type-validation';
|
|
@@ -532,7 +533,7 @@ export function buildSqlContractFromDefinition(
|
|
|
532
533
|
const nsInput: SqlNamespaceTablesInput = {
|
|
533
534
|
id,
|
|
534
535
|
tables: tablesByNamespace[id] ?? {},
|
|
535
|
-
...ifDefined('
|
|
536
|
+
...ifDefined('enum', enumTypes),
|
|
536
537
|
};
|
|
537
538
|
return [id, createNamespace ? createNamespace(nsInput) : nsInput];
|
|
538
539
|
}),
|
|
@@ -578,8 +579,24 @@ export function buildSqlContractFromDefinition(
|
|
|
578
579
|
}
|
|
579
580
|
}
|
|
580
581
|
|
|
581
|
-
const
|
|
582
|
-
|
|
582
|
+
const extensionPackCapabilitySources = definition.extensionPacks
|
|
583
|
+
? Object.values(definition.extensionPacks).map(
|
|
584
|
+
(pack) => pack.capabilities as CapabilityMatrix | undefined,
|
|
585
|
+
)
|
|
586
|
+
: [];
|
|
587
|
+
const capabilities = mergeCapabilityMatrices(
|
|
588
|
+
definition.target.capabilities as CapabilityMatrix | undefined,
|
|
589
|
+
...extensionPackCapabilitySources,
|
|
590
|
+
);
|
|
591
|
+
// Internal `profileHash` computation is unchanged from `origin/main`: it
|
|
592
|
+
// continues to fingerprint the author-declared capability subset. With
|
|
593
|
+
// `capabilities` removed from the `defineContract` input that subset is
|
|
594
|
+
// now always empty, so the hash naturally stabilises at `hash({})`.
|
|
595
|
+
const profileHash = computeProfileHash({
|
|
596
|
+
target,
|
|
597
|
+
targetFamily,
|
|
598
|
+
capabilities: {},
|
|
599
|
+
});
|
|
583
600
|
|
|
584
601
|
const executionWithHash = executionSection
|
|
585
602
|
? {
|
package/src/contract-builder.ts
CHANGED
|
@@ -53,7 +53,6 @@ type ContractDefinition<
|
|
|
53
53
|
Types extends Record<string, StorageTypeInstance | PostgresEnumStorageEntry>,
|
|
54
54
|
Models extends Record<string, ModelLike>,
|
|
55
55
|
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,
|
|
56
|
-
Capabilities extends Record<string, Record<string, boolean>> | undefined,
|
|
57
56
|
Naming extends ContractInput['naming'] | undefined,
|
|
58
57
|
StorageHash extends string | undefined,
|
|
59
58
|
ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined,
|
|
@@ -65,7 +64,6 @@ type ContractDefinition<
|
|
|
65
64
|
readonly naming?: Naming;
|
|
66
65
|
readonly storageHash?: StorageHash;
|
|
67
66
|
readonly foreignKeyDefaults?: ForeignKeyDefaults;
|
|
68
|
-
readonly capabilities?: Capabilities;
|
|
69
67
|
readonly namespaces?: Namespaces;
|
|
70
68
|
readonly createNamespace?: (input: SqlNamespaceTablesInput) => Namespace;
|
|
71
69
|
readonly types?: Types;
|
|
@@ -77,7 +75,6 @@ type ContractScaffold<
|
|
|
77
75
|
Family extends FamilyPackRef<string>,
|
|
78
76
|
Target extends TargetPackRef<'sql', string>,
|
|
79
77
|
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,
|
|
80
|
-
Capabilities extends Record<string, Record<string, boolean>> | undefined,
|
|
81
78
|
Naming extends ContractInput['naming'] | undefined,
|
|
82
79
|
StorageHash extends string | undefined,
|
|
83
80
|
ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined,
|
|
@@ -89,7 +86,6 @@ type ContractScaffold<
|
|
|
89
86
|
readonly naming?: Naming;
|
|
90
87
|
readonly storageHash?: StorageHash;
|
|
91
88
|
readonly foreignKeyDefaults?: ForeignKeyDefaults;
|
|
92
|
-
readonly capabilities?: Capabilities;
|
|
93
89
|
readonly namespaces?: Namespaces;
|
|
94
90
|
readonly createNamespace?: (input: SqlNamespaceTablesInput) => Namespace;
|
|
95
91
|
readonly codecLookup?: CodecLookup;
|
|
@@ -305,7 +301,6 @@ export function defineContract<
|
|
|
305
301
|
const ExtensionPacks extends
|
|
306
302
|
| Record<string, ExtensionPackRef<'sql', string>>
|
|
307
303
|
| undefined = undefined,
|
|
308
|
-
const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,
|
|
309
304
|
const Naming extends ContractInput['naming'] | undefined = undefined,
|
|
310
305
|
const StorageHash extends string | undefined = undefined,
|
|
311
306
|
const ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined = undefined,
|
|
@@ -317,7 +312,6 @@ export function defineContract<
|
|
|
317
312
|
Types,
|
|
318
313
|
Models,
|
|
319
314
|
ExtensionPacks,
|
|
320
|
-
Capabilities,
|
|
321
315
|
Naming,
|
|
322
316
|
StorageHash,
|
|
323
317
|
ForeignKeyDefaults,
|
|
@@ -330,7 +324,6 @@ export function defineContract<
|
|
|
330
324
|
Types,
|
|
331
325
|
Models,
|
|
332
326
|
ExtensionPacks,
|
|
333
|
-
Capabilities,
|
|
334
327
|
Naming,
|
|
335
328
|
StorageHash,
|
|
336
329
|
ForeignKeyDefaults,
|
|
@@ -348,7 +341,6 @@ export function defineContract<
|
|
|
348
341
|
const ExtensionPacks extends
|
|
349
342
|
| Record<string, ExtensionPackRef<'sql', string>>
|
|
350
343
|
| undefined = undefined,
|
|
351
|
-
const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,
|
|
352
344
|
const Naming extends ContractInput['naming'] | undefined = undefined,
|
|
353
345
|
const StorageHash extends string | undefined = undefined,
|
|
354
346
|
const ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined = undefined,
|
|
@@ -358,7 +350,6 @@ export function defineContract<
|
|
|
358
350
|
Family,
|
|
359
351
|
Target,
|
|
360
352
|
ExtensionPacks,
|
|
361
|
-
Capabilities,
|
|
362
353
|
Naming,
|
|
363
354
|
StorageHash,
|
|
364
355
|
ForeignKeyDefaults,
|
|
@@ -372,7 +363,6 @@ export function defineContract<
|
|
|
372
363
|
Types,
|
|
373
364
|
Models,
|
|
374
365
|
ExtensionPacks,
|
|
375
|
-
Capabilities,
|
|
376
366
|
Naming,
|
|
377
367
|
StorageHash,
|
|
378
368
|
ForeignKeyDefaults,
|
|
@@ -118,14 +118,13 @@ export interface ModelNode {
|
|
|
118
118
|
export interface ContractDefinition {
|
|
119
119
|
readonly target: TargetPackRef<'sql', string>;
|
|
120
120
|
readonly extensionPacks?: Record<string, ExtensionPackRef<'sql', string>>;
|
|
121
|
-
readonly capabilities?: Record<string, Record<string, boolean>>;
|
|
122
121
|
readonly storageHash?: string;
|
|
123
122
|
readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
|
|
124
123
|
readonly storageTypes?: Record<string, StorageTypeInstance | PostgresEnumStorageEntry>;
|
|
125
124
|
/**
|
|
126
125
|
* Enum types declared inside a named `namespace { enum … }` block,
|
|
127
126
|
* keyed first by namespace id then by type name. These are routed to
|
|
128
|
-
* `storage.namespaces[nsId].
|
|
127
|
+
* `storage.namespaces[nsId].enum` rather than the implicit fallback
|
|
129
128
|
* namespace used for top-level `storageTypes` enums.
|
|
130
129
|
*/
|
|
131
130
|
readonly namespaceTypes?: Readonly<
|
package/src/contract-dsl.ts
CHANGED
|
@@ -1209,7 +1209,6 @@ export type ContractInput<
|
|
|
1209
1209
|
>
|
|
1210
1210
|
> = Record<never, never>,
|
|
1211
1211
|
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined,
|
|
1212
|
-
Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,
|
|
1213
1212
|
> = {
|
|
1214
1213
|
readonly family: Family;
|
|
1215
1214
|
readonly target: Target;
|
|
@@ -1217,7 +1216,6 @@ export type ContractInput<
|
|
|
1217
1216
|
readonly naming?: NamingConfig;
|
|
1218
1217
|
readonly storageHash?: string;
|
|
1219
1218
|
readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
|
|
1220
|
-
readonly capabilities?: Capabilities;
|
|
1221
1219
|
/**
|
|
1222
1220
|
* Declared namespace coordinates the contract recognises. Per-model
|
|
1223
1221
|
* `namespace` references must reference an entry in this list (or the
|
package/src/contract-lowering.ts
CHANGED
|
@@ -708,7 +708,6 @@ export function buildContractDefinition(definition: ContractInput): ContractDefi
|
|
|
708
708
|
return {
|
|
709
709
|
target: definition.target,
|
|
710
710
|
...(definition.extensionPacks ? { extensionPacks: definition.extensionPacks } : {}),
|
|
711
|
-
...(definition.capabilities ? { capabilities: definition.capabilities } : {}),
|
|
712
711
|
...(definition.storageHash ? { storageHash: definition.storageHash } : {}),
|
|
713
712
|
...(definition.foreignKeyDefaults ? { foreignKeyDefaults: definition.foreignKeyDefaults } : {}),
|
|
714
713
|
...(Object.keys(collection.storageTypes).length > 0
|
package/src/contract-types.ts
CHANGED
|
@@ -69,11 +69,35 @@ type DefinitionExtensionPacks<Definition> = Definition extends {
|
|
|
69
69
|
? Packs
|
|
70
70
|
: Record<never, never>;
|
|
71
71
|
|
|
72
|
-
type
|
|
73
|
-
readonly capabilities?: infer
|
|
72
|
+
type ExtractPackCapabilities<P> = P extends {
|
|
73
|
+
readonly capabilities?: infer Caps extends Record<string, Record<string, boolean>>;
|
|
74
74
|
}
|
|
75
|
-
?
|
|
76
|
-
:
|
|
75
|
+
? Caps
|
|
76
|
+
: never;
|
|
77
|
+
|
|
78
|
+
type MergeExtensionPackCapabilities<Packs> =
|
|
79
|
+
Packs extends Record<string, unknown>
|
|
80
|
+
? keyof Packs extends never
|
|
81
|
+
? Record<string, never>
|
|
82
|
+
: UnionToIntersection<
|
|
83
|
+
{
|
|
84
|
+
[K in keyof Packs]: ExtractPackCapabilities<Packs[K]>;
|
|
85
|
+
}[keyof Packs]
|
|
86
|
+
>
|
|
87
|
+
: Record<string, never>;
|
|
88
|
+
|
|
89
|
+
type Defaulted<T, Fallback> = [T] extends [never] ? Fallback : T;
|
|
90
|
+
|
|
91
|
+
// Build-time capability derivation no longer reads an author-declared
|
|
92
|
+
// `capabilities` block — that field was removed from the `defineContract`
|
|
93
|
+
// input. The build-time matrix is the merge of the target pack's caps and
|
|
94
|
+
// every extension pack's caps; adapter and driver caps are layered in by
|
|
95
|
+
// `enrichContract` at CLI emit time.
|
|
96
|
+
type DerivedCapabilities<Definition> = Defaulted<
|
|
97
|
+
ExtractPackCapabilities<DefinitionTarget<Definition>>,
|
|
98
|
+
Record<string, never>
|
|
99
|
+
> &
|
|
100
|
+
MergeExtensionPackCapabilities<DefinitionExtensionPacks<Definition>>;
|
|
77
101
|
|
|
78
102
|
type DefinitionTargetId<Definition> = Definition extends {
|
|
79
103
|
readonly target: TargetPackRef<'sql', infer Target>;
|
|
@@ -561,14 +585,14 @@ type BuiltStorage<Definition> = {
|
|
|
561
585
|
readonly id: '__unbound__';
|
|
562
586
|
readonly kind: string;
|
|
563
587
|
readonly tables: BuiltStorageTables<Definition>;
|
|
564
|
-
readonly
|
|
588
|
+
readonly enum?: Readonly<Record<string, PostgresEnumStorageEntry>>;
|
|
565
589
|
};
|
|
566
590
|
} & {
|
|
567
591
|
readonly [Ns in Exclude<DefinitionNamespaces<Definition>, '__unbound__'>]: {
|
|
568
592
|
readonly id: Ns;
|
|
569
593
|
readonly kind: string;
|
|
570
594
|
readonly tables: Record<never, never>;
|
|
571
|
-
readonly
|
|
595
|
+
readonly enum?: Readonly<Record<string, PostgresEnumStorageEntry>>;
|
|
572
596
|
};
|
|
573
597
|
};
|
|
574
598
|
};
|
|
@@ -608,12 +632,7 @@ export type SqlContractResult<Definition> = ContractWithTypeMaps<
|
|
|
608
632
|
readonly extensionPacks: keyof DefinitionExtensionPacks<Definition> extends never
|
|
609
633
|
? Record<string, never>
|
|
610
634
|
: DefinitionExtensionPacks<Definition>;
|
|
611
|
-
readonly capabilities:
|
|
612
|
-
string,
|
|
613
|
-
Record<string, boolean>
|
|
614
|
-
>
|
|
615
|
-
? DefinitionCapabilities<Definition>
|
|
616
|
-
: Record<string, Record<string, boolean>>;
|
|
635
|
+
readonly capabilities: DerivedCapabilities<Definition>;
|
|
617
636
|
},
|
|
618
637
|
TypeMaps<
|
|
619
638
|
CodecTypesFromDefinition<Definition>,
|