@prisma-next/framework-components 0.11.0-dev.5 → 0.11.0-dev.51
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/codec-BFOsuHKK.d.mts.map +1 -1
- package/dist/codec.d.mts.map +1 -1
- package/dist/codec.mjs.map +1 -1
- package/dist/components.d.mts +33 -1
- package/dist/components.d.mts.map +1 -0
- package/dist/components.mjs +64 -1
- package/dist/components.mjs.map +1 -0
- package/dist/control.d.mts +25 -17
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs.map +1 -1
- package/dist/emission-types-CMv_053d.d.mts.map +1 -1
- package/dist/execution.d.mts.map +1 -1
- package/dist/execution.mjs.map +1 -1
- package/dist/framework-authoring-BPPe9C9D.d.mts.map +1 -1
- package/dist/framework-authoring-DcEZ5Lin.mjs.map +1 -1
- package/dist/framework-components-CuoUhyB5.d.mts.map +1 -1
- package/dist/framework-components-FdqmlGUj.mjs.map +1 -1
- package/dist/ir.d.mts +4 -4
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs.map +1 -1
- package/dist/psl-ast-BDXL7iCg.d.mts.map +1 -1
- package/dist/psl-ast.mjs.map +1 -1
- package/dist/runtime.d.mts +11 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +6 -2
- package/dist/runtime.mjs.map +1 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +7 -7
- package/src/control/contract-serializer.ts +19 -0
- package/src/control/control-migration-types.ts +0 -17
- package/src/control/control-result-types.ts +7 -0
- package/src/execution/runtime-core.ts +13 -2
- package/src/execution/runtime-middleware.ts +11 -0
- package/src/exports/components.ts +1 -0
- package/src/exports/control.ts +0 -1
- package/src/ir/ir-node.ts +1 -1
- package/src/ir/namespace.ts +2 -2
- package/src/ir/storage-type.ts +1 -1
- package/src/shared/capabilities.ts +90 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability matrix merge primitive shared by emit-time and runtime stack composition.
|
|
3
|
+
*
|
|
4
|
+
* The CLI's `enrichContract` and the SQL runtime's `createExecutionContext` both need
|
|
5
|
+
* to fold a stack of component descriptors' `capabilities` declarations into a single
|
|
6
|
+
* matrix keyed by namespace. Keeping the primitive here lets both call sites stay
|
|
7
|
+
* byte-for-byte consistent without one depending on the other.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { blindCast } from '@prisma-next/utils/casts';
|
|
11
|
+
|
|
12
|
+
type CapabilityMatrix = Record<string, Record<string, boolean>>;
|
|
13
|
+
|
|
14
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function sortDeep(value: unknown): unknown {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value.map(sortDeep);
|
|
21
|
+
}
|
|
22
|
+
if (!isPlainObject(value)) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
|
|
26
|
+
const next: Record<string, unknown> = {};
|
|
27
|
+
for (const [key, child] of entries) {
|
|
28
|
+
next[key] = sortDeep(child);
|
|
29
|
+
}
|
|
30
|
+
return next;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function extractCapabilityMatrix(value: unknown): CapabilityMatrix {
|
|
34
|
+
if (!isPlainObject(value)) return {};
|
|
35
|
+
|
|
36
|
+
const out: CapabilityMatrix = {};
|
|
37
|
+
for (const [namespace, maybeCaps] of Object.entries(value)) {
|
|
38
|
+
if (!isPlainObject(maybeCaps)) continue;
|
|
39
|
+
const caps: Record<string, boolean> = {};
|
|
40
|
+
for (const [key, flag] of Object.entries(maybeCaps)) {
|
|
41
|
+
if (typeof flag === 'boolean') {
|
|
42
|
+
caps[key] = flag;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (Object.keys(caps).length > 0) {
|
|
46
|
+
out[namespace] = caps;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Merge an ordered list of contributor capability declarations into a base matrix.
|
|
55
|
+
*
|
|
56
|
+
* Behaviour:
|
|
57
|
+
* - `base` and each contributor's `capabilities` are filtered through the same
|
|
58
|
+
* structural extraction: non-plain-object namespace blocks are dropped,
|
|
59
|
+
* non-boolean leaves inside a namespace block are dropped, and a namespace
|
|
60
|
+
* block that ends up with zero boolean leaves is omitted entirely (so a
|
|
61
|
+
* later contributor with a malformed namespace cannot erase a namespace
|
|
62
|
+
* already present in `base`).
|
|
63
|
+
* - Non-plain-object `capabilities` on a contributor (including `undefined`,
|
|
64
|
+
* `null`, arrays, primitives) are skipped silently — the contributor
|
|
65
|
+
* contributes nothing.
|
|
66
|
+
* - Later contributors win on `(namespace, key)` collisions.
|
|
67
|
+
* - The returned object is fresh — neither `base` nor any contributor is mutated.
|
|
68
|
+
* - Output keys are sorted lexicographically at every plain-object level.
|
|
69
|
+
*/
|
|
70
|
+
export function mergeCapabilityMatrices(
|
|
71
|
+
base: Record<string, Record<string, boolean>>,
|
|
72
|
+
contributors: ReadonlyArray<{ readonly capabilities?: unknown }>,
|
|
73
|
+
): Record<string, Record<string, boolean>> {
|
|
74
|
+
const merged: CapabilityMatrix = extractCapabilityMatrix(base);
|
|
75
|
+
|
|
76
|
+
for (const contributor of contributors) {
|
|
77
|
+
const extracted = extractCapabilityMatrix(contributor.capabilities);
|
|
78
|
+
for (const [namespace, capabilities] of Object.entries(extracted)) {
|
|
79
|
+
merged[namespace] = {
|
|
80
|
+
...(merged[namespace] ?? {}),
|
|
81
|
+
...capabilities,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return blindCast<
|
|
87
|
+
CapabilityMatrix,
|
|
88
|
+
"sortDeep preserves the matrix shape but the recursive generic relationship can't be expressed to TS"
|
|
89
|
+
>(sortDeep(merged));
|
|
90
|
+
}
|