@prisma/composer 0.1.0 → 0.2.0-dev.10
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-CVyObaOe-PF94uVBK.d.mts +419 -0
- package/dist/app-config-CVyObaOe-PF94uVBK.d.mts.map +1 -0
- package/dist/assertions.d.mts +1 -1
- package/dist/assertions.d.mts.map +1 -0
- package/dist/bin.mjs +220 -258
- package/dist/bin.mjs.map +1 -1
- package/dist/casts.d.mts +1 -1
- package/dist/casts.d.mts.map +1 -0
- package/dist/config-BP2DrIX_.d.mts +1 -0
- package/dist/config.d.mts +3 -2
- package/dist/config.mjs +2 -1
- package/dist/config.mjs.map +1 -1
- package/dist/container-transport-DKmKg5JQ-DKWs0ubK.mjs +45 -0
- package/dist/container-transport-DKmKg5JQ-DKWs0ubK.mjs.map +1 -0
- package/dist/deploy-BP2DrIX_.d.mts +1 -0
- package/dist/deploy.d.mts +3 -2
- package/dist/deploy.mjs +181 -23
- package/dist/deploy.mjs.map +1 -1
- package/dist/{dist-zBU8ASQW.mjs → dist-BkSJOwTm.mjs} +16 -4
- package/dist/dist-BkSJOwTm.mjs.map +1 -0
- package/dist/{graph-BYdCQKya-BI0njTow.mjs → graph-CP16cJyH-D5IW87Y-.mjs} +118 -21
- package/dist/graph-CP16cJyH-D5IW87Y-.mjs.map +1 -0
- package/dist/graph-DUSgjmzA-DhtkTqoz.d.mts +18 -0
- package/dist/graph-DUSgjmzA-DhtkTqoz.d.mts.map +1 -0
- package/dist/{config-ob5OhCSP-sP3GW3uu.d.mts → graph-types-BcbVhojU-C3fhxjPK.d.mts} +205 -114
- package/dist/graph-types-BcbVhojU-C3fhxjPK.d.mts.map +1 -0
- package/dist/{index-CZSc9drz.d.mts → index-BFBNz7Aw.d.mts} +5 -20
- package/dist/index-BFBNz7Aw.d.mts.map +1 -0
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -3
- package/dist/{index-Dh4Zro0y.d.mts → nextjs-DLyeRR7M-DwnBjryZ.d.mts} +6 -5
- package/dist/nextjs-DLyeRR7M-DwnBjryZ.d.mts.map +1 -0
- package/dist/nextjs-control.d.mts +6 -5
- package/dist/nextjs-control.d.mts.map +1 -0
- package/dist/nextjs-control.mjs +9 -11
- package/dist/nextjs-control.mjs.map +1 -1
- package/dist/nextjs.d.mts +2 -2
- package/dist/nextjs.mjs.map +1 -1
- package/dist/node-control.d.mts +5 -3
- package/dist/node-control.d.mts.map +1 -0
- package/dist/node-control.mjs +115 -24
- package/dist/node-control.mjs.map +1 -1
- package/dist/node.d.mts +18 -5
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +2 -1
- package/dist/node.mjs.map +1 -1
- package/dist/report.d.mts +17 -0
- package/dist/report.d.mts.map +1 -0
- package/dist/report.mjs +79 -0
- package/dist/report.mjs.map +1 -0
- package/dist/service-rpc.d.mts +61 -0
- package/dist/service-rpc.d.mts.map +1 -0
- package/dist/service-rpc.mjs +353 -0
- package/dist/service-rpc.mjs.map +1 -0
- package/dist/testing.d.mts +2 -3
- package/dist/testing.d.mts.map +1 -0
- package/package.json +20 -18
- package/src/exports/assertions.ts +1 -0
- package/src/exports/casts.ts +1 -0
- package/src/exports/config.ts +1 -0
- package/src/exports/deploy.ts +1 -0
- package/src/exports/index.ts +1 -0
- package/src/exports/nextjs-control.ts +1 -0
- package/src/exports/nextjs.ts +2 -0
- package/src/exports/node-control.ts +1 -0
- package/src/exports/node.ts +2 -0
- package/src/exports/report.ts +1 -0
- package/src/exports/service-rpc.ts +1 -0
- package/src/exports/testing.ts +1 -0
- package/dist/app-config-BUqyK6N6-CVq3uvHF.d.mts +0 -188
- package/dist/config-BVVgDSdq.d.mts +0 -1
- package/dist/deploy-BVVgDSdq.d.mts +0 -1
- package/dist/dist-zBU8ASQW.mjs.map +0 -1
- package/dist/graph-BYdCQKya-BI0njTow.mjs.map +0 -1
- package/dist/rpc.d.mts +0 -43
- package/dist/rpc.mjs +0 -132
- package/dist/rpc.mjs.map +0 -1
- package/dist/tsdown.d.mts +0 -9
- package/dist/tsdown.mjs +0 -35
- package/dist/tsdown.mjs.map +0 -1
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { P as ServiceNode, T as ResourceNode, d as Graph, n as Config, t as BuildAdapter, x as NodeId, y as ModuleNode } from "./config-ob5OhCSP-sP3GW3uu.mjs";
|
|
2
|
-
import * as Alchemy from "alchemy";
|
|
3
|
-
import { StackServices } from "alchemy";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as Layer from "effect/Layer";
|
|
6
|
-
import { State } from "alchemy/State/State";
|
|
7
|
-
|
|
8
|
-
//#region ../../0-framework/1-core/core/dist/app-config-BUqyK6N6.d.mts
|
|
9
|
-
//#region src/deploy.d.ts
|
|
10
|
-
/** The Layer shape every Alchemy state store must satisfy — what `LowerOptions.state` and `PrismaAppConfig.state` both traffic in. */
|
|
11
|
-
type AlchemyStateLayer = Layer.Layer<State, never, StackServices>;
|
|
12
|
-
/**
|
|
13
|
-
* An extension's application-level descriptor: shared infrastructure that runs
|
|
14
|
-
* once per lowering, before any node. Its outputs reach the extension's own
|
|
15
|
-
* SPI calls via LowerContext.application.
|
|
16
|
-
*/
|
|
17
|
-
interface ApplicationDescriptor {
|
|
18
|
-
provision(ctx: LowerContext): Effect.Effect<LoweredNode, unknown, unknown>;
|
|
19
|
-
}
|
|
20
|
-
/** The phased service SPI — the seam between the phases belongs to CORE. */
|
|
21
|
-
interface ServiceLowering {
|
|
22
|
-
/** Makes the platform-specific thing that will host the service — identity-bearing infrastructure only, no code runs. */
|
|
23
|
-
provision(ctx: LowerContext): Effect.Effect<LoweredNode, unknown, unknown>;
|
|
24
|
-
/**
|
|
25
|
-
* Encodes the typed Config into the service's runtime environment. Boot-side
|
|
26
|
-
* deserialize reverses it through the same serializer. Returns the env-var
|
|
27
|
-
* records so `deploy` can reference them.
|
|
28
|
-
*/
|
|
29
|
-
serialize(ctx: LowerContext, provisioned: LoweredNode, config: Config): Effect.Effect<LoweredNode, unknown, unknown>;
|
|
30
|
-
/**
|
|
31
|
-
* Prints the bootstrap and assembles the deployable artifact from the
|
|
32
|
-
* app-built bundle. Must be byte-deterministic: an unchanged service noops
|
|
33
|
-
* on redeploy.
|
|
34
|
-
*/
|
|
35
|
-
package(ctx: LowerContext, input: PackageInput): Effect.Effect<Artifact, unknown, unknown>;
|
|
36
|
-
/** Ships the packaged artifact into the provisioned thing and runs it. Returns the trustworthy URL. */
|
|
37
|
-
deploy(ctx: LowerContext, provisioned: LoweredNode, artifact: Artifact, serialized: LoweredNode): Effect.Effect<LoweredNode, unknown, unknown>;
|
|
38
|
-
}
|
|
39
|
-
/** Input to an extension's package() step: the built bundle and the node's graph address. */
|
|
40
|
-
interface PackageInput {
|
|
41
|
-
/** The build descriptor's normalized output: the bundle dir + the app's runnable. */
|
|
42
|
-
readonly assembled: Bundle;
|
|
43
|
-
/** The node's graph address — baked into the printed bootstrap. */
|
|
44
|
-
readonly address: string;
|
|
45
|
-
}
|
|
46
|
-
/** One node's realization. Runs inside the Alchemy stack effect. */
|
|
47
|
-
type Lowering = (ctx: LowerContext) => Effect.Effect<LoweredNode, unknown, unknown>;
|
|
48
|
-
interface LowerContext {
|
|
49
|
-
readonly id: NodeId;
|
|
50
|
-
/**
|
|
51
|
-
* The node's deployment address: its full, dot-joined hierarchical
|
|
52
|
-
* position in the graph (e.g. "auth.api"). The config-key namespace and
|
|
53
|
-
* the bootstrap parameter.
|
|
54
|
-
*/
|
|
55
|
-
readonly address: string;
|
|
56
|
-
readonly node: ServiceNode | ResourceNode;
|
|
57
|
-
readonly graph: Graph;
|
|
58
|
-
readonly opts: LowerOptions;
|
|
59
|
-
/** The owning extension's application hook outputs (`{ outputs: {} }` when it declares none). */
|
|
60
|
-
readonly application: LoweredNode;
|
|
61
|
-
/** Already-lowered deps (topo order). */
|
|
62
|
-
readonly lowered: ReadonlyMap<NodeId, LoweredNode>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* What a lowering hands downstream — e.g. a deployed URL a later node's env
|
|
66
|
-
* wiring consumes. The inter-node config-wiring hook for Connections.
|
|
67
|
-
*/
|
|
68
|
-
interface LoweredNode {
|
|
69
|
-
readonly outputs: Readonly<Record<string, unknown>>;
|
|
70
|
-
}
|
|
71
|
-
interface LowerOptions {
|
|
72
|
-
/** Stack + root node id. */
|
|
73
|
-
readonly name: string;
|
|
74
|
-
readonly bundles: Record<string, Bundle>;
|
|
75
|
-
readonly stage?: string;
|
|
76
|
-
/** Alchemy state store for the stack. Defaults to the config's own state layer. */
|
|
77
|
-
readonly state?: AlchemyStateLayer;
|
|
78
|
-
}
|
|
79
|
-
/** A build descriptor's normalized output: the produced bundle dir plus the app's runnable entry within it. */
|
|
80
|
-
interface Bundle {
|
|
81
|
-
readonly dir: string;
|
|
82
|
-
readonly entry: string;
|
|
83
|
-
}
|
|
84
|
-
/** Shared input shape for every extension's build descriptor. */
|
|
85
|
-
interface AssembleInput {
|
|
86
|
-
readonly build: BuildAdapter;
|
|
87
|
-
/** Extra patterns to inline into the wrapper besides `@prisma/composer*` (e.g. the app's own workspace packages). */
|
|
88
|
-
readonly wrapperNoExternal?: readonly RegExp[];
|
|
89
|
-
/** The service's graph address (e.g. "storefront.web"). Unique per service, so the assembler uses it to name this service's own working directory: `<cwd>/.prisma-composer/artifacts/<address>/`. */
|
|
90
|
-
readonly address: string;
|
|
91
|
-
/** The directory the deploy command was run from. The assembler puts its working directory under it (`<cwd>/.prisma-composer/`), the same place the CLI writes its other generated files. */
|
|
92
|
-
readonly cwd: string;
|
|
93
|
-
}
|
|
94
|
-
/** package()'s product. */
|
|
95
|
-
interface Artifact {
|
|
96
|
-
readonly path: string;
|
|
97
|
-
readonly sha256: string;
|
|
98
|
-
}
|
|
99
|
-
declare class LowerError extends Error {
|
|
100
|
-
constructor(message: string);
|
|
101
|
-
}
|
|
102
|
-
/** Assembles a service's typed Config from its dependency edges' lowered outputs plus its own param defaults. */
|
|
103
|
-
declare function buildConfig(node: ServiceNode, id: NodeId, graph: Graph, lowered: ReadonlyMap<NodeId, LoweredNode>): Config;
|
|
104
|
-
/**
|
|
105
|
-
* The state-layer precedence a deploy resolves to: an explicit opts.state
|
|
106
|
-
* always wins; failing that, the config's own (required) state. A pure
|
|
107
|
-
* function so the precedence is testable without booting Alchemy.
|
|
108
|
-
*/
|
|
109
|
-
declare function resolveStateLayer(opts: LowerOptions, config: PrismaAppConfig): AlchemyStateLayer;
|
|
110
|
-
/**
|
|
111
|
-
* All configured extensions' providers merged, config array order — an
|
|
112
|
-
* extension without `providers` is skipped; no used-extensions-only
|
|
113
|
-
* filtering (ADR-0017's pinned providers rule).
|
|
114
|
-
*/
|
|
115
|
-
declare function mergedProviders(config: PrismaAppConfig): Layer.Layer<never>;
|
|
116
|
-
/**
|
|
117
|
-
* Composable form for mixed stacks: hand-wired Alchemy resources alongside Prisma App nodes in one stack effect.
|
|
118
|
-
* Fails with LowerError or whatever an extension's lowering raises — the error type is open.
|
|
119
|
-
*/
|
|
120
|
-
declare function lowering(root: ModuleNode, config: PrismaAppConfig, opts: LowerOptions): Effect.Effect<LoweredNode, LowerError, unknown>;
|
|
121
|
-
/**
|
|
122
|
-
* The whole-stack wrapper: Load → route each node through the config's
|
|
123
|
-
* extension registries → an Alchemy Stack (the default export the alchemy
|
|
124
|
-
* CLI consumes).
|
|
125
|
-
*/
|
|
126
|
-
declare function lower(root: ModuleNode, config: PrismaAppConfig, opts: LowerOptions): Effect.Effect<Alchemy.CompiledStack<LoweredNode, any>, import("effect/Config").ConfigError, never>; //#endregion
|
|
127
|
-
//#region src/app-config.d.ts
|
|
128
|
-
/**
|
|
129
|
-
* One extension's control-plane registry: everything the deploy pipeline may
|
|
130
|
-
* look up for a node whose `extension` field names this package. `nodes` is
|
|
131
|
-
* keyed by the node's within-extension ID (`node.type` / `build.type`).
|
|
132
|
-
*/
|
|
133
|
-
interface ExtensionDescriptor {
|
|
134
|
-
/** The extension's package name, e.g. "@prisma/composer-prisma-cloud" — what a node's `extension` field is matched against. */
|
|
135
|
-
readonly id: string;
|
|
136
|
-
/** ONE registry per extension, keyed by node ID. */
|
|
137
|
-
readonly nodes: Record<string, NodeDescriptor>;
|
|
138
|
-
/** Once-per-lowering hook — the application's shared infrastructure (e.g. prisma-cloud's Project). */
|
|
139
|
-
readonly application?: ApplicationDescriptor;
|
|
140
|
-
/** The extension's Alchemy providers — merged across all configured extensions (config order). */
|
|
141
|
-
readonly providers?: () => Layer.Layer<never>;
|
|
142
|
-
/**
|
|
143
|
-
* Deploy-time prerequisite check — the CLI runs it once, after the app's
|
|
144
|
-
* Project/Branch are resolved and BEFORE any stack file is written or Alchemy
|
|
145
|
-
* runs. A target uses it to verify platform prerequisites (e.g. that every
|
|
146
|
-
* secret env var in the provision manifest exists for the resolved stage) and
|
|
147
|
-
* throws to abort the deploy. Async: it talks to the platform (ADR-0029).
|
|
148
|
-
*/
|
|
149
|
-
readonly preflight?: (input: PreflightInput) => Promise<void>;
|
|
150
|
-
}
|
|
151
|
-
/** The resolved deploy context handed to an extension's `preflight` hook. */
|
|
152
|
-
interface PreflightInput {
|
|
153
|
-
/** The loaded application graph — the manifest of prerequisites is read from it (`provisionManifest`). */
|
|
154
|
-
readonly graph: Graph;
|
|
155
|
-
/** The resolved Prisma Cloud Project id. */
|
|
156
|
-
readonly projectId: string;
|
|
157
|
-
/** The resolved Branch id for a named stage; `undefined` for the default (production) stage. */
|
|
158
|
-
readonly branchId: string | undefined;
|
|
159
|
-
/** The stage name (`--stage`), or `undefined` for the default stage — for diagnostics/scope. */
|
|
160
|
-
readonly stage: string | undefined;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* What one registry entry can do. The `kind` discriminant is checked at every
|
|
164
|
-
* lookup site against what the site needs — a resource node looked up against
|
|
165
|
-
* a `service` descriptor is an error naming (extension, type, expected kind).
|
|
166
|
-
*/
|
|
167
|
-
type NodeDescriptor = ({
|
|
168
|
-
readonly kind: 'resource';
|
|
169
|
-
} & Lowering) | ({
|
|
170
|
-
readonly kind: 'service';
|
|
171
|
-
} & ServiceLowering) | {
|
|
172
|
-
readonly kind: 'build';
|
|
173
|
-
assemble(input: AssembleInput): Promise<Bundle>;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* The config file's default export. `extensions` lists every extension the
|
|
177
|
-
* app deploys through; `state` is the ONE state store per deploy — explicit,
|
|
178
|
-
* platform-agnostic, never defaulted by an extension.
|
|
179
|
-
*/
|
|
180
|
-
interface PrismaAppConfig {
|
|
181
|
-
readonly extensions: ExtensionDescriptor[];
|
|
182
|
-
readonly state: () => AlchemyStateLayer;
|
|
183
|
-
}
|
|
184
|
-
/** Typed identity — exists so `prisma-composer.config.ts` gets checked against PrismaAppConfig where it is written. */
|
|
185
|
-
declare function defineConfig(config: PrismaAppConfig): PrismaAppConfig; //#endregion
|
|
186
|
-
//#endregion
|
|
187
|
-
export { resolveStateLayer as S, buildConfig as _, Bundle as a, lowering as b, LowerError as c, Lowering as d, NodeDescriptor as f, ServiceLowering as g, PrismaAppConfig as h, AssembleInput as i, LowerOptions as l, PreflightInput as m, ApplicationDescriptor as n, ExtensionDescriptor as o, PackageInput as p, Artifact as r, LowerContext as s, AlchemyStateLayer as t, LoweredNode as u, defineConfig as v, mergedProviders as x, lower as y };
|
|
188
|
-
//# sourceMappingURL=app-config-BUqyK6N6-CVq3uvHF.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dist-zBU8ASQW.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 { a as isNode, c as resource, d as service, f as LoadError, i as freezeNode, l as secret, n as ResourceNodeBase, o as isSecretSource, r as dependency, s as module, t as Load, u as secretSource } from \"./graph-BYdCQKya.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}\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};\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, isSecretSource, module, number, param, provisionManifest, 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;AACD;;;;;;;;;;;ACxBA,SAAS,cAAc,QAAQ;CAC9B,OAAO,EAAE,QAAQ,OAAO,YAAY,CAAC,OAAO;AAC7C;;;;;;;;;;AAUA,SAAS,SAAS,MAAM;CACvB,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,MAAM,GAAG;EACzD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EACjD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,WAAW,MAAM,GAAG,QAAQ,KAAK;GACjF,OAAO,EAAE,MAAM;GACf;GACA,QAAQ,cAAc,MAAM,MAAM;GAClC,UAAU,MAAM,aAAa;GAC7B,SAAS,MAAM;EAChB,CAAC;CACF;CACA,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAAK,MAAM,GAAG,QAAQ,KAAK;EACrE,OAAO;EACP;EACA,QAAQ,cAAc,MAAM,MAAM;EAClC,UAAU,MAAM,aAAa;EAC7B,SAAS,MAAM;CAChB,CAAC;CACD,OAAO;AACR;;;;;;;;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C5D,MAAM,SAAS,OAAO,OAAO,SAAS,CAAC;EACvC,MAAM,SAAS,UAAU,WAAW,QAAQ,MAAM;EAClD,IAAI,kBAAkB,SAAS,MAAM,IAAI,MAAM,iCAAiC,KAAK,oEAAoE;EACzJ,KAAK,QAAQ;CACd;CACA,OAAO;AACR;;;;;;;;;;AAUA,SAAS,eAAe,MAAM,QAAQ;CACrC,MAAM,QAAQ,CAAC;CACf,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,WAAW,GAAG;EACjD,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAK,GAAG,MAAM,IAAI,MAAM,gBAAgB,KAAK,iGAAiG;EAC5J,MAAM,QAAQ,IAAIC,UAAY,KAAK;CACpC;CACA,OAAO,UAAU,KAAK;AACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-BYdCQKya-BI0njTow.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/graph-BYdCQKya.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\n//#region src/graph-types.ts\n/** Thrown by Load when the graph is malformed. */\nvar LoadError = class extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = \"LoadError\";\n\t}\n};\n//#endregion\n//#region src/node.ts\n/**\n* Core model: node types and the factories that construct them, plain frozen\n* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).\n*/\nconst NODE = Symbol.for(\"prisma:node\");\nconst SECRET_NEED = blindCast(Symbol.for(\"prisma:secret-need\"));\nconst SECRET_SOURCE = blindCast(Symbol.for(\"prisma:secret-source\"));\n/** Declares a secret NEED. Nameless — the platform name is bound at the root via `envSecret`. */\nfunction secret() {\n\treturn Object.freeze({\n\t\t[SECRET_NEED]: true,\n\t\tkind: \"secret\"\n\t});\n}\n/** Builds an opaque secret source from a target-defined payload — the SPI a deploy target's own source constructor (e.g. `envSecret`) calls. Core forwards the source and never inspects the payload. */\nfunction secretSource(payload) {\n\treturn Object.freeze({\n\t\t[SECRET_SOURCE]: true,\n\t\tpayload\n\t});\n}\n/** True if `value` is a secret source (an `envSecret` result or a forwarded ctx.secrets ref). */\nfunction isSecretSource(value) {\n\treturn typeof value === \"object\" && value !== null && blindCast(value)[SECRET_SOURCE] === true;\n}\nfunction requireType(type, factory) {\n\tif (typeof type !== \"string\" || type.length === 0) throw new Error(`${factory}() requires a non-empty node type.`);\n}\nfunction requireName(name, factory) {\n\tif (typeof name !== \"string\" || name.length === 0) throw new Error(`${factory}() requires a non-empty name.`);\n}\nfunction requireExtension(extension, factory) {\n\tif (typeof extension !== \"string\" || extension.length === 0) throw new Error(`${factory}() requires a non-empty extension (the authoring extension's package name).`);\n}\n/**\n* Config keys join address/input/param names with \"_\" and uppercase — an\n* underscore inside a name would collide with that separator (e.g. param\n* \"db_url\" vs input \"db\"'s param \"url\" both hitting env key \"DB_URL\").\n*/\nfunction requireNoUnderscoreName(name, kind, factory) {\n\tif (name.includes(\"_\")) throw new Error(`${factory}() ${kind} name \"${name}\" may not contain \"_\" — config keys join names with \"_\" as the separator (e.g. an input \"db\"'s param \"url\" becomes env key \"DB_URL\"), so an underscore inside a name would collide with that separator.`);\n}\nfunction requireNoUnderscoreNames(names, kind, factory) {\n\tfor (const name of names) requireNoUnderscoreName(name, kind, factory);\n}\nfunction freezeParams(params) {\n\tconst frozen = {};\n\tfor (const [name, param] of Object.entries(params)) frozen[name] = Object.freeze({ ...param });\n\treturn Object.freeze(frozen);\n}\nfunction freezeSecrets(secrets) {\n\tconst frozen = {};\n\tfor (const [name, need] of Object.entries(secrets)) frozen[name] = Object.freeze({ ...need });\n\treturn blindCast(Object.freeze(frozen));\n}\n/** A frozen shallow copy that keeps the caller's declared type. */\nfunction frozenShallowCopy(obj) {\n\treturn blindCast(Object.freeze({ ...obj }));\n}\n/**\n* Seals a node instance after its constructor has assigned all fields — the\n* last statement of a concrete node class's constructor. A free function, not\n* a base-class method, so an instance stays structurally a plain frozen node.\n*/\nfunction freezeNode(node) {\n\tObject.freeze(node);\n\treturn node;\n}\n/**\n* Everything `resource()` establishes, minus the freeze — an extension\n* whose resource node carries extra fields extends this, assigns them, and\n* calls `freezeNode(this)` as its constructor's last statement.\n*/\nvar ResourceNodeBase = class {\n\t[NODE] = true;\n\tkind = \"resource\";\n\tname;\n\textension;\n\ttype;\n\tprovides;\n\tconstructor(def) {\n\t\trequireName(def.name, \"resource\");\n\t\trequireExtension(def.extension, \"resource\");\n\t\tconst provides = def.provides;\n\t\tif (typeof provides !== \"object\" || provides === null || typeof provides.kind !== \"string\" || provides.kind.length === 0 || typeof provides.satisfies !== \"function\") throw new Error(\"resource() requires `provides` — the Contract this resource offers (a non-empty `kind` plus its `satisfies()`).\");\n\t\tthis.name = def.name;\n\t\tthis.extension = def.extension;\n\t\tthis.type = provides.kind;\n\t\tthis.provides = provides;\n\t}\n};\n/** The core leaf: exactly the base, frozen. */\nvar FrozenResourceNode = class extends ResourceNodeBase {\n\tconstructor(def) {\n\t\tsuper(def);\n\t\tfreezeNode(this);\n\t}\n};\n/**\n* Constructs a branded, frozen Resource node — an identity plus the Contract\n* it provides; the routing `type` is the contract's `kind`. Pure — nothing\n* is provisioned until a module provisions it.\n*/\nfunction resource(def) {\n\treturn new FrozenResourceNode(def);\n}\n/**\n* Constructs a branded, frozen Service node — declarations only (inputs,\n* params, build adapter, and the ports it exposes). Pure; carries no runtime behavior.\n*/\nfunction service(def) {\n\trequireName(def.name, \"service\");\n\trequireExtension(def.extension, \"service\");\n\trequireType(def.type, \"service\");\n\trequireNoUnderscoreNames(Object.keys(def.inputs), \"input\", \"service\");\n\trequireNoUnderscoreNames(Object.keys(def.params), \"param\", \"service\");\n\trequireNoUnderscoreNames(Object.keys(def.secrets ?? {}), \"secret\", \"service\");\n\tfor (const slot of Object.keys(def.secrets ?? {})) if (Object.hasOwn(def.params, slot)) throw new Error(`service() secret slot \"${slot}\" collides with a param of the same name — a secret slot and a service param derive the same config key (COMPOSE_<addr>_${slot.toUpperCase()}); rename one.`);\n\treturn Object.freeze({\n\t\t[NODE]: true,\n\t\tkind: \"service\",\n\t\tname: def.name,\n\t\textension: def.extension,\n\t\ttype: def.type,\n\t\tinputs: frozenShallowCopy(def.inputs),\n\t\tparams: freezeParams(def.params),\n\t\tsecretSlots: freezeSecrets(def.secrets ?? blindCast({})),\n\t\tbuild: Object.freeze({ ...def.build }),\n\t\texpose: def.expose !== void 0 ? frozenShallowCopy(def.expose) : void 0\n\t});\n}\n/**\n* Constructs a branded, frozen DependencyEnd. `required` (if given) is the\n* contract Load compares a wired ref against via `satisfies()`; an unnamed\n* end's diagnostic `name` falls back to its `type`.\n*/\nfunction dependency(def) {\n\trequireType(def.type, \"dependency\");\n\trequireNoUnderscoreNames(Object.keys(def.connection.params), \"param\", \"dependency\");\n\tconst connection = Object.freeze({\n\t\tparams: freezeParams(def.connection.params),\n\t\thydrate: def.connection.hydrate\n\t});\n\treturn Object.freeze({\n\t\t[NODE]: true,\n\t\tkind: \"dependency\",\n\t\tname: def.name !== void 0 && def.name.length > 0 ? def.name : def.type,\n\t\ttype: def.type,\n\t\tconnection,\n\t\trequired: def.required\n\t});\n}\n/**\n* Constructs a branded, frozen Module node. Construction is INERT — the body is\n* wiring, not user code, and runs only when the module is Loaded.\n*/\nfunction module(name, boundaryOrBody, maybeBody) {\n\trequireName(name, \"module\");\n\tconst closedRoot = typeof boundaryOrBody === \"function\";\n\tconst boundary = closedRoot ? {} : boundaryOrBody;\n\tconst deps = frozenShallowCopy(boundary.deps ?? {});\n\tconst secretSlots = frozenShallowCopy(boundary.secrets ?? {});\n\tconst expose = frozenShallowCopy(boundary.expose ?? {});\n\tconst body = closedRoot ? (ctx) => {\n\t\tboundaryOrBody(ctx);\n\t\treturn {};\n\t} : maybeBody;\n\treturn Object.freeze({\n\t\t[NODE]: true,\n\t\tkind: \"module\",\n\t\tname,\n\t\tdeps,\n\t\tsecretSlots,\n\t\texpose,\n\t\tbody\n\t});\n}\n/**\n* True if `value` was constructed by this module's factories. Checks the\n* brand only, never a prototype — a graph may mix nodes from a different\n* installed copy of core (dual-package hazard).\n*/\nfunction isNode(value) {\n\treturn typeof value === \"object\" && value !== null && value[NODE] === true;\n}\n//#endregion\n//#region src/toposort.ts\n/**\n* Stable topological sort: every edge's `from` precedes its `to` in the\n* result. Ties (nodes with no ordering constraint between them) keep their\n* relative order from `nodes` — so a graph already authored producer-first\n* comes out byte-identical to its pre-sort layout; only a graph that\n* genuinely needs reordering (e.g. a module wired via a forged ref pointing at a\n* not-yet-provisioned producer) actually moves. A Kahn's-algorithm variant\n* that always picks the ready node with the smallest original index. Edges\n* whose endpoint falls outside `nodes` (e.g. a service-root's input edges\n* targeting the root, which is appended separately) are ignored. Cycles\n* cannot reach here: `assertDependencyDag` already rejects them for\n* dependency edges, and input edges never cycle.\n*/\nfunction topoSort(nodes, edges) {\n\tconst byId = new Map(nodes.map((n) => [n.id, n]));\n\tconst indexOf = new Map(nodes.map((n, i) => [n.id, i]));\n\tconst indegree = new Map(nodes.map((n) => [n.id, 0]));\n\tconst successors = /* @__PURE__ */ new Map();\n\tfor (const edge of edges) {\n\t\tif (!byId.has(edge.from) || !byId.has(edge.to)) continue;\n\t\tconst targets = successors.get(edge.from) ?? [];\n\t\ttargets.push(edge.to);\n\t\tsuccessors.set(edge.from, targets);\n\t\tindegree.set(edge.to, (indegree.get(edge.to) ?? 0) + 1);\n\t}\n\tconst ready = new Set(nodes.filter((n) => indegree.get(n.id) === 0).map((n) => n.id));\n\tconst order = [];\n\twhile (ready.size > 0) {\n\t\tlet next;\n\t\tlet bestIndex = Number.POSITIVE_INFINITY;\n\t\tfor (const id of ready) {\n\t\t\tconst index = indexOf.get(id) ?? Number.POSITIVE_INFINITY;\n\t\t\tif (index < bestIndex) {\n\t\t\t\tbestIndex = index;\n\t\t\t\tnext = id;\n\t\t\t}\n\t\t}\n\t\tif (next === void 0) break;\n\t\tready.delete(next);\n\t\torder.push(next);\n\t\tfor (const target of successors.get(next) ?? []) {\n\t\t\tconst remaining = (indegree.get(target) ?? 0) - 1;\n\t\t\tindegree.set(target, remaining);\n\t\t\tif (remaining === 0) ready.add(target);\n\t\t}\n\t}\n\tif (order.length !== nodes.length) throw new LoadError(`topological sort processed ${order.length} of ${nodes.length} nodes — the graph contains a cycle that slipped past the DAG validation.`);\n\treturn order.map((id) => byId.get(id)).filter((n) => n !== void 0);\n}\n//#endregion\n//#region src/load-service.ts\nfunction serviceInputs(service, serviceId) {\n\tif (typeof service.inputs !== \"object\" || service.inputs === null) throw new LoadError(`Service \"${serviceId}\" has no inputs map.`);\n\tconst nodes = [];\n\tconst edges = [];\n\tfor (const [input, value] of Object.entries(service.inputs)) {\n\t\tconst kind = isNode(value) ? value.kind : void 0;\n\t\tif (kind === \"resource\") throw new LoadError(`Input \"${input}\" of \"${serviceId}\" is a resource node — a resource is provisioned by the composing module, never created for a service that mentions it. Declare the input as a dependency (the pack's dependency factory) and wire the module-provisioned resource's ref into it.`);\n\t\tif (kind !== \"dependency\") throw new LoadError(`Input \"${input}\" of \"${serviceId}\" is not a branded dependency end (construct it with the dependency() factory).`);\n\t\tif (value.type.length === 0) throw new LoadError(`Input \"${input}\" of \"${serviceId}\" has an empty node type.`);\n\t\tconst id = `${serviceId}.${input}`;\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tnode: value\n\t\t});\n\t\tedges.push({\n\t\t\tfrom: id,\n\t\t\tto: serviceId,\n\t\t\tinput,\n\t\t\tkind: \"input\"\n\t\t});\n\t}\n\treturn {\n\t\tnodes,\n\t\tedges\n\t};\n}\nfunction loadService(root, rootId) {\n\tfor (const [input, value] of Object.entries(root.inputs)) if (isNode(value) && value.kind === \"dependency\") throw new LoadError(`Service \"${rootId}\" has an unwired dependency input \"${input}\" — this service is composed by a module; deploy the module instead of loading \"${rootId}\" directly.`);\n\tconst secretSlots = Object.keys(root.secretSlots);\n\tif (secretSlots.length > 0) {\n\t\tconst names = secretSlots.map((k) => `\"${k}\"`).join(\", \");\n\t\tthrow new LoadError(`Service \"${rootId}\" declares secret slot${secretSlots.length > 1 ? \"s\" : \"\"} ${names} but is being loaded directly — a lone service has no enclosing scope to bind them. Compose it inside a module that binds each with envSecret('NAME').`);\n\t}\n\tconst rootGraphNode = {\n\t\tid: rootId,\n\t\tnode: root\n\t};\n\tconst { nodes, edges } = serviceInputs(root, rootId);\n\treturn {\n\t\troot: rootGraphNode,\n\t\tnodes: [...topoSort(nodes, edges), rootGraphNode],\n\t\tedges,\n\t\tsecrets: []\n\t};\n}\n//#endregion\n//#region src/load-module.ts\n/**\n* Builds the ref a provision() call hands back: the id (so a producer with no\n* exposed ports — or an untyped slot — can still be wired wholesale) plus one\n* ref-port per exposed contract, each the contract's own runtime value (so\n* its `satisfies()` still works) tagged with the provider's id.\n*/\nfunction refFor(id, service) {\n\tconst ports = {};\n\tfor (const [port, contract] of Object.entries(service.expose ?? {})) ports[port] = {\n\t\t...contract,\n\t\t__providerId: id\n\t};\n\treturn blindCast({\n\t\tid,\n\t\t...ports\n\t});\n}\n/**\n* The resource variant of refFor: a resource has exactly one port — the\n* contract it provides — flattened onto the ref itself, tagged with the\n* provider id. `id` is written last so a hostile contract value cannot\n* clobber it.\n*/\nfunction refForResource(id, resource) {\n\treturn blindCast({\n\t\t...resource.provides,\n\t\t__providerId: id,\n\t\tid\n\t});\n}\n/** A wired value's producer id: a ref-port's `__providerId`, or a bare ref's `id`. */\nfunction producerIdOf(ref) {\n\tif (typeof ref !== \"object\" || ref === null) return void 0;\n\tif (\"__providerId\" in ref && typeof ref.__providerId === \"string\") return ref.__providerId;\n\tif (\"id\" in ref && typeof ref.id === \"string\") return ref.id;\n}\n/**\n* Brands each `ctx.inputs` entry with the input key it stands for (see\n* flatten): diagnostic only — usage attribution relies on the per-key object\n* identity the branding copy creates, never on reading this back.\n*/\nconst MODULE_INPUT_KEY = Symbol(\"prisma:module-input-key\");\n/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.secrets` forwarding channel. */\nconst MODULE_SECRET_KEY = Symbol(\"prisma:module-secret-key\");\n/** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */\nfunction satisfiesRequired(ref, required) {\n\treturn typeof ref === \"object\" && ref !== null && \"satisfies\" in ref && typeof ref.satisfies === \"function\" && ref.satisfies(required);\n}\n/**\n* Checks one recorded `wiring` object against the Deps it was wired against:\n* every named input exists and is a dependency slot, every referenced\n* producer is a real (by-now-provisioned) address, and a wired ref whose\n* slot declares a required contract must satisfy() it — no producer-kind\n* branching, the contract alone determines validity, whether the producer is\n* a service port or a resource. Shared by both provisioned kinds so a\n* module-as-child gets exactly the checks a service gets, and run once per\n* entry against the one `byId` shared by the whole recursive flatten, so a\n* forwarded ref resolves through to its real producer address regardless of\n* which ancestor scope provisioned it.\n*/\nfunction validateWiring(pending, byId) {\n\tconst { deps, wiring, targetId, targetKind, enclosingModuleName } = pending;\n\tfor (const [input, ref] of Object.entries(wiring)) {\n\t\tconst declared = blindCast(deps[input]);\n\t\tif (declared === void 0 || !isNode(declared) || declared.kind !== \"dependency\") throw new LoadError(`The deps for \"${targetId}\" name \"${input}\", which is not a dependency slot of that ${targetKind}.`);\n\t\tconst producerId = producerIdOf(ref);\n\t\tconst producer = producerId !== void 0 ? byId.get(producerId) : void 0;\n\t\tif (producerId === void 0 || producer === void 0) throw new LoadError(`The deps for \"${targetId}.${input}\" reference \"${String(producerId)}\", which is not provisioned in module \"${enclosingModuleName}\".`);\n\t\tconst required = declared.required;\n\t\tif (required !== void 0 && !satisfiesRequired(ref, required)) throw new LoadError(`The deps for \"${targetId}.${input}\" do not satisfy the slot's required contract.`);\n\t}\n\tfor (const [input, rawValue] of Object.entries(deps)) {\n\t\tconst value = blindCast(rawValue);\n\t\tif (!isNode(value) || wiring[input] !== void 0) continue;\n\t\tif (value.kind === \"dependency\") throw new LoadError(`Dependency input \"${input}\" of provisioned ${targetKind} \"${targetId}\" is not wired to a producer (module \"${enclosingModuleName}\").`);\n\t}\n}\n/** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */\nfunction wiringEdges(wiring, targetId) {\n\treturn Object.entries(wiring).map(([input, ref]) => ({\n\t\tfrom: producerIdOf(ref) ?? \"\",\n\t\tto: targetId,\n\t\tinput,\n\t\tkind: \"dependency\"\n\t}));\n}\n/**\n* Checks the secrets wired into one provisioned child: every declared slot is\n* bound to a real secret source (an `envSecret` or a forwarded ctx.secrets\n* ref), and no wired key names a slot the child doesn't declare — the secret\n* analog of `validateWiring`'s per-input checks, but resolved inline (a source\n* carries its own name, so no whole-graph pass is needed).\n*/\nfunction validateSecretBinding(child, id, secretWiring, enclosingModuleName) {\n\tconst { kind } = child;\n\tfor (const slot of Object.keys(child.secretSlots)) {\n\t\tconst bound = secretWiring[slot];\n\t\tif (bound === void 0) throw new LoadError(`Secret slot \"${slot}\" of provisioned ${kind} \"${id}\" is not bound (module \"${enclosingModuleName}\") — bind it with envSecret('NAME') or forward ctx.secrets.`);\n\t\tif (!isSecretSource(bound)) throw new LoadError(`Secret slot \"${slot}\" of \"${id}\" (module \"${enclosingModuleName}\") was wired with a non-secret value — use envSecret('NAME') or a forwarded ctx.secrets ref.`);\n\t}\n\tfor (const slot of Object.keys(secretWiring)) if (!Object.hasOwn(child.secretSlots, slot)) throw new LoadError(`The secrets for \"${id}\" name \"${slot}\", which is not a secret slot of that ${kind} (module \"${enclosingModuleName}\").`);\n}\n/**\n* Recursively flattens one module's body into the shared graph state and\n* returns its resolved ModuleOutputs (one ref-port per expose key) for the\n* caller (the enclosing provision() call, or Load itself for the root) to\n* use. `address` is this module's OWN full address, or `undefined` for the root\n* scope — its direct children then get bare (unprefixed) addresses, keeping\n* a single-level module identical to before nesting existed. `wiring` supplies a\n* resolved producer ref-port for each of this module's OWN declared deps (empty\n* for the root, which may not declare any — see the root non-empty-deps\n* check in loadModule). `nodes`, `edges`, `pending`, and `byId` are shared\n* across the ENTIRE recursive flatten, not per scope — a nested module may\n* forward in a producer provisioned by an ancestor scope, and it is the\n* shared `byId` (keyed by full address) that lets that resolve.\n*/\nfunction flatten(moduleNode, address, wiring, secretWiring, nodes, edges, pending, secretBindings, byId) {\n\tconst localIds = /* @__PURE__ */ new Set();\n\tconst used = /* @__PURE__ */ new Set();\n\tconst usedSecrets = /* @__PURE__ */ new Set();\n\tconst ctxInputs = {};\n\tfor (const key of Object.keys(moduleNode.deps)) {\n\t\tconst wired = wiring[key];\n\t\tctxInputs[key] = typeof wired === \"object\" && wired !== null ? {\n\t\t\t...wired,\n\t\t\t[MODULE_INPUT_KEY]: key\n\t\t} : wired;\n\t}\n\tconst markUsed = (values) => {\n\t\tfor (const value of Object.values(values)) for (const key of Object.keys(ctxInputs)) if (value === ctxInputs[key]) used.add(key);\n\t};\n\tconst ctxSecrets = {};\n\tfor (const key of Object.keys(moduleNode.secretSlots)) {\n\t\tconst bound = secretWiring[key];\n\t\tctxSecrets[key] = typeof bound === \"object\" && bound !== null ? {\n\t\t\t...bound,\n\t\t\t[MODULE_SECRET_KEY]: key\n\t\t} : bound;\n\t}\n\tconst markSecretsUsed = (values) => {\n\t\tfor (const value of Object.values(values)) for (const key of Object.keys(ctxSecrets)) if (value === ctxSecrets[key]) usedSecrets.add(key);\n\t};\n\tconst provision = (child, opts) => {\n\t\tconst id = opts?.id ?? child.name;\n\t\tconst provisionWiring = opts?.deps;\n\t\tconst provisionSecrets = opts?.secrets;\n\t\tif (typeof id !== \"string\" || id.length === 0) throw new LoadError(`provision() requires a non-empty id (module \"${moduleNode.name}\").`);\n\t\tif (id.includes(\"_\") || id.includes(\".\")) throw new LoadError(`provision() id \"${id}\" (module \"${moduleNode.name}\") may not contain \"_\" or \".\" — \"_\" is the config-key separator and \".\" the node-id path separator; either inside an id collides with the joined form of other names.`);\n\t\tif (localIds.has(id)) throw new LoadError(`Duplicate provision id \"${id}\" in module \"${moduleNode.name}\".`);\n\t\tconst untrusted = child;\n\t\tif (!isNode(untrusted) || untrusted.kind !== \"service\" && untrusted.kind !== \"resource\" && untrusted.kind !== \"module\") throw new LoadError(`provision(\"${id}\") expects a branded service, resource, or module node (construct it with the service()/resource()/module() factories or a pack's own).`);\n\t\tlocalIds.add(id);\n\t\tconst fullAddress = address === void 0 ? id : `${address}.${id}`;\n\t\tif (child.kind === \"resource\") {\n\t\t\tif (provisionWiring !== void 0) throw new LoadError(`provision(\"${id}\") received deps for a resource — a resource has no dependency slots to satisfy.`);\n\t\t\tif (provisionSecrets !== void 0) throw new LoadError(`provision(\"${id}\") received secrets for a resource — a resource has no secret slots to satisfy.`);\n\t\t\tif (child.type.length === 0) throw new LoadError(`provision(\"${id}\") received a resource with an empty node type.`);\n\t\t\tbyId.set(fullAddress, child);\n\t\t\tnodes.push({\n\t\t\t\tid: fullAddress,\n\t\t\t\tnode: child\n\t\t\t});\n\t\t\treturn refForResource(fullAddress, child);\n\t\t}\n\t\tconst localWiring = { ...provisionWiring ?? {} };\n\t\tmarkUsed(localWiring);\n\t\tconst localSecrets = { ...provisionSecrets ?? {} };\n\t\tmarkSecretsUsed(localSecrets);\n\t\tvalidateSecretBinding(child, id, localSecrets, moduleNode.name);\n\t\tif (child.kind === \"service\") {\n\t\t\tfor (const slot of Object.keys(child.secretSlots)) {\n\t\t\t\tconst bound = localSecrets[slot];\n\t\t\t\tif (isSecretSource(bound)) secretBindings.push({\n\t\t\t\t\tserviceAddress: fullAddress,\n\t\t\t\t\tslot,\n\t\t\t\t\tsource: bound\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst inputs = serviceInputs(child, fullAddress);\n\t\t\tnodes.push(...inputs.nodes, {\n\t\t\t\tid: fullAddress,\n\t\t\t\tnode: child\n\t\t\t});\n\t\t\tedges.push(...inputs.edges, ...wiringEdges(localWiring, fullAddress));\n\t\t\tpending.push({\n\t\t\t\tdeps: child.inputs,\n\t\t\t\twiring: localWiring,\n\t\t\t\ttargetId: fullAddress,\n\t\t\t\ttargetKind: \"service\",\n\t\t\t\tenclosingModuleName: moduleNode.name\n\t\t\t});\n\t\t\tbyId.set(fullAddress, child);\n\t\t\treturn refFor(fullAddress, child);\n\t\t}\n\t\tedges.push(...wiringEdges(localWiring, fullAddress));\n\t\tpending.push({\n\t\t\tdeps: child.deps,\n\t\t\twiring: localWiring,\n\t\t\ttargetId: fullAddress,\n\t\t\ttargetKind: \"module\",\n\t\t\tenclosingModuleName: moduleNode.name\n\t\t});\n\t\tconst childOutputs = flatten(child, fullAddress, localWiring, localSecrets, nodes, edges, pending, secretBindings, byId);\n\t\tnodes.push({\n\t\t\tid: fullAddress,\n\t\t\tnode: child\n\t\t});\n\t\tbyId.set(fullAddress, child);\n\t\treturn blindCast({\n\t\t\tid: fullAddress,\n\t\t\t...childOutputs\n\t\t});\n\t};\n\tconst ctx = blindCast({\n\t\tinputs: ctxInputs,\n\t\tsecrets: ctxSecrets,\n\t\tprovision: blindCast(provision)\n\t});\n\tconst outputs = blindCast(moduleNode.body(ctx) ?? {});\n\tmarkUsed(outputs);\n\tfor (const key of Object.keys(moduleNode.deps)) if (!used.has(key)) throw new LoadError(`Module \"${moduleNode.name}\" declares input \"${key}\" but never forwards it into a provision nor returns it as an output.`);\n\tfor (const key of Object.keys(moduleNode.secretSlots)) if (!usedSecrets.has(key)) throw new LoadError(`Module \"${moduleNode.name}\" declares secret \"${key}\" but never forwards it into a provision.`);\n\tfor (const [key, contract] of Object.entries(moduleNode.expose)) {\n\t\tconst port = outputs[key];\n\t\tif (port === void 0) throw new LoadError(`Module \"${moduleNode.name}\" declares expose \"${key}\" but its body did not return a port for it.`);\n\t\tif (!satisfiesRequired(port, contract)) throw new LoadError(`Module \"${moduleNode.name}\"'s returned port for expose \"${key}\" does not satisfy its declared contract.`);\n\t}\n\treturn outputs;\n}\nfunction loadModule(root, opts) {\n\tconst rootId = opts?.id ?? root.name;\n\tconst rootDepKeys = Object.keys(root.deps);\n\tif (rootDepKeys.length > 0) {\n\t\tconst names = rootDepKeys.map((k) => `\"${k}\"`).join(\", \");\n\t\tthrow new LoadError(`Module \"${root.name}\" declares input${rootDepKeys.length > 1 ? \"s\" : \"\"} ${names} but is being deployed as the root — a root has no enclosing scope to wire them; compose \"${root.name}\" from another module that provisions and wires it instead.`);\n\t}\n\tconst rootSecretKeys = Object.keys(root.secretSlots);\n\tif (rootSecretKeys.length > 0) {\n\t\tconst names = rootSecretKeys.map((k) => `\"${k}\"`).join(\", \");\n\t\tthrow new LoadError(`Module \"${root.name}\" declares secret${rootSecretKeys.length > 1 ? \"s\" : \"\"} ${names} but is being deployed as the root — a root has no enclosing scope to bind them; the root binds secrets with envSecret('NAME'), it does not declare secret slots of its own.`);\n\t}\n\tconst nodes = [];\n\tconst edges = [];\n\tconst pending = [];\n\tconst secretBindings = [];\n\tconst byId = /* @__PURE__ */ new Map();\n\tflatten(root, void 0, {}, {}, nodes, edges, pending, secretBindings, byId);\n\tfor (const entry of pending) validateWiring(entry, byId);\n\tassertDependencyDag(edges);\n\tconst rootGraphNode = {\n\t\tid: rootId,\n\t\tnode: root\n\t};\n\treturn {\n\t\troot: rootGraphNode,\n\t\tnodes: [...topoSort(nodes, edges), rootGraphNode],\n\t\tedges,\n\t\tsecrets: secretBindings\n\t};\n}\n/**\n* The dependency edges must form a DAG — a cycle means neither producer can\n* deploy first. Resources take no wiring, so only service/module-to-service/module\n* edges can ever participate in a cycle; no special-casing needed.\n*/\nfunction assertDependencyDag(edges) {\n\tconst adjacency = /* @__PURE__ */ new Map();\n\tfor (const edge of edges) {\n\t\tif (edge.kind !== \"dependency\") continue;\n\t\tconst targets = adjacency.get(edge.from) ?? [];\n\t\ttargets.push(edge.to);\n\t\tadjacency.set(edge.from, targets);\n\t}\n\tconst visiting = /* @__PURE__ */ new Set();\n\tconst done = /* @__PURE__ */ new Set();\n\tconst stack = [];\n\tconst visit = (id) => {\n\t\tif (done.has(id)) return;\n\t\tif (visiting.has(id)) throw new LoadError(`Dependency cycle: ${[...stack.slice(stack.indexOf(id)), id].join(\" → \")} — no deploy order exists.`);\n\t\tvisiting.add(id);\n\t\tstack.push(id);\n\t\tfor (const next of adjacency.get(id) ?? []) visit(next);\n\t\tstack.pop();\n\t\tvisiting.delete(id);\n\t\tdone.add(id);\n\t};\n\tfor (const id of adjacency.keys()) visit(id);\n}\n//#endregion\n//#region src/graph.ts\n/**\n* Builds the in-memory graph from a root node. A service root walks its own\n* `inputs`; a module root executes its body (wiring, not user code — the\n* designed exception to imports-run-nothing) and recursively flattens every\n* module it provisions into one graph of hierarchical addresses. A malformed\n* graph is a `LoadError` that names its fix; the individual validation rules\n* live with `loadService` / `loadModule` and are covered by name in the Load\n* tests. Executes nothing of the user's own code beyond module bodies.\n*/\nfunction Load(root, opts) {\n\tif (!isNode(root)) throw new LoadError(\"Load expects a branded service or module node (construct it with the service()/module() factories).\");\n\tif (root.kind === \"module\") return loadModule(root, opts);\n\tif (root.kind === \"service\") return loadService(root, opts?.id ?? \"root\");\n\tthrow new LoadError(\"Load expects a service or module root (received another node kind).\");\n}\n//#endregion\nexport { isNode as a, resource as c, service as d, LoadError as f, freezeNode as i, secret as l, ResourceNodeBase as n, isSecretSource as o, dependency as r, module as s, Load as t, secretSource as u };\n\n//# sourceMappingURL=graph-BYdCQKya.mjs.map"],"mappings":";;;AAGA,IAAI,YAAY,cAAc,MAAM;CACnC,YAAY,SAAS;EACpB,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;;;;;AAOA,MAAM,OAAO,OAAO,IAAI,aAAa;AACrC,MAAM,cAAc,UAAU,OAAO,IAAI,oBAAoB,CAAC;AAC9D,MAAM,gBAAgB,UAAU,OAAO,IAAI,sBAAsB,CAAC;;AAElE,SAAS,SAAS;CACjB,OAAO,OAAO,OAAO;GACnB,cAAc;EACf,MAAM;CACP,CAAC;AACF;;AAEA,SAAS,aAAa,SAAS;CAC9B,OAAO,OAAO,OAAO;GACnB,gBAAgB;EACjB;CACD,CAAC;AACF;;AAEA,SAAS,eAAe,OAAO;CAC9B,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,KAAK,CAAC,CAAC,mBAAmB;AAC3F;AACA,SAAS,YAAY,MAAM,SA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AW,MAAM,IAAI;CACxD,IAAI,KAAK,SAAS,WAAW,OAAO,YAAY,MAAM,MAAM,MAAM,MAAM;CACxE,MAAM,IAAI,UAAU,qEAAqE;AAC1F"}
|
package/dist/rpc.d.mts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { D as RunnableServiceNode, o as Contract, s as DependencyEnd } from "./config-ob5OhCSP-sP3GW3uu.mjs";
|
|
2
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
|
|
4
|
-
//#region ../../0-framework/2-authoring/rpc/dist/index.d.mts
|
|
5
|
-
//#region src/rpc.d.ts
|
|
6
|
-
/** The concrete function-map bound every RPC Contract's Cmp must fit. */
|
|
7
|
-
type RpcFns = Record<string, (input: any) => Promise<any>>;
|
|
8
|
-
declare function rpc<I extends StandardSchemaV1, O extends StandardSchemaV1>(m: {
|
|
9
|
-
input: I;
|
|
10
|
-
output: O;
|
|
11
|
-
}): (input: StandardSchemaV1.InferInput<I>) => Promise<StandardSchemaV1.InferOutput<O>>;
|
|
12
|
-
declare function rpc<C extends Contract<'rpc', RpcFns>>(contract: C): DependencyEnd<Client<C>, C>;
|
|
13
|
-
/** The typed client a consumer's `rpc(contract)` dependency hydrates to. */
|
|
14
|
-
type Client<C> = C extends Contract<string, infer Cmp> ? Cmp : never; //#endregion
|
|
15
|
-
//#region src/client.d.ts
|
|
16
|
-
/**
|
|
17
|
-
* A fetch-shaped transport. Defaults to the real `fetch`; a served handler
|
|
18
|
-
* (`serve()`'s return value) works too — the binding does not have to be a
|
|
19
|
-
* network hop.
|
|
20
|
-
*/
|
|
21
|
-
type Transport = (req: Request) => Promise<Response>;
|
|
22
|
-
declare function makeClient<C extends Contract<'rpc', RpcFns>>(contract: C, url: string, opts?: {
|
|
23
|
-
fetch?: Transport;
|
|
24
|
-
}): Client<C>; //#endregion
|
|
25
|
-
//#region src/contract.d.ts
|
|
26
|
-
declare function contract<Fns extends Record<string, (input: any) => Promise<any>>>(fns: Fns): Contract<'rpc', Fns>; //#endregion
|
|
27
|
-
//#region src/serve.d.ts
|
|
28
|
-
type AnyRunnable = RunnableServiceNode<any, any, any>;
|
|
29
|
-
type CmpOf<C> = C extends Contract<string, infer Cmp> ? Cmp : never;
|
|
30
|
-
type HandlerFor<Fn, LoadedDeps> = Fn extends ((input: infer I) => Promise<infer O>) ? (input: I, deps: LoadedDeps) => Promise<O> : never;
|
|
31
|
-
/** Every exposed port's methods, turned into a handler map typed off S's own `expose` and `load()`. */
|
|
32
|
-
type Handlers<S extends AnyRunnable> = { [Port in keyof NonNullable<S['expose']>]: { [M in keyof CmpOf<NonNullable<S['expose']>[Port]>]: HandlerFor<CmpOf<NonNullable<S['expose']>[Port]>[M], ReturnType<S['load']>> } };
|
|
33
|
-
/**
|
|
34
|
-
* Routes `POST /rpc/<method>`: parses JSON, validates input, calls the
|
|
35
|
-
* handler with `service.load()`'s deps, validates the output, and responds
|
|
36
|
-
* JSON. An unknown method or invalid input is a 4xx; a handler (or output
|
|
37
|
-
* validation) failure is a 5xx — either way the process does not crash.
|
|
38
|
-
* `load()` is called exactly once, here, before the handler ever runs.
|
|
39
|
-
*/
|
|
40
|
-
declare function serve<S extends AnyRunnable, H extends Handlers<S>>(service: S, handlers: H): (req: Request) => Promise<Response>; //#endregion
|
|
41
|
-
//#endregion
|
|
42
|
-
export { type Client, type Handlers, type Transport, contract, makeClient, rpc, serve };
|
|
43
|
-
//# sourceMappingURL=rpc.d.mts.map
|
package/dist/rpc.mjs
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { t as blindCast } from "./casts-Ci5rYYaR.mjs";
|
|
2
|
-
import { i as dependency } from "./graph-BYdCQKya-BI0njTow.mjs";
|
|
3
|
-
import { c as string } from "./dist-zBU8ASQW.mjs";
|
|
4
|
-
//#region ../../0-framework/2-authoring/rpc/dist/index.mjs
|
|
5
|
-
async function standardValidate(schema, value) {
|
|
6
|
-
const result = await schema["~standard"].validate(value);
|
|
7
|
-
if (result.issues !== void 0) throw new Error(`Schema validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
8
|
-
return result.value;
|
|
9
|
-
}
|
|
10
|
-
/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */
|
|
11
|
-
function methodUrl(base, method) {
|
|
12
|
-
const normalizedBase = base.endsWith("/") ? base : `${base}/`;
|
|
13
|
-
return new URL(`rpc/${method}`, normalizedBase).toString();
|
|
14
|
-
}
|
|
15
|
-
/** The server's `{ error }` body, if the response has one — undefined otherwise. */
|
|
16
|
-
async function errorDetail(res) {
|
|
17
|
-
try {
|
|
18
|
-
const body = await res.json();
|
|
19
|
-
return typeof body === "object" && body !== null && "error" in body ? String(body.error) : void 0;
|
|
20
|
-
} catch {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function makeClient(contract, url, opts) {
|
|
25
|
-
const send = opts?.fetch ?? fetch;
|
|
26
|
-
const client = {};
|
|
27
|
-
for (const [method, schemas] of Object.entries(blindCast(contract.__cmp))) client[method] = async (input) => {
|
|
28
|
-
const res = await send(new Request(methodUrl(url, method), {
|
|
29
|
-
method: "POST",
|
|
30
|
-
headers: { "content-type": "application/json" },
|
|
31
|
-
body: JSON.stringify(input)
|
|
32
|
-
}));
|
|
33
|
-
if (!res.ok) {
|
|
34
|
-
const detail = await errorDetail(res);
|
|
35
|
-
throw new Error(`RPC call "${method}" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : ""));
|
|
36
|
-
}
|
|
37
|
-
return standardValidate(schemas.output, await res.json());
|
|
38
|
-
};
|
|
39
|
-
return blindCast(client);
|
|
40
|
-
}
|
|
41
|
-
function contract(fns) {
|
|
42
|
-
const value = {
|
|
43
|
-
kind: "rpc",
|
|
44
|
-
__cmp: fns,
|
|
45
|
-
satisfies: (required) => value === required
|
|
46
|
-
};
|
|
47
|
-
return Object.freeze(value);
|
|
48
|
-
}
|
|
49
|
-
function rpc(arg) {
|
|
50
|
-
if (!isRpcContract(arg)) return arg;
|
|
51
|
-
return dependency({
|
|
52
|
-
type: "rpc",
|
|
53
|
-
connection: {
|
|
54
|
-
params: { url: string() },
|
|
55
|
-
hydrate: ({ url }) => makeClient(arg, url)
|
|
56
|
-
},
|
|
57
|
-
required: arg
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
function isRpcContract(value) {
|
|
61
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "rpc" && "__cmp" in value && "satisfies" in value;
|
|
62
|
-
}
|
|
63
|
-
function jsonResponse(body, status = 200) {
|
|
64
|
-
return new Response(JSON.stringify(body), {
|
|
65
|
-
status,
|
|
66
|
-
headers: { "content-type": "application/json" }
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Flattens every exposed port's methods into one method → {schemas, handler}
|
|
71
|
-
* table. RPC dispatch is flat (`/rpc/<method>`), so a method name exposed by
|
|
72
|
-
* more than one port is a construction-time error, as is a missing handler.
|
|
73
|
-
*/
|
|
74
|
-
function methodTable(expose, handlers) {
|
|
75
|
-
const table = /* @__PURE__ */ new Map();
|
|
76
|
-
for (const [port, contract] of Object.entries(expose)) {
|
|
77
|
-
const portHandlers = handlers[port] ?? {};
|
|
78
|
-
for (const [method, fn] of Object.entries(contract.__cmp)) {
|
|
79
|
-
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.`);
|
|
80
|
-
const handler = portHandlers[method];
|
|
81
|
-
if (handler === void 0) throw new Error(`serve(): no handler supplied for exposed method "${port}.${method}".`);
|
|
82
|
-
const { input, output } = blindCast(fn);
|
|
83
|
-
table.set(method, {
|
|
84
|
-
input,
|
|
85
|
-
output,
|
|
86
|
-
handler
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return table;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Routes `POST /rpc/<method>`: parses JSON, validates input, calls the
|
|
94
|
-
* handler with `service.load()`'s deps, validates the output, and responds
|
|
95
|
-
* JSON. An unknown method or invalid input is a 4xx; a handler (or output
|
|
96
|
-
* validation) failure is a 5xx — either way the process does not crash.
|
|
97
|
-
* `load()` is called exactly once, here, before the handler ever runs.
|
|
98
|
-
*/
|
|
99
|
-
function serve(service, handlers) {
|
|
100
|
-
const table = methodTable(service.expose ?? {}, blindCast(handlers));
|
|
101
|
-
const deps = service.load();
|
|
102
|
-
return async (req) => {
|
|
103
|
-
const { pathname } = new URL(req.url);
|
|
104
|
-
const methodName = /^\/rpc\/([^/]+)$/.exec(pathname)?.[1];
|
|
105
|
-
if (methodName === void 0) return jsonResponse({ error: `Not found: ${pathname}` }, 404);
|
|
106
|
-
const method = table.get(methodName);
|
|
107
|
-
if (method === void 0) return jsonResponse({ error: `Unknown RPC method "${methodName}"` }, 404);
|
|
108
|
-
if (req.method !== "POST") return jsonResponse({ error: `Method "${methodName}" requires POST` }, 405);
|
|
109
|
-
let body;
|
|
110
|
-
try {
|
|
111
|
-
body = await req.json();
|
|
112
|
-
} catch {
|
|
113
|
-
return jsonResponse({ error: "Request body must be JSON" }, 400);
|
|
114
|
-
}
|
|
115
|
-
let input;
|
|
116
|
-
try {
|
|
117
|
-
input = await standardValidate(method.input, body);
|
|
118
|
-
} catch (err) {
|
|
119
|
-
return jsonResponse({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const result = await method.handler(input, deps);
|
|
123
|
-
return jsonResponse(await standardValidate(method.output, result));
|
|
124
|
-
} catch (err) {
|
|
125
|
-
return jsonResponse({ error: err instanceof Error ? err.message : String(err) }, 500);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
export { contract, makeClient, rpc, serve };
|
|
131
|
-
|
|
132
|
-
//# sourceMappingURL=rpc.mjs.map
|
package/dist/rpc.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.mjs","names":[],"sources":["../../../0-framework/2-authoring/rpc/dist/index.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\nimport { dependency, string } from \"@internal/core\";\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/client.ts\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/** 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}\nfunction makeClient(contract, url, opts) {\n\tconst send = opts?.fetch ?? fetch;\n\tconst client = {};\n\tfor (const [method, schemas] of Object.entries(blindCast(contract.__cmp))) client[method] = async (input) => {\n\t\tconst res = await send(new Request(methodUrl(url, method), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify(input)\n\t\t}));\n\t\tif (!res.ok) {\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\treturn standardValidate(schemas.output, await res.json());\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\nfunction rpc(arg) {\n\tif (!isRpcContract(arg)) return arg;\n\treturn dependency({\n\t\ttype: \"rpc\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: ({ url }) => makeClient(arg, url)\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/serve.ts\nfunction jsonResponse(body, status = 200) {\n\treturn new Response(JSON.stringify(body), {\n\t\tstatus,\n\t\theaders: { \"content-type\": \"application/json\" }\n\t});\n}\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>`: parses JSON, validates input, calls the\n* handler with `service.load()`'s deps, validates the output, and responds\n* JSON. An unknown method or invalid input is a 4xx; a handler (or output\n* validation) failure is a 5xx — either way the process does not crash.\n* `load()` is called exactly 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\treturn async (req) => {\n\t\tconst { pathname } = new URL(req.url);\n\t\tconst methodName = /^\\/rpc\\/([^/]+)$/.exec(pathname)?.[1];\n\t\tif (methodName === void 0) return jsonResponse({ error: `Not found: ${pathname}` }, 404);\n\t\tconst method = table.get(methodName);\n\t\tif (method === void 0) return jsonResponse({ error: `Unknown RPC method \"${methodName}\"` }, 404);\n\t\tif (req.method !== \"POST\") return jsonResponse({ error: `Method \"${methodName}\" requires POST` }, 405);\n\t\tlet body;\n\t\ttry {\n\t\t\tbody = await req.json();\n\t\t} catch {\n\t\t\treturn jsonResponse({ error: \"Request body must be JSON\" }, 400);\n\t\t}\n\t\tlet input;\n\t\ttry {\n\t\t\tinput = await standardValidate(method.input, body);\n\t\t} catch (err) {\n\t\t\treturn jsonResponse({ error: err instanceof Error ? err.message : String(err) }, 400);\n\t\t}\n\t\ttry {\n\t\t\tconst result = await method.handler(input, deps);\n\t\t\treturn jsonResponse(await standardValidate(method.output, result));\n\t\t} catch (err) {\n\t\t\treturn jsonResponse({ error: err instanceof Error ? err.message : String(err) }, 500);\n\t\t}\n\t};\n}\n//#endregion\nexport { contract, makeClient, rpc, serve };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;AAGA,eAAe,iBAAiB,QAAQ,OAAO;CAC9C,MAAM,SAAS,MAAM,OAAO,YAAY,CAAC,SAAS,KAAK;CACvD,IAAI,OAAO,WAAW,KAAK,GAAG,MAAM,IAAI,MAAM,6BAA6B,OAAO,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG;CACnI,OAAO,OAAO;AACf;;AAIA,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;;AAEA,eAAe,YAAY,KAAK;CAC/B,IAAI;EACH,MAAM,OAAO,MAAM,IAA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GAAG;EACrG,IAAI;EACJ,IAAI;GACH,OAAO,MAAM,IAAI,KAAK;EACvB,QAAQ;GACP,OAAO,aAAa,EAAE,OAAO,4BAA4B,GAAG,GAAG;EAChE;EACA,IAAI;EACJ,IAAI;GACH,QAAQ,MAAM,iBAAiB,OAAO,OAAO,IAAI;EAClD,SAAS,KAAK;GACb,OAAO,aAAa,EAAE,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAAE,GAAG,GAAG;EACrF;EACA,IAAI;GACH,MAAM,SAAS,MAAM,OAAO,QAAQ,OAAO,IAAI;GAC/C,OAAO,aAAa,MAAM,iBAAiB,OAAO,QAAQ,MAAM,CAAC;EAClE,SAAS,KAAK;GACb,OAAO,aAAa,EAAE,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAAE,GAAG,GAAG;EACrF;CACD;AACD"}
|
package/dist/tsdown.d.mts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UserConfig } from "tsdown";
|
|
2
|
-
|
|
3
|
-
//#region src/tsdown.d.ts
|
|
4
|
-
declare function prismaTsDownConfig(config: UserConfig & {
|
|
5
|
-
entry: NonNullable<UserConfig['entry']>;
|
|
6
|
-
}): UserConfig;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { prismaTsDownConfig };
|
|
9
|
-
//# sourceMappingURL=tsdown.d.mts.map
|
package/dist/tsdown.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/tsdown.ts
|
|
2
|
-
/**
|
|
3
|
-
* `tsdown` config for a Prisma App's own runnable — the build ADR-0005 expects
|
|
4
|
-
* an app to produce before deploy. Its one job is a **self-contained** ESM
|
|
5
|
-
* bundle: `node_modules` is never shipped, so everything the entry touches at
|
|
6
|
-
* runtime must be inlined, and the artifact must not lean on bun's runtime
|
|
7
|
-
* auto-install to fill gaps. So it inlines EVERYTHING except the runtime's own
|
|
8
|
-
* built-ins (`bun`, `bun:*`, `node:*`) — a denylist, not a per-package
|
|
9
|
-
* allowlist. Allowlists are the trap: `noExternal: [/^pg$/]` inlines `pg` but
|
|
10
|
-
* misses its subpath imports (`pg/lib/*`), which then vanish from the bundle and
|
|
11
|
-
* crash the service at boot. This mirrors the deploy wrapper's own inline
|
|
12
|
-
* policy, so app and wrapper are self-contained the same way.
|
|
13
|
-
*
|
|
14
|
-
* Pass your `entry` (and any override); everything else is dictated.
|
|
15
|
-
*/
|
|
16
|
-
const appBaseConfig = {
|
|
17
|
-
outDir: "dist",
|
|
18
|
-
format: "esm",
|
|
19
|
-
platform: "node",
|
|
20
|
-
external: ["bun"],
|
|
21
|
-
noExternal: [/^(?!bun$)(?!bun:)(?!node:).+/],
|
|
22
|
-
dts: false,
|
|
23
|
-
sourcemap: false,
|
|
24
|
-
clean: true
|
|
25
|
-
};
|
|
26
|
-
function prismaTsDownConfig(config) {
|
|
27
|
-
return {
|
|
28
|
-
...appBaseConfig,
|
|
29
|
-
...config
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { prismaTsDownConfig };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=tsdown.mjs.map
|
package/dist/tsdown.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.mjs","names":[],"sources":["../src/tsdown.ts"],"sourcesContent":["import type { UserConfig } from 'tsdown';\n\n/**\n * `tsdown` config for a Prisma App's own runnable — the build ADR-0005 expects\n * an app to produce before deploy. Its one job is a **self-contained** ESM\n * bundle: `node_modules` is never shipped, so everything the entry touches at\n * runtime must be inlined, and the artifact must not lean on bun's runtime\n * auto-install to fill gaps. So it inlines EVERYTHING except the runtime's own\n * built-ins (`bun`, `bun:*`, `node:*`) — a denylist, not a per-package\n * allowlist. Allowlists are the trap: `noExternal: [/^pg$/]` inlines `pg` but\n * misses its subpath imports (`pg/lib/*`), which then vanish from the bundle and\n * crash the service at boot. This mirrors the deploy wrapper's own inline\n * policy, so app and wrapper are self-contained the same way.\n *\n * Pass your `entry` (and any override); everything else is dictated.\n */\nconst appBaseConfig: UserConfig = {\n outDir: 'dist',\n format: 'esm',\n platform: 'node',\n external: ['bun'],\n // Inline everything except runtime built-ins (bun/bun:/node:).\n noExternal: [/^(?!bun$)(?!bun:)(?!node:).+/],\n dts: false,\n sourcemap: false,\n clean: true,\n};\n\nexport function prismaTsDownConfig(\n config: UserConfig & { entry: NonNullable<UserConfig['entry']> },\n): UserConfig {\n return {\n ...appBaseConfig,\n ...config,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAM,gBAA4B;CAChC,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,UAAU,CAAC,KAAK;CAEhB,YAAY,CAAC,8BAA8B;CAC3C,KAAK;CACL,WAAW;CACX,OAAO;AACT;AAEA,SAAgB,mBACd,QACY;CACZ,OAAO;EACL,GAAG;EACH,GAAG;CACL;AACF"}
|