@prisma/composer 0.3.0 → 0.4.0-dev.2
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/{app-config-Dw3r7sUa-D3dr8rg2.d.mts → app-config-bsTo57A8-BfG21wAI.d.mts} +4 -4
- package/dist/{app-config-Dw3r7sUa-D3dr8rg2.d.mts.map → app-config-bsTo57A8-BfG21wAI.d.mts.map} +1 -1
- package/dist/arktype.d.mts +16 -0
- package/dist/arktype.d.mts.map +1 -0
- package/dist/arktype.mjs +22 -0
- package/dist/arktype.mjs.map +1 -0
- package/dist/bin.mjs +56 -32
- package/dist/bin.mjs.map +1 -1
- package/dist/{casts-Ci5rYYaR.mjs → casts-DpaahrlC-C5XMnP9S.mjs} +2 -2
- package/dist/casts-DpaahrlC-C5XMnP9S.mjs.map +1 -0
- package/dist/casts.mjs +1 -1
- package/dist/config-DUzvB5cQ.d.mts +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/{deploy-H3PKi0ZR-Chgm12Bn.mjs → deploy-C4DxNkJ9-D73lmBqy.mjs} +3 -3
- package/dist/{deploy-H3PKi0ZR-Chgm12Bn.mjs.map → deploy-C4DxNkJ9-D73lmBqy.mjs.map} +1 -1
- package/dist/deploy-DUzvB5cQ.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/deploy.mjs +1 -1
- package/dist/{dist-BkSJOwTm.mjs → dist-BdvFDCLV.mjs} +12 -76
- package/dist/dist-BdvFDCLV.mjs.map +1 -0
- package/dist/{graph-DUSgjmzA-DhtkTqoz.d.mts → graph-DDpXh7S8-b-93BcHn.d.mts} +3 -3
- package/dist/graph-DDpXh7S8-b-93BcHn.d.mts.map +1 -0
- package/dist/{graph-CP16cJyH-D5IW87Y-.mjs → graph-DgbALPDo-BEHF94BN.mjs} +60 -41
- package/dist/graph-DgbALPDo-BEHF94BN.mjs.map +1 -0
- package/dist/{graph-types-BcbVhojU-C3fhxjPK.d.mts → graph-types-C3FOaaXm-C6_rGzfn.d.mts} +87 -87
- package/dist/graph-types-C3FOaaXm-C6_rGzfn.d.mts.map +1 -0
- package/dist/index-BQVrMGfe.d.mts +22 -0
- package/dist/index-BQVrMGfe.d.mts.map +1 -0
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +4 -3
- package/dist/local-target.d.mts +1 -1
- package/dist/local-target.mjs +1 -1
- package/dist/local-target.mjs.map +1 -1
- package/dist/{nextjs-DLyeRR7M-DwnBjryZ.d.mts → nextjs-DLyeRR7M-D47aMmfr.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-DwnBjryZ.d.mts.map → nextjs-DLyeRR7M-D47aMmfr.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/report.d.mts +2 -2
- package/dist/report.mjs +4 -0
- package/dist/report.mjs.map +1 -1
- package/dist/secret-CHOw4LBU-C8yXoC9N.d.mts +25 -0
- package/dist/secret-CHOw4LBU-C8yXoC9N.d.mts.map +1 -0
- package/dist/secret-DoWGmN7m-DO5Brq1Y.mjs +55 -0
- package/dist/secret-DoWGmN7m-DO5Brq1Y.mjs.map +1 -0
- package/dist/service-rpc.d.mts +15 -5
- package/dist/service-rpc.d.mts.map +1 -1
- package/dist/service-rpc.mjs +6 -4
- package/dist/service-rpc.mjs.map +1 -1
- package/dist/testing.d.mts +17 -11
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +12 -20
- package/dist/testing.mjs.map +1 -1
- package/package.json +12 -11
- package/src/exports/arktype.ts +1 -0
- package/dist/casts-Ci5rYYaR.mjs.map +0 -1
- package/dist/config-121C4hAb.d.mts +0 -1
- package/dist/deploy-121C4hAb.d.mts +0 -1
- package/dist/dist-BkSJOwTm.mjs.map +0 -1
- package/dist/graph-CP16cJyH-D5IW87Y-.mjs.map +0 -1
- package/dist/graph-DUSgjmzA-DhtkTqoz.d.mts.map +0 -1
- package/dist/graph-types-BcbVhojU-C3fhxjPK.d.mts.map +0 -1
- package/dist/index-BFBNz7Aw.d.mts +0 -32
- package/dist/index-BFBNz7Aw.d.mts.map +0 -1
package/dist/report.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as DeploymentResult } from "./app-config-
|
|
2
|
-
import "./deploy-
|
|
1
|
+
import { d as DeploymentResult } from "./app-config-bsTo57A8-BfG21wAI.mjs";
|
|
2
|
+
import "./deploy-DUzvB5cQ.mjs";
|
|
3
3
|
//#region ../../0-framework/3-tooling/cli/dist/report.d.mts
|
|
4
4
|
//#region src/render-deployment.d.ts
|
|
5
5
|
/**
|
package/dist/report.mjs
CHANGED
|
@@ -61,6 +61,10 @@ function renderDeployment(result) {
|
|
|
61
61
|
const prefix = index === 0 ? row.label : row.continuation;
|
|
62
62
|
lines.push(`${pad(prefix, column)}${entityLine(entity)}`);
|
|
63
63
|
if (entity.url !== void 0) lines.push(`${pad(row.continuation, column)}${entity.url}`);
|
|
64
|
+
for (const [key, value] of Object.entries(entity.details ?? {})) {
|
|
65
|
+
if (value === "") continue;
|
|
66
|
+
for (const line of value.split("\n")) lines.push(`${pad(row.continuation, column)}${key} ${line}`);
|
|
67
|
+
}
|
|
64
68
|
});
|
|
65
69
|
}
|
|
66
70
|
return lines.join("\n");
|
package/dist/report.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/report.mjs"],"sourcesContent":["//#region src/render-deployment.ts\n/** Gap between the deepest tree label and the entity column. */\nconst LABEL_GAP = 3;\nconst emptyNode = (segment) => ({\n\tsegment,\n\tchildren: /* @__PURE__ */ new Map()\n});\n/** Builds the address tree, splitting each dot-address into its segments. */\nfunction buildTree(nodes) {\n\tconst root = emptyNode(\"\");\n\tfor (const deployed of nodes) {\n\t\tlet node = root;\n\t\tfor (const segment of deployed.address.split(\".\")) {\n\t\t\tlet child = node.children.get(segment);\n\t\t\tif (child === void 0) {\n\t\t\t\tchild = emptyNode(segment);\n\t\t\t\tnode.children.set(segment, child);\n\t\t\t}\n\t\t\tnode = child;\n\t\t}\n\t\tnode.deployed = deployed;\n\t}\n\treturn root;\n}\n/** Flattens the tree to rows in address order, drawing the box guides. */\nfunction toRows(node, guides, rows) {\n\tconst children = Array.from(node.children.values());\n\tchildren.forEach((child, index) => {\n\t\tconst isLast = index === children.length - 1;\n\t\trows.push({\n\t\t\tlabel: `${guides}${isLast ? \"└─ \" : \"├─ \"}${child.segment}`,\n\t\t\tcontinuation: `${guides}${isLast ? \" \" : \"│ \"}`,\n\t\t\tdeployed: child.deployed\n\t\t});\n\t\ttoRows(child, `${guides}${isLast ? \" \" : \"│ \"}`, rows);\n\t});\n}\n/** `kind id` — the one line an entity gets. */\nconst entityLine = (entity) => `${entity.kind} ${entity.id}`;\n/** Pads `prefix` out to `width`, so every entity starts in the same column. */\nconst pad = (prefix, width) => prefix.padEnd(width, \" \");\n/**\n* Renders a deploy's result as the app's own topology. Pure — returns the\n* string; the caller prints.\n*/\nfunction renderDeployment(result) {\n\tconst rows = [];\n\ttoRows(buildTree(result.nodes), \"\", rows);\n\tconst column = Math.max(0, ...rows.map((row) => row.label.length)) + LABEL_GAP;\n\tconst lines = [result.app];\n\tfor (const row of rows) {\n\t\tif (row.deployed === void 0) {\n\t\t\tlines.push(row.label);\n\t\t\tcontinue;\n\t\t}\n\t\tif (row.deployed.entities.length === 0) {\n\t\t\tlines.push(`${pad(row.label, column)}(no entities reported)`);\n\t\t\tcontinue;\n\t\t}\n\t\trow.deployed.entities.forEach((entity, index) => {\n\t\t\tconst prefix = index === 0 ? row.label : row.continuation;\n\t\t\tlines.push(`${pad(prefix, column)}${entityLine(entity)}`);\n\t\t\tif (entity.url !== void 0) lines.push(`${pad(row.continuation, column)}${entity.url}`);\n\t\t});\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* The report hook the generated stack file wires into `LowerOptions`. Prints a\n* leading blank line so the summary separates from alchemy's own apply output.\n*/\nfunction deploymentReport(result) {\n\tconsole.log(\"\");\n\tconsole.log(renderDeployment(result));\n}\n//#endregion\nexport { deploymentReport, renderDeployment };\n\n//# sourceMappingURL=report.mjs.map"],"mappings":";;AAEA,MAAM,YAAY;AAClB,MAAM,aAAa,aAAa;CAC/B;CACA,0BAA0B,IAAI,IAAI;AACnC;;AAEA,SAAS,UAAU,OAAO;CACzB,MAAM,OAAO,UAAU,EAAE;CACzB,KAAK,MAAM,YAAY,OAAO;EAC7B,IAAI,OAAO;EACX,KAAK,MAAM,WAAW,SAAS,QAAQ,MAAM,GAAG,GAAG;GAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO;GACrC,IAAI,UAAU,KAAK,GAAG;IACrB,QAAQ,UAAU,OAAO;IACzB,KAAK,SAAS,IAAI,SAAS,KAAK;GACjC;GACA,OAAO;EACR;EACA,KAAK,WAAW;CACjB;CACA,OAAO;AACR;;AAEA,SAAS,OAAO,MAAM,QAAQ,MAAM;CACnC,MAAM,WAAW,MAAM,KAAK,KAAK,SAAS,OAAO,CAAC;CAClD,SAAS,SAAS,OAAO,UAAU;EAClC,MAAM,SAAS,UAAU,SAAS,SAAS;EAC3C,KAAK,KAAK;GACT,OAAO,GAAG,SAAS,SAAS,QAAQ,QAAQ,MAAM;GAClD,cAAc,GAAG,SAAS,SAAS,QAAQ;GAC3C,UAAU,MAAM;EACjB,CAAC;EACD,OAAO,OAAO,GAAG,SAAS,SAAS,QAAQ,SAAS,IAAI;CACzD,CAAC;AACF;;AAEA,MAAM,cAAc,WAAW,GAAG,OAAO,KAAK,GAAG,OAAO;;AAExD,MAAM,OAAO,QAAQ,UAAU,OAAO,OAAO,OAAO,GAAG;;;;;AAKvD,SAAS,iBAAiB,QAAQ;CACjC,MAAM,OAAO,CAAC;CACd,OAAO,UAAU,OAAO,KAAK,GAAG,IAAI,IAAI;CACxC,MAAM,SAAS,KAAK,IAAI,GAAG,GAAG,KAAK,KAAK,QAAQ,IAAI,MAAM,MAAM,CAAC,IAAI;CACrE,MAAM,QAAQ,CAAC,OAAO,GAAG;CACzB,KAAK,MAAM,OAAO,MAAM;EACvB,IAAI,IAAI,aAAa,KAAK,GAAG;GAC5B,MAAM,KAAK,IAAI,KAAK;GACpB;EACD;EACA,IAAI,IAAI,SAAS,SAAS,WAAW,GAAG;GACvC,MAAM,KAAK,GAAG,IAAI,IAAI,OAAO,MAAM,EAAE,uBAAuB;GAC5D;EACD;EACA,IAAI,SAAS,SAAS,SAAS,QAAQ,UAAU;GAChD,MAAM,SAAS,UAAU,IAAI,IAAI,QAAQ,IAAI;GAC7C,MAAM,KAAK,GAAG,IAAI,QAAQ,MAAM,IAAI,WAAW,MAAM,GAAG;GACxD,IAAI,OAAO,QAAQ,KAAK,GAAG,MAAM,KAAK,GAAG,IAAI,IAAI,cAAc,MAAM,IAAI,OAAO,KAAK;
|
|
1
|
+
{"version":3,"file":"report.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/report.mjs"],"sourcesContent":["//#region src/render-deployment.ts\n/** Gap between the deepest tree label and the entity column. */\nconst LABEL_GAP = 3;\nconst emptyNode = (segment) => ({\n\tsegment,\n\tchildren: /* @__PURE__ */ new Map()\n});\n/** Builds the address tree, splitting each dot-address into its segments. */\nfunction buildTree(nodes) {\n\tconst root = emptyNode(\"\");\n\tfor (const deployed of nodes) {\n\t\tlet node = root;\n\t\tfor (const segment of deployed.address.split(\".\")) {\n\t\t\tlet child = node.children.get(segment);\n\t\t\tif (child === void 0) {\n\t\t\t\tchild = emptyNode(segment);\n\t\t\t\tnode.children.set(segment, child);\n\t\t\t}\n\t\t\tnode = child;\n\t\t}\n\t\tnode.deployed = deployed;\n\t}\n\treturn root;\n}\n/** Flattens the tree to rows in address order, drawing the box guides. */\nfunction toRows(node, guides, rows) {\n\tconst children = Array.from(node.children.values());\n\tchildren.forEach((child, index) => {\n\t\tconst isLast = index === children.length - 1;\n\t\trows.push({\n\t\t\tlabel: `${guides}${isLast ? \"└─ \" : \"├─ \"}${child.segment}`,\n\t\t\tcontinuation: `${guides}${isLast ? \" \" : \"│ \"}`,\n\t\t\tdeployed: child.deployed\n\t\t});\n\t\ttoRows(child, `${guides}${isLast ? \" \" : \"│ \"}`, rows);\n\t});\n}\n/** `kind id` — the one line an entity gets. */\nconst entityLine = (entity) => `${entity.kind} ${entity.id}`;\n/** Pads `prefix` out to `width`, so every entity starts in the same column. */\nconst pad = (prefix, width) => prefix.padEnd(width, \" \");\n/**\n* Renders a deploy's result as the app's own topology. Pure — returns the\n* string; the caller prints.\n*/\nfunction renderDeployment(result) {\n\tconst rows = [];\n\ttoRows(buildTree(result.nodes), \"\", rows);\n\tconst column = Math.max(0, ...rows.map((row) => row.label.length)) + LABEL_GAP;\n\tconst lines = [result.app];\n\tfor (const row of rows) {\n\t\tif (row.deployed === void 0) {\n\t\t\tlines.push(row.label);\n\t\t\tcontinue;\n\t\t}\n\t\tif (row.deployed.entities.length === 0) {\n\t\t\tlines.push(`${pad(row.label, column)}(no entities reported)`);\n\t\t\tcontinue;\n\t\t}\n\t\trow.deployed.entities.forEach((entity, index) => {\n\t\t\tconst prefix = index === 0 ? row.label : row.continuation;\n\t\t\tlines.push(`${pad(prefix, column)}${entityLine(entity)}`);\n\t\t\tif (entity.url !== void 0) lines.push(`${pad(row.continuation, column)}${entity.url}`);\n\t\t\tfor (const [key, value] of Object.entries(entity.details ?? {})) {\n\t\t\t\tif (value === \"\") continue;\n\t\t\t\tfor (const line of value.split(\"\\n\")) lines.push(`${pad(row.continuation, column)}${key} ${line}`);\n\t\t\t}\n\t\t});\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* The report hook the generated stack file wires into `LowerOptions`. Prints a\n* leading blank line so the summary separates from alchemy's own apply output.\n*/\nfunction deploymentReport(result) {\n\tconsole.log(\"\");\n\tconsole.log(renderDeployment(result));\n}\n//#endregion\nexport { deploymentReport, renderDeployment };\n\n//# sourceMappingURL=report.mjs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,MAAM,KAAK,IAAI,KAAK;GACpB;EACD;EACA,IAAI,IAAI,SAAS,SAAS,WAAW,GAAG;GACvC,MAAM,KAAK,GAAG,IAAI,IAAI,OAAO,MAAM,EAAE,uBAAuB;GAC5D;EACD;EACA,IAAI,SAAS,SAAS,SAAS,QAAQ,UAAU;GAChD,MAAM,SAAS,UAAU,IAAI,IAAI,QAAQ,IAAI;GAC7C,MAAM,KAAK,GAAG,IAAI,QAAQ,MAAM,IAAI,WAAW,MAAM,GAAG;GACxD,IAAI,OAAO,QAAQ,KAAK,GAAG,MAAM,KAAK,GAAG,IAAI,IAAI,cAAc,MAAM,IAAI,OAAO,KAAK;GACrF,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,WAAW,CAAC,CAAC,GAAG;IAChE,IAAI,UAAU,IAAI;IAClB,KAAK,MAAM,QAAQ,MAAM,MAAM,IAAI,GAAG,MAAM,KAAK,GAAG,IAAI,IAAI,cAAc,MAAM,IAAI,IAAI,GAAG,MAAM;GAClG;EACD,CAAC;CACF;CACA,OAAO,MAAM,KAAK,IAAI;AACvB;;;;;AAKA,SAAS,iBAAiB,QAAQ;CACjC,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,iBAAiB,MAAM,CAAC;AACrC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret-CHOw4LBU.d.mts
|
|
2
|
+
//#region src/secret.d.ts
|
|
3
|
+
declare const SECRET_BOX: unique symbol;
|
|
4
|
+
declare class SecretBox<T> {
|
|
5
|
+
#private;
|
|
6
|
+
readonly [SECRET_BOX] = true;
|
|
7
|
+
constructor(value: T);
|
|
8
|
+
/** The sole explicit door to the wrapped value. */
|
|
9
|
+
expose(): T;
|
|
10
|
+
toString(): string;
|
|
11
|
+
toJSON(): string;
|
|
12
|
+
valueOf(): string;
|
|
13
|
+
[Symbol.toPrimitive](): string;
|
|
14
|
+
}
|
|
15
|
+
/** The common case: a secret string. */
|
|
16
|
+
type SecretString = SecretBox<string>;
|
|
17
|
+
/**
|
|
18
|
+
* True for a redacting secret box — what a schema's secret leaf checks
|
|
19
|
+
* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
|
|
20
|
+
* duplicated module copy in a bundle counts and a look-alike does not.
|
|
21
|
+
*/
|
|
22
|
+
declare function isSecretString(value: unknown): value is SecretString;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { SecretString as n, isSecretString as r, SecretBox as t };
|
|
25
|
+
//# sourceMappingURL=secret-CHOw4LBU-C8yXoC9N.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-CHOw4LBU-C8yXoC9N.d.mts","names":[],"sources":["../../../0-framework/0-foundation/foundation/dist/secret-CHOw4LBU.d.mts"],"mappings":";;cACc;cACA,UAAU;;YAEZ;EACV,YAAY,OAAO;;EAEnB,UAAU;EACV;EACA;EACA;GACC,OAAO;;;KAGL,eAAe;;;;;;iBAMH,eAAe,iBAAiB,SAAS"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
|
|
3
|
+
/**
|
|
4
|
+
* A value wrapper that redacts everywhere except the one explicit reader,
|
|
5
|
+
* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
|
|
6
|
+
* sink must remember to check: `String(box)`, template interpolation,
|
|
7
|
+
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
8
|
+
* a secret can't leak through an accidental log or serialization.
|
|
9
|
+
*
|
|
10
|
+
* Every box carries a brand property keyed by the registered symbol
|
|
11
|
+
* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
|
|
12
|
+
* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
|
|
13
|
+
* public shape still matches the platform's own `secrecy` type
|
|
14
|
+
* (pdp-control-plane).
|
|
15
|
+
*/
|
|
16
|
+
const REDACTED = "[REDACTED]";
|
|
17
|
+
const SECRET_BOX = blindCast(Symbol.for("prisma:secret-box"));
|
|
18
|
+
var SecretBox = class {
|
|
19
|
+
[SECRET_BOX] = true;
|
|
20
|
+
#value;
|
|
21
|
+
constructor(value) {
|
|
22
|
+
this.#value = value;
|
|
23
|
+
}
|
|
24
|
+
/** The sole explicit door to the wrapped value. */
|
|
25
|
+
expose() {
|
|
26
|
+
return this.#value;
|
|
27
|
+
}
|
|
28
|
+
toString() {
|
|
29
|
+
return REDACTED;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return REDACTED;
|
|
33
|
+
}
|
|
34
|
+
valueOf() {
|
|
35
|
+
return REDACTED;
|
|
36
|
+
}
|
|
37
|
+
[Symbol.toPrimitive]() {
|
|
38
|
+
return REDACTED;
|
|
39
|
+
}
|
|
40
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
41
|
+
return REDACTED;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* True for a redacting secret box — what a schema's secret leaf checks
|
|
46
|
+
* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
|
|
47
|
+
* duplicated module copy in a bundle counts and a look-alike does not.
|
|
48
|
+
*/
|
|
49
|
+
function isSecretString(value) {
|
|
50
|
+
return typeof value === "object" && value !== null && blindCast(value)[SECRET_BOX] === true;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { isSecretString as n, SecretBox as t };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=secret-DoWGmN7m-DO5Brq1Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-DoWGmN7m-DO5Brq1Y.mjs","names":["#value"],"sources":["../../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs"],"sourcesContent":["import { t as blindCast } from \"./casts-DpaahrlC.mjs\";\n//#region src/secret.ts\n/**\n* A value wrapper that redacts everywhere except the one explicit reader,\n* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a\n* sink must remember to check: `String(box)`, template interpolation,\n* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so\n* a secret can't leak through an accidental log or serialization.\n*\n* Every box carries a brand property keyed by the registered symbol\n* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A\n* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's\n* public shape still matches the platform's own `secrecy` type\n* (pdp-control-plane).\n*/\nconst REDACTED = \"[REDACTED]\";\nconst SECRET_BOX = blindCast(Symbol.for(\"prisma:secret-box\"));\nvar SecretBox = class {\n\t[SECRET_BOX] = true;\n\t#value;\n\tconstructor(value) {\n\t\tthis.#value = value;\n\t}\n\t/** The sole explicit door to the wrapped value. */\n\texpose() {\n\t\treturn this.#value;\n\t}\n\ttoString() {\n\t\treturn REDACTED;\n\t}\n\ttoJSON() {\n\t\treturn REDACTED;\n\t}\n\tvalueOf() {\n\t\treturn REDACTED;\n\t}\n\t[Symbol.toPrimitive]() {\n\t\treturn REDACTED;\n\t}\n\t[Symbol.for(\"nodejs.util.inspect.custom\")]() {\n\t\treturn REDACTED;\n\t}\n};\n/**\n* True for a redacting secret box — what a schema's secret leaf checks\n* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a\n* duplicated module copy in a bundle counts and a look-alike does not.\n*/\nfunction isSecretString(value) {\n\treturn typeof value === \"object\" && value !== null && blindCast(value)[SECRET_BOX] === true;\n}\n//#endregion\nexport { isSecretString as n, SecretBox as t };\n\n//# sourceMappingURL=secret-DoWGmN7m.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,WAAW;AACjB,MAAM,aAAa,UAAU,OAAO,IAAI,mBAAmB,CAAC;AAC5D,IAAI,YAAY,MAAM;CACrB,CAAC,cAAc;CACf;CACA,YAAY,OAAO;EAClB,KAAKA,SAAS;CACf;;CAEA,SAAS;EACR,OAAO,KAAKA;CACb;CACA,WAAW;EACV,OAAO;CACR;CACA,SAAS;EACR,OAAO;CACR;CACA,UAAU;EACT,OAAO;CACR;CACA,CAAC,OAAO,eAAe;EACtB,OAAO;CACR;CACA,CAAC,OAAO,IAAI,4BAA4B,KAAK;EAC5C,OAAO;CACR;AACD;;;;;;AAMA,SAAS,eAAe,OAAO;CAC9B,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,KAAK,CAAC,CAAC,gBAAgB;AACxF"}
|
package/dist/service-rpc.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./index-
|
|
1
|
+
import { L as RunnableServiceNode, M as ProvisionNeed, o as Contract, s as DependencyEnd } from "./graph-types-C3FOaaXm-C6_rGzfn.mjs";
|
|
2
|
+
import "./index-BQVrMGfe.mjs";
|
|
3
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
4
|
//#region ../../0-framework/2-authoring/service-rpc/dist/index.d.mts
|
|
5
5
|
//#region src/rpc.d.ts
|
|
@@ -14,6 +14,8 @@ declare function rpc<I extends StandardSchemaV1, O extends StandardSchemaV1>(m:
|
|
|
14
14
|
output: O;
|
|
15
15
|
}): (input: StandardSchemaV1.InferInput<I>) => Promise<StandardSchemaV1.InferOutput<O>>;
|
|
16
16
|
declare function rpc<C extends Contract<'rpc', RpcFns>>(contract: C): DependencyEnd<Client<C>, C>;
|
|
17
|
+
/** True iff `value` is an RPC-kind Contract (a function-map `__cmp`, dispatchable by serve()). */
|
|
18
|
+
declare function isRpcContract(value: unknown): value is Contract<'rpc', RpcFns>;
|
|
17
19
|
/** The typed client a consumer's `rpc(contract)` dependency hydrates to. */
|
|
18
20
|
type Client<C> = C extends Contract<string, infer Cmp> ? Cmp : never;
|
|
19
21
|
//#endregion
|
|
@@ -43,8 +45,16 @@ interface RpcHandlerContext {
|
|
|
43
45
|
readonly idempotencyKey: string | undefined;
|
|
44
46
|
}
|
|
45
47
|
type HandlerFor<Fn, LoadedDeps> = Fn extends ((input: infer I) => Promise<infer O>) ? (input: I, deps: LoadedDeps, ctx: RpcHandlerContext) => Promise<O> : never;
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The keys of `E` whose contract is an RPC contract. A service may expose
|
|
50
|
+
* non-rpc ports beside its rpc ones (e.g. a public HTTP surface whose
|
|
51
|
+
* contract carries connection config, not methods) — serve() has nothing to
|
|
52
|
+
* dispatch for those, so `Handlers<S>` must not demand a handler map for
|
|
53
|
+
* them. The runtime mirror is `methodTable`'s kind check.
|
|
54
|
+
*/
|
|
55
|
+
type RpcPortKeys<E> = { [P in keyof E]: E[P] extends Contract<'rpc', any> ? P : never; }[keyof E];
|
|
56
|
+
/** Every exposed RPC port's methods, turned into a handler map typed off S's own `expose` and `load()`. Non-rpc exposed ports are skipped. */
|
|
57
|
+
type Handlers<S extends AnyRunnable> = { [Port in RpcPortKeys<NonNullable<S['expose']>>]: { [M in keyof CmpOf<NonNullable<S['expose']>[Port]>]: HandlerFor<CmpOf<NonNullable<S['expose']>[Port]>[M], ReturnType<S['load']>>; }; };
|
|
48
58
|
/**
|
|
49
59
|
* Routes `POST /rpc/<method>`: checks the service key, requires an
|
|
50
60
|
* Idempotency-Key, single-flights/replays through `IdempotencyStore`, and —
|
|
@@ -57,5 +67,5 @@ type Handlers<S extends AnyRunnable> = { [Port in keyof NonNullable<S['expose']>
|
|
|
57
67
|
*/
|
|
58
68
|
declare function serve<S extends AnyRunnable, H extends Handlers<S>>(service: S, handlers: H): (req: Request) => Promise<Response>;
|
|
59
69
|
//#endregion
|
|
60
|
-
export { type Client, type Handlers, RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, type RpcHandlerContext, type Transport, contract, makeClient, perBindingToken, rpc, serve };
|
|
70
|
+
export { type Client, type Handlers, RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, type RpcHandlerContext, type Transport, contract, isRpcContract, makeClient, perBindingToken, rpc, serve };
|
|
61
71
|
//# sourceMappingURL=service-rpc.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-rpc.d.mts","names":[],"sources":["../../../0-framework/2-authoring/service-rpc/dist/index.d.mts"],"mappings":";;;;;;cAIc;;cAEA,uBAAuB;;KAEhC,SAAS,gBAAgB,eAAe;iBAC5B,IAAI,UAAU,kBAAkB,UAAU,kBAAkB;EAC3E,OAAO;EACP,QAAQ;KACL,OAAO,iBAAiB,WAAW,OAAO,QAAQ,iBAAiB,YAAY;iBACnE,IAAI,UAAU,gBAAgB,SAAS,UAAU,IAAI,cAAc,OAAO,IAAI;;
|
|
1
|
+
{"version":3,"file":"service-rpc.d.mts","names":[],"sources":["../../../0-framework/2-authoring/service-rpc/dist/index.d.mts"],"mappings":";;;;;;cAIc;;cAEA,uBAAuB;;KAEhC,SAAS,gBAAgB,eAAe;iBAC5B,IAAI,UAAU,kBAAkB,UAAU,kBAAkB;EAC3E,OAAO;EACP,QAAQ;KACL,OAAO,iBAAiB,WAAW,OAAO,QAAQ,iBAAiB,YAAY;iBACnE,IAAI,UAAU,gBAAgB,SAAS,UAAU,IAAI,cAAc,OAAO,IAAI;;iBAE9E,cAAc,iBAAiB,SAAS,gBAAgB;;KAEpE,OAAO,KAAK,UAAU,uBAAuB,OAAO;;;;;;;;KAQpD,aAAa,KAAK,YAAY,QAAQ;iBAC1B,WAAW,UAAU,gBAAgB,SAAS,UAAU,GAAG,aAAa;EACvF,QAAQ;EACR;IACE,OAAO;;;iBAGM,SAAS,YAAY,gBAAgB,eAAe,eAAe,KAAK,MAAM,gBAAgB;;;;cAIjG;KACT,cAAc;KACd,MAAM,KAAK,UAAU,uBAAuB,OAAO;;UAE9C;;WAEC;;KAEN,WAAW,IAAI,cAAc,aAAa,aAAa,MAAM,cAAc,OAAO,OAAO,GAAG,MAAM,YAAY,KAAK,sBAAsB,QAAQ;;;;;;;;KAQjJ,YAAY,QAAQ,WAAW,IAAI,EAAE,WAAW,uBAAuB,mBAAmB;;KAE1F,SAAS,UAAU,kBAAkB,QAAQ,YAAY,YAAY,mBAAmB,WAAW,MAAM,YAAY,aAAa,SAAS,WAAW,MAAM,YAAY,aAAa,OAAO,IAAI,WAAW;;;;;;;;;;;iBAW/L,MAAM,UAAU,aAAa,UAAU,SAAS,IAAI,SAAS,GAAG,UAAU,KAAK,KAAK,YAAY,QAAQ"}
|
package/dist/service-rpc.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as blindCast } from "./casts-
|
|
2
|
-
import { i as dependency, p as provisionNeed } from "./graph-
|
|
3
|
-
import {
|
|
1
|
+
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
+
import { i as dependency, p as provisionNeed } from "./graph-DgbALPDo-BEHF94BN.mjs";
|
|
3
|
+
import { c as string } from "./dist-BdvFDCLV.mjs";
|
|
4
4
|
//#region ../../0-framework/2-authoring/service-rpc/dist/index.mjs
|
|
5
5
|
/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */
|
|
6
6
|
const RETRY = {
|
|
@@ -108,6 +108,7 @@ function rpc(arg) {
|
|
|
108
108
|
required: arg
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
/** True iff `value` is an RPC-kind Contract (a function-map `__cmp`, dispatchable by serve()). */
|
|
111
112
|
function isRpcContract(value) {
|
|
112
113
|
return typeof value === "object" && value !== null && "kind" in value && value.kind === "rpc" && "__cmp" in value && "satisfies" in value;
|
|
113
114
|
}
|
|
@@ -268,6 +269,7 @@ const IDEMPOTENCY_KEY_HEADER = "Idempotency-Key";
|
|
|
268
269
|
function methodTable(expose, handlers) {
|
|
269
270
|
const table = /* @__PURE__ */ new Map();
|
|
270
271
|
for (const [port, contract] of Object.entries(expose)) {
|
|
272
|
+
if (!isRpcContract(contract)) continue;
|
|
271
273
|
const portHandlers = handlers[port] ?? {};
|
|
272
274
|
for (const [method, fn] of Object.entries(contract.__cmp)) {
|
|
273
275
|
if (table.has(method)) throw new Error(`serve(): method "${method}" is exposed by more than one port — RPC dispatch is flat (POST /rpc/<method>), so method names must be unique across a service's exposed ports.`);
|
|
@@ -348,6 +350,6 @@ function serve(service, handlers) {
|
|
|
348
350
|
};
|
|
349
351
|
}
|
|
350
352
|
//#endregion
|
|
351
|
-
export { RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, contract, makeClient, perBindingToken, rpc, serve };
|
|
353
|
+
export { RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, contract, isRpcContract, makeClient, perBindingToken, rpc, serve };
|
|
352
354
|
|
|
353
355
|
//# sourceMappingURL=service-rpc.mjs.map
|
package/dist/service-rpc.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-rpc.mjs","names":[],"sources":["../../../0-framework/2-authoring/service-rpc/dist/index.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\nimport { dependency, provisionNeed, string } from \"@internal/core\";\n//#region src/client.ts\n/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */\nconst RETRY = {\n\tinitialDelayMs: 250,\n\tmultiplier: 2,\n\tmaxDelayMs: 5e3,\n\tmaxRetries: 5\n};\nconst IDEMPOTENCY_KEY_HEADER$1 = \"Idempotency-Key\";\nfunction sleep(ms) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n/** Whether a non-OK response is safe to retry: 429 or any 5xx, never another 4xx. */\nfunction isRetryableStatus(status) {\n\treturn status === 429 || status >= 500;\n}\n/** The server's `{ error }` body, if the response has one — undefined otherwise. */\nasync function errorDetail(res) {\n\ttry {\n\t\tconst body = await res.json();\n\t\treturn typeof body === \"object\" && body !== null && \"error\" in body ? String(body.error) : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\n/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */\nfunction methodUrl(base, method) {\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\treturn new URL(`rpc/${method}`, normalizedBase).toString();\n}\n/**\n* Sends one call over `send`, retrying a thrown error, 429, or 5xx with\n* full-jitter backoff. `buildRequest` runs per attempt but carries the same\n* idempotency key each time — only the transport call repeats, not the key.\n*/\nasync function callWithRetry(send, buildRequest, method) {\n\tlet delay = RETRY.initialDelayMs;\n\tlet retries = 0;\n\tfor (;;) {\n\t\tlet res;\n\t\ttry {\n\t\t\tres = await send(buildRequest());\n\t\t} catch (err) {\n\t\t\tif (retries >= RETRY.maxRetries) throw err;\n\t\t\tretries += 1;\n\t\t\tawait sleep(Math.random() * delay);\n\t\t\tdelay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);\n\t\t\tcontinue;\n\t\t}\n\t\tif (res.ok) return res.json();\n\t\tif (!isRetryableStatus(res.status) || retries >= RETRY.maxRetries) {\n\t\t\tconst detail = await errorDetail(res);\n\t\t\tthrow new Error(`RPC call \"${method}\" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : \"\"));\n\t\t}\n\t\tretries += 1;\n\t\tawait sleep(Math.random() * delay);\n\t\tdelay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);\n\t}\n}\nfunction makeClient(contract, url, opts) {\n\tconst send = opts?.fetch ?? fetch;\n\tconst baseHeaders = { \"content-type\": \"application/json\" };\n\tif (opts?.serviceKey !== void 0) baseHeaders[\"Authorization\"] = `Bearer ${opts.serviceKey}`;\n\tconst client = {};\n\tfor (const method of Object.keys(contract.__cmp)) client[method] = async (input) => {\n\t\tconst idempotencyKey = crypto.randomUUID();\n\t\tconst body = JSON.stringify(input);\n\t\treturn callWithRetry(send, () => new Request(methodUrl(url, method), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t...baseHeaders,\n\t\t\t\t[IDEMPOTENCY_KEY_HEADER$1]: idempotencyKey\n\t\t\t},\n\t\t\tbody\n\t\t}), method);\n\t};\n\treturn blindCast(client);\n}\n//#endregion\n//#region src/contract.ts\nfunction contract(fns) {\n\tconst value = {\n\t\tkind: \"rpc\",\n\t\t__cmp: fns,\n\t\tsatisfies: (required) => value === required\n\t};\n\treturn Object.freeze(value);\n}\n//#endregion\n//#region src/rpc.ts\n/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */\nconst RPC_PEER_KEY = Symbol.for(\"prisma:rpc/per-binding-key\");\n/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */\nconst perBindingToken = () => provisionNeed(RPC_PEER_KEY);\nfunction rpc(arg) {\n\tif (!isRpcContract(arg)) return arg;\n\treturn dependency({\n\t\ttype: \"rpc\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tserviceKey: string({\n\t\t\t\t\toptional: true,\n\t\t\t\t\tprovision: perBindingToken()\n\t\t\t\t})\n\t\t\t},\n\t\t\thydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })\n\t\t},\n\t\trequired: arg\n\t});\n}\nfunction isRpcContract(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value && value.kind === \"rpc\" && \"__cmp\" in value && \"satisfies\" in value;\n}\n//#endregion\n//#region src/standard-schema.ts\nasync function standardValidate(schema, value) {\n\tconst result = await schema[\"~standard\"].validate(value);\n\tif (result.issues !== void 0) throw new Error(`Schema validation failed: ${result.issues.map((issue) => issue.message).join(\"; \")}`);\n\treturn result.value;\n}\n//#endregion\n//#region src/serve.ts\n/** The reserved env var the target (slice 2) writes the accepted key set to. */\nconst RPC_ACCEPTED_KEYS_ENV = \"COMPOSER_RPC_ACCEPTED_KEYS\";\nfunction outcome(body, status = 200) {\n\treturn {\n\t\tstatus,\n\t\tbodyText: JSON.stringify(body)\n\t};\n}\nfunction toResponse(o) {\n\treturn new Response(o.bodyText, {\n\t\tstatus: o.status,\n\t\theaders: { \"content-type\": \"application/json\" }\n\t});\n}\n/** The generic message every caller-facing 500 carries — the real error goes to `console.error` instead. */\nconst INTERNAL_ERROR_MESSAGE = \"Internal server error\";\n/** Request body cap. Internal RPC payloads are small records, not uploads; 1 MiB bounds a slow request's memory. */\nconst MAX_BODY_BYTES = 1048576;\nvar RequestBodyTooLargeError = class extends Error {};\n/** Reads the body as text, aborting past `maxBytes` of bytes actually read — `content-length` is caller-supplied, so untrusted. */\nasync function readBoundedBody(req, maxBytes) {\n\tconst reader = req.body?.getReader();\n\tif (reader === void 0) return \"\";\n\tconst decoder = new TextDecoder();\n\tlet text = \"\";\n\tlet total = 0;\n\tfor (;;) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\ttotal += value.byteLength;\n\t\tif (total > maxBytes) {\n\t\t\tawait reader.cancel();\n\t\t\tthrow new RequestBodyTooLargeError();\n\t\t}\n\t\ttext += decoder.decode(value, { stream: true });\n\t}\n\ttext += decoder.decode();\n\treturn text;\n}\n/** How long a completed 2xx/4xx answer stays replayable for a repeated key. */\nconst REPLAY_TTL_MS = 6e4;\n/**\n* Per-method, per-key deduplication. A duplicate arriving mid-execution\n* single-flights onto the same promise; a completed 2xx/4xx replays for\n* REPLAY_TTL_MS; a 5xx is never kept, since that is what a retry re-executes.\n* Keyed by method first, so a replay can never answer a different method.\n*/\nvar IdempotencyStore = class {\n\tbyMethod = /* @__PURE__ */ new Map();\n\tlru = /* @__PURE__ */ new Set();\n\tasync dispatch(method, key, run) {\n\t\tconst bucket = this.bucketFor(method);\n\t\tconst existing = bucket.get(key);\n\t\tif (existing?.kind === \"pending\") return existing.promise;\n\t\tif (existing?.kind === \"completed\") {\n\t\t\tif (Date.now() - existing.completedAt < REPLAY_TTL_MS) {\n\t\t\t\tthis.lru.delete(existing);\n\t\t\t\tthis.lru.add(existing);\n\t\t\t\treturn existing.outcome;\n\t\t\t}\n\t\t\tbucket.delete(key);\n\t\t\tthis.lru.delete(existing);\n\t\t}\n\t\tconst promise = run();\n\t\tbucket.set(key, {\n\t\t\tkind: \"pending\",\n\t\t\tpromise\n\t\t});\n\t\tlet result;\n\t\ttry {\n\t\t\tresult = await promise;\n\t\t} catch (err) {\n\t\t\tbucket.delete(key);\n\t\t\tthrow err;\n\t\t}\n\t\tif (result.status >= 500) bucket.delete(key);\n\t\telse {\n\t\t\tconst entry = {\n\t\t\t\tkind: \"completed\",\n\t\t\t\toutcome: result,\n\t\t\t\tcompletedAt: Date.now(),\n\t\t\t\tmethod,\n\t\t\t\tkey\n\t\t\t};\n\t\t\tbucket.set(key, entry);\n\t\t\tthis.lru.add(entry);\n\t\t\tthis.evictOverflow();\n\t\t}\n\t\treturn result;\n\t}\n\tbucketFor(method) {\n\t\tlet bucket = this.byMethod.get(method);\n\t\tif (bucket === void 0) {\n\t\t\tbucket = /* @__PURE__ */ new Map();\n\t\t\tthis.byMethod.set(method, bucket);\n\t\t}\n\t\treturn bucket;\n\t}\n\tevictOverflow() {\n\t\tif (this.lru.size <= 1e3) return;\n\t\tconst oldest = this.lru.values().next().value;\n\t\tif (oldest !== void 0) {\n\t\t\tthis.lru.delete(oldest);\n\t\t\tthis.byMethod.get(oldest.method)?.delete(oldest.key);\n\t\t}\n\t}\n};\n/** The provisioned accepted key set, or undefined when the deploy never provisioned one (local/test — enforcement off). */\nfunction acceptedKeys() {\n\tconst raw = process.env[RPC_ACCEPTED_KEYS_ENV];\n\tif (raw === void 0 || raw === \"\") return void 0;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn [];\n\t}\n\treturn Array.isArray(parsed) && parsed.every((key) => typeof key === \"string\") ? parsed : [];\n}\n/**\n* Length-independent constant-time string equality — no early exit on the\n* first mismatched character or on a length difference, so a caller cannot\n* time its way toward a valid key. No `node:crypto`, to keep this module\n* runtime-agnostic.\n*/\nfunction constantTimeEquals(a, b) {\n\tconst length = Math.max(a.length, b.length);\n\tlet diff = a.length ^ b.length;\n\tfor (let i = 0; i < length; i++) diff |= (i < a.length ? a.charCodeAt(i) : 0) ^ (i < b.length ? b.charCodeAt(i) : 0);\n\treturn diff === 0;\n}\n/** Whether `presented` is a member of `accepted` — always compares against every key. */\nfunction isAcceptedKey(presented, accepted) {\n\tlet matched = false;\n\tfor (const key of accepted) matched = constantTimeEquals(presented, key) || matched;\n\treturn matched;\n}\nconst BEARER_PREFIX = \"Bearer \";\n/** The bearer token on `Authorization`, or `''` if the header is missing or malformed. */\nfunction bearerToken(req) {\n\tconst header = req.headers.get(\"authorization\");\n\treturn header?.startsWith(BEARER_PREFIX) ? header.slice(7) : \"\";\n}\nconst IDEMPOTENCY_KEY_HEADER = \"Idempotency-Key\";\n/**\n* Flattens every exposed port's methods into one method → {schemas, handler}\n* table. RPC dispatch is flat (`/rpc/<method>`), so a method name exposed by\n* more than one port is a construction-time error, as is a missing handler.\n*/\nfunction methodTable(expose, handlers) {\n\tconst table = /* @__PURE__ */ new Map();\n\tfor (const [port, contract] of Object.entries(expose)) {\n\t\tconst portHandlers = handlers[port] ?? {};\n\t\tfor (const [method, fn] of Object.entries(contract.__cmp)) {\n\t\t\tif (table.has(method)) throw new Error(`serve(): method \"${method}\" is exposed by more than one port — RPC dispatch is flat (POST /rpc/<method>), so method names must be unique across a service's exposed ports.`);\n\t\t\tconst handler = portHandlers[method];\n\t\t\tif (handler === void 0) throw new Error(`serve(): no handler supplied for exposed method \"${port}.${method}\".`);\n\t\t\tconst { input, output } = blindCast(fn);\n\t\t\ttable.set(method, {\n\t\t\t\tinput,\n\t\t\t\toutput,\n\t\t\t\thandler\n\t\t\t});\n\t\t}\n\t}\n\treturn table;\n}\n/**\n* Routes `POST /rpc/<method>`: checks the service key, requires an\n* Idempotency-Key, single-flights/replays through `IdempotencyStore`, and —\n* per call — parses JSON within the body cap, validates input, calls the\n* handler with `service.load()`'s deps plus `{ idempotencyKey }`, validates\n* the output, and responds JSON. A handler or output-validation failure\n* masks its message behind a generic 500 and logs the real error; an\n* unknown method or invalid input is a 4xx. `load()` is called exactly\n* once, here, before the handler ever runs.\n*/\nfunction serve(service, handlers) {\n\tconst table = methodTable(service.expose ?? {}, blindCast(handlers));\n\tconst deps = service.load();\n\tconst idempotency = new IdempotencyStore();\n\treturn async (req) => {\n\t\tconst accepted = acceptedKeys();\n\t\tif (accepted !== void 0 && !isAcceptedKey(bearerToken(req), accepted)) return toResponse(outcome({ error: \"Unauthorized: missing or invalid service key\" }, 401));\n\t\tconst { pathname } = new URL(req.url);\n\t\tconst methodName = /^\\/rpc\\/([^/]+)$/.exec(pathname)?.[1];\n\t\tif (methodName === void 0) return toResponse(outcome({ error: `Not found: ${pathname}` }, 404));\n\t\tconst method = table.get(methodName);\n\t\tif (method === void 0) return toResponse(outcome({ error: `Unknown RPC method \"${methodName}\"` }, 404));\n\t\tif (req.method !== \"POST\") return toResponse(outcome({ error: `Method \"${methodName}\" requires POST` }, 405));\n\t\tconst idempotencyKey = req.headers.get(IDEMPOTENCY_KEY_HEADER.toLowerCase()) || void 0;\n\t\tconst ctx = { idempotencyKey };\n\t\tconst run = async () => {\n\t\t\tlet bodyText;\n\t\t\ttry {\n\t\t\t\tbodyText = await readBoundedBody(req, MAX_BODY_BYTES);\n\t\t\t} catch (err) {\n\t\t\t\tif (err instanceof RequestBodyTooLargeError) return outcome({ error: `Request body exceeds the ${MAX_BODY_BYTES}-byte limit` }, 413);\n\t\t\t\tconsole.error(`serve(): reading the request body for \"${methodName}\" failed:`, err);\n\t\t\t\treturn outcome({ error: INTERNAL_ERROR_MESSAGE }, 500);\n\t\t\t}\n\t\t\tlet body;\n\t\t\ttry {\n\t\t\t\tbody = JSON.parse(bodyText);\n\t\t\t} catch {\n\t\t\t\treturn outcome({ error: \"Request body must be JSON\" }, 400);\n\t\t\t}\n\t\t\tlet input;\n\t\t\ttry {\n\t\t\t\tinput = await standardValidate(method.input, body);\n\t\t\t} catch (err) {\n\t\t\t\treturn outcome({ error: err instanceof Error ? err.message : String(err) }, 400);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await method.handler(input, deps, ctx);\n\t\t\t\tlet output;\n\t\t\t\ttry {\n\t\t\t\t\toutput = await standardValidate(method.output, result);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`serve(): handler for \"${methodName}\" returned output that failed schema validation — this is a provider bug:`, err);\n\t\t\t\t\treturn outcome({ error: INTERNAL_ERROR_MESSAGE }, 500);\n\t\t\t\t}\n\t\t\t\treturn outcome(output);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`serve(): handler for \"${methodName}\" threw:`, err);\n\t\t\t\treturn outcome({ error: INTERNAL_ERROR_MESSAGE }, 500);\n\t\t\t}\n\t\t};\n\t\treturn toResponse(idempotencyKey === void 0 ? await run() : await idempotency.dispatch(methodName, idempotencyKey, run));\n\t};\n}\n//#endregion\nexport { RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, contract, makeClient, perBindingToken, rpc, serve };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;AAIA,MAAM,QAAQ;CACb,gBAAgB;CAChB,YAAY;CACZ,YAAY;CACZ,YAAY;AACb;AACA,MAAM,2BAA2B;AACjC,SAAS,MAAM,IAAI;CAClB,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACxD;;AAEA,SAAS,kBAAkB,QAAQ;CAClC,OAAO,WAAW,OAAO,UAAU;AACpC;;AAEA,eAAe,YAAY,KAAK;CAC/B,IAAI;EACH,MAAM,OAAO,MAAM,IAAI,KAAK;EAC5B,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,OAAO,OAAO,KAAK,KAAK,IAAI,KAAK;CACjG,QAAQ;EACP;CACD;AACD;;AAEA,SAAS,UAAU,MAAM,QAAQ;CAChC,MAAM,iBAAiB,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,KAAK;CAC3D,OAAO,IAAI,IAAI,OAAO,UAAU,cAAc,CAAC,CAAC,SAAS;AAC1D;;;;;;AAMA,eAAe,cAAc,MAAM,cAAc,QAAQ;CACxD,IAAI,QAAQ,MAAM;CAClB,I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AyB,WAAW,WAAW,GAAG;IAChE,OAAO,QAAQ,EAAE,OAAO,uBAAuB,GAAG,GAAG;GACtD;EACD;EACA,OAAO,WAAW,mBAAmB,KAAK,IAAI,MAAM,IAAI,IAAI,MAAM,YAAY,SAAS,YAAY,gBAAgB,GAAG,CAAC;CACxH;AACD"}
|
|
1
|
+
{"version":3,"file":"service-rpc.mjs","names":[],"sources":["../../../0-framework/2-authoring/service-rpc/dist/index.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\nimport { dependency, provisionNeed, string } from \"@internal/core\";\n//#region src/client.ts\n/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */\nconst RETRY = {\n\tinitialDelayMs: 250,\n\tmultiplier: 2,\n\tmaxDelayMs: 5e3,\n\tmaxRetries: 5\n};\nconst IDEMPOTENCY_KEY_HEADER$1 = \"Idempotency-Key\";\nfunction sleep(ms) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n/** Whether a non-OK response is safe to retry: 429 or any 5xx, never another 4xx. */\nfunction isRetryableStatus(status) {\n\treturn status === 429 || status >= 500;\n}\n/** The server's `{ error }` body, if the response has one — undefined otherwise. */\nasync function errorDetail(res) {\n\ttry {\n\t\tconst body = await res.json();\n\t\treturn typeof body === \"object\" && body !== null && \"error\" in body ? String(body.error) : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\n/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */\nfunction methodUrl(base, method) {\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\treturn new URL(`rpc/${method}`, normalizedBase).toString();\n}\n/**\n* Sends one call over `send`, retrying a thrown error, 429, or 5xx with\n* full-jitter backoff. `buildRequest` runs per attempt but carries the same\n* idempotency key each time — only the transport call repeats, not the key.\n*/\nasync function callWithRetry(send, buildRequest, method) {\n\tlet delay = RETRY.initialDelayMs;\n\tlet retries = 0;\n\tfor (;;) {\n\t\tlet res;\n\t\ttry {\n\t\t\tres = await send(buildRequest());\n\t\t} catch (err) {\n\t\t\tif (retries >= RETRY.maxRetries) throw err;\n\t\t\tretries += 1;\n\t\t\tawait sleep(Math.random() * delay);\n\t\t\tdelay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);\n\t\t\tcontinue;\n\t\t}\n\t\tif (res.ok) return res.json();\n\t\tif (!isRetryableStatus(res.status) || retries >= RETRY.maxRetries) {\n\t\t\tconst detail = await errorDetail(res);\n\t\t\tthrow new Error(`RPC call \"${method}\" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : \"\"));\n\t\t}\n\t\tretries += 1;\n\t\tawait sleep(Math.random() * delay);\n\t\tdelay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);\n\t}\n}\nfunction makeClient(contract, url, opts) {\n\tconst send = opts?.fetch ?? fetch;\n\tconst baseHeaders = { \"content-type\": \"application/json\" };\n\tif (opts?.serviceKey !== void 0) baseHeaders[\"Authorization\"] = `Bearer ${opts.serviceKey}`;\n\tconst client = {};\n\tfor (const method of Object.keys(contract.__cmp)) client[method] = async (input) => {\n\t\tconst idempotencyKey = crypto.randomUUID();\n\t\tconst body = JSON.stringify(input);\n\t\treturn callWithRetry(send, () => new Request(methodUrl(url, method), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t...baseHeaders,\n\t\t\t\t[IDEMPOTENCY_KEY_HEADER$1]: idempotencyKey\n\t\t\t},\n\t\t\tbody\n\t\t}), method);\n\t};\n\treturn blindCast(client);\n}\n//#endregion\n//#region src/contract.ts\nfunction contract(fns) {\n\tconst value = {\n\t\tkind: \"rpc\",\n\t\t__cmp: fns,\n\t\tsatisfies: (required) => value === required\n\t};\n\treturn Object.freeze(value);\n}\n//#endregion\n//#region src/rpc.ts\n/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */\nconst RPC_PEER_KEY = Symbol.for(\"prisma:rpc/per-binding-key\");\n/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */\nconst perBindingToken = () => provisionNeed(RPC_PEER_KEY);\nfunction rpc(arg) {\n\tif (!isRpcContract(arg)) return arg;\n\treturn dependency({\n\t\ttype: \"rpc\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tserviceKey: string({\n\t\t\t\t\toptional: true,\n\t\t\t\t\tprovision: perBindingToken()\n\t\t\t\t})\n\t\t\t},\n\t\t\thydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })\n\t\t},\n\t\trequired: arg\n\t});\n}\n/** True iff `value` is an RPC-kind Contract (a function-map `__cmp`, dispatchable by serve()). */\nfunction isRpcContract(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value && value.kind === \"rpc\" && \"__cmp\" in value && \"satisfies\" in value;\n}\n//#endregion\n//#region src/standard-schema.ts\nasync function standardValidate(schema, value) {\n\tconst result = await schema[\"~standard\"].validate(value);\n\tif (result.issues !== void 0) throw new Error(`Schema validation failed: ${result.issues.map((issue) => issue.message).join(\"; \")}`);\n\treturn result.value;\n}\n//#endregion\n//#region src/serve.ts\n/** The reserved env var the target (slice 2) writes the accepted key set to. */\nconst RPC_ACCEPTED_KEYS_ENV = \"COMPOSER_RPC_ACCEPTED_KEYS\";\nfunction outcome(body, status = 200) {\n\treturn {\n\t\tstatus,\n\t\tbodyText: JSON.stringify(body)\n\t};\n}\nfunction toResponse(o) {\n\treturn new Response(o.bodyText, {\n\t\tstatus: o.status,\n\t\theaders: { \"content-type\": \"application/json\" }\n\t});\n}\n/** The generic message every caller-facing 500 carries — the real error goes to `console.error` instead. */\nconst INTERNAL_ERROR_MESSAGE = \"Internal server error\";\n/** Request body cap. Internal RPC payloads are small records, not uploads; 1 MiB bounds a slow request's memory. */\nconst MAX_BODY_BYTES = 1048576;\nvar RequestBodyTooLargeError = class extends Error {};\n/** Reads the body as text, aborting past `maxBytes` of bytes actually read — `content-length` is caller-supplied, so untrusted. */\nasync function readBoundedBody(req, maxBytes) {\n\tconst reader = req.body?.getReader();\n\tif (reader === void 0) return \"\";\n\tconst decoder = new TextDecoder();\n\tlet text = \"\";\n\tlet total = 0;\n\tfor (;;) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\ttotal += value.byteLength;\n\t\tif (total > maxBytes) {\n\t\t\tawait reader.cancel();\n\t\t\tthrow new RequestBodyTooLargeError();\n\t\t}\n\t\ttext += decoder.decode(value, { stream: true });\n\t}\n\ttext += decoder.decode();\n\treturn text;\n}\n/** How long a completed 2xx/4xx answer stays replayable for a repeated key. */\nconst REPLAY_TTL_MS = 6e4;\n/**\n* Per-method, per-key deduplication. A duplicate arriving mid-execution\n* single-flights onto the same promise; a completed 2xx/4xx replays for\n* REPLAY_TTL_MS; a 5xx is never kept, since that is what a retry re-executes.\n* Keyed by method first, so a replay can never answer a different method.\n*/\nvar IdempotencyStore = class {\n\tbyMethod = /* @__PURE__ */ new Map();\n\tlru = /* @__PURE__ */ new Set();\n\tasync dispatch(method, key, run) {\n\t\tconst bucket = this.bucketFor(method);\n\t\tconst existing = bucket.get(key);\n\t\tif (existing?.kind === \"pending\") return existing.promise;\n\t\tif (existing?.kind === \"completed\") {\n\t\t\tif (Date.now() - existing.completedAt < REPLAY_TTL_MS) {\n\t\t\t\tthis.lru.delete(existing);\n\t\t\t\tthis.lru.add(existing);\n\t\t\t\treturn existing.outcome;\n\t\t\t}\n\t\t\tbucket.delete(key);\n\t\t\tthis.lru.delete(existing);\n\t\t}\n\t\tconst promise = run();\n\t\tbucket.set(key, {\n\t\t\tkind: \"pending\",\n\t\t\tpromise\n\t\t});\n\t\tlet result;\n\t\ttry {\n\t\t\tresult = await promise;\n\t\t} catch (err) {\n\t\t\tbucket.delete(key);\n\t\t\tthrow err;\n\t\t}\n\t\tif (result.status >= 500) bucket.delete(key);\n\t\telse {\n\t\t\tconst entry = {\n\t\t\t\tkind: \"completed\",\n\t\t\t\toutcome: result,\n\t\t\t\tcompletedAt: Date.now(),\n\t\t\t\tmethod,\n\t\t\t\tkey\n\t\t\t};\n\t\t\tbucket.set(key, entry);\n\t\t\tthis.lru.add(entry);\n\t\t\tthis.evictOverflow();\n\t\t}\n\t\treturn result;\n\t}\n\tbucketFor(method) {\n\t\tlet bucket = this.byMethod.get(method);\n\t\tif (bucket === void 0) {\n\t\t\tbucket = /* @__PURE__ */ new Map();\n\t\t\tthis.byMethod.set(method, bucket);\n\t\t}\n\t\treturn bucket;\n\t}\n\tevictOverflow() {\n\t\tif (this.lru.size <= 1e3) return;\n\t\tconst oldest = this.lru.values().next().value;\n\t\tif (oldest !== void 0) {\n\t\t\tthis.lru.delete(oldest);\n\t\t\tthis.byMethod.get(oldest.method)?.delete(oldest.key);\n\t\t}\n\t}\n};\n/** The provisioned accepted key set, or undefined when the deploy never provisioned one (local/test — enforcement off). */\nfunction acceptedKeys() {\n\tconst raw = process.env[RPC_ACCEPTED_KEYS_ENV];\n\tif (raw === void 0 || raw === \"\") return void 0;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn [];\n\t}\n\treturn Array.isArray(parsed) && parsed.every((key) => typeof key === \"string\") ? parsed : [];\n}\n/**\n* Length-independent constant-time string equality — no early exit on the\n* first mismatched character or on a length difference, so a caller cannot\n* time its way toward a valid key. No `node:crypto`, to keep this module\n* runtime-agnostic.\n*/\nfunction constantTimeEquals(a, b) {\n\tconst length = Math.max(a.length, b.length);\n\tlet diff = a.length ^ b.length;\n\tfor (let i = 0; i < length; i++) diff |= (i < a.length ? a.charCodeAt(i) : 0) ^ (i < b.length ? b.charCodeAt(i) : 0);\n\treturn diff === 0;\n}\n/** Whether `presented` is a member of `accepted` — always compares against every key. */\nfunction isAcceptedKey(presented, accepted) {\n\tlet matched = false;\n\tfor (const key of accepted) matched = constantTimeEquals(presented, key) || matched;\n\treturn matched;\n}\nconst BEARER_PREFIX = \"Bearer \";\n/** The bearer token on `Authorization`, or `''` if the header is missing or malformed. */\nfunction bearerToken(req) {\n\tconst header = req.headers.get(\"authorization\");\n\treturn header?.startsWith(BEARER_PREFIX) ? header.slice(7) : \"\";\n}\nconst IDEMPOTENCY_KEY_HEADER = \"Idempotency-Key\";\n/**\n* Flattens every exposed port's methods into one method → {schemas, handler}\n* table. RPC dispatch is flat (`/rpc/<method>`), so a method name exposed by\n* more than one port is a construction-time error, as is a missing handler.\n*/\nfunction methodTable(expose, handlers) {\n\tconst table = /* @__PURE__ */ new Map();\n\tfor (const [port, contract] of Object.entries(expose)) {\n\t\tif (!isRpcContract(contract)) continue;\n\t\tconst portHandlers = handlers[port] ?? {};\n\t\tfor (const [method, fn] of Object.entries(contract.__cmp)) {\n\t\t\tif (table.has(method)) throw new Error(`serve(): method \"${method}\" is exposed by more than one port — RPC dispatch is flat (POST /rpc/<method>), so method names must be unique across a service's exposed ports.`);\n\t\t\tconst handler = portHandlers[method];\n\t\t\tif (handler === void 0) throw new Error(`serve(): no handler supplied for exposed method \"${port}.${method}\".`);\n\t\t\tconst { input, output } = blindCast(fn);\n\t\t\ttable.set(method, {\n\t\t\t\tinput,\n\t\t\t\toutput,\n\t\t\t\thandler\n\t\t\t});\n\t\t}\n\t}\n\treturn table;\n}\n/**\n* Routes `POST /rpc/<method>`: checks the service key, requires an\n* Idempotency-Key, single-flights/replays through `IdempotencyStore`, and —\n* per call — parses JSON within the body cap, validates input, calls the\n* handler with `service.load()`'s deps plus `{ idempotencyKey }`, validates\n* the output, and responds JSON. A handler or output-validation failure\n* masks its message behind a generic 500 and logs the real error; an\n* unknown method or invalid input is a 4xx. `load()` is called exactly\n* once, here, before the handler ever runs.\n*/\nfunction serve(service, handlers) {\n\tconst table = methodTable(service.expose ?? {}, blindCast(handlers));\n\tconst deps = service.load();\n\tconst idempotency = new IdempotencyStore();\n\treturn async (req) => {\n\t\tconst accepted = acceptedKeys();\n\t\tif (accepted !== void 0 && !isAcceptedKey(bearerToken(req), accepted)) return toResponse(outcome({ error: \"Unauthorized: missing or invalid service key\" }, 401));\n\t\tconst { pathname } = new URL(req.url);\n\t\tconst methodName = /^\\/rpc\\/([^/]+)$/.exec(pathname)?.[1];\n\t\tif (methodName === void 0) return toResponse(outcome({ error: `Not found: ${pathname}` }, 404));\n\t\tconst method = table.get(methodName);\n\t\tif (method === void 0) return toResponse(outcome({ error: `Unknown RPC method \"${methodName}\"` }, 404));\n\t\tif (req.method !== \"POST\") return toResponse(outcome({ error: `Method \"${methodName}\" requires POST` }, 405));\n\t\tconst idempotencyKey = req.headers.get(IDEMPOTENCY_KEY_HEADER.toLowerCase()) || void 0;\n\t\tconst ctx = { idempotencyKey };\n\t\tconst run = async () => {\n\t\t\tlet bodyText;\n\t\t\ttry {\n\t\t\t\tbodyText = await readBoundedBody(req, MAX_BODY_BYTES);\n\t\t\t} catch (err) {\n\t\t\t\tif (err instanceof RequestBodyTooLargeError) return outcome({ error: `Request body exceeds the ${MAX_BODY_BYTES}-byte limit` }, 413);\n\t\t\t\tconsole.error(`serve(): reading the request body for \"${methodName}\" failed:`, err);\n\t\t\t\treturn outcome({ error: INTERNAL_ERROR_MESSAGE }, 500);\n\t\t\t}\n\t\t\tlet body;\n\t\t\ttry {\n\t\t\t\tbody = JSON.parse(bodyText);\n\t\t\t} catch {\n\t\t\t\treturn outcome({ error: \"Request body must be JSON\" }, 400);\n\t\t\t}\n\t\t\tlet input;\n\t\t\ttry {\n\t\t\t\tinput = await standardValidate(method.input, body);\n\t\t\t} catch (err) {\n\t\t\t\treturn outcome({ error: err instanceof Error ? err.message : String(err) }, 400);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await method.handler(input, deps, ctx);\n\t\t\t\tlet output;\n\t\t\t\ttry {\n\t\t\t\t\toutput = await standardValidate(method.output, result);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`serve(): handler for \"${methodName}\" returned output that failed schema validation — this is a provider bug:`, err);\n\t\t\t\t\treturn outcome({ error: INTERNAL_ERROR_MESSAGE }, 500);\n\t\t\t\t}\n\t\t\t\treturn outcome(output);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`serve(): handler for \"${methodName}\" threw:`, err);\n\t\t\t\treturn outcome({ error: INTERNAL_ERROR_MESSAGE }, 500);\n\t\t\t}\n\t\t};\n\t\treturn toResponse(idempotencyKey === void 0 ? await run() : await idempotency.dispatch(methodName, idempotencyKey, run));\n\t};\n}\n//#endregion\nexport { RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, contract, isRpcContract, makeClient, perBindingToken, rpc, serve };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;AAIA,MAAM,QAAQ;CACb,gBAAgB;CAChB,YAAY;CACZ,YAAY;CACZ,YAAY;AACb;AACA,MAAM,2BAA2B;AACjC,SAAS,MAAM,IAAI;CAClB,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACxD;;AAEA,SAAS,kBAAkB,QAAQ;CAClC,OAAO,WAAW,OAAO,UAAU;AACpC;;AAEA,eAAe,YAAY,KAAK;CAC/B,IAAI;EACH,MAAM,OAAO,MAAM,IAAI,KAAK;EAC5B,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,OAAO,OAAO,KAAK,KAAK,IAAI,KAAK;CACjG,QAAQ;EACP;CACD;AACD;;AAEA,SAAS,UAAU,MAAM,QAAQ;CAChC,MAAM,iBAAiB,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,KAAK;CAC3D,OAAO,IAAI,IAAI,OAAO,UAAU,cAAc,CAAC,CAAC,SAAS;AAC1D;;;;;;AAMA,eAAe,cAAc,MAAM,cAAc,QAAQ;CACxD,IAAI,QAAQ,MAAM;CAClB,IAAI,UAAU;CACd,SAAS;EACR,IAAI;EACJ,IAAI;GACH,MAAM,MAAM,KAAK,aAAa,CAAC;EAChC,SAAS,KAAK;GACb,IAAI,WAAW,MAAM,YAAY,MAAM;GACvC,WAAW;GACX,MAAM,MAAM,KAAK,OAAO,IAAI,KAAK;GACjC,QAA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AAS,YAAY,gBAAgB,GAAG,CAAC;CACxH;AACD"}
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as RunnableServiceNode, c as Deps, j as Params, m as HydratedDeps, u as Expose } from "./graph-types-C3FOaaXm-C6_rGzfn.mjs";
|
|
2
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
3
|
//#region ../../0-framework/1-core/core/dist/testing.d.mts
|
|
3
4
|
//#region src/testing.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* `mockService`'s override argument: every declared dependency, typed against
|
|
6
7
|
* its own hydrated shape (`Client<C>` for an RPC dep, the resource binding
|
|
7
|
-
* for a resource dep) — a double of the wrong shape is a compile error
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* for a resource dep) — a double of the wrong shape is a compile error — plus
|
|
9
|
+
* `input`, the already-validated input object, required exactly when the
|
|
10
|
+
* service declares an input schema (ADR-0042). A dependency literally named
|
|
11
|
+
* "input" shadows the input override — rename the dependency.
|
|
10
12
|
*/
|
|
11
|
-
type LoadOverrides<D extends Deps,
|
|
13
|
+
type LoadOverrides<D extends Deps, I extends StandardSchemaV1 | undefined> = HydratedDeps<D> & (I extends StandardSchemaV1 ? {
|
|
14
|
+
input: StandardSchemaV1.InferOutput<I>;
|
|
15
|
+
} : {
|
|
16
|
+
input?: never;
|
|
17
|
+
});
|
|
12
18
|
/**
|
|
13
19
|
* Returns a service node whose `load()` yields the dependency doubles and
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* `input()` the given input object — everything else about the node (its
|
|
21
|
+
* deps, input schema, build, expose) is unchanged. The input double is NOT
|
|
22
|
+
* validated: the test supplies the typed, already-validated shape directly.
|
|
23
|
+
* `run()` is not meaningful on a mock (there is no boot, no environment) and
|
|
24
|
+
* throws if called.
|
|
19
25
|
*/
|
|
20
|
-
declare function mockService<D extends Deps, P extends Params, E extends Expose,
|
|
26
|
+
declare function mockService<D extends Deps, P extends Params, E extends Expose, I extends StandardSchemaV1 | undefined>(service: RunnableServiceNode<D, P, E, I>, overrides: LoadOverrides<D, I>): RunnableServiceNode<D, P, E, I>;
|
|
21
27
|
//#endregion
|
|
22
28
|
export { LoadOverrides, mockService };
|
|
23
29
|
//# sourceMappingURL=testing.d.mts.map
|
package/dist/testing.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/1-core/core/dist/testing.d.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/1-core/core/dist/testing.d.mts"],"mappings":";;;;;;;;;;;;KAWK,cAAc,UAAU,MAAM,UAAU,gCAAgC,aAAa,MAAM,UAAU;EACxG,OAAO,iBAAiB,YAAY;;EAEpC;;;;;;;;;;iBAUe,YAAY,UAAU,MAAM,UAAU,QAAQ,UAAU,QAAQ,UAAU,8BAA8B,SAAS,oBAAoB,GAAG,GAAG,GAAG,IAAI,WAAW,cAAc,GAAG,KAAK,oBAAoB,GAAG,GAAG,GAAG"}
|
package/dist/testing.mjs
CHANGED
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
import { t as blindCast } from "./casts-
|
|
1
|
+
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
2
|
//#region ../../0-framework/1-core/core/dist/testing.mjs
|
|
3
3
|
/**
|
|
4
4
|
* The unit-test seam (testing.md § Unit): `mockService` replaces a service
|
|
5
|
-
* node's `load()` and `
|
|
6
|
-
*
|
|
5
|
+
* node's `load()` and `input()` output so any code that pulls dependencies or
|
|
6
|
+
* input through them — a page, a server action, a helper — runs against typed
|
|
7
7
|
* doubles with no server and no environment. Target-agnostic: every service
|
|
8
|
-
* node has `load()`/`
|
|
8
|
+
* node has `load()`/`input()`. It does no module mocking; wiring the
|
|
9
9
|
* substitution into a test runner (`vi.mock`, `mock.module`) stays in the test.
|
|
10
10
|
* The integration seam (`bootstrapService`) is target-specific and lives in the
|
|
11
11
|
* target's own testing entry (e.g. `@prisma/composer-prisma-cloud/testing`).
|
|
12
12
|
*/
|
|
13
|
-
function paramDefaults(params) {
|
|
14
|
-
const defaults = {};
|
|
15
|
-
for (const [name, param] of Object.entries(params)) if (param.default !== void 0) defaults[name] = param.default;
|
|
16
|
-
return blindCast(defaults);
|
|
17
|
-
}
|
|
18
13
|
/**
|
|
19
14
|
* Returns a service node whose `load()` yields the dependency doubles and
|
|
20
|
-
* `
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
15
|
+
* `input()` the given input object — everything else about the node (its
|
|
16
|
+
* deps, input schema, build, expose) is unchanged. The input double is NOT
|
|
17
|
+
* validated: the test supplies the typed, already-validated shape directly.
|
|
18
|
+
* `run()` is not meaningful on a mock (there is no boot, no environment) and
|
|
19
|
+
* throws if called.
|
|
25
20
|
*/
|
|
26
21
|
function mockService(service, overrides) {
|
|
27
22
|
const entries = Object.entries(overrides);
|
|
28
23
|
const deps = blindCast(Object.fromEntries(entries.filter(([name]) => name in service.inputs)));
|
|
29
|
-
const
|
|
30
|
-
...paramDefaults(service.params),
|
|
31
|
-
...Object.fromEntries(entries.filter(([name]) => name in service.params))
|
|
32
|
-
});
|
|
24
|
+
const input = blindCast(entries.find(([name]) => name === "input")?.[1]);
|
|
33
25
|
return Object.freeze({
|
|
34
26
|
...service,
|
|
35
27
|
run() {
|
|
36
|
-
throw new Error(`mockService(): "${service.name}" is a load()/
|
|
28
|
+
throw new Error(`mockService(): "${service.name}" is a load()/input()-only mock — it has no run() (no boot, no environment).`);
|
|
37
29
|
},
|
|
38
30
|
load: () => deps,
|
|
39
|
-
|
|
31
|
+
input: () => input
|
|
40
32
|
});
|
|
41
33
|
}
|
|
42
34
|
//#endregion
|
package/dist/testing.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/testing.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\n//#region src/testing.ts\n/**\n* The unit-test seam (testing.md § Unit): `mockService` replaces a service\n* node's `load()` and `
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/testing.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\n//#region src/testing.ts\n/**\n* The unit-test seam (testing.md § Unit): `mockService` replaces a service\n* node's `load()` and `input()` output so any code that pulls dependencies or\n* input through them — a page, a server action, a helper — runs against typed\n* doubles with no server and no environment. Target-agnostic: every service\n* node has `load()`/`input()`. It does no module mocking; wiring the\n* substitution into a test runner (`vi.mock`, `mock.module`) stays in the test.\n* The integration seam (`bootstrapService`) is target-specific and lives in the\n* target's own testing entry (e.g. `@prisma/composer-prisma-cloud/testing`).\n*/\n/**\n* Returns a service node whose `load()` yields the dependency doubles and\n* `input()` the given input object — everything else about the node (its\n* deps, input schema, build, expose) is unchanged. The input double is NOT\n* validated: the test supplies the typed, already-validated shape directly.\n* `run()` is not meaningful on a mock (there is no boot, no environment) and\n* throws if called.\n*/\nfunction mockService(service, overrides) {\n\tconst entries = Object.entries(overrides);\n\tconst deps = blindCast(Object.fromEntries(entries.filter(([name]) => name in service.inputs)));\n\tconst input = blindCast(entries.find(([name]) => name === \"input\")?.[1]);\n\treturn Object.freeze({\n\t\t...service,\n\t\trun() {\n\t\t\tthrow new Error(`mockService(): \"${service.name}\" is a load()/input()-only mock — it has no run() (no boot, no environment).`);\n\t\t},\n\t\tload: () => deps,\n\t\tinput: () => input\n\t});\n}\n//#endregion\nexport { mockService };\n\n//# sourceMappingURL=testing.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,YAAY,SAAS,WAAW;CACxC,MAAM,UAAU,OAAO,QAAQ,SAAS;CACxC,MAAM,OAAO,UAAU,OAAO,YAAY,QAAQ,QAAQ,CAAC,UAAU,QAAQ,QAAQ,MAAM,CAAC,CAAC;CAC7F,MAAM,QAAQ,UAAU,QAAQ,MAAM,CAAC,UAAU,SAAS,OAAO,CAAC,GAAG,EAAE;CACvE,OAAO,OAAO,OAAO;EACpB,GAAG;EACH,MAAM;GACL,MAAM,IAAI,MAAM,mBAAmB,QAAQ,KAAK,6EAA6E;EAC9H;EACA,YAAY;EACZ,aAAa;CACd,CAAC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/composer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-dev.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Prisma Composer — build a Prisma App by composing Modules. Core authoring, deploy pipeline, the prisma-composer CLI, and the service-rpc/node/nextjs authoring surfaces.",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"./testing": "./dist/testing.mjs",
|
|
16
16
|
"./casts": "./dist/casts.mjs",
|
|
17
17
|
"./assertions": "./dist/assertions.mjs",
|
|
18
|
+
"./arktype": "./dist/arktype.mjs",
|
|
18
19
|
"./service-rpc": "./dist/service-rpc.mjs",
|
|
19
20
|
"./node": "./dist/node.mjs",
|
|
20
21
|
"./node/control": "./dist/node-control.mjs",
|
|
@@ -38,16 +39,16 @@
|
|
|
38
39
|
"@prisma/management-api-sdk": "^1.50.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@internal/assemble": "0.
|
|
42
|
-
"@internal/cli": "0.
|
|
43
|
-
"@internal/core": "0.
|
|
44
|
-
"@internal/foundation": "0.
|
|
45
|
-
"@internal/lowering": "0.
|
|
46
|
-
"@internal/nextjs": "0.
|
|
47
|
-
"@internal/node": "0.
|
|
48
|
-
"@internal/service-rpc": "0.
|
|
49
|
-
"@internal/tsdown-config": "0.
|
|
50
|
-
"@types/node": "^
|
|
42
|
+
"@internal/assemble": "0.4.0-dev.2",
|
|
43
|
+
"@internal/cli": "0.4.0-dev.2",
|
|
44
|
+
"@internal/core": "0.4.0-dev.2",
|
|
45
|
+
"@internal/foundation": "0.4.0-dev.2",
|
|
46
|
+
"@internal/lowering": "0.4.0-dev.2",
|
|
47
|
+
"@internal/nextjs": "0.4.0-dev.2",
|
|
48
|
+
"@internal/node": "0.4.0-dev.2",
|
|
49
|
+
"@internal/service-rpc": "0.4.0-dev.2",
|
|
50
|
+
"@internal/tsdown-config": "0.4.0-dev.2",
|
|
51
|
+
"@types/node": "^26.0.1",
|
|
51
52
|
"tsdown": "^0.22.7",
|
|
52
53
|
"typescript": "^6.0.3"
|
|
53
54
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@internal/foundation/arktype';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"casts-Ci5rYYaR.mjs","names":[],"sources":["../../../0-framework/0-foundation/foundation/dist/casts.mjs"],"sourcesContent":["//#region src/casts.ts\n/**\n* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**\n*\n* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes\n* unnecessary**: tighten an input type, add a runtime check that narrows via a type\n* predicate, restructure a generic so the compiler can see the relationship you're\n* asserting, or use {@link castAs} when the value already satisfies the target type.\n* Only when no rewrite is feasible does `blindCast` become the right answer — and at\n* that point, the `Reason` literal you supply must articulate the compromise in\n* language a reviewer can evaluate.\n*\n* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,\n* that is not a signal to soften the reason; it is a signal to go back and solve the\n* underlying type-system problem properly. An unconvincing justification is rework,\n* not a free pass.\n*\n* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses\n* the compiler's checks (the input type is `unknown`, the output type is whatever the\n* caller asks for), but it forces the unsafety to be named at the call site instead of\n* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile\n* time — it is not present in the emitted JavaScript — but it is grep-able and\n* visible to future readers.\n*\n* @example\n* ```typescript\n* const stringValue = blindCast<\n* string,\n* \"JSON.parse returns `unknown`; this field is documented to be a string in the API contract\"\n* >(parsed[key]);\n* ```\n*\n* @typeParam TargetType - The type the caller is asserting the input has.\n* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.\n* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.\n*/\nfunction blindCast(input) {\n\treturn input;\n}\n/**\n* Type-checked, runtime pass-through alternative to a bare `as Type` cast.\n*\n* Use `castAs` when the value already satisfies the target type but you want to make\n* the type assertion explicit at the call site — for example, when an inferred type is\n* wider than the type you want to publish, or when a literal object should be tagged\n* with its nominal interface. Unlike {@link blindCast}, the compiler still checks that\n* the value is assignable to the target type, so this helper cannot smuggle in an\n* unsafe assertion.\n*\n* `castAs` exists alongside `blindCast` so authors pick the right name at the call\n* site: a `castAs` is type-checked and benign; a `blindCast` is the unsafe escape\n* hatch. The split makes review faster — readers know which casts to scrutinize and\n* which are pure annotations.\n*\n* @example\n* ```typescript\n* interface FancyObject {\n* key: string;\n* keyTwo: {\n* subKey: string;\n* subKeyTwo: number;\n* };\n* }\n*\n* const typedObject = castAs<FancyObject>({\n* key: 'Chookede',\n* keyTwo: {\n* subKey: 'Choookeeeee',\n* subKeyTwo: 2,\n* },\n* });\n* ```\n*\n* @typeParam Type - The type to constrain and tag the value with. The value must be assignable to `Type`.\n*/\nfunction castAs(value) {\n\treturn value;\n}\n//#endregion\nexport { blindCast, castAs };\n\n//# sourceMappingURL=casts.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,UAAU,OAAO;CACzB,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,OAAO,OAAO;CACtB,OAAO;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./app-config-Dw3r7sUa-D3dr8rg2.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./app-config-Dw3r7sUa-D3dr8rg2.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dist-BkSJOwTm.mjs","names":["#value","SecretBox$1"],"sources":["../../../0-framework/0-foundation/foundation/dist/secret.mjs","../../../0-framework/1-core/core/dist/index.mjs"],"sourcesContent":["//#region src/secret.ts\n/**\n* A value wrapper that redacts everywhere except the one explicit reader,\n* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a\n* sink must remember to check: `String(box)`, template interpolation,\n* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so\n* a secret can't leak through an accidental log or serialization.\n*\n* Shape matches the platform's own `secrecy` type (pdp-control-plane). The class\n* is nominal enough on its own — no phantom brand.\n*/\nconst REDACTED = \"[REDACTED]\";\nvar SecretBox = class {\n\t#value;\n\tconstructor(value) {\n\t\tthis.#value = value;\n\t}\n\t/** The sole explicit door to the wrapped value. */\n\texpose() {\n\t\treturn this.#value;\n\t}\n\ttoString() {\n\t\treturn REDACTED;\n\t}\n\ttoJSON() {\n\t\treturn REDACTED;\n\t}\n\tvalueOf() {\n\t\treturn REDACTED;\n\t}\n\t[Symbol.toPrimitive]() {\n\t\treturn REDACTED;\n\t}\n\t[Symbol.for(\"nodejs.util.inspect.custom\")]() {\n\t\treturn REDACTED;\n\t}\n};\n//#endregion\nexport { SecretBox };\n\n//# sourceMappingURL=secret.mjs.map","import { _ as LoadError, a as isNode, c as isSecretSource, d as paramSource, f as provisionNeed, g as service, h as secretSource, i as freezeNode, l as module, m as secret, n as ResourceNodeBase, o as isParamSource, p as resource, r as dependency, s as isProvisionNeed, t as Load, u as paramNeed } from \"./graph-CP16cJyH.mjs\";\nimport { SecretBox, SecretBox as SecretBox$1 } from \"@internal/foundation/secret\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/config.ts\n/**\n* A data-only descriptor of a param's schema for introspection — the\n* validator's vendor tag, never the schema's own `validate`. `configOf`\n* reports it where the old model reported `type: 'string' | 'number'`, so the\n* config surface stays enumerable without leaking a function. Nothing consumes\n* more than the vendor tag yet; a richer projection (e.g. a JSON-Schema export\n* when the vendor offers one) is an additive change if a consumer needs it.\n*/\nfunction projectSchema(schema) {\n\treturn { vendor: schema[\"~standard\"].vendor };\n}\n/**\n* Enumerates every config param the service declares: each input's connection\n* params, then the service's own params. Pure — reads `root.inputs`/`params`\n* directly, executes nothing but the (also pure) schema projection. Deliberately\n* does not go through `Load`: a service's connection-end inputs are legitimately\n* unwired from its own point of view (wiring is an enclosing module's concern),\n* and this introspects one service's declared shape regardless of how — or\n* whether — it composes into a larger graph.\n*/\nfunction configOf(root) {\n\tconst entries = [];\n\tfor (const [input, value] of Object.entries(root.inputs)) {\n\t\tif (typeof value !== \"object\" || value === null) continue;\n\t\tfor (const [name, param] of Object.entries(value.connection.params)) entries.push({\n\t\t\towner: { input },\n\t\t\tname,\n\t\t\tschema: projectSchema(param.schema),\n\t\t\toptional: param.optional === true,\n\t\t\tdefault: param.default\n\t\t});\n\t}\n\tfor (const [name, param] of Object.entries(root.params)) entries.push({\n\t\towner: \"service\",\n\t\tname,\n\t\tschema: projectSchema(param.schema),\n\t\toptional: param.optional === true,\n\t\tdefault: param.default\n\t});\n\treturn entries;\n}\n/**\n* The app's provision manifest: every secret binding the root resolved across\n* the graph (ADR-0029) — an opaque, target-defined source per service secret\n* slot; a deploy target's preflight reads its own payload. Pure graph\n* introspection, TARGET-AGNOSTIC — the target consumes it to verify each secret\n* exists on the platform before deploy. The values are provisioned out-of-band.\n*/\nfunction provisionManifest(graph) {\n\treturn graph.secrets;\n}\n/**\n* The app's param-binding manifest: every param a `provision()` call bound —\n* literal or an opaque, target-defined `ParamSource` — at the address that\n* declared it. The param sibling of `provisionManifest`, for a deploy\n* target's own preflight to consume (D2). Pure graph introspection,\n* TARGET-AGNOSTIC; a param this manifest omits simply falls back to its own\n* `default` at `buildConfig`.\n*/\nfunction paramManifest(graph) {\n\treturn graph.params;\n}\nfunction scalarSchema(name, check) {\n\treturn { \"~standard\": {\n\t\tversion: 1,\n\t\tvendor: \"@prisma/composer\",\n\t\tvalidate: (value) => check(value) ? { value } : { issues: [{ message: `expected ${name}, got ${typeof value}` }] }\n\t} };\n}\nconst stringSchema = scalarSchema(\"string\", (v) => typeof v === \"string\");\nconst numberSchema = scalarSchema(\"number\", (v) => typeof v === \"number\" && Number.isFinite(v));\nfunction withFacets(schema, opts) {\n\treturn {\n\t\tschema,\n\t\t...opts.optional !== void 0 ? { optional: opts.optional } : {},\n\t\t...opts.default !== void 0 ? { default: opts.default } : {},\n\t\t...opts.provision !== void 0 ? { provision: opts.provision } : {}\n\t};\n}\n/** A string-valued param. */\nfunction string(opts = {}) {\n\treturn withFacets(stringSchema, opts);\n}\n/** A number-valued param. */\nfunction number(opts = {}) {\n\treturn withFacets(numberSchema, opts);\n}\n/** A param over any caller-supplied Standard Schema — a structured `jobs`, say. */\nfunction param(schema, opts = {}) {\n\treturn withFacets(schema, opts);\n}\n//#endregion\n//#region src/hydrate.ts\n/**\n* The boot-side half of the runtime split (see core-model.md § Runtime:\n* booting a service). Core's job at boot is structural only: turn a\n* concrete, typed Config into hydrated deps by calling each input's\n* connection.hydrate with its value slice. No environment read, no\n* validation, no strings — the pack's `load()` already read the process-local\n* stash into a typed Config before calling this.\n*/\n/**\n* Given a service and a concrete typed Config, hydrate every input\n* (connection.hydrate with its typed value slice). A resource dep and a\n* connection dep hydrate through identical machinery — the loaded client is\n* indistinguishable. The service's own params ride alongside in\n* `config.service`; the node's `load()` merges the two.\n*/\nasync function hydrate(root, config) {\n\tconst deps = {};\n\tfor (const [name, inputNode] of Object.entries(root.inputs)) {\n\t\tconst values = config.inputs[name] ?? {};\n\t\tdeps[name] = await inputNode.connection.hydrate(values);\n\t}\n\treturn deps;\n}\n/**\n* Synchronous hydrate — what the node's `load()` uses so\n* `const { db } = service.load()` reads without `await`. Requires every\n* connection.hydrate to return synchronously; a Promise return is a loud error\n* naming the input (an async client factory must use the async `hydrate` path).\n*/\nfunction hydrateSync(root, config) {\n\tconst deps = {};\n\tfor (const [name, inputNode] of Object.entries(root.inputs)) {\n\t\tconst values = config.inputs[name] ?? {};\n\t\tconst client = inputNode.connection.hydrate(values);\n\t\tif (client instanceof Promise) throw new Error(`Connection hydrate for input \"${name}\" returned a Promise; load() requires a synchronous client factory.`);\n\t\tdeps[name] = client;\n\t}\n\treturn deps;\n}\n/**\n* Wraps each of a service's resolved secret values in a redacting `SecretBox`\n* — what the node's `secrets()` accessor returns (ADR-0021, sibling to\n* `load()`/`config()`). The RESOLUTION of a secret's value (the boot\n* double-lookup that reads the platform var the pointer names) is the target\n* pack's job; core is handed the already-resolved strings and only boxes them,\n* so a secret is redacted by TYPE from here on. A declared slot missing from\n* `values` is a target contract violation, named loudly.\n*/\nfunction hydrateSecrets(root, values) {\n\tconst boxed = {};\n\tfor (const slot of Object.keys(root.secretSlots)) {\n\t\tconst value = values[slot];\n\t\tif (value === void 0) throw new Error(`secret slot \"${slot}\" has no resolved value — the target must resolve every declared secret before hydrateSecrets().`);\n\t\tboxed[slot] = new SecretBox$1(value);\n\t}\n\treturn blindCast(boxed);\n}\n//#endregion\nexport { Load, LoadError, ResourceNodeBase, SecretBox, configOf, dependency, freezeNode, hydrate, hydrateSecrets, hydrateSync, isNode, isParamSource, isProvisionNeed, isSecretSource, module, number, param, paramManifest, paramNeed, paramSource, provisionManifest, provisionNeed, resource, secret, secretSource, service, string };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,WAAW;AACjB,IAAI,YAAY,MAAM;CACrB;CACA,YAAY,OAAO;EAClB,KAAKA,SAAS;CACf;;CAEA,SAAS;EACR,OAAO,KAAKA;CACb;CACA,WAAW;EACV,OAAO;CACR;CACA,SAAS;EACR,OAAO;CACR;CACA,UAAU;EACT,OAAO;CACR;CACA,CAAC,OAAO,eAAe;EACtB,OAAO;CACR;CACA,CAAC,OAAO,IAAI,4BAA4B,KAAK;EAC5C,OAAO;CACR;A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