@prisma-next/framework-components 0.11.0-dev.17 → 0.11.0-dev.18

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.
@@ -1,2 +1,34 @@
1
1
  import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-CuoUhyB5.mjs";
2
- export { type AdapterDescriptor, type AdapterInstance, type AdapterPackRef, type ComponentDescriptor, type ComponentMetadata, type ContractComponentRequirementsCheckInput, type ContractComponentRequirementsCheckResult, type DriverDescriptor, type DriverInstance, type DriverPackRef, type ExtensionDescriptor, type ExtensionInstance, type ExtensionPackRef, type FamilyDescriptor, type FamilyInstance, type FamilyPackRef, type PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, checkContractComponentRequirements };
2
+
3
+ //#region src/shared/capabilities.d.ts
4
+ /**
5
+ * Capability matrix merge primitive shared by emit-time and runtime stack composition.
6
+ *
7
+ * The CLI's `enrichContract` and the SQL runtime's `createExecutionContext` both need
8
+ * to fold a stack of component descriptors' `capabilities` declarations into a single
9
+ * matrix keyed by namespace. Keeping the primitive here lets both call sites stay
10
+ * byte-for-byte consistent without one depending on the other.
11
+ */
12
+ /**
13
+ * Merge an ordered list of contributor capability declarations into a base matrix.
14
+ *
15
+ * Behaviour:
16
+ * - `base` and each contributor's `capabilities` are filtered through the same
17
+ * structural extraction: non-plain-object namespace blocks are dropped,
18
+ * non-boolean leaves inside a namespace block are dropped, and a namespace
19
+ * block that ends up with zero boolean leaves is omitted entirely (so a
20
+ * later contributor with a malformed namespace cannot erase a namespace
21
+ * already present in `base`).
22
+ * - Non-plain-object `capabilities` on a contributor (including `undefined`,
23
+ * `null`, arrays, primitives) are skipped silently — the contributor
24
+ * contributes nothing.
25
+ * - Later contributors win on `(namespace, key)` collisions.
26
+ * - The returned object is fresh — neither `base` nor any contributor is mutated.
27
+ * - Output keys are sorted lexicographically at every plain-object level.
28
+ */
29
+ declare function mergeCapabilityMatrices(base: Record<string, Record<string, boolean>>, contributors: ReadonlyArray<{
30
+ readonly capabilities?: unknown;
31
+ }>): Record<string, Record<string, boolean>>;
32
+ //#endregion
33
+ export { type AdapterDescriptor, type AdapterInstance, type AdapterPackRef, type ComponentDescriptor, type ComponentMetadata, type ContractComponentRequirementsCheckInput, type ContractComponentRequirementsCheckResult, type DriverDescriptor, type DriverInstance, type DriverPackRef, type ExtensionDescriptor, type ExtensionInstance, type ExtensionPackRef, type FamilyDescriptor, type FamilyInstance, type FamilyPackRef, type PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, checkContractComponentRequirements, mergeCapabilityMatrices };
34
+ //# sourceMappingURL=components.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.mts","names":[],"sources":["../src/shared/capabilities.ts"],"mappings":";;;;;;AAqEA;;;;;;;;;;;;;;;;;;;AAGwB;;;iBAHR,uBAAA,CACd,IAAA,EAAM,MAAA,SAAe,MAAA,oBACrB,YAAA,EAAc,aAAA;EAAA,SAAyB,YAAA;AAAA,KACtC,MAAA,SAAe,MAAA"}
@@ -1,2 +1,65 @@
1
1
  import { t as checkContractComponentRequirements } from "./framework-components-FdqmlGUj.mjs";
2
- export { checkContractComponentRequirements };
2
+ import { blindCast } from "@prisma-next/utils/casts";
3
+ //#region src/shared/capabilities.ts
4
+ /**
5
+ * Capability matrix merge primitive shared by emit-time and runtime stack composition.
6
+ *
7
+ * The CLI's `enrichContract` and the SQL runtime's `createExecutionContext` both need
8
+ * to fold a stack of component descriptors' `capabilities` declarations into a single
9
+ * matrix keyed by namespace. Keeping the primitive here lets both call sites stay
10
+ * byte-for-byte consistent without one depending on the other.
11
+ */
12
+ function isPlainObject(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function sortDeep(value) {
16
+ if (Array.isArray(value)) return value.map(sortDeep);
17
+ if (!isPlainObject(value)) return value;
18
+ const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
19
+ const next = {};
20
+ for (const [key, child] of entries) next[key] = sortDeep(child);
21
+ return next;
22
+ }
23
+ function extractCapabilityMatrix(value) {
24
+ if (!isPlainObject(value)) return {};
25
+ const out = {};
26
+ for (const [namespace, maybeCaps] of Object.entries(value)) {
27
+ if (!isPlainObject(maybeCaps)) continue;
28
+ const caps = {};
29
+ for (const [key, flag] of Object.entries(maybeCaps)) if (typeof flag === "boolean") caps[key] = flag;
30
+ if (Object.keys(caps).length > 0) out[namespace] = caps;
31
+ }
32
+ return out;
33
+ }
34
+ /**
35
+ * Merge an ordered list of contributor capability declarations into a base matrix.
36
+ *
37
+ * Behaviour:
38
+ * - `base` and each contributor's `capabilities` are filtered through the same
39
+ * structural extraction: non-plain-object namespace blocks are dropped,
40
+ * non-boolean leaves inside a namespace block are dropped, and a namespace
41
+ * block that ends up with zero boolean leaves is omitted entirely (so a
42
+ * later contributor with a malformed namespace cannot erase a namespace
43
+ * already present in `base`).
44
+ * - Non-plain-object `capabilities` on a contributor (including `undefined`,
45
+ * `null`, arrays, primitives) are skipped silently — the contributor
46
+ * contributes nothing.
47
+ * - Later contributors win on `(namespace, key)` collisions.
48
+ * - The returned object is fresh — neither `base` nor any contributor is mutated.
49
+ * - Output keys are sorted lexicographically at every plain-object level.
50
+ */
51
+ function mergeCapabilityMatrices(base, contributors) {
52
+ const merged = extractCapabilityMatrix(base);
53
+ for (const contributor of contributors) {
54
+ const extracted = extractCapabilityMatrix(contributor.capabilities);
55
+ for (const [namespace, capabilities] of Object.entries(extracted)) merged[namespace] = {
56
+ ...merged[namespace] ?? {},
57
+ ...capabilities
58
+ };
59
+ }
60
+ return blindCast(sortDeep(merged));
61
+ }
62
+ //#endregion
63
+ export { checkContractComponentRequirements, mergeCapabilityMatrices };
64
+
65
+ //# sourceMappingURL=components.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.mjs","names":[],"sources":["../src/shared/capabilities.ts"],"sourcesContent":["/**\n * Capability matrix merge primitive shared by emit-time and runtime stack composition.\n *\n * The CLI's `enrichContract` and the SQL runtime's `createExecutionContext` both need\n * to fold a stack of component descriptors' `capabilities` declarations into a single\n * matrix keyed by namespace. Keeping the primitive here lets both call sites stay\n * byte-for-byte consistent without one depending on the other.\n */\n\nimport { blindCast } from '@prisma-next/utils/casts';\n\ntype CapabilityMatrix = Record<string, Record<string, boolean>>;\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction sortDeep(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortDeep);\n }\n if (!isPlainObject(value)) {\n return value;\n }\n const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));\n const next: Record<string, unknown> = {};\n for (const [key, child] of entries) {\n next[key] = sortDeep(child);\n }\n return next;\n}\n\nfunction extractCapabilityMatrix(value: unknown): CapabilityMatrix {\n if (!isPlainObject(value)) return {};\n\n const out: CapabilityMatrix = {};\n for (const [namespace, maybeCaps] of Object.entries(value)) {\n if (!isPlainObject(maybeCaps)) continue;\n const caps: Record<string, boolean> = {};\n for (const [key, flag] of Object.entries(maybeCaps)) {\n if (typeof flag === 'boolean') {\n caps[key] = flag;\n }\n }\n if (Object.keys(caps).length > 0) {\n out[namespace] = caps;\n }\n }\n\n return out;\n}\n\n/**\n * Merge an ordered list of contributor capability declarations into a base matrix.\n *\n * Behaviour:\n * - `base` and each contributor's `capabilities` are filtered through the same\n * structural extraction: non-plain-object namespace blocks are dropped,\n * non-boolean leaves inside a namespace block are dropped, and a namespace\n * block that ends up with zero boolean leaves is omitted entirely (so a\n * later contributor with a malformed namespace cannot erase a namespace\n * already present in `base`).\n * - Non-plain-object `capabilities` on a contributor (including `undefined`,\n * `null`, arrays, primitives) are skipped silently — the contributor\n * contributes nothing.\n * - Later contributors win on `(namespace, key)` collisions.\n * - The returned object is fresh — neither `base` nor any contributor is mutated.\n * - Output keys are sorted lexicographically at every plain-object level.\n */\nexport function mergeCapabilityMatrices(\n base: Record<string, Record<string, boolean>>,\n contributors: ReadonlyArray<{ readonly capabilities?: unknown }>,\n): Record<string, Record<string, boolean>> {\n const merged: CapabilityMatrix = extractCapabilityMatrix(base);\n\n for (const contributor of contributors) {\n const extracted = extractCapabilityMatrix(contributor.capabilities);\n for (const [namespace, capabilities] of Object.entries(extracted)) {\n merged[namespace] = {\n ...(merged[namespace] ?? {}),\n ...capabilities,\n };\n }\n }\n\n return blindCast<\n CapabilityMatrix,\n \"sortDeep preserves the matrix shape but the recursive generic relationship can't be expressed to TS\"\n >(sortDeep(merged));\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAS,cAAc,OAAkD;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,SAAS,OAAyB;CACzC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,QAAQ;CAE3B,IAAI,CAAC,cAAc,KAAK,GACtB,OAAO;CAET,MAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CAC3E,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,KAAK,UAAU,SACzB,KAAK,OAAO,SAAS,KAAK;CAE5B,OAAO;AACT;AAEA,SAAS,wBAAwB,OAAkC;CACjE,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO,CAAC;CAEnC,MAAM,MAAwB,CAAC;CAC/B,KAAK,MAAM,CAAC,WAAW,cAAc,OAAO,QAAQ,KAAK,GAAG;EAC1D,IAAI,CAAC,cAAc,SAAS,GAAG;EAC/B,MAAM,OAAgC,CAAC;EACvC,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,SAAS,GAChD,IAAI,OAAO,SAAS,WAClB,KAAK,OAAO;EAGhB,IAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAC7B,IAAI,aAAa;CAErB;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,wBACd,MACA,cACyC;CACzC,MAAM,SAA2B,wBAAwB,IAAI;CAE7D,KAAK,MAAM,eAAe,cAAc;EACtC,MAAM,YAAY,wBAAwB,YAAY,YAAY;EAClE,KAAK,MAAM,CAAC,WAAW,iBAAiB,OAAO,QAAQ,SAAS,GAC9D,OAAO,aAAa;GAClB,GAAI,OAAO,cAAc,CAAC;GAC1B,GAAG;EACL;CAEJ;CAEA,OAAO,UAGL,SAAS,MAAM,CAAC;AACpB"}
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@prisma-next/framework-components",
3
- "version": "0.11.0-dev.17",
3
+ "version": "0.11.0-dev.18",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Framework component types, assembly logic, and stack creation for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/contract": "0.11.0-dev.17",
10
- "@prisma-next/operations": "0.11.0-dev.17",
11
- "@prisma-next/ts-render": "0.11.0-dev.17",
12
- "@prisma-next/utils": "0.11.0-dev.17",
9
+ "@prisma-next/contract": "0.11.0-dev.18",
10
+ "@prisma-next/operations": "0.11.0-dev.18",
11
+ "@prisma-next/ts-render": "0.11.0-dev.18",
12
+ "@prisma-next/utils": "0.11.0-dev.18",
13
13
  "@standard-schema/spec": "^1.1.0",
14
14
  "arktype": "^2.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@prisma-next/tsconfig": "0.11.0-dev.17",
18
- "@prisma-next/tsdown": "0.11.0-dev.17",
17
+ "@prisma-next/tsconfig": "0.11.0-dev.18",
18
+ "@prisma-next/tsdown": "0.11.0-dev.18",
19
19
  "tsdown": "0.22.0",
20
20
  "typescript": "5.9.3",
21
21
  "vitest": "4.1.6"
@@ -1,3 +1,4 @@
1
+ export { mergeCapabilityMatrices } from '../shared/capabilities';
1
2
  export type {
2
3
  AdapterDescriptor,
3
4
  AdapterInstance,
@@ -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
+ }