@prisma/composer 0.1.0-dev.1
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/LICENSE +201 -0
- package/dist/app-config-CpWN1ZfP-CZ1c6Eqk.d.mts +325 -0
- package/dist/assertions.d.mts +31 -0
- package/dist/assertions.mjs +35 -0
- package/dist/assertions.mjs.map +1 -0
- package/dist/bin.mjs +1229 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/casts-Ci5rYYaR.mjs +82 -0
- package/dist/casts-Ci5rYYaR.mjs.map +1 -0
- package/dist/casts.d.mts +78 -0
- package/dist/casts.mjs +2 -0
- package/dist/config-D-h0FACe.d.mts +1 -0
- package/dist/config-ad92ubCB-D0-dZUgA.d.mts +568 -0
- package/dist/config.d.mts +3 -0
- package/dist/config.mjs +9 -0
- package/dist/config.mjs.map +1 -0
- package/dist/deploy-D-h0FACe.d.mts +1 -0
- package/dist/deploy.d.mts +3 -0
- package/dist/deploy.mjs +305 -0
- package/dist/deploy.mjs.map +1 -0
- package/dist/dist-B0axxnBf.mjs +193 -0
- package/dist/dist-B0axxnBf.mjs.map +1 -0
- package/dist/graph-BmrUEdo9-6Oq1hSmS.mjs +688 -0
- package/dist/graph-BmrUEdo9-6Oq1hSmS.mjs.map +1 -0
- package/dist/graph-DXuL5tN6-BeAHOb0u.d.mts +18 -0
- package/dist/index-C1f1Aot7.d.mts +16 -0
- package/dist/index-Cy4C23u1.d.mts +32 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +3 -0
- package/dist/nextjs-control.d.mts +14 -0
- package/dist/nextjs-control.mjs +105 -0
- package/dist/nextjs-control.mjs.map +1 -0
- package/dist/nextjs.d.mts +2 -0
- package/dist/nextjs.mjs +12 -0
- package/dist/nextjs.mjs.map +1 -0
- package/dist/node-control.d.mts +11 -0
- package/dist/node-control.mjs +142 -0
- package/dist/node-control.mjs.map +1 -0
- package/dist/node.d.mts +23 -0
- package/dist/node.mjs +12 -0
- package/dist/node.mjs.map +1 -0
- package/dist/report.d.mts +17 -0
- package/dist/report.mjs +79 -0
- package/dist/report.mjs.map +1 -0
- package/dist/rpc.d.mts +53 -0
- package/dist/rpc.mjs +184 -0
- package/dist/rpc.mjs.map +1 -0
- package/dist/testing.d.mts +23 -0
- package/dist/testing.mjs +45 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret.d.mts
|
|
3
|
+
//#region src/secret.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A value wrapper that redacts everywhere except the one explicit reader,
|
|
6
|
+
* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
|
|
7
|
+
* sink must remember to check: `String(box)`, template interpolation,
|
|
8
|
+
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
9
|
+
* a secret can't leak through an accidental log or serialization.
|
|
10
|
+
*
|
|
11
|
+
* Shape matches the platform's own `secrecy` type (pdp-control-plane). The class
|
|
12
|
+
* is nominal enough on its own — no phantom brand.
|
|
13
|
+
*/
|
|
14
|
+
declare class SecretBox<T> {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(value: T);
|
|
17
|
+
/** The sole explicit door to the wrapped value. */
|
|
18
|
+
expose(): T;
|
|
19
|
+
toString(): string;
|
|
20
|
+
toJSON(): string;
|
|
21
|
+
valueOf(): string;
|
|
22
|
+
[Symbol.toPrimitive](): string;
|
|
23
|
+
}
|
|
24
|
+
/** The common case: a secret string. */
|
|
25
|
+
type SecretString = SecretBox<string>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../../0-framework/1-core/core/dist/config-ad92ubCB.d.mts
|
|
28
|
+
//#region src/contract.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* A Contract is the declared interface of a service-to-service dependency: a
|
|
31
|
+
* protocol brand (`kind`) plus an opaque comparison type (`Cmp`) the core
|
|
32
|
+
* never inspects. Wiring compatibility is plain TypeScript assignability on
|
|
33
|
+
* `Cmp`, checked at `ModuleBuilder.provision`'s call site (node.ts); `satisfies`
|
|
34
|
+
* is its runtime mirror, called at Load (graph.ts). Correctness comes from
|
|
35
|
+
* the kind's builder shaping `Cmp` so assignability means the right thing —
|
|
36
|
+
* see @prisma/composer/rpc's `contract()`/`rpc()`.
|
|
37
|
+
*/
|
|
38
|
+
interface Contract<Kind extends string, Cmp> {
|
|
39
|
+
readonly kind: Kind;
|
|
40
|
+
readonly __cmp: Cmp;
|
|
41
|
+
satisfies(required: Contract<Kind, unknown>): boolean;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/node.d.ts
|
|
45
|
+
declare const NODE: unique symbol;
|
|
46
|
+
declare const SECRET_NEED: unique symbol;
|
|
47
|
+
declare const SECRET_SOURCE: unique symbol;
|
|
48
|
+
/** A declared secret input slot — nameless; the root binds it and the topology forwards it in. */
|
|
49
|
+
interface SecretNeed {
|
|
50
|
+
readonly [SECRET_NEED]: true;
|
|
51
|
+
readonly kind: 'secret';
|
|
52
|
+
}
|
|
53
|
+
/** A service/module's secret slots: name → the need it declares. */
|
|
54
|
+
type Secrets = Record<string, SecretNeed>;
|
|
55
|
+
/** The wiring value bound to a secret slot: a target-defined payload core forwards but never inspects. A target (e.g. @prisma/composer-prisma-cloud's `envSecret`) builds one via `secretSource()`. */
|
|
56
|
+
interface SecretSource<T = unknown> {
|
|
57
|
+
readonly [SECRET_SOURCE]: true;
|
|
58
|
+
/** Target-defined. Core never reads this; the target that authored the source reads it back. */
|
|
59
|
+
readonly payload: T;
|
|
60
|
+
}
|
|
61
|
+
/** What `provision(node, { secrets })` supplies: one source per declared secret slot. */
|
|
62
|
+
type SecretBindings<S extends Secrets> = { [K in keyof S]: SecretSource; };
|
|
63
|
+
/** What `secrets()` returns: one redacting SecretBox per declared slot. */
|
|
64
|
+
type SecretValues<S extends Secrets> = { readonly [K in keyof S]: SecretString; };
|
|
65
|
+
/** Declares a secret NEED. Nameless — the platform name is bound at the root via `envSecret`. */
|
|
66
|
+
declare function secret(): SecretNeed;
|
|
67
|
+
/** 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. */
|
|
68
|
+
declare function secretSource<T>(payload: T): SecretSource<T>;
|
|
69
|
+
/** True if `value` is a secret source (an `envSecret` result or a forwarded ctx.secrets ref). */
|
|
70
|
+
declare function isSecretSource(value: unknown): value is SecretSource;
|
|
71
|
+
declare const PROVISION_NEED: unique symbol;
|
|
72
|
+
/** A param value the framework mints. Opaque to core: it forwards the payload to the resolved provisioner and never reads it (ADR-0031). */
|
|
73
|
+
interface ProvisionNeed<T = unknown> {
|
|
74
|
+
readonly [PROVISION_NEED]: true;
|
|
75
|
+
/** Selects the provisioner in an extension's `provisions` registry. */
|
|
76
|
+
readonly brand: symbol;
|
|
77
|
+
/** Provisioner-defined; core never reads it. */
|
|
78
|
+
readonly payload: T;
|
|
79
|
+
}
|
|
80
|
+
/** Builds an opaque provisioning need — the declaring package's own brand plus whatever payload its provisioner reads back. */
|
|
81
|
+
declare function provisionNeed<T = undefined>(brand: symbol, payload?: T): ProvisionNeed<T>;
|
|
82
|
+
/** True if `value` is a provisioning need (a `provisionNeed()` result). */
|
|
83
|
+
declare function isProvisionNeed(value: unknown): value is ProvisionNeed;
|
|
84
|
+
declare const PARAM_SOURCE: unique symbol;
|
|
85
|
+
declare const PARAM_NEED: unique symbol;
|
|
86
|
+
/** The wiring value bound to a param at provision time: a target-defined payload core forwards but never inspects. A target (e.g. @prisma/composer-prisma-cloud's `envParam`) builds one via `paramSource()`. */
|
|
87
|
+
interface ParamSource<T = unknown> {
|
|
88
|
+
readonly [PARAM_SOURCE]: true;
|
|
89
|
+
/** Target-defined. Core never reads this; the target that authored the source reads it back. */
|
|
90
|
+
readonly payload: T;
|
|
91
|
+
}
|
|
92
|
+
/** Builds an opaque param source from a target-defined payload — the SPI a deploy target's own source constructor (e.g. `envParam`) calls. Core forwards the source and never inspects the payload. */
|
|
93
|
+
declare function paramSource<T>(payload: T): ParamSource<T>;
|
|
94
|
+
/** True if `value` is a param source (an `envParam` result or a forwarded ctx.params ref). */
|
|
95
|
+
declare function isParamSource(value: unknown): value is ParamSource;
|
|
96
|
+
/** A module's declared param-forwarding slot — nameless, schema-less; the root (or an ancestor module) binds a `ParamSource` and the topology forwards it into a child's real, schema-bearing param. */
|
|
97
|
+
interface ParamNeed {
|
|
98
|
+
readonly [PARAM_NEED]: true;
|
|
99
|
+
readonly kind: 'param';
|
|
100
|
+
}
|
|
101
|
+
/** A module's param-forwarding slots: name → the need it declares. */
|
|
102
|
+
type ParamNeeds = Record<string, ParamNeed>;
|
|
103
|
+
/** Declares a module param-forwarding NEED. Nameless — bound to a `ParamSource` by an enclosing scope and forwarded into a child's real param. */
|
|
104
|
+
declare function paramNeed(): ParamNeed;
|
|
105
|
+
/** What `provision(service, { params })` accepts per declared param: a literal (schema-validated when config is built) or an opaque `ParamSource`, taking precedence over `param.default`. Every entry is optional — an unbound param falls back to its `default`. */
|
|
106
|
+
type ParamBindings<P extends Params> = { readonly [K in keyof P]?: StandardSchemaV1.InferOutput<P[K]['schema']> | ParamSource; };
|
|
107
|
+
/** What `provision(moduleChild, { params })` accepts per declared `ParamNeed`: a `ParamSource` only — a need carries no schema to validate a literal against. */
|
|
108
|
+
type ParamNeedBindings<PN extends ParamNeeds> = { readonly [K in keyof PN]?: ParamSource; };
|
|
109
|
+
/** Opaque `Contract<any, any>` bound shared by every node/port type that doesn't care which contract. */
|
|
110
|
+
type AnyContract = Contract<any, any>;
|
|
111
|
+
/** How a service's app becomes a runnable artifact — the build descriptor's routing key (`extension`/`type`) plus paths resolved relative to the authoring module. */
|
|
112
|
+
interface BuildAdapter {
|
|
113
|
+
/** The extension package that provides the build descriptor, e.g. "@prisma/composer/node". */
|
|
114
|
+
readonly extension: string;
|
|
115
|
+
/** The build descriptor's node ID within its extension, e.g. "node" · "nextjs". */
|
|
116
|
+
readonly type: string;
|
|
117
|
+
/** The authoring module's `import.meta.url` — every other path on this descriptor resolves relative to `dirname(module)`. */
|
|
118
|
+
readonly module: string;
|
|
119
|
+
/** The app's built runnable, resolved relative to `dirname(module)` and interpreted by the type's build descriptor (e.g. "node": a server file; "nextjs": located in the standalone tree). */
|
|
120
|
+
readonly entry: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A Resource's identity: the one place a piece of infrastructure exists.
|
|
124
|
+
* Provisioned by a module, never embedded in a service's deps. `provides`
|
|
125
|
+
* is the Contract the resource offers; `type` is derived from `provides.kind`.
|
|
126
|
+
*/
|
|
127
|
+
interface ResourceNode<C extends AnyContract = AnyContract> {
|
|
128
|
+
readonly [NODE]: true;
|
|
129
|
+
readonly kind: 'resource';
|
|
130
|
+
/** Human-readable, given at authoring — logs/diagnostics only; identity remains the deploy address (ADR-0006). */
|
|
131
|
+
readonly name: string;
|
|
132
|
+
/** The extension package that authored this node, e.g. "@prisma/composer-prisma-cloud" — the registry key at deploy. */
|
|
133
|
+
readonly extension: string;
|
|
134
|
+
readonly type: C['kind'];
|
|
135
|
+
/** The Contract this resource provides — the resource's single port. */
|
|
136
|
+
readonly provides: C;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A Service: inputs + its own declared params + how it is built. Inspectable,
|
|
140
|
+
* inert until run, and carries NO runtime behavior — an extension's factory
|
|
141
|
+
* wraps it into a runnable/loadable shape (see RunnableServiceNode).
|
|
142
|
+
*/
|
|
143
|
+
interface ServiceNode<D extends Deps = Deps, P extends Params = Params, E extends Expose = Expose, S extends Secrets = Secrets> {
|
|
144
|
+
readonly [NODE]: true;
|
|
145
|
+
readonly kind: 'service';
|
|
146
|
+
/** Human-readable, given at authoring — logs/diagnostics only; identity remains the deploy address (ADR-0006). */
|
|
147
|
+
readonly name: string;
|
|
148
|
+
/** The extension package that authored this node, e.g. "@prisma/composer-prisma-cloud" — the registry key at deploy. */
|
|
149
|
+
readonly extension: string;
|
|
150
|
+
readonly type: string;
|
|
151
|
+
readonly inputs: D;
|
|
152
|
+
/** Service-level config declarations (e.g. port). */
|
|
153
|
+
readonly params: P;
|
|
154
|
+
/** Declared secret input slots (authored as `secrets`) — bound at the root via `envSecret`, read via the `secrets()` accessor (ADR-0029). Named `secretSlots` on the node so the data field does not collide with that accessor. */
|
|
155
|
+
readonly secretSlots: S;
|
|
156
|
+
/** How the app's entry is built + assembled. */
|
|
157
|
+
readonly build: BuildAdapter;
|
|
158
|
+
/** Named output ports this service exposes — the Contracts a consumer's `rpc(contract)` can require. `undefined` when the service exposes nothing. */
|
|
159
|
+
readonly expose: E | undefined;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The extension's runnable/loadable service node. `run` boots the app after
|
|
163
|
+
* deserializing its Config; `load`/`config` then read deps/params back out
|
|
164
|
+
* (kept separate per ADR-0021 so a same-named dep and param never collide).
|
|
165
|
+
*/
|
|
166
|
+
interface RunnableServiceNode<D extends Deps = Deps, P extends Params = Params, E extends Expose = Expose, S extends Secrets = Secrets> extends ServiceNode<D, P, E, S> {
|
|
167
|
+
run(address: string, boot: () => Promise<unknown>): Promise<unknown>;
|
|
168
|
+
load(): HydratedDeps<D>;
|
|
169
|
+
config(): Values<P>;
|
|
170
|
+
/** The service's secrets, each a redacting SecretBox — a third accessor beside load()/config() (ADR-0021). */
|
|
171
|
+
secrets(): SecretValues<S>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A service's dependency slot. At Load the enclosing module wires a
|
|
175
|
+
* producer's ref into it; at run it hydrates a client via Connection. `Req`
|
|
176
|
+
* is the required contract (`unknown` for an untyped end like `http()`).
|
|
177
|
+
*/
|
|
178
|
+
interface DependencyEnd<C = unknown, Req = unknown> {
|
|
179
|
+
readonly [NODE]: true;
|
|
180
|
+
readonly kind: 'dependency';
|
|
181
|
+
/** Human-readable, given at authoring — logs/diagnostics only. */
|
|
182
|
+
readonly name: string;
|
|
183
|
+
readonly type: string;
|
|
184
|
+
readonly connection: Connection<Params, C>;
|
|
185
|
+
/** The required contract, or `undefined` for an untyped end (e.g. `http()`). */
|
|
186
|
+
readonly required: Req | undefined;
|
|
187
|
+
}
|
|
188
|
+
/** A Module: the same Deps/Expose boundary a service has, around transparent wiring instead of a black-box body — its `body` runs at Load, not at authoring. */
|
|
189
|
+
interface ModuleNode<D extends Deps = Deps, E extends Expose = Expose, S extends Secrets = Secrets, PN extends ParamNeeds = ParamNeeds> {
|
|
190
|
+
readonly [NODE]: true;
|
|
191
|
+
readonly kind: 'module';
|
|
192
|
+
/** Human-readable, given at authoring — logs/diagnostics only. */
|
|
193
|
+
readonly name: string;
|
|
194
|
+
readonly deps: D;
|
|
195
|
+
/** Declared secret input slots (authored as `secrets`) — forwarded to internals via `ctx.secrets` (ADR-0029). */
|
|
196
|
+
readonly secretSlots: S;
|
|
197
|
+
/** Declared param-forwarding slots (authored as `params`) — forwarded to internals via `ctx.params`, the same rail secrets ride on. */
|
|
198
|
+
readonly paramSlots: PN;
|
|
199
|
+
readonly expose: E;
|
|
200
|
+
body(ctx: ModuleContext<D, S, PN>): ModuleOutputs<E> | void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* What a module's body receives: its declared inputs as forwardable wiring
|
|
204
|
+
* values, plus `provision` to register the owned services/modules it wires them into.
|
|
205
|
+
*/
|
|
206
|
+
interface ModuleContext<D extends Deps, S extends Secrets = Secrets, PN extends ParamNeeds = ParamNeeds> {
|
|
207
|
+
/** The module's declared inputs as wiring values — pass them into provision(). */
|
|
208
|
+
readonly inputs: { [K in keyof D]: InputRef<D[K]>; };
|
|
209
|
+
/** The module's declared secret slots as forwardable sources — pass them into a child's `secrets` (ADR-0029). */
|
|
210
|
+
readonly secrets: { readonly [K in keyof S]: SecretSource; };
|
|
211
|
+
/** The module's declared param-forwarding slots as forwardable sources — pass them into a child's `params`. */
|
|
212
|
+
readonly params: { readonly [K in keyof PN]: ParamSource; };
|
|
213
|
+
/** Registers an owned child (service or module) under a stable id. */
|
|
214
|
+
readonly provision: ModuleBuilder['provision'];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* A module's forwarded-input value: the same ref-port shape a producer's
|
|
218
|
+
* output carries, so it flows down a nested `provision()` call indistinguishably
|
|
219
|
+
* from a sibling's exposed port.
|
|
220
|
+
*/
|
|
221
|
+
type InputRef<DE> = DE extends DependencyEnd<any, infer Req extends AnyContract> ? RefPort<Req> : never;
|
|
222
|
+
/** One ref-port per declared expose key, contract-checked against `E` (mirrors `Wiring`'s `NoInfer` use). */
|
|
223
|
+
type ModuleOutputs<E extends Expose> = { [P in keyof E]: RefPort<NoInfer<E[P]>>; };
|
|
224
|
+
/**
|
|
225
|
+
* A provisioned producer's port as a wiring-time value: its contract, tagged
|
|
226
|
+
* with which provider produced it (`__providerId`, read by Load to resolve the edge).
|
|
227
|
+
*/
|
|
228
|
+
type RefPort<C extends AnyContract> = C & {
|
|
229
|
+
readonly __providerId: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* What `provision(id, service)` hands back: a stable id plus one ref-port per
|
|
233
|
+
* exposed contract. `provision(id, resource)` returns the same shape with the
|
|
234
|
+
* resource's one port flattened onto the ref itself.
|
|
235
|
+
*/
|
|
236
|
+
type ProvisionedRef<E extends Expose = Record<never, never>> = {
|
|
237
|
+
readonly id: string;
|
|
238
|
+
} & { readonly [P in keyof E]: RefPort<E[P]>; };
|
|
239
|
+
/** A DependencyEnd's required contract (unknown for an untyped end). */
|
|
240
|
+
type ReqOf<DE> = DE extends DependencyEnd<any, infer Req> ? Req : never;
|
|
241
|
+
/**
|
|
242
|
+
* The producers that satisfy a node's declared dependency slots — one ref per
|
|
243
|
+
* slot, checked against its required contract. A slot also accepts
|
|
244
|
+
* `InputRef<D[K]>` so a module body can forward its own `ctx.inputs` straight
|
|
245
|
+
* into a nested `provision()` call — the same value shape a producer's own
|
|
246
|
+
* exposed port carries.
|
|
247
|
+
*/
|
|
248
|
+
type DepBindings<D extends Deps> = { [K in keyof D]: NoInfer<ReqOf<D[K]>> | InputRef<D[K]>; };
|
|
249
|
+
/**
|
|
250
|
+
* `provision`'s trailing options: an explicit `id` (default: the node's own
|
|
251
|
+
* `name`) plus, for a node that declares dependency slots, the `deps` that
|
|
252
|
+
* satisfy them. `deps` is required exactly when the node has slots —
|
|
253
|
+
* `[keyof D] extends [never]` is the "no slots" test — so a dependency can
|
|
254
|
+
* never be left unwired at compile time. The whole object is therefore
|
|
255
|
+
* optional for a slot-less node and required for one with slots. `params` is
|
|
256
|
+
* always optional — a bound value overrides `param.default`, but a param may
|
|
257
|
+
* fall back to its default (or be `optional`) instead, unlike `deps`/`secrets`.
|
|
258
|
+
* `PB` is the params-binding map appropriate to the target: `ParamBindings<P>`
|
|
259
|
+
* for a service's real, schema-bearing params; `ParamNeedBindings<PN>` for a
|
|
260
|
+
* child module's nameless forwarding slots.
|
|
261
|
+
*/
|
|
262
|
+
type ProvisionArgs<D extends Deps, S extends Secrets, PB> = [keyof D] extends [never] ? [keyof S] extends [never] ? [opts?: {
|
|
263
|
+
id?: string;
|
|
264
|
+
params?: PB;
|
|
265
|
+
}] : [opts: {
|
|
266
|
+
id?: string;
|
|
267
|
+
secrets: SecretBindings<S>;
|
|
268
|
+
params?: PB;
|
|
269
|
+
}] : [keyof S] extends [never] ? [opts: {
|
|
270
|
+
id?: string;
|
|
271
|
+
deps: DepBindings<D>;
|
|
272
|
+
params?: PB;
|
|
273
|
+
}] : [opts: {
|
|
274
|
+
id?: string;
|
|
275
|
+
deps: DepBindings<D>;
|
|
276
|
+
secrets: SecretBindings<S>;
|
|
277
|
+
params?: PB;
|
|
278
|
+
}];
|
|
279
|
+
interface ModuleBuilder {
|
|
280
|
+
/** Provisions an owned resource; its id defaults to the node's `name`. */
|
|
281
|
+
provision<C extends AnyContract>(resource: ResourceNode<C>, opts?: {
|
|
282
|
+
id?: string;
|
|
283
|
+
}): {
|
|
284
|
+
readonly id: string;
|
|
285
|
+
} & RefPort<C>;
|
|
286
|
+
/** Registers an owned service; its id defaults to the node's `name`; `deps`/`secrets` are required iff it declares them; a declared param may be bound (literal or `ParamSource`), overriding its default. */
|
|
287
|
+
provision<D extends Deps, P extends Params, E extends Expose, S extends Secrets>(service: ServiceNode<D, P, E, S>, ...args: ProvisionArgs<D, S, ParamBindings<P>>): ProvisionedRef<E>;
|
|
288
|
+
/**
|
|
289
|
+
* The service call with `deps`/`secrets` spelled out. `ProvisionArgs` above
|
|
290
|
+
* cannot resolve while `D`/`S` are still unbound type parameters — a generic
|
|
291
|
+
* wrapper like `cron()` provisioning a caller-supplied service — so that call
|
|
292
|
+
* site resolves to this concrete overload instead.
|
|
293
|
+
*/
|
|
294
|
+
provision<D extends Deps, P extends Params, E extends Expose, S extends Secrets>(service: ServiceNode<D, P, E, S>, opts: {
|
|
295
|
+
id?: string;
|
|
296
|
+
deps: DepBindings<D>;
|
|
297
|
+
secrets?: SecretBindings<S>;
|
|
298
|
+
params?: ParamBindings<P>;
|
|
299
|
+
}): ProvisionedRef<E>;
|
|
300
|
+
/** Registers an owned child module; its id defaults to the node's `name`; `deps`/`secrets` are required iff it declares them; a declared param-forwarding slot may be bound to a `ParamSource`. */
|
|
301
|
+
provision<D extends Deps, E extends Expose, S extends Secrets, PN extends ParamNeeds>(child: ModuleNode<D, E, S, PN>, ...args: ProvisionArgs<D, S, ParamNeedBindings<PN>>): ProvisionedRef<E>;
|
|
302
|
+
/** The child-module call with `deps`/`secrets` spelled out — the same generic-wrapper escape as the service overload above. */
|
|
303
|
+
provision<D extends Deps, E extends Expose, S extends Secrets, PN extends ParamNeeds>(child: ModuleNode<D, E, S, PN>, opts: {
|
|
304
|
+
id?: string;
|
|
305
|
+
deps: DepBindings<D>;
|
|
306
|
+
secrets?: SecretBindings<S>;
|
|
307
|
+
params?: ParamNeedBindings<PN>;
|
|
308
|
+
}): ProvisionedRef<E>;
|
|
309
|
+
}
|
|
310
|
+
/** Dependency map: name → the slot the service declares. Only declarations are admitted, never a concrete ResourceNode. */
|
|
311
|
+
type Deps = Record<string, DependencyEnd<any, any>>;
|
|
312
|
+
/** Output-port map: name → the Contract a service exposes for others to depend on. */
|
|
313
|
+
type Expose = Readonly<Record<string, AnyContract>>;
|
|
314
|
+
type Hydrated<N> = N extends DependencyEnd<infer C, any> ? C : never;
|
|
315
|
+
type HydratedDeps<D extends Deps> = { readonly [K in keyof D]: Hydrated<D[K]>; };
|
|
316
|
+
/**
|
|
317
|
+
* Seals a node instance after its constructor has assigned all fields — the
|
|
318
|
+
* last statement of a concrete node class's constructor. A free function, not
|
|
319
|
+
* a base-class method, so an instance stays structurally a plain frozen node.
|
|
320
|
+
*/
|
|
321
|
+
declare function freezeNode<T extends object>(node: T): T;
|
|
322
|
+
/**
|
|
323
|
+
* Everything `resource()` establishes, minus the freeze — an extension
|
|
324
|
+
* whose resource node carries extra fields extends this, assigns them, and
|
|
325
|
+
* calls `freezeNode(this)` as its constructor's last statement.
|
|
326
|
+
*/
|
|
327
|
+
declare abstract class ResourceNodeBase<C extends AnyContract = AnyContract> implements ResourceNode<C> {
|
|
328
|
+
readonly [NODE]: true;
|
|
329
|
+
readonly kind: "resource";
|
|
330
|
+
readonly name: string;
|
|
331
|
+
readonly extension: string;
|
|
332
|
+
readonly type: C['kind'];
|
|
333
|
+
readonly provides: C;
|
|
334
|
+
constructor(def: {
|
|
335
|
+
name: string;
|
|
336
|
+
extension: string;
|
|
337
|
+
provides: C;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Constructs a branded, frozen Resource node — an identity plus the Contract
|
|
342
|
+
* it provides; the routing `type` is the contract's `kind`. Pure — nothing
|
|
343
|
+
* is provisioned until a module provisions it.
|
|
344
|
+
*/
|
|
345
|
+
declare function resource<C extends AnyContract>(def: {
|
|
346
|
+
name: string;
|
|
347
|
+
extension: string;
|
|
348
|
+
provides: C;
|
|
349
|
+
}): ResourceNode<C>;
|
|
350
|
+
/**
|
|
351
|
+
* Constructs a branded, frozen Service node — declarations only (inputs,
|
|
352
|
+
* params, build adapter, and the ports it exposes). Pure; carries no runtime behavior.
|
|
353
|
+
*/
|
|
354
|
+
declare function service<D extends Deps, P extends Params, E extends Expose = Record<never, never>, S extends Secrets = Record<never, never>>(def: {
|
|
355
|
+
name: string;
|
|
356
|
+
extension: string;
|
|
357
|
+
type: string;
|
|
358
|
+
inputs: D;
|
|
359
|
+
params: P;
|
|
360
|
+
secrets?: S;
|
|
361
|
+
build: BuildAdapter;
|
|
362
|
+
expose?: E;
|
|
363
|
+
}): ServiceNode<D, P, E, S>;
|
|
364
|
+
/**
|
|
365
|
+
* Constructs a branded, frozen DependencyEnd. `required` (if given) is the
|
|
366
|
+
* contract Load compares a wired ref against via `satisfies()`; an unnamed
|
|
367
|
+
* end's diagnostic `name` falls back to its `type`.
|
|
368
|
+
*/
|
|
369
|
+
declare function dependency<P extends Params, C, Req = unknown>(def: {
|
|
370
|
+
name?: string;
|
|
371
|
+
type: string;
|
|
372
|
+
connection: Connection<P, C>;
|
|
373
|
+
required?: Req;
|
|
374
|
+
}): DependencyEnd<C, Req>;
|
|
375
|
+
/**
|
|
376
|
+
* A closed root: no `deps`, no `expose`, nothing wiring in or out. The body
|
|
377
|
+
* only provisions and needs no return. Omitting the boundary argument IS the
|
|
378
|
+
* closed-root shape — `module(name, body)` instead of `module(name, {}, () =>
|
|
379
|
+
* ({}))`.
|
|
380
|
+
*/
|
|
381
|
+
declare function module(name: string, body: (ctx: ModuleContext<Record<never, never>, Record<never, never>, Record<never, never>>) => void): ModuleNode<Record<never, never>, Record<never, never>, Record<never, never>, Record<never, never>>;
|
|
382
|
+
/**
|
|
383
|
+
* A module with a boundary: `deps` and/or `expose` declare what wires in and
|
|
384
|
+
* out, the same way a service does. The body returns one port per `expose` key.
|
|
385
|
+
*/
|
|
386
|
+
declare function module<D extends Deps = Record<never, never>, E extends Expose = Record<never, never>, S extends Secrets = Record<never, never>, PN extends ParamNeeds = Record<never, never>>(name: string, boundary: {
|
|
387
|
+
deps?: D;
|
|
388
|
+
secrets?: S;
|
|
389
|
+
params?: PN;
|
|
390
|
+
expose?: E;
|
|
391
|
+
}, body: (ctx: ModuleContext<D, S, PN>) => ModuleOutputs<E> | void): ModuleNode<D, E, S, PN>;
|
|
392
|
+
/**
|
|
393
|
+
* True if `value` was constructed by this module's factories. Checks the
|
|
394
|
+
* brand only, never a prototype — a graph may mix nodes from a different
|
|
395
|
+
* installed copy of core (dual-package hazard).
|
|
396
|
+
*/
|
|
397
|
+
declare function isNode(value: unknown): value is ServiceNode | ResourceNode | DependencyEnd | ModuleNode;
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/graph-types.d.ts
|
|
400
|
+
/** Path-derived: root-scope children are bare ids ("auth", "db"); a nested module's own children dot-join under its address ("auth.db"). */
|
|
401
|
+
type NodeId = string;
|
|
402
|
+
interface GraphNode {
|
|
403
|
+
readonly id: NodeId;
|
|
404
|
+
readonly node: ServiceNode | ResourceNode | DependencyEnd | ModuleNode;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* `input`: a service consumes its own declared dependency slot — from the
|
|
408
|
+
* slot node to the service. `dependency`: a service consumes a provisioned
|
|
409
|
+
* producer (a service or a resource — the one wiring mechanism) — from the
|
|
410
|
+
* producer to the consumer, labeled with the consumer's input name (from the
|
|
411
|
+
* module wiring).
|
|
412
|
+
*/
|
|
413
|
+
interface Edge {
|
|
414
|
+
readonly from: NodeId;
|
|
415
|
+
readonly to: NodeId;
|
|
416
|
+
readonly input: string;
|
|
417
|
+
readonly kind: 'input' | 'dependency';
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A resolved secret binding: the root bound a service's secret slot to an
|
|
421
|
+
* opaque, target-defined source, and the wiring forwarded it to that service's
|
|
422
|
+
* address (ADR-0029). Core never inspects the source; the deploy target reads
|
|
423
|
+
* its own payload. A target's serializer keys the pointer row off this; the
|
|
424
|
+
* preflight manifest aggregates the sources.
|
|
425
|
+
*/
|
|
426
|
+
interface SecretBinding {
|
|
427
|
+
/** The graph address of the service that declares the secret slot. */
|
|
428
|
+
readonly serviceAddress: NodeId;
|
|
429
|
+
/** The secret slot key on that service. */
|
|
430
|
+
readonly slot: string;
|
|
431
|
+
/** The opaque source the root bound the slot to. Core never inspects it; the deploy target reads back its own payload. */
|
|
432
|
+
readonly source: SecretSource;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* A resolved param binding: a `provision()` call bound a service's param
|
|
436
|
+
* slot to either a literal value or an opaque `ParamSource` — the non-secret
|
|
437
|
+
* sibling of `SecretBinding`. Unlike a secret, a param binding is not
|
|
438
|
+
* required for every declared param (a param may fall back to its own
|
|
439
|
+
* `default`), so this list only carries the ones a `provision()` call
|
|
440
|
+
* actually bound.
|
|
441
|
+
*/
|
|
442
|
+
interface ParamBinding {
|
|
443
|
+
/** The graph address of the service that declares the param. */
|
|
444
|
+
readonly serviceAddress: NodeId;
|
|
445
|
+
/** The param name on that service. */
|
|
446
|
+
readonly slot: string;
|
|
447
|
+
/** A literal value (schema-validated by `buildConfig`) or an opaque `ParamSource` (the deploy target reads its own payload back) — check with `isParamSource`. Core never inspects a `ParamSource`'s payload. */
|
|
448
|
+
readonly binding: unknown;
|
|
449
|
+
}
|
|
450
|
+
interface Graph {
|
|
451
|
+
readonly root: GraphNode;
|
|
452
|
+
/** Root + one per input, topo-ordered (deps first). */
|
|
453
|
+
readonly nodes: readonly GraphNode[];
|
|
454
|
+
readonly edges: readonly Edge[];
|
|
455
|
+
/** Every service secret slot resolved to its root-bound opaque source. */
|
|
456
|
+
readonly secrets: readonly SecretBinding[];
|
|
457
|
+
/** Every service param bound at provision — literal or source; unbound params are absent here and fall back to their `default` (see `buildConfig`). */
|
|
458
|
+
readonly params: readonly ParamBinding[];
|
|
459
|
+
}
|
|
460
|
+
/** Thrown by Load when the graph is malformed. */
|
|
461
|
+
declare class LoadError extends Error {
|
|
462
|
+
constructor(message: string);
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/config.d.ts
|
|
466
|
+
/**
|
|
467
|
+
* A declared config param — pure data: a caller-owned Standard Schema
|
|
468
|
+
* (ADR-0018) plus a few framework facets. The framework carries the schema,
|
|
469
|
+
* infers the value type from it, and validates with it, without ever
|
|
470
|
+
* enumerating permitted shapes. Turning a value into stored config and back is
|
|
471
|
+
* the deploy target's job, not the param's (ADR-0019) — the same split RPC
|
|
472
|
+
* uses: schema on the declaration, wire owned by the mover.
|
|
473
|
+
*/
|
|
474
|
+
interface ConfigParam<S extends StandardSchemaV1 = StandardSchemaV1> {
|
|
475
|
+
readonly schema: S;
|
|
476
|
+
readonly optional?: boolean;
|
|
477
|
+
readonly default?: StandardSchemaV1.InferOutput<S>;
|
|
478
|
+
/**
|
|
479
|
+
* A framework-minted value (ADR-0031): core resolves `provision.brand`
|
|
480
|
+
* against the consumer extension's `provisions` registry and mints this
|
|
481
|
+
* param's value per dependency edge. Opaque — core forwards the need and
|
|
482
|
+
* never reads its payload.
|
|
483
|
+
*/
|
|
484
|
+
readonly provision?: ProvisionNeed;
|
|
485
|
+
}
|
|
486
|
+
type Params = Record<string, ConfigParam>;
|
|
487
|
+
/** What implementations receive — undefined only for optional params with no default. */
|
|
488
|
+
type Values<P extends Params> = { readonly [K in keyof P]: P[K]['optional'] extends true ? undefined extends P[K]['default'] ? StandardSchemaV1.InferOutput<P[K]['schema']> | undefined : StandardSchemaV1.InferOutput<P[K]['schema']> : StandardSchemaV1.InferOutput<P[K]['schema']>; };
|
|
489
|
+
/**
|
|
490
|
+
* The connection face of a dependency: declared params (data) and how
|
|
491
|
+
* validated values become a client (the hydrate behavior slot). Both P and C
|
|
492
|
+
* are INFERRED — the declaration types hydrate's input; the factory types the
|
|
493
|
+
* loaded dep.
|
|
494
|
+
*/
|
|
495
|
+
interface Connection<P extends Params = Params, C = unknown> {
|
|
496
|
+
readonly params: P;
|
|
497
|
+
hydrate(values: Values<P>): C | Promise<C>;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* The enumerable config surface of a service — derivable from the graph
|
|
501
|
+
* alone, nothing booted, no platform keys. The introspection artifact (values
|
|
502
|
+
* absent). `schema` is a data-only projection of the param's Standard Schema
|
|
503
|
+
* (JSON Schema when the vendor supports the optional conversion, a `{ vendor }`
|
|
504
|
+
* tag otherwise) — never the param's functions. Physical locations are the
|
|
505
|
+
* target pack's business. Secrets are not here — they live on their own slot.
|
|
506
|
+
*/
|
|
507
|
+
interface ConfigDeclaration {
|
|
508
|
+
readonly owner: 'service' | {
|
|
509
|
+
readonly input: string;
|
|
510
|
+
};
|
|
511
|
+
readonly name: string;
|
|
512
|
+
readonly schema: Readonly<Record<string, unknown>>;
|
|
513
|
+
readonly optional: boolean;
|
|
514
|
+
readonly default: unknown;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* The resolved, typed configuration of one service — what crosses the
|
|
518
|
+
* core→pack boundary. Core builds it at deploy (leaf values are provisioning
|
|
519
|
+
* refs, so the env writes depend on the resources/producer — the ordering
|
|
520
|
+
* edges); the pack serializes it, and at boot reconstructs the identical
|
|
521
|
+
* structure with concrete values. Both forms conform to the shape from
|
|
522
|
+
* configOf. Core never stringifies.
|
|
523
|
+
*/
|
|
524
|
+
interface Config {
|
|
525
|
+
readonly service: Readonly<Record<string, unknown>>;
|
|
526
|
+
readonly inputs: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Enumerates every config param the service declares: each input's connection
|
|
530
|
+
* params, then the service's own params. Pure — reads `root.inputs`/`params`
|
|
531
|
+
* directly, executes nothing but the (also pure) schema projection. Deliberately
|
|
532
|
+
* does not go through `Load`: a service's connection-end inputs are legitimately
|
|
533
|
+
* unwired from its own point of view (wiring is an enclosing module's concern),
|
|
534
|
+
* and this introspects one service's declared shape regardless of how — or
|
|
535
|
+
* whether — it composes into a larger graph.
|
|
536
|
+
*/
|
|
537
|
+
declare function configOf(root: ServiceNode): readonly ConfigDeclaration[];
|
|
538
|
+
/**
|
|
539
|
+
* The app's provision manifest: every secret binding the root resolved across
|
|
540
|
+
* the graph (ADR-0029) — an opaque, target-defined source per service secret
|
|
541
|
+
* slot; a deploy target's preflight reads its own payload. Pure graph
|
|
542
|
+
* introspection, TARGET-AGNOSTIC — the target consumes it to verify each secret
|
|
543
|
+
* exists on the platform before deploy. The values are provisioned out-of-band.
|
|
544
|
+
*/
|
|
545
|
+
declare function provisionManifest(graph: Graph): readonly SecretBinding[];
|
|
546
|
+
/**
|
|
547
|
+
* The app's param-binding manifest: every param a `provision()` call bound —
|
|
548
|
+
* literal or an opaque, target-defined `ParamSource` — at the address that
|
|
549
|
+
* declared it. The param sibling of `provisionManifest`, for a deploy
|
|
550
|
+
* target's own preflight to consume (D2). Pure graph introspection,
|
|
551
|
+
* TARGET-AGNOSTIC; a param this manifest omits simply falls back to its own
|
|
552
|
+
* `default` at `buildConfig`.
|
|
553
|
+
*/
|
|
554
|
+
declare function paramManifest(graph: Graph): readonly ParamBinding[];
|
|
555
|
+
interface ParamOptions<T> {
|
|
556
|
+
readonly optional?: boolean;
|
|
557
|
+
readonly default?: T;
|
|
558
|
+
readonly provision?: ProvisionNeed;
|
|
559
|
+
}
|
|
560
|
+
/** A string-valued param. */
|
|
561
|
+
declare function string(opts?: ParamOptions<string>): ConfigParam<StandardSchemaV1<string, string>>;
|
|
562
|
+
/** A number-valued param. */
|
|
563
|
+
declare function number(opts?: ParamOptions<number>): ConfigParam<StandardSchemaV1<number, number>>;
|
|
564
|
+
/** A param over any caller-supplied Standard Schema — a structured `jobs`, say. */
|
|
565
|
+
declare function param<S extends StandardSchemaV1>(schema: S, opts?: ParamOptions<StandardSchemaV1.InferOutput<S>>): ConfigParam<S>;
|
|
566
|
+
//#endregion
|
|
567
|
+
export { paramManifest as $, ProvisionedRef as A, Secrets as B, ParamBindings as C, ParamSource as D, ParamNeeds as E, SecretBinding as F, freezeNode as G, Values as H, SecretBindings as I, isProvisionNeed as J, isNode as K, SecretNeed as L, ResourceNode as M, ResourceNodeBase as N, Params as O, RunnableServiceNode as P, param as Q, SecretSource as R, ParamBinding as S, ParamNeedBindings as T, configOf as U, ServiceNode as V, dependency as W, module as X, isSecretSource as Y, number as Z, ModuleBuilder as _, Connection as a, secret as at, ModuleOutputs as b, Deps as c, string as ct, Graph as d, paramNeed as et, GraphNode as f, LoadError as g, InputRef as h, ConfigParam as i, resource as it, RefPort as j, ProvisionNeed as k, Edge as l, SecretBox as lt, HydratedDeps as m, Config as n, provisionManifest as nt, Contract as o, secretSource as ot, Hydrated as p, isParamSource as q, ConfigDeclaration as r, provisionNeed as rt, DependencyEnd as s, service as st, BuildAdapter as t, paramSource as tt, Expose as u, SecretString as ut, ModuleContext as v, ParamNeed as w, NodeId as x, ModuleNode as y, SecretValues as z };
|
|
568
|
+
//# sourceMappingURL=config-ad92ubCB-D0-dZUgA.d.mts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { C as TeardownInput, T as defineConfig, h as NodeDescriptor, l as ExtensionDescriptor, v as PreflightInput, y as PrismaAppConfig } from "./app-config-CpWN1ZfP-CZ1c6Eqk.mjs";
|
|
2
|
+
import "./config-D-h0FACe.mjs";
|
|
3
|
+
export { ExtensionDescriptor, NodeDescriptor, PreflightInput, PrismaAppConfig, TeardownInput, defineConfig };
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region ../../0-framework/1-core/core/dist/config.mjs
|
|
2
|
+
/** Typed identity — exists so `prisma-composer.config.ts` gets checked against PrismaAppConfig where it is written. */
|
|
3
|
+
function defineConfig(config) {
|
|
4
|
+
return config;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { defineConfig };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/config.mjs"],"sourcesContent":["//#region src/app-config.ts\n/** Typed identity — exists so `prisma-composer.config.ts` gets checked against PrismaAppConfig where it is written. */\nfunction defineConfig(config) {\n\treturn config;\n}\n//#endregion\nexport { defineConfig };\n\n//# sourceMappingURL=config.mjs.map"],"mappings":";;AAEA,SAAS,aAAa,QAAQ;CAC7B,OAAO;AACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./app-config-CpWN1ZfP-CZ1c6Eqk.mjs";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as resolveStateLayer, D as lower, E as joinDeployment, O as lowering, S as ServiceLowering, _ as PackageInput, a as Bundle, b as ProvisionEdge, c as DeploymentResult, d as LowerError, f as LowerOptions, g as Outputs, i as AssembleInput, k as mergedProviders, m as Lowering, n as ApplicationDescriptor, o as DeployedEntity, p as LoweredResult, r as Artifact, s as DeployedNode, t as AlchemyStateLayer, u as LowerContext, w as buildConfig, x as ProvisionerDescriptor } from "./app-config-CpWN1ZfP-CZ1c6Eqk.mjs";
|
|
2
|
+
import "./deploy-D-h0FACe.mjs";
|
|
3
|
+
export { AlchemyStateLayer, ApplicationDescriptor, Artifact, AssembleInput, Bundle, DeployedEntity, DeployedNode, DeploymentResult, LowerContext, LowerError, LowerOptions, LoweredResult, Lowering, Outputs, PackageInput, ProvisionEdge, ProvisionerDescriptor, ServiceLowering, buildConfig, joinDeployment, lower, lowering, mergedProviders, resolveStateLayer };
|