@prisma/composer 0.1.0-dev.7 → 0.1.0-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import { M as ResourceNode, V as ServiceNode, d as Graph, k as ProvisionNeed, n as Config, t as BuildAdapter, x as NodeId, y as ModuleNode } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- import "./graph-D383dfW2-Cepin3Om.mjs";
1
+ import { M as ResourceNode, V as ServiceNode, d as Graph, k as ProvisionNeed, n as Config, t as BuildAdapter, x as NodeId, y as ModuleNode } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ import "./graph-B7NcPiOr-UazPNQTc.mjs";
3
3
  import * as Alchemy from "alchemy";
4
4
  import { Input, StackServices } from "alchemy";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Layer from "effect/Layer";
7
7
  import { State } from "alchemy/State/State";
8
- //#region ../../0-framework/1-core/core/dist/app-config-5mXxjaEl.d.mts
8
+ //#region ../../0-framework/1-core/core/dist/app-config-Bhu93gjR.d.mts
9
9
  //#region src/exports/deploy.d.ts
10
10
  /** The Layer shape every Alchemy state store must satisfy — what `LowerOptions.state` and `PrismaAppConfig.state` both traffic in. */
11
11
  type AlchemyStateLayer = Layer.Layer<State, never, StackServices>;
@@ -322,4 +322,4 @@ interface PrismaAppConfig {
322
322
  declare function defineConfig(config: PrismaAppConfig): PrismaAppConfig;
323
323
  //#endregion
324
324
  export { resolveStateLayer as A, TeardownInput as C, lower as D, joinDeployment as E, lowering as O, ServiceLowering as S, defineConfig as T, PackageInput as _, Bundle as a, ProvisionEdge as b, DeploymentResult as c, LowerError as d, LowerOptions as f, Outputs as g, NodeDescriptor as h, AssembleInput as i, mergedProviders as k, ExtensionDescriptor as l, Lowering as m, ApplicationDescriptor as n, DeployedEntity as o, LoweredResult as p, Artifact as r, DeployedNode as s, AlchemyStateLayer as t, LowerContext as u, PreflightInput as v, buildConfig as w, ProvisionerDescriptor as x, PrismaAppConfig as y };
325
- //# sourceMappingURL=app-config-5mXxjaEl-D2Q6MU5g.d.mts.map
325
+ //# sourceMappingURL=app-config-Bhu93gjR-BFLsU-gF.d.mts.map
@@ -0,0 +1 @@
1
+ import "./app-config-Bhu93gjR-BFLsU-gF.mjs";
package/dist/config.d.mts CHANGED
@@ -1,3 +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-5mXxjaEl-D2Q6MU5g.mjs";
2
- import "./config-C23NciC8.mjs";
1
+ import { C as TeardownInput, T as defineConfig, h as NodeDescriptor, l as ExtensionDescriptor, v as PreflightInput, y as PrismaAppConfig } from "./app-config-Bhu93gjR-BFLsU-gF.mjs";
2
+ import "./config-Bz1VQOKQ.mjs";
3
3
  export { ExtensionDescriptor, NodeDescriptor, PreflightInput, PrismaAppConfig, TeardownInput, defineConfig };
@@ -0,0 +1 @@
1
+ import "./app-config-Bhu93gjR-BFLsU-gF.mjs";
package/dist/deploy.d.mts CHANGED
@@ -1,3 +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-5mXxjaEl-D2Q6MU5g.mjs";
2
- import "./deploy-C23NciC8.mjs";
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-Bhu93gjR-BFLsU-gF.mjs";
2
+ import "./deploy-Bz1VQOKQ.mjs";
3
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 };
@@ -1,5 +1,5 @@
1
- import { V as ServiceNode, d as Graph, x as NodeId, y as ModuleNode } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- //#region ../../0-framework/1-core/core/dist/graph-D383dfW2.d.mts
1
+ import { V as ServiceNode, d as Graph, x as NodeId, y as ModuleNode } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ //#region ../../0-framework/1-core/core/dist/graph-B7NcPiOr.d.mts
3
3
  //#region src/graph.d.ts
4
4
  /**
5
5
  * Builds the in-memory graph from a root node. A service root walks its own
@@ -15,4 +15,4 @@ declare function Load(root: ServiceNode | ModuleNode, opts?: {
15
15
  }): Graph;
16
16
  //#endregion
17
17
  export { Load as t };
18
- //# sourceMappingURL=graph-D383dfW2-Cepin3Om.d.mts.map
18
+ //# sourceMappingURL=graph-B7NcPiOr-UazPNQTc.d.mts.map
@@ -24,7 +24,7 @@ declare class SecretBox<T> {
24
24
  /** The common case: a secret string. */
25
25
  type SecretString = SecretBox<string>;
26
26
  //#endregion
27
- //#region ../../0-framework/1-core/core/dist/graph-types-COu3ss99.d.mts
27
+ //#region ../../0-framework/1-core/core/dist/graph-types-BgT9UEdm.d.mts
28
28
  //#region src/config.d.ts
29
29
  /**
30
30
  * A declared config param — pure data: a caller-owned Standard Schema
@@ -135,7 +135,7 @@ declare function param<S extends StandardSchemaV1>(schema: S, opts?: ParamOption
135
135
  * `Cmp`, checked at `ModuleBuilder.provision`'s call site (node.ts); `satisfies`
136
136
  * is its runtime mirror, called at Load (graph.ts). Correctness comes from
137
137
  * the kind's builder shaping `Cmp` so assignability means the right thing —
138
- * see @prisma/composer/rpc's `contract()`/`rpc()`.
138
+ * see @prisma/composer/service-rpc's `contract()`/`rpc()`.
139
139
  */
140
140
  interface Contract<Kind extends string, Cmp> {
141
141
  readonly kind: Kind;
@@ -565,4 +565,4 @@ declare class LoadError extends Error {
565
565
  }
566
566
  //#endregion
567
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=graph-types-COu3ss99-CrJcsbDJ.d.mts.map
568
+ //# sourceMappingURL=graph-types-BgT9UEdm-Cg7wPD1I.d.mts.map
@@ -1,5 +1,5 @@
1
- import { B as Secrets, V as ServiceNode, c as Deps, m as HydratedDeps, n as Config, z as SecretValues } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- import "./graph-D383dfW2-Cepin3Om.mjs";
1
+ import { B as Secrets, V as ServiceNode, c as Deps, m as HydratedDeps, n as Config, z as SecretValues } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ import "./graph-B7NcPiOr-UazPNQTc.mjs";
3
3
  //#region ../../0-framework/1-core/core/dist/index.d.mts
4
4
  //#region src/hydrate.d.ts
5
5
  /**
@@ -29,4 +29,4 @@ declare function hydrateSync(root: ServiceNode, config: Config): HydratedDeps<De
29
29
  declare function hydrateSecrets(root: ServiceNode, values: Record<string, string>): SecretValues<Secrets>;
30
30
  //#endregion
31
31
  export { hydrateSecrets as n, hydrateSync as r, hydrate as t };
32
- //# sourceMappingURL=index-8wU5wpMV.d.mts.map
32
+ //# sourceMappingURL=index-BoUJ4fEs.d.mts.map
@@ -1,5 +1,5 @@
1
- import { t as BuildAdapter } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- import "./index-8wU5wpMV.mjs";
1
+ import { t as BuildAdapter } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ import "./index-BoUJ4fEs.mjs";
3
3
  //#region ../../0-framework/2-authoring/nextjs/dist/index.d.mts
4
4
  //#region src/exports/index.d.ts
5
5
  /** The nextjs build adapter's descriptor — `appDir` is this kind's own extra path input (the Next app root), beyond the shared `{ extension, type, module, entry }`. `entry` is a placeholder; the assembler locates `server.js` in the standalone tree. */
@@ -13,4 +13,4 @@ declare const nextjsBuild: (opts: {
13
13
  }) => NextjsBuildAdapter;
14
14
  //#endregion
15
15
  export { nextjsBuild as n, NextjsBuildAdapter as t };
16
- //# sourceMappingURL=index-DIyo-rxT.d.mts.map
16
+ //# sourceMappingURL=index-DYfGGlv4.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as paramManifest, A as ProvisionedRef, B as Secrets, C as ParamBindings, D as ParamSource, E as ParamNeeds, F as SecretBinding, G as freezeNode, H as Values, I as SecretBindings, J as isProvisionNeed, K as isNode, L as SecretNeed, M as ResourceNode, N as ResourceNodeBase, O as Params, P as RunnableServiceNode, Q as param, R as SecretSource, S as ParamBinding, T as ParamNeedBindings, U as configOf, V as ServiceNode, W as dependency, X as module, Y as isSecretSource, Z as number, _ as ModuleBuilder, a as Connection, at as secret, b as ModuleOutputs, c as Deps, ct as string, d as Graph, et as paramNeed, f as GraphNode, g as LoadError, h as InputRef, i as ConfigParam, it as resource, j as RefPort, k as ProvisionNeed, l as Edge, lt as SecretBox, m as HydratedDeps, n as Config, nt as provisionManifest, o as Contract, ot as secretSource, p as Hydrated, q as isParamSource, r as ConfigDeclaration, rt as provisionNeed, s as DependencyEnd, st as service, t as BuildAdapter, tt as paramSource, u as Expose, ut as SecretString, v as ModuleContext, w as ParamNeed, x as NodeId, y as ModuleNode, z as SecretValues } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- import { t as Load } from "./graph-D383dfW2-Cepin3Om.mjs";
3
- import { n as hydrateSecrets, r as hydrateSync, t as hydrate } from "./index-8wU5wpMV.mjs";
1
+ import { $ as paramManifest, A as ProvisionedRef, B as Secrets, C as ParamBindings, D as ParamSource, E as ParamNeeds, F as SecretBinding, G as freezeNode, H as Values, I as SecretBindings, J as isProvisionNeed, K as isNode, L as SecretNeed, M as ResourceNode, N as ResourceNodeBase, O as Params, P as RunnableServiceNode, Q as param, R as SecretSource, S as ParamBinding, T as ParamNeedBindings, U as configOf, V as ServiceNode, W as dependency, X as module, Y as isSecretSource, Z as number, _ as ModuleBuilder, a as Connection, at as secret, b as ModuleOutputs, c as Deps, ct as string, d as Graph, et as paramNeed, f as GraphNode, g as LoadError, h as InputRef, i as ConfigParam, it as resource, j as RefPort, k as ProvisionNeed, l as Edge, lt as SecretBox, m as HydratedDeps, n as Config, nt as provisionManifest, o as Contract, ot as secretSource, p as Hydrated, q as isParamSource, r as ConfigDeclaration, rt as provisionNeed, s as DependencyEnd, st as service, t as BuildAdapter, tt as paramSource, u as Expose, ut as SecretString, v as ModuleContext, w as ParamNeed, x as NodeId, y as ModuleNode, z as SecretValues } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ import { t as Load } from "./graph-B7NcPiOr-UazPNQTc.mjs";
3
+ import { n as hydrateSecrets, r as hydrateSync, t as hydrate } from "./index-BoUJ4fEs.mjs";
4
4
  export { type BuildAdapter, type Config, type ConfigDeclaration, type ConfigParam, type Connection, type Contract, type DependencyEnd, type Deps, type Edge, type Expose, type Graph, type GraphNode, type Hydrated, type HydratedDeps, type InputRef, Load, LoadError, type ModuleBuilder, type ModuleContext, type ModuleNode, type ModuleOutputs, type NodeId, type ParamBinding, type ParamBindings, type ParamNeed, type ParamNeedBindings, type ParamNeeds, type ParamSource, type Params, type ProvisionNeed, type ProvisionedRef, type RefPort, type ResourceNode, ResourceNodeBase, type RunnableServiceNode, type SecretBinding, type SecretBindings, SecretBox, type SecretNeed, type SecretSource, type SecretString, type SecretValues, type Secrets, type ServiceNode, type Values, configOf, dependency, freezeNode, hydrate, hydrateSecrets, hydrateSync, isNode, isParamSource, isProvisionNeed, isSecretSource, module, number, param, paramManifest, paramNeed, paramSource, provisionManifest, provisionNeed, resource, secret, secretSource, service, string };
@@ -1,7 +1,7 @@
1
- import { a as Bundle, i as AssembleInput, l as ExtensionDescriptor } from "./app-config-5mXxjaEl-D2Q6MU5g.mjs";
2
- import "./config-C23NciC8.mjs";
3
- import "./deploy-C23NciC8.mjs";
4
- import { t as NextjsBuildAdapter } from "./index-DIyo-rxT.mjs";
1
+ import { a as Bundle, i as AssembleInput, l as ExtensionDescriptor } from "./app-config-Bhu93gjR-BFLsU-gF.mjs";
2
+ import "./config-Bz1VQOKQ.mjs";
3
+ import "./deploy-Bz1VQOKQ.mjs";
4
+ import { t as NextjsBuildAdapter } from "./index-DYfGGlv4.mjs";
5
5
  //#region ../../0-framework/2-authoring/nextjs/dist/control.d.mts
6
6
  //#region src/exports/control.d.ts
7
7
  /** The built standalone server.js for a nextjs build — `appDir`'s standalone root plus the app subpath Next recorded. Single-sourced so `assemble()` (deploy) and the integration-test seam can't drift. */
package/dist/nextjs.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as nextjsBuild, t as NextjsBuildAdapter } from "./index-DIyo-rxT.mjs";
1
+ import { n as nextjsBuild, t as NextjsBuildAdapter } from "./index-DYfGGlv4.mjs";
2
2
  export { NextjsBuildAdapter, nextjsBuild as default };
@@ -1,6 +1,6 @@
1
- import { a as Bundle, i as AssembleInput, l as ExtensionDescriptor } from "./app-config-5mXxjaEl-D2Q6MU5g.mjs";
2
- import "./config-C23NciC8.mjs";
3
- import "./deploy-C23NciC8.mjs";
1
+ import { a as Bundle, i as AssembleInput, l as ExtensionDescriptor } from "./app-config-Bhu93gjR-BFLsU-gF.mjs";
2
+ import "./config-Bz1VQOKQ.mjs";
3
+ import "./deploy-Bz1VQOKQ.mjs";
4
4
  //#region ../../0-framework/2-authoring/node/dist/control.d.mts
5
5
  //#region src/exports/control.d.ts
6
6
  declare function assemble(input: AssembleInput): Promise<Bundle>;
package/dist/node.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as BuildAdapter } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- import "./index-8wU5wpMV.mjs";
1
+ import { t as BuildAdapter } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ import "./index-BoUJ4fEs.mjs";
3
3
  //#region ../../0-framework/2-authoring/node/dist/index.d.mts
4
4
  //#region src/exports/index.d.ts
5
5
  /** The node build adapter's descriptor. `dir` is the directory form's own extra path input (the built tree to copy verbatim), beyond the shared `{ extension, type, module, entry }`; absent, `entry` is the whole built runnable. */
package/dist/report.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as DeploymentResult } from "./app-config-5mXxjaEl-D2Q6MU5g.mjs";
2
- import "./deploy-C23NciC8.mjs";
1
+ import { c as DeploymentResult } from "./app-config-Bhu93gjR-BFLsU-gF.mjs";
2
+ import "./deploy-Bz1VQOKQ.mjs";
3
3
  //#region ../../0-framework/3-tooling/cli/dist/report.d.mts
4
4
  //#region src/exports/render-deployment.d.ts
5
5
  /**
@@ -1,7 +1,7 @@
1
- import { P as RunnableServiceNode, k as ProvisionNeed, o as Contract, s as DependencyEnd } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
2
- import "./index-8wU5wpMV.mjs";
1
+ import { P as RunnableServiceNode, k as ProvisionNeed, o as Contract, s as DependencyEnd } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
+ import "./index-BoUJ4fEs.mjs";
3
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
- //#region ../../0-framework/2-authoring/rpc/dist/index.d.mts
4
+ //#region ../../0-framework/2-authoring/service-rpc/dist/index.d.mts
5
5
  //#region src/rpc.d.ts
6
6
  /** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
7
7
  declare const RPC_PEER_KEY: unique symbol;
@@ -50,4 +50,4 @@ type Handlers<S extends AnyRunnable> = { [Port in keyof NonNullable<S['expose']>
50
50
  declare function serve<S extends AnyRunnable, H extends Handlers<S>>(service: S, handlers: H): (req: Request) => Promise<Response>;
51
51
  //#endregion
52
52
  export { type Client, type Handlers, RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, type Transport, contract, makeClient, perBindingToken, rpc, serve };
53
- //# sourceMappingURL=rpc.d.mts.map
53
+ //# sourceMappingURL=service-rpc.d.mts.map
@@ -1,7 +1,7 @@
1
1
  import { t as blindCast } from "./casts-Ci5rYYaR.mjs";
2
2
  import { i as dependency, p as provisionNeed } from "./graph-BmrUEdo9-6Oq1hSmS.mjs";
3
3
  import { l as string } from "./dist-B0axxnBf.mjs";
4
- //#region ../../0-framework/2-authoring/rpc/dist/index.mjs
4
+ //#region ../../0-framework/2-authoring/service-rpc/dist/index.mjs
5
5
  async function standardValidate(schema, value) {
6
6
  const result = await schema["~standard"].validate(value);
7
7
  if (result.issues !== void 0) throw new Error(`Schema validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
@@ -181,4 +181,4 @@ function serve(service, handlers) {
181
181
  //#endregion
182
182
  export { RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, contract, makeClient, perBindingToken, rpc, serve };
183
183
 
184
- //# sourceMappingURL=rpc.mjs.map
184
+ //# sourceMappingURL=service-rpc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-rpc.mjs","names":[],"sources":["../../../0-framework/2-authoring/service-rpc/dist/index.mjs"],"sourcesContent":["import { blindCast } from \"@internal/foundation/casts\";\nimport { dependency, provisionNeed, string } from \"@internal/core\";\n//#region src/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 headers = { \"content-type\": \"application/json\" };\n\tif (opts?.serviceKey !== void 0) headers[\"Authorization\"] = `Bearer ${opts.serviceKey}`;\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,\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\n/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */\nconst RPC_PEER_KEY = Symbol.for(\"prisma:rpc/per-binding-key\");\n/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */\nconst perBindingToken = () => provisionNeed(RPC_PEER_KEY);\nfunction rpc(arg) {\n\tif (!isRpcContract(arg)) return arg;\n\treturn dependency({\n\t\ttype: \"rpc\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tserviceKey: string({\n\t\t\t\t\toptional: true,\n\t\t\t\t\tprovision: perBindingToken()\n\t\t\t\t})\n\t\t\t},\n\t\t\thydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })\n\t\t},\n\t\trequired: arg\n\t});\n}\nfunction isRpcContract(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value && value.kind === \"rpc\" && \"__cmp\" in value && \"satisfies\" in value;\n}\n//#endregion\n//#region src/serve.ts\n/** The reserved env var the target (slice 2) writes the accepted key set to. */\nconst RPC_ACCEPTED_KEYS_ENV = \"COMPOSER_RPC_ACCEPTED_KEYS\";\nfunction 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/** The provisioned accepted key set, or undefined when the deploy never provisioned one (local/test — enforcement off). */\nfunction acceptedKeys() {\n\tconst raw = process.env[RPC_ACCEPTED_KEYS_ENV];\n\tif (raw === void 0 || raw === \"\") return void 0;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn [];\n\t}\n\treturn Array.isArray(parsed) && parsed.every((key) => typeof key === \"string\") ? parsed : [];\n}\n/**\n* Length-independent constant-time string equality — no early exit on the\n* first mismatched character or on a length difference, so a caller cannot\n* time its way toward a valid key. No `node:crypto`, to keep this module\n* runtime-agnostic.\n*/\nfunction constantTimeEquals(a, b) {\n\tconst length = Math.max(a.length, b.length);\n\tlet diff = a.length ^ b.length;\n\tfor (let i = 0; i < length; i++) diff |= (i < a.length ? a.charCodeAt(i) : 0) ^ (i < b.length ? b.charCodeAt(i) : 0);\n\treturn diff === 0;\n}\n/** Whether `presented` is a member of `accepted` — always compares against every key. */\nfunction isAcceptedKey(presented, accepted) {\n\tlet matched = false;\n\tfor (const key of accepted) matched = constantTimeEquals(presented, key) || matched;\n\treturn matched;\n}\nconst BEARER_PREFIX = \"Bearer \";\n/** The bearer token on `Authorization`, or `''` if the header is missing or malformed. */\nfunction bearerToken(req) {\n\tconst header = req.headers.get(\"authorization\");\n\treturn header?.startsWith(BEARER_PREFIX) ? header.slice(7) : \"\";\n}\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 accepted = acceptedKeys();\n\t\tif (accepted !== void 0 && !isAcceptedKey(bearerToken(req), accepted)) return jsonResponse({ error: \"Unauthorized: missing or invalid service key\" }, 401);\n\t\tconst { pathname } = new URL(req.url);\n\t\tconst methodName = /^\\/rpc\\/([^/]+)$/.exec(pathname)?.[1];\n\t\tif (methodName === void 0) return 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 { RPC_ACCEPTED_KEYS_ENV, RPC_PEER_KEY, contract, makeClient, perBindingToken, rpc, serve };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;AAGA,eAAe,iBAAiB,QAAQ,OAAO;CAC9C,MAAM,SAAS,MAAM,OAAO,YAAY,CAAC,SAAS,KAAK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,GAAG,OAAO,aAAa,EAAE,OAAO,+CAA+C,GAAG,GAAG;EACzJ,MAAM,EAAE,aAAa,IAAI,IAAI,IAAI,GAAG;EACpC,MAAM,aAAa,mBAAmB,KAAK,QAAQ,CAAC,GAAG;EACvD,IAAI,eAAe,KAAK,GAAG,OAAO,aAAa,EAAE,OAAO,cAAc,WAAW,GAAG,GAAG;EACvF,MAAM,SAAS,MAAM,IAAI,UAAU;EACnC,IAAI,WAAW,KAAK,GAAG,OAAO,aAAa,EAAE,OAAO,uBAAuB,WAAW,GAAG,GAAG,GAAG;EAC/F,IAAI,IAAI,WAAW,QAAQ,OAAO,aAAa,EAAE,OAAO,WAAW,WAAW,iBAAiB,GAAG,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"}
@@ -1,4 +1,4 @@
1
- import { B as Secrets, H as Values, O as Params, P as RunnableServiceNode, c as Deps, m as HydratedDeps, u as Expose } from "./graph-types-COu3ss99-CrJcsbDJ.mjs";
1
+ import { B as Secrets, H as Values, O as Params, P as RunnableServiceNode, c as Deps, m as HydratedDeps, u as Expose } from "./graph-types-BgT9UEdm-Cg7wPD1I.mjs";
2
2
  //#region ../../0-framework/1-core/core/dist/testing.d.mts
3
3
  //#region src/exports/testing.d.ts
4
4
  /**
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@prisma/composer",
3
- "version": "0.1.0-dev.7",
3
+ "version": "0.1.0-dev.9",
4
4
  "type": "module",
5
- "description": "Prisma Composer — build a Prisma App by composing Modules. Core authoring, deploy pipeline, the prisma-composer CLI, and the rpc/node/nextjs authoring surfaces.",
5
+ "description": "Prisma Composer — build a Prisma App by composing Modules. Core authoring, deploy pipeline, the prisma-composer CLI, and the service-rpc/node/nextjs authoring surfaces.",
6
6
  "bin": {
7
7
  "prisma-composer": "./dist/bin.mjs"
8
8
  },
@@ -14,7 +14,7 @@
14
14
  "./testing": "./dist/testing.mjs",
15
15
  "./casts": "./dist/casts.mjs",
16
16
  "./assertions": "./dist/assertions.mjs",
17
- "./rpc": "./dist/rpc.mjs",
17
+ "./service-rpc": "./dist/service-rpc.mjs",
18
18
  "./node": "./dist/node.mjs",
19
19
  "./node/control": "./dist/node-control.mjs",
20
20
  "./nextjs": "./dist/nextjs.mjs",
@@ -36,15 +36,15 @@
36
36
  "@prisma/management-api-sdk": "^1.47.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@internal/assemble": "0.1.0-dev.7",
40
- "@internal/cli": "0.1.0-dev.7",
41
- "@internal/core": "0.1.0-dev.7",
42
- "@internal/foundation": "0.1.0-dev.7",
43
- "@internal/lowering": "0.1.0-dev.7",
44
- "@internal/nextjs": "0.1.0-dev.7",
45
- "@internal/node": "0.1.0-dev.7",
46
- "@internal/rpc": "0.1.0-dev.7",
47
- "@internal/tsdown-config": "0.1.0-dev.7",
39
+ "@internal/assemble": "0.1.0-dev.9",
40
+ "@internal/cli": "0.1.0-dev.9",
41
+ "@internal/core": "0.1.0-dev.9",
42
+ "@internal/foundation": "0.1.0-dev.9",
43
+ "@internal/lowering": "0.1.0-dev.9",
44
+ "@internal/nextjs": "0.1.0-dev.9",
45
+ "@internal/node": "0.1.0-dev.9",
46
+ "@internal/service-rpc": "0.1.0-dev.9",
47
+ "@internal/tsdown-config": "0.1.0-dev.9",
48
48
  "@types/node": "^25.9.3",
49
49
  "tsdown": "^0.22.7",
50
50
  "typescript": "^6.0.3"
@@ -1 +0,0 @@
1
- import "./app-config-5mXxjaEl-D2Q6MU5g.mjs";
@@ -1 +0,0 @@
1
- import "./app-config-5mXxjaEl-D2Q6MU5g.mjs";
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, provisionNeed, 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 headers = { \"content-type\": \"application/json\" };\n\tif (opts?.serviceKey !== void 0) headers[\"Authorization\"] = `Bearer ${opts.serviceKey}`;\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,\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\n/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */\nconst RPC_PEER_KEY = Symbol.for(\"prisma:rpc/per-binding-key\");\n/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */\nconst perBindingToken = () => provisionNeed(RPC_PEER_KEY);\nfunction rpc(arg) {\n\tif (!isRpcContract(arg)) return arg;\n\treturn dependency({\n\t\ttype: \"rpc\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tserviceKey: string({\n\t\t\t\t\toptional: true,\n\t\t\t\t\tprovision: perBindingToken()\n\t\t\t\t})\n\t\t\t},\n\t\t\thydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })\n\t\t},\n\t\trequired: arg\n\t});\n}\nfunction isRpcContract(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value && value.kind === \"rpc\" && \"__cmp\" in value && \"satisfies\" in value;\n}\n//#endregion\n//#region src/serve.ts\n/** The reserved env var the target (slice 2) writes the accepted key set to. */\nconst RPC_ACCEPTED_KEYS_ENV = \"COMPOSER_RPC_ACCEPTED_KEYS\";\nfunction 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/** The provisioned accepted key set, or undefined when the deploy never provisioned one (local/test — enforcement off). */\nfunction acceptedKeys() {\n\tconst raw = process.env[RPC_ACCEPTED_KEYS_ENV];\n\tif (raw === void 0 || raw === \"\") return void 0;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn [];\n\t}\n\treturn Array.isArray(parsed) && parsed.every((key) => typeof key === \"string\") ? parsed : [];\n}\n/**\n* Length-independent constant-time string equality — no early exit on the\n* first mismatched character or on a length difference, so a caller cannot\n* time its way toward a valid key. No `node:crypto`, to keep this module\n* runtime-agnostic.\n*/\nfunction constantTimeEquals(a, b) {\n\tconst length = Math.max(a.length, b.length);\n\tlet diff = a.length ^ b.length;\n\tfor (let i = 0; i < length; i++) diff |= (i < a.length ? a.charCodeAt(i) : 0) ^ (i < b.length ? b.charCodeAt(i) : 0);\n\treturn diff === 0;\n}\n/** Whether `presented` is a member of `accepted` — always compares against every key. */\nfunction isAcceptedKey(presented, accepted) {\n\tlet matched = false;\n\tfor (const key of accepted) matched = constantTimeEquals(presented, key) || matched;\n\treturn matched;\n}\nconst BEARER_PREFIX = \"Bearer \";\n/** The bearer token on `Authorization`, or `''` if the header is missing or malformed. */\nfunction bearerToken(req) {\n\tconst header = req.headers.get(\"authorization\");\n\treturn header?.startsWith(BEARER_PREFIX) ? header.slice(7) : \"\";\n}\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 accepted = acceptedKeys();\n\t\tif (accepted !== void 0 && !isAcceptedKey(bearerToken(req), accepted)) return jsonResponse({ error: \"Unauthorized: missing or invalid service key\" }, 401);\n\t\tconst { pathname } = new URL(req.url);\n\t\tconst methodName = /^\\/rpc\\/([^/]+)$/.exec(pathname)?.[1];\n\t\tif (methodName === void 0) return 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 { RPC_ACCEPTED_KEYS_EN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