@prisma/composer-prisma-cloud 0.1.0 → 0.2.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/dist/control.d.mts +79 -36
- package/dist/control.mjs +1074 -330
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +63 -10
- package/dist/cron/index.mjs +255 -42
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +563 -289
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +255 -42
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/index.d.mts +152 -26
- package/dist/index.mjs +108 -43
- package/dist/index.mjs.map +1 -1
- package/dist/{prisma-next-COrwlg3N.mjs → prisma-next-DlU01kXJ-2sP5mQb6.mjs} +3 -3
- package/dist/prisma-next-DlU01kXJ-2sP5mQb6.mjs.map +1 -0
- package/dist/prisma-next.d.mts +1 -2
- package/dist/prisma-next.mjs +1 -1
- package/dist/provisioned-edges-B_XS1Mz--NFJgcXK7.mjs +211 -0
- package/dist/provisioned-edges-B_XS1Mz--NFJgcXK7.mjs.map +1 -0
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts +36 -0
- package/dist/{serializer-C2CsA7xm-29Eg2Tjl.mjs → serializer-D8_84XWO-DA2B6YbX.mjs} +91 -7
- package/dist/serializer-D8_84XWO-DA2B6YbX.mjs.map +1 -0
- package/dist/storage/index.d.mts +56 -20
- package/dist/storage/index.mjs +267 -44
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +7395 -53
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +267 -44
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/storage/testing.d.mts +7 -4
- package/dist/storage/testing.mjs.map +1 -1
- package/dist/streams/index.d.mts +222 -0
- package/dist/streams/index.mjs +4170 -0
- package/dist/streams/index.mjs.map +1 -0
- package/dist/streams/streams-entrypoint.mjs +48207 -0
- package/dist/streams/streams-entrypoint.mjs.map +1 -0
- package/dist/streams/streams-service.mjs +923 -0
- package/dist/streams/streams-service.mjs.map +1 -0
- package/dist/streams/testing.d.mts +33 -0
- package/dist/streams/testing.mjs +31335 -0
- package/dist/streams/testing.mjs.map +1 -0
- package/dist/testing.d.mts +1 -2
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +27 -22
- package/dist/prisma-next-COrwlg3N.mjs.map +0 -1
- package/dist/serializer-C2CsA7xm-29Eg2Tjl.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { n as configKey } from "./serializer-Cx5slrV4-xJfH6EWS.mjs";
|
|
2
|
+
import { BuildAdapter, Contract, DependencyEnd, Deps, Expose, Graph, HydratedDeps, NODE, ParamBinding, ParamSource, Params, ProvisionNeed, ResourceNode, RunnableServiceNode, SecretBinding, SecretSource, SecretValues, Secrets, ServiceNode, Values } from "@prisma/composer";
|
|
3
3
|
//#region ../../1-prisma-cloud/1-extensions/target/dist/index.d.mts
|
|
4
|
+
//#region src/bucket.d.ts
|
|
5
|
+
interface BucketConfig {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly bucket: string;
|
|
8
|
+
readonly accessKeyId: string;
|
|
9
|
+
readonly secretAccessKey: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The contract a provisioned Bucket provides — deliberately kind-equal to the
|
|
13
|
+
* storage module's `s3Contract` (`kind: 's3'`). `satisfies` compares KIND,
|
|
14
|
+
* not identity (mirrors `postgresContract`): a real bucket and the emulator
|
|
15
|
+
* are interchangeable at every `s3()` dependency slot. Cross-layer import of
|
|
16
|
+
* the storage module's contract is not allowed (layering: 2-shared-modules
|
|
17
|
+
* depends on 1-extensions, not the reverse), which is exactly the design
|
|
18
|
+
* rationale for kind-equality — the two contracts cooperate through their
|
|
19
|
+
* shared kind string, not through object identity.
|
|
20
|
+
*/
|
|
21
|
+
declare const bucketContract: Contract<'s3', BucketConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* The one Bucket factory; the argument shape picks the role.
|
|
24
|
+
*
|
|
25
|
+
* `{ name }` — the resource identity a module provisions: the ONE place the
|
|
26
|
+
* bucket exists, providing `bucketContract`. Return type declared explicitly
|
|
27
|
+
* so nothing widens.
|
|
28
|
+
*/
|
|
29
|
+
declare function bucket(opts: {
|
|
30
|
+
name: string;
|
|
31
|
+
}): ResourceNode<typeof bucketContract>;
|
|
32
|
+
/**
|
|
33
|
+
* `bucket()` — a service's dependency on a real bucket. Its binding (what
|
|
34
|
+
* `load()` returns) is the typed connection config `BucketConfig` itself —
|
|
35
|
+
* `{ url, bucket, accessKeyId, secretAccessKey }`. The app constructs its own
|
|
36
|
+
* S3 client from that config (ADR-0015). The kind `'s3'` makes this slot
|
|
37
|
+
* interchangeable with the storage emulator's `s3()` dependency: any provider
|
|
38
|
+
* whose contract has `kind === 's3'` — whether a real bucket or the emulator
|
|
39
|
+
* — will wire here.
|
|
40
|
+
*/
|
|
41
|
+
declare function bucket(): DependencyEnd<BucketConfig, typeof bucketContract>;
|
|
42
|
+
//#endregion
|
|
4
43
|
//#region src/compute.d.ts
|
|
5
44
|
declare const reservedParams: {
|
|
6
45
|
readonly port: import("@prisma/composer").ConfigParam<import("@standard-schema/spec").StandardSchemaV1<number, number>>;
|
|
@@ -11,7 +50,7 @@ type ReservedParams = typeof reservedParams;
|
|
|
11
50
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
12
51
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
13
52
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
14
|
-
*
|
|
53
|
+
*
|
|
15
54
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
16
55
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
17
56
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -19,12 +58,36 @@ type ReservedParams = typeof reservedParams;
|
|
|
19
58
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
20
59
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
21
60
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
61
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
62
|
+
* stash `run()` populates; memoized per process.
|
|
22
63
|
*
|
|
23
|
-
*
|
|
64
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
24
65
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
25
66
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
26
|
-
* deploy time; nodes are pure data.
|
|
67
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
27
68
|
*/
|
|
69
|
+
declare class ComputeService<D extends Deps, P extends Params, E extends Expose, S extends Secrets> implements RunnableServiceNode<D, P & ReservedParams, E, S> {
|
|
70
|
+
#private;
|
|
71
|
+
readonly [NODE]: true;
|
|
72
|
+
readonly kind: 'service';
|
|
73
|
+
readonly name: string;
|
|
74
|
+
readonly extension: string;
|
|
75
|
+
readonly type: string;
|
|
76
|
+
readonly inputs: D;
|
|
77
|
+
readonly params: P & ReservedParams;
|
|
78
|
+
readonly secretSlots: S;
|
|
79
|
+
readonly build: BuildAdapter;
|
|
80
|
+
readonly expose: E | undefined;
|
|
81
|
+
constructor(node: ServiceNode<D, P & ReservedParams, E, S>);
|
|
82
|
+
run(address: string, boot: () => Promise<unknown>): Promise<unknown>;
|
|
83
|
+
load(): HydratedDeps<D>;
|
|
84
|
+
config(): Values<P & ReservedParams>;
|
|
85
|
+
secrets(): SecretValues<S>;
|
|
86
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
87
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
88
|
+
* has stashed it (readOrigin's pinned message). */
|
|
89
|
+
origin(): string;
|
|
90
|
+
}
|
|
28
91
|
declare const compute: <D extends Deps, P extends Params = Record<never, never>, E extends Expose = Record<never, never>, S extends Secrets = Record<never, never>>(def: {
|
|
29
92
|
name: string;
|
|
30
93
|
deps: D;
|
|
@@ -32,7 +95,8 @@ declare const compute: <D extends Deps, P extends Params = Record<never, never>,
|
|
|
32
95
|
secrets?: S;
|
|
33
96
|
build: BuildAdapter;
|
|
34
97
|
expose?: E;
|
|
35
|
-
}) =>
|
|
98
|
+
}) => ComputeService<D, P, E, S>;
|
|
99
|
+
//#endregion
|
|
36
100
|
//#region src/http.d.ts
|
|
37
101
|
/** A service-to-service dependency's client: a thin URL-anchored fetch wrapper. */
|
|
38
102
|
interface HttpClient {
|
|
@@ -50,7 +114,40 @@ interface HttpClient {
|
|
|
50
114
|
*/
|
|
51
115
|
declare const http: (opts: {
|
|
52
116
|
name: string;
|
|
53
|
-
}) => DependencyEnd<HttpClient>;
|
|
117
|
+
}) => DependencyEnd<HttpClient>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/param.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Brands the payload `envParam` builds. Core's `paramSource()` is a public
|
|
122
|
+
* SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;
|
|
123
|
+
* the brand lets `paramName` reject such a source (or another target's) with
|
|
124
|
+
* a clear error instead of reading an absent `.name`.
|
|
125
|
+
*/
|
|
126
|
+
declare const PRISMA_CLOUD_PARAM_SOURCE: unique symbol;
|
|
127
|
+
/** The Prisma Cloud param source payload: the platform env-var name the slot resolves to, under a brand only `envParam` sets. */
|
|
128
|
+
interface EnvParamPayload {
|
|
129
|
+
readonly [PRISMA_CLOUD_PARAM_SOURCE]: true;
|
|
130
|
+
readonly name: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Binds a param slot to a named Prisma Cloud platform env var — the non-secret
|
|
134
|
+
* sibling of `envSecret` (spec: env-sourced config params). The platform
|
|
135
|
+
* injects the value into the running instance per stage; the param's own
|
|
136
|
+
* schema validates it at boot, unredacted. The name may not use the
|
|
137
|
+
* framework's reserved `COMPOSER_` prefix or the poisoned
|
|
138
|
+
* `DATABASE_URL(_POOLED)` keys — same parity as `envSecret`.
|
|
139
|
+
*/
|
|
140
|
+
declare function envParam(name: string): ParamSource<EnvParamPayload>;
|
|
141
|
+
/**
|
|
142
|
+
* Reads the Prisma Cloud env-var name back out of a param binding's opaque
|
|
143
|
+
* source. A source not built by `envParam` (a raw `paramSource(...)` or
|
|
144
|
+
* another target's source) carries no name — reject it here. `paramName` runs
|
|
145
|
+
* in preflight and at serialize before any value ever crosses the wire, so a
|
|
146
|
+
* foreign source fails early and clearly rather than producing a broken
|
|
147
|
+
* deploy with an undefined name.
|
|
148
|
+
*/
|
|
149
|
+
declare function paramName(binding: ParamBinding): string;
|
|
150
|
+
//#endregion
|
|
54
151
|
//#region src/postgres.d.ts
|
|
55
152
|
interface PostgresConfig {
|
|
56
153
|
readonly url: string;
|
|
@@ -81,7 +178,26 @@ declare function postgres(opts: {
|
|
|
81
178
|
* `const sql = new SQL({ url: db.url })`. No driver choice lives in the
|
|
82
179
|
* declaration.
|
|
83
180
|
*/
|
|
84
|
-
declare function postgres(): DependencyEnd<PostgresConfig, typeof postgresContract>;
|
|
181
|
+
declare function postgres(): DependencyEnd<PostgresConfig, typeof postgresContract>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/provisioned-edges.d.ts
|
|
184
|
+
/** One faceted dependency edge: a consumer input whose param carries a provisioning need. */
|
|
185
|
+
interface ProvisionedEdge {
|
|
186
|
+
/** `${consumerAddress}.${input}` — `ctx.provisioned`'s key. */
|
|
187
|
+
readonly edgeId: string;
|
|
188
|
+
readonly consumerAddress: string;
|
|
189
|
+
readonly input: string;
|
|
190
|
+
readonly providerAddress: string;
|
|
191
|
+
/** The need's brand — opaque here; the target's registry gives it meaning. */
|
|
192
|
+
readonly brand: symbol;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Every provisioned edge in the graph. Core resolves and mints these (one
|
|
196
|
+
* value per edge, keyed by `edgeId`); this scan is how the target finds them
|
|
197
|
+
* again when it gathers a provider's inbound values.
|
|
198
|
+
*/
|
|
199
|
+
declare function provisionedEdges(graph: Graph): readonly ProvisionedEdge[];
|
|
200
|
+
//#endregion
|
|
85
201
|
//#region src/s3-credentials.d.ts
|
|
86
202
|
interface CredentialsConfig {
|
|
87
203
|
readonly accessKeyId: string;
|
|
@@ -107,7 +223,8 @@ declare function s3Credentials(opts: {
|
|
|
107
223
|
* the typed `CredentialsConfig`. The storage service reads the pair through this
|
|
108
224
|
* dependency binding (invariant 4 — no bespoke env reads).
|
|
109
225
|
*/
|
|
110
|
-
declare function s3Credentials(): DependencyEnd<CredentialsConfig, typeof credentialsContract>;
|
|
226
|
+
declare function s3Credentials(): DependencyEnd<CredentialsConfig, typeof credentialsContract>;
|
|
227
|
+
//#endregion
|
|
111
228
|
//#region src/s3-store.d.ts
|
|
112
229
|
/**
|
|
113
230
|
* The storage service authoring factory — a `compute` service routed to the
|
|
@@ -120,8 +237,16 @@ declare function s3Credentials(): DependencyEnd<CredentialsConfig, typeof creden
|
|
|
120
237
|
* return type is compute's exactly (including the reserved `port` param). The
|
|
121
238
|
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
122
239
|
* param, and `expose: { store: s3Contract }`.
|
|
240
|
+
*
|
|
241
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
242
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
243
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
244
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
245
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
246
|
+
* properties) with `type` overridden keeps every method intact.
|
|
123
247
|
*/
|
|
124
|
-
declare function s3StoreService<D extends Deps, P extends Params = Record<never, never>, E extends Expose = Record<never, never>>(def: Parameters<typeof compute<D, P, E>>[0]): ReturnType<typeof compute<D, P, E>>;
|
|
248
|
+
declare function s3StoreService<D extends Deps, P extends Params = Record<never, never>, E extends Expose = Record<never, never>>(def: Parameters<typeof compute<D, P, E>>[0]): ReturnType<typeof compute<D, P, E>>;
|
|
249
|
+
//#endregion
|
|
125
250
|
//#region src/secret.d.ts
|
|
126
251
|
/**
|
|
127
252
|
* Brands the payload `envSecret` builds. Core's `secretSource()` is a public
|
|
@@ -138,7 +263,7 @@ interface EnvSecretPayload {
|
|
|
138
263
|
/**
|
|
139
264
|
* Binds a secret slot to a named Prisma Cloud platform env var (ADR-0029). The
|
|
140
265
|
* value is provisioned out-of-band; only the name is carried. The name may not
|
|
141
|
-
* use the framework's reserved `
|
|
266
|
+
* use the framework's reserved `COMPOSER_` prefix or the poisoned
|
|
142
267
|
* `DATABASE_URL(_POOLED)` keys.
|
|
143
268
|
*/
|
|
144
269
|
declare function envSecret(name: string): SecretSource<EnvSecretPayload>;
|
|
@@ -149,20 +274,21 @@ declare function envSecret(name: string): SecretSource<EnvSecretPayload>;
|
|
|
149
274
|
* in preflight before any provisioning, so a foreign source fails early and
|
|
150
275
|
* clearly rather than producing a broken deploy with an undefined name.
|
|
151
276
|
*/
|
|
152
|
-
declare function secretName(binding: SecretBinding): string;
|
|
153
|
-
//#
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
277
|
+
declare function secretName(binding: SecretBinding): string;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/streams-keys.d.ts
|
|
280
|
+
/** ADR-0031's need brand for the streams module's bearer key — control.ts registers the provisioner under this. */
|
|
281
|
+
declare const STREAMS_API_KEY: unique symbol;
|
|
282
|
+
/**
|
|
283
|
+
* The provisioning need `durableStreams()`'s `apiKey` param declares: an
|
|
284
|
+
* unguessable value the target mints ONCE PER PROVIDER (not per edge) —
|
|
285
|
+
* `@prisma/streams-server` authenticates a single `API_KEY`, so every
|
|
286
|
+
* consumer of one streams module must present the same value. Per-provider
|
|
287
|
+
* cardinality is provisioner policy (ADR-0031), invisible to core.
|
|
288
|
+
*/
|
|
289
|
+
declare const streamsApiKeyNeed: () => ProvisionNeed;
|
|
290
|
+
/** The address-free name compute.ts re-stashes to and the streams entrypoint reads. */
|
|
291
|
+
declare const STREAMS_API_KEY_ENV: string;
|
|
166
292
|
//#endregion
|
|
167
|
-
export { type CredentialsConfig, type CredentialsContract, type HttpClient, type PostgresConfig, compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };
|
|
293
|
+
export { type BucketConfig, ComputeService, type CredentialsConfig, type CredentialsContract, type HttpClient, type PostgresConfig, type ProvisionedEdge, STREAMS_API_KEY, STREAMS_API_KEY_ENV, bucket, bucketContract, compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, provisionedEdges, s3Credentials, s3StoreService, secretName, streamsApiKeyNeed };
|
|
168
294
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as stash, i as deserializeSecrets, l as readOrigin, m as stashSecrets, n as configKey, p as stashProviderParams, r as deserialize, s as envSecret, u as secretName } from "./serializer-D8_84XWO-DA2B6YbX.mjs";
|
|
2
|
+
import { a as envParam, c as paramName, i as STREAMS_API_KEY_ENV, l as provisionedEdges, r as STREAMS_API_KEY, t as RESERVED_PROVIDER_PARAMS, u as streamsApiKeyNeed } from "./provisioned-edges-B_XS1Mz--NFJgcXK7.mjs";
|
|
2
3
|
import { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from "@prisma/composer";
|
|
3
4
|
import { blindCast } from "@prisma/composer/casts";
|
|
4
5
|
//#region ../../1-prisma-cloud/1-extensions/target/dist/index.mjs
|
|
6
|
+
/**
|
|
7
|
+
* The contract a provisioned Bucket provides — deliberately kind-equal to the
|
|
8
|
+
* storage module's `s3Contract` (`kind: 's3'`). `satisfies` compares KIND,
|
|
9
|
+
* not identity (mirrors `postgresContract`): a real bucket and the emulator
|
|
10
|
+
* are interchangeable at every `s3()` dependency slot. Cross-layer import of
|
|
11
|
+
* the storage module's contract is not allowed (layering: 2-shared-modules
|
|
12
|
+
* depends on 1-extensions, not the reverse), which is exactly the design
|
|
13
|
+
* rationale for kind-equality — the two contracts cooperate through their
|
|
14
|
+
* shared kind string, not through object identity.
|
|
15
|
+
*/
|
|
16
|
+
const bucketContract = Object.freeze({
|
|
17
|
+
kind: "s3",
|
|
18
|
+
__cmp: {
|
|
19
|
+
url: "",
|
|
20
|
+
bucket: "",
|
|
21
|
+
accessKeyId: "",
|
|
22
|
+
secretAccessKey: ""
|
|
23
|
+
},
|
|
24
|
+
satisfies: (required) => required.kind === "s3"
|
|
25
|
+
});
|
|
26
|
+
function bucket(opts) {
|
|
27
|
+
if (opts?.name !== void 0) return resource({
|
|
28
|
+
name: opts.name,
|
|
29
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
30
|
+
provides: bucketContract
|
|
31
|
+
});
|
|
32
|
+
return dependency({
|
|
33
|
+
type: "s3",
|
|
34
|
+
connection: {
|
|
35
|
+
params: {
|
|
36
|
+
url: string(),
|
|
37
|
+
bucket: string(),
|
|
38
|
+
accessKeyId: string(),
|
|
39
|
+
secretAccessKey: string()
|
|
40
|
+
},
|
|
41
|
+
hydrate: (v) => v
|
|
42
|
+
},
|
|
43
|
+
required: bucketContract
|
|
44
|
+
});
|
|
45
|
+
}
|
|
5
46
|
const reservedParams = { port: number({ default: 3e3 }) };
|
|
6
47
|
/**
|
|
7
48
|
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
8
49
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
9
50
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
10
51
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
11
|
-
*
|
|
52
|
+
*
|
|
12
53
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
13
54
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
14
55
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -16,23 +57,69 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
16
57
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
17
58
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
18
59
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
60
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
61
|
+
* stash `run()` populates; memoized per process.
|
|
19
62
|
*
|
|
20
|
-
*
|
|
63
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
21
64
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
22
65
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
23
|
-
* deploy time; nodes are pure data.
|
|
66
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
24
67
|
*/
|
|
68
|
+
var ComputeService = class {
|
|
69
|
+
#resolved;
|
|
70
|
+
#loadedDeps;
|
|
71
|
+
#loadedParams;
|
|
72
|
+
#loadedSecrets;
|
|
73
|
+
#origin;
|
|
74
|
+
constructor(node) {
|
|
75
|
+
Object.assign(this, node);
|
|
76
|
+
}
|
|
77
|
+
#processConfig() {
|
|
78
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
79
|
+
return this.#resolved;
|
|
80
|
+
}
|
|
81
|
+
async run(address, boot) {
|
|
82
|
+
const config = deserialize(this, address);
|
|
83
|
+
stash(this, config);
|
|
84
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
85
|
+
stashSecrets(this, address);
|
|
86
|
+
const port = config.service["port"];
|
|
87
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
88
|
+
return boot();
|
|
89
|
+
}
|
|
90
|
+
load() {
|
|
91
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
92
|
+
return this.#loadedDeps;
|
|
93
|
+
}
|
|
94
|
+
config() {
|
|
95
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
96
|
+
return this.#loadedParams;
|
|
97
|
+
}
|
|
98
|
+
secrets() {
|
|
99
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
100
|
+
return this.#loadedSecrets;
|
|
101
|
+
}
|
|
102
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
103
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
104
|
+
* has stashed it (readOrigin's pinned message). */
|
|
105
|
+
origin() {
|
|
106
|
+
this.#origin ??= readOrigin();
|
|
107
|
+
return this.#origin;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
25
110
|
const compute = (def) => {
|
|
26
111
|
const userParams = def.params ?? blindCast({});
|
|
27
112
|
for (const reserved of Object.keys(reservedParams)) {
|
|
28
113
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
29
114
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
30
115
|
}
|
|
116
|
+
for (const name of Object.keys(userParams)) if (name.toUpperCase() === "ORIGIN") throw new Error(`compute(): param "${name}" collides with the framework-written origin row — rename the param.`);
|
|
117
|
+
for (const name of Object.keys(def.secrets ?? {})) if (name.toUpperCase() === "ORIGIN") throw new Error(`compute(): secret "${name}" collides with the framework-written origin row — rename the secret.`);
|
|
31
118
|
const params = blindCast({
|
|
32
119
|
...userParams,
|
|
33
120
|
...reservedParams
|
|
34
121
|
});
|
|
35
|
-
const
|
|
122
|
+
const instance = new ComputeService(service({
|
|
36
123
|
name: def.name,
|
|
37
124
|
extension: "@prisma/composer-prisma-cloud",
|
|
38
125
|
type: "compute",
|
|
@@ -41,39 +128,9 @@ const compute = (def) => {
|
|
|
41
128
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
42
129
|
build: def.build,
|
|
43
130
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
let loadedParams;
|
|
48
|
-
let loadedSecrets;
|
|
49
|
-
function processConfig() {
|
|
50
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
51
|
-
return resolved;
|
|
52
|
-
}
|
|
53
|
-
const runnable = {
|
|
54
|
-
...node,
|
|
55
|
-
async run(address, boot) {
|
|
56
|
-
const config = deserialize(node, address);
|
|
57
|
-
stash(node, config);
|
|
58
|
-
stashSecrets(node, address);
|
|
59
|
-
const port = config.service["port"];
|
|
60
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
61
|
-
return boot();
|
|
62
|
-
},
|
|
63
|
-
load() {
|
|
64
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
65
|
-
return loadedDeps;
|
|
66
|
-
},
|
|
67
|
-
config() {
|
|
68
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
69
|
-
return loadedParams;
|
|
70
|
-
},
|
|
71
|
-
secrets() {
|
|
72
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
73
|
-
return loadedSecrets;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return Object.freeze(blindCast(runnable));
|
|
131
|
+
}));
|
|
132
|
+
Object.freeze(instance);
|
|
133
|
+
return instance;
|
|
77
134
|
};
|
|
78
135
|
const defaultHttpClient = (cfg) => ({
|
|
79
136
|
url: cfg.url,
|
|
@@ -165,15 +222,23 @@ function s3Credentials(opts) {
|
|
|
165
222
|
* return type is compute's exactly (including the reserved `port` param). The
|
|
166
223
|
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
167
224
|
* param, and `expose: { store: s3Contract }`.
|
|
225
|
+
*
|
|
226
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
227
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
228
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
229
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
230
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
231
|
+
* properties) with `type` overridden keeps every method intact.
|
|
168
232
|
*/
|
|
169
233
|
function s3StoreService(def) {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
...node,
|
|
234
|
+
const instance = new ComputeService({
|
|
235
|
+
...compute(def),
|
|
173
236
|
type: "s3-store"
|
|
174
|
-
})
|
|
237
|
+
});
|
|
238
|
+
Object.freeze(instance);
|
|
239
|
+
return instance;
|
|
175
240
|
}
|
|
176
241
|
//#endregion
|
|
177
|
-
export { compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };
|
|
242
|
+
export { ComputeService, STREAMS_API_KEY, STREAMS_API_KEY_ENV, bucket, bucketContract, compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, provisionedEdges, s3Credentials, s3StoreService, secretName, streamsApiKeyNeed };
|
|
178
243
|
|
|
179
244
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/index.mjs"],"sourcesContent":["import { c as stashSecrets, l as envSecret, n as deserialize, r as deserializeSecrets, s as stash, t as configKey, u as secretName } from \"./serializer-C2CsA7xm.mjs\";\nimport { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/compute.ts\nconst reservedParams = { port: number({ default: 3e3 }) };\n/**\n* A Prisma Compute service — declarations only (deps + params + build + the\n* ports it exposes), no descriptor. `params` merges with the reserved\n* `ReservedParams` (`port`); a user param whose name collides with a reserved\n* one fails at authoring, the same way a colliding dependency name does.\n* Returns the extension's runnable/loadable node:\n* · run(address, boot) — the process controller: deserialize the platform\n* environment (keyed off `address`, the extension's ONE env read) into a\n* typed Config, re-emit it under address-free process-local stash keys,\n* then call boot() to start the app's entry.\n* · load() / config() — called from inside the app's entry: read the stash;\n* load() hydrates + memoizes the deps, config() returns the typed params.\n* Separate accessors so a dep and a param never share a namespace (ADR-0021).\n*\n* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —\n* the control-plane registry key `prisma-composer deploy` resolves through the\n* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at\n* deploy time; nodes are pure data.\n*/\nconst compute = (def) => {\n\tconst userParams = def.params ?? blindCast({});\n\tfor (const reserved of Object.keys(reservedParams)) {\n\t\tif (reserved in def.deps) throw new Error(`compute(): dependency \"${reserved}\" collides with the reserved service param of the same name — rename the dependency.`);\n\t\tif (reserved in userParams) throw new Error(`compute(): param \"${reserved}\" collides with the reserved service param of the same name — rename the param.`);\n\t}\n\tconst params = blindCast({\n\t\t...userParams,\n\t\t...reservedParams\n\t});\n\tconst node = service({\n\t\tname: def.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\ttype: \"compute\",\n\t\tinputs: def.deps,\n\t\tparams,\n\t\t...def.secrets !== void 0 ? { secrets: def.secrets } : {},\n\t\tbuild: def.build,\n\t\t...def.expose !== void 0 ? { expose: def.expose } : {}\n\t});\n\tlet resolved;\n\tlet loadedDeps;\n\tlet loadedParams;\n\tlet loadedSecrets;\n\tfunction processConfig() {\n\t\tif (resolved === void 0) resolved = deserialize(node, \"\");\n\t\treturn resolved;\n\t}\n\tconst runnable = {\n\t\t...node,\n\t\tasync run(address, boot) {\n\t\t\tconst config = deserialize(node, address);\n\t\t\tstash(node, config);\n\t\t\tstashSecrets(node, address);\n\t\t\tconst port = config.service[\"port\"];\n\t\t\tif (typeof port === \"number\") process.env[\"PORT\"] = String(port);\n\t\t\treturn boot();\n\t\t},\n\t\tload() {\n\t\t\tif (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));\n\t\t\treturn loadedDeps;\n\t\t},\n\t\tconfig() {\n\t\t\tif (loadedParams === void 0) loadedParams = blindCast(processConfig().service);\n\t\t\treturn loadedParams;\n\t\t},\n\t\tsecrets() {\n\t\t\tif (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, \"\")));\n\t\t\treturn loadedSecrets;\n\t\t}\n\t};\n\treturn Object.freeze(blindCast(runnable));\n};\n//#endregion\n//#region src/http.ts\nconst defaultHttpClient = (cfg) => ({\n\turl: cfg.url,\n\tfetch: (path, init) => fetch(new URL(path, cfg.url), init)\n});\n/**\n* A service-to-service dependency. Its binding (what `load()` returns) is a\n* derived HttpClient — a thin URL-anchored fetch wrapper (fetch is standard\n* across runtimes — no driver, no runtime coupling). http() is a\n* protocol-owned kind: the framework owns the transport, so the client is\n* kind-canonical and derived from the contract, with no user client in the\n* declaration (ADR-0015). The typed generated client arrives with the\n* interface primitive (a later extension point).\n*/\nconst http = (opts) => dependency({\n\tname: opts.name,\n\ttype: \"http\",\n\tconnection: {\n\t\tparams: { url: string() },\n\t\thydrate: (v) => defaultHttpClient({ url: v.url })\n\t}\n});\n//#endregion\n//#region src/postgres.ts\n/**\n* The contract a Postgres provides — and the contract its consumers require.\n* `satisfies` compares KIND, not identity: an extension module can be duplicated\n* across a workspace (same rationale as the Symbol.for node brand), and every\n* duplicate's contract must still satisfy. `__cmp` is the connection config a\n* postgres offers; core never inspects it.\n*/\nconst postgresContract = Object.freeze({\n\tkind: \"postgres\",\n\t__cmp: { url: \"\" },\n\tsatisfies: (required) => required.kind === \"postgres\"\n});\nfunction postgres(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: postgresContract\n\t});\n\treturn dependency({\n\t\ttype: \"postgres\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: postgresContract\n\t});\n}\n//#endregion\n//#region src/s3-credentials.ts\n/**\n* The contract the `s3-credentials` resource provides — a minted SigV4 key\n* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is\n* the config the resource offers, which core never inspects.\n*/\nconst credentialsContract = Object.freeze({\n\tkind: \"credentials\",\n\t__cmp: {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"credentials\"\n});\nfunction s3Credentials(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: credentialsContract\n\t});\n\treturn dependency({\n\t\ttype: \"credentials\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: credentialsContract\n\t});\n}\n//#endregion\n//#region src/s3-store.ts\n/**\n* The storage service authoring factory — a `compute` service routed to the\n* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s\n* runnable (run/load/config, deps, params, build, expose) with the routing\n* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the\n* serializer keys off the deployment address and each param's owner/name, and\n* `load`/`config` off deps/params), so only the deploy-time descriptor lookup\n* sees the override and routes to the extended-output lowering (§ 5). The\n* return type is compute's exactly (including the reserved `port` param). The\n* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`\n* param, and `expose: { store: s3Contract }`.\n*/\nfunction s3StoreService(def) {\n\tconst node = compute(def);\n\treturn Object.freeze(blindCast({\n\t\t...node,\n\t\ttype: \"s3-store\"\n\t}));\n}\n//#endregion\nexport { compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";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;IACpB,iBAAiB,OAAO;GACzB;GACA,UAAU,MAAM;EACjB;EACA,UAAU;CACX,CAAC;AACF;;;;;;;;;;;;;AAeA,SAAS,eAAe,KAAK;CAC5B,MAAM,OAAO,QAAQ,GAAG;CACxB,OAAO,OAAO,OAAO,UAAU;EAC9B,GAAG;EACH,MAAM;CACP,CAAC,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#resolved","#loadedDeps","#processConfig","#loadedParams","#loadedSecrets","#origin"],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/index.mjs"],"sourcesContent":["import { c as readOrigin, d as stashProviderParams, f as stashSecrets, i as deserializeSecrets, m as secretName, n as configKey, p as envSecret, r as deserialize, u as stash } from \"./serializer-D8_84XWO.mjs\";\nimport { a as paramName, c as STREAMS_API_KEY_ENV, l as streamsApiKeyNeed, n as envParam, o as RESERVED_PROVIDER_PARAMS, s as STREAMS_API_KEY, t as provisionedEdges } from \"./provisioned-edges-B_XS1Mz-.mjs\";\nimport { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/bucket.ts\n/**\n* The contract a provisioned Bucket provides — deliberately kind-equal to the\n* storage module's `s3Contract` (`kind: 's3'`). `satisfies` compares KIND,\n* not identity (mirrors `postgresContract`): a real bucket and the emulator\n* are interchangeable at every `s3()` dependency slot. Cross-layer import of\n* the storage module's contract is not allowed (layering: 2-shared-modules\n* depends on 1-extensions, not the reverse), which is exactly the design\n* rationale for kind-equality — the two contracts cooperate through their\n* shared kind string, not through object identity.\n*/\nconst bucketContract = Object.freeze({\n\tkind: \"s3\",\n\t__cmp: {\n\t\turl: \"\",\n\t\tbucket: \"\",\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"s3\"\n});\nfunction bucket(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: bucketContract\n\t});\n\treturn dependency({\n\t\ttype: \"s3\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tbucket: string(),\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: bucketContract\n\t});\n}\n//#endregion\n//#region src/compute.ts\nconst reservedParams = { port: number({ default: 3e3 }) };\n/**\n* A Prisma Compute service — declarations only (deps + params + build + the\n* ports it exposes), no descriptor. `params` merges with the reserved\n* `ReservedParams` (`port`); a user param whose name collides with a reserved\n* one fails at authoring, the same way a colliding dependency name does.\n*\n* · run(address, boot) — the process controller: deserialize the platform\n* environment (keyed off `address`, the extension's ONE env read) into a\n* typed Config, re-emit it under address-free process-local stash keys,\n* then call boot() to start the app's entry.\n* · load() / config() — called from inside the app's entry: read the stash;\n* load() hydrates + memoizes the deps, config() returns the typed params.\n* Separate accessors so a dep and a param never share a namespace (ADR-0021).\n* · origin() — this service's platform-assigned public origin, read from the\n* stash `run()` populates; memoized per process.\n*\n* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —\n* the control-plane registry key `prisma-composer deploy` resolves through the\n* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at\n* deploy time; nodes are pure data until run() or load() is called.\n*/\nvar ComputeService = class {\n\t#resolved;\n\t#loadedDeps;\n\t#loadedParams;\n\t#loadedSecrets;\n\t#origin;\n\tconstructor(node) {\n\t\tObject.assign(this, node);\n\t}\n\t#processConfig() {\n\t\tif (this.#resolved === void 0) this.#resolved = deserialize(this, \"\");\n\t\treturn this.#resolved;\n\t}\n\tasync run(address, boot) {\n\t\tconst config = deserialize(this, address);\n\t\tstash(this, config);\n\t\tstashProviderParams(RESERVED_PROVIDER_PARAMS, address);\n\t\tstashSecrets(this, address);\n\t\tconst port = config.service[\"port\"];\n\t\tif (typeof port === \"number\") process.env[\"PORT\"] = String(port);\n\t\treturn boot();\n\t}\n\tload() {\n\t\tif (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));\n\t\treturn this.#loadedDeps;\n\t}\n\tconfig() {\n\t\tif (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);\n\t\treturn this.#loadedParams;\n\t}\n\tsecrets() {\n\t\tif (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, \"\")));\n\t\treturn this.#loadedSecrets;\n\t}\n\t/** This service's platform-assigned public origin — read from the stash\n\t* run() populates and memoized per process. Throws if called before run()\n\t* has stashed it (readOrigin's pinned message). */\n\torigin() {\n\t\tthis.#origin ??= readOrigin();\n\t\treturn this.#origin;\n\t}\n};\nconst compute = (def) => {\n\tconst userParams = def.params ?? blindCast({});\n\tfor (const reserved of Object.keys(reservedParams)) {\n\t\tif (reserved in def.deps) throw new Error(`compute(): dependency \"${reserved}\" collides with the reserved service param of the same name — rename the dependency.`);\n\t\tif (reserved in userParams) throw new Error(`compute(): param \"${reserved}\" collides with the reserved service param of the same name — rename the param.`);\n\t}\n\tfor (const name of Object.keys(userParams)) if (name.toUpperCase() === \"ORIGIN\") throw new Error(`compute(): param \"${name}\" collides with the framework-written origin row — rename the param.`);\n\tfor (const name of Object.keys(def.secrets ?? {})) if (name.toUpperCase() === \"ORIGIN\") throw new Error(`compute(): secret \"${name}\" collides with the framework-written origin row — rename the secret.`);\n\tconst params = blindCast({\n\t\t...userParams,\n\t\t...reservedParams\n\t});\n\tconst instance = new ComputeService(service({\n\t\tname: def.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\ttype: \"compute\",\n\t\tinputs: def.deps,\n\t\tparams,\n\t\t...def.secrets !== void 0 ? { secrets: def.secrets } : {},\n\t\tbuild: def.build,\n\t\t...def.expose !== void 0 ? { expose: def.expose } : {}\n\t}));\n\tObject.freeze(instance);\n\treturn instance;\n};\n//#endregion\n//#region src/http.ts\nconst defaultHttpClient = (cfg) => ({\n\turl: cfg.url,\n\tfetch: (path, init) => fetch(new URL(path, cfg.url), init)\n});\n/**\n* A service-to-service dependency. Its binding (what `load()` returns) is a\n* derived HttpClient — a thin URL-anchored fetch wrapper (fetch is standard\n* across runtimes — no driver, no runtime coupling). http() is a\n* protocol-owned kind: the framework owns the transport, so the client is\n* kind-canonical and derived from the contract, with no user client in the\n* declaration (ADR-0015). The typed generated client arrives with the\n* interface primitive (a later extension point).\n*/\nconst http = (opts) => dependency({\n\tname: opts.name,\n\ttype: \"http\",\n\tconnection: {\n\t\tparams: { url: string() },\n\t\thydrate: (v) => defaultHttpClient({ url: v.url })\n\t}\n});\n//#endregion\n//#region src/postgres.ts\n/**\n* The contract a Postgres provides — and the contract its consumers require.\n* `satisfies` compares KIND, not identity: an extension module can be duplicated\n* across a workspace (same rationale as the Symbol.for node brand), and every\n* duplicate's contract must still satisfy. `__cmp` is the connection config a\n* postgres offers; core never inspects it.\n*/\nconst postgresContract = Object.freeze({\n\tkind: \"postgres\",\n\t__cmp: { url: \"\" },\n\tsatisfies: (required) => required.kind === \"postgres\"\n});\nfunction postgres(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: postgresContract\n\t});\n\treturn dependency({\n\t\ttype: \"postgres\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: postgresContract\n\t});\n}\n//#endregion\n//#region src/s3-credentials.ts\n/**\n* The contract the `s3-credentials` resource provides — a minted SigV4 key\n* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is\n* the config the resource offers, which core never inspects.\n*/\nconst credentialsContract = Object.freeze({\n\tkind: \"credentials\",\n\t__cmp: {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"credentials\"\n});\nfunction s3Credentials(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: credentialsContract\n\t});\n\treturn dependency({\n\t\ttype: \"credentials\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: credentialsContract\n\t});\n}\n//#endregion\n//#region src/s3-store.ts\n/**\n* The storage service authoring factory — a `compute` service routed to the\n* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s\n* runnable (run/load/config, deps, params, build, expose) with the routing\n* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the\n* serializer keys off the deployment address and each param's owner/name, and\n* `load`/`config` off deps/params), so only the deploy-time descriptor lookup\n* sees the override and routes to the extended-output lowering (§ 5). The\n* return type is compute's exactly (including the reserved `port` param). The\n* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`\n* param, and `expose: { store: s3Contract }`.\n*\n* `compute()`'s result is a `ComputeService` instance — its run/load/config/\n* secrets/origin methods live on the class prototype, not as the instance's\n* own properties, so a plain object spread (`{ ...node }`) would silently\n* drop them. Building a fresh `ComputeService` from the same data fields\n* (which `{ ...node }` DOES copy — they're the node's own enumerable\n* properties) with `type` overridden keeps every method intact.\n*/\nfunction s3StoreService(def) {\n\tconst instance = new ComputeService({\n\t\t...compute(def),\n\t\ttype: \"s3-store\"\n\t});\n\tObject.freeze(instance);\n\treturn instance;\n}\n//#endregion\nexport { ComputeService, STREAMS_API_KEY, STREAMS_API_KEY_ENV, bucket, bucketContract, compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, provisionedEdges, s3Credentials, s3StoreService, secretName, streamsApiKeyNeed };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,iBAAiB,OAAO,OAAO;CACpC,MAAM;CACN,OAAO;EACN,KAAK;EACL,QAAQ;EACR,aAAa;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WAAW;CACjC,MAAM,KAAK;CACX,MAAM;CACN,YAAY;EACX,QAAQ,EAAE,KAAK,OAAO,EAAE;EACxB,UAAU,MAAM,kBAAkB,EAAE,KAAK,EAAE,IAAI,CAAC;CACjD;AACD,CAAC;;;;;;;;AAUD,MAAM,mBAAmB,OAAO,OAAO;CACtC,MAAM;CACN,OAAO,EAAE,KAAK,GAAG;CACjB,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;AACD,SAAS,SAAS,MAAM;CACvB,IAAI,MAAM,SAAS,KAAK,GAAG,OAAO,SAAS;EAC1C,MAAM,KAAK;EACX,WAAW;EACX,UAAU;CACX,CAAC;CACD,OAAO,WAAW;EACjB,MAAM;EACN,YAAY;GACX,QAAQ,EAAE,KAAK,OAAO,EAAE;GACxB,UAAU,MAAM;EACjB;EACA,UAAU;CACX,CAAC;AACF;;;;;;AAQA,MAAM,sBAAsB,OAAO,OAAO;CACzC,MAAM;CACN,OAAO;EACN,aAAa;EACb,iBAAiB;CAClB;CACA,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;AACD,SAAS,cAAc,MAAM;CAC5B,IAAI,MAAM,SAAS,KAAK,GAAG,OAAO,SAAS;EAC1C,MAAM,KAAK;EACX,WAAW;EACX,UAAU;CACX,CAAC;CACD,OAAO,WAAW;EACjB,MAAM;EACN,YAAY;GACX,QAAQ;IACP,aAAa,OAAO;IACpB,iBAAiB,OAAO;GACzB;GACA,UAAU,MAAM;EACjB;EACA,UAAU;CACX,CAAC;AACF;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,eAAe,KAAK;CAC5B,MAAM,WAAW,IAAI,eAAe;EACnC,GAAG,QAAQ,GAAG;EACd,MAAM;CACP,CAAC;CACD,OAAO,OAAO,QAAQ;CACtB,OAAO;AACR"}
|
|
@@ -2,7 +2,7 @@ import { ResourceNodeBase, dependency, freezeNode, string } from "@prisma/compos
|
|
|
2
2
|
import { blindCast } from "@prisma/composer/casts";
|
|
3
3
|
import pg from "pg";
|
|
4
4
|
import pnPostgresRuntime from "@prisma-next/postgres/runtime";
|
|
5
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/pg-connection.mjs
|
|
5
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/pg-connection-CadPZuEK.mjs
|
|
6
6
|
/** Connection resilience helpers for Prisma Postgres cold-starts (FT-5226); no heavy imports (no `effect`/`alchemy`/`pg`), so the deploy lowerings, the pnPostgres runtime client, and bun-runnable services (the storage store, via the pure `@internal/prisma-cloud/connection` subpath) all share one implementation. */
|
|
7
7
|
/** Network-level socket failures node-postgres surfaces as `err.code`. */
|
|
8
8
|
const TRANSIENT_CODES = /* @__PURE__ */ new Set([
|
|
@@ -78,7 +78,7 @@ function retryTransientConnect(acquire, opts = {}) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/prisma-next.mjs
|
|
81
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/prisma-next-DlU01kXJ.mjs
|
|
82
82
|
/**
|
|
83
83
|
* The `prisma-next` resource node: a core Resource node plus `config`, the
|
|
84
84
|
* `prisma-next.config.ts` path the deploy-only migration lowering loads to
|
|
@@ -173,4 +173,4 @@ function storageHashOf(contract) {
|
|
|
173
173
|
//#endregion
|
|
174
174
|
export { normalizeSslMode as a, pnPostgres as i, isPnPostgresResourceNode as n, withConnectionRetry as o, pnContract as r, PnPostgresResourceNode as t };
|
|
175
175
|
|
|
176
|
-
//# sourceMappingURL=prisma-next-
|
|
176
|
+
//# sourceMappingURL=prisma-next-DlU01kXJ-2sP5mQb6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-next-DlU01kXJ-2sP5mQb6.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/pg-connection-CadPZuEK.mjs","../../../1-prisma-cloud/1-extensions/target/dist/prisma-next-DlU01kXJ.mjs"],"sourcesContent":["//#region src/pg-connection.ts\n/** Connection resilience helpers for Prisma Postgres cold-starts (FT-5226); no heavy imports (no `effect`/`alchemy`/`pg`), so the deploy lowerings, the pnPostgres runtime client, and bun-runnable services (the storage store, via the pure `@internal/prisma-cloud/connection` subpath) all share one implementation. */\n/** Network-level socket failures node-postgres surfaces as `err.code`. */\nconst TRANSIENT_CODES = /* @__PURE__ */ new Set([\n\t\"ECONNREFUSED\",\n\t\"ECONNRESET\",\n\t\"ETIMEDOUT\",\n\t\"EPIPE\",\n\t\"ENOTFOUND\",\n\t\"EAI_AGAIN\"\n]);\n/** Connection-establishment failure messages (no useful `err.code`). */\nconst TRANSIENT_MESSAGE_FRAGMENTS = [\n\t\"upstream database\",\n\t\"connection terminated\",\n\t\"connection refused\",\n\t\"terminating connection\",\n\t\"server closed the connection\",\n\t\"connection timeout\",\n\t\"timeout expired\"\n];\n/** Whether an error is a transient connection failure worth retrying, as opposed to a real query error that must surface at once. */\nfunction isTransientConnectionError(error) {\n\tif (typeof error !== \"object\" || error === null) return false;\n\tconst code = \"code\" in error && typeof error.code === \"string\" ? error.code : void 0;\n\tif (code !== void 0 && TRANSIENT_CODES.has(code)) return true;\n\tconst message = \"message\" in error && typeof error.message === \"string\" ? error.message.toLowerCase() : \"\";\n\treturn TRANSIENT_MESSAGE_FRAGMENTS.some((fragment) => message.includes(fragment));\n}\n/**\n* Rewrites a deprecating `sslmode` (`require`/`prefer`/`verify-ca`) to the\n* explicit `verify-full` these already mean, silencing node-postgres's\n* deprecation warning. `disable`/`no-verify`/unset are left untouched.\n*/\nfunction normalizeSslMode(url) {\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {\n\t\treturn url;\n\t}\n\tconst sslmode = parsed.searchParams.get(\"sslmode\");\n\tif (sslmode === \"require\" || sslmode === \"prefer\" || sslmode === \"verify-ca\") {\n\t\tparsed.searchParams.set(\"sslmode\", \"verify-full\");\n\t\treturn parsed.toString();\n\t}\n\treturn url;\n}\n/**\n* Retries an operation past a transient connection failure, bounded (default\n* ~1 min). `shouldRetry` decides what's transient — defaults to retrying\n* everything; the runtime client passes {@link isTransientConnectionError}.\n*/\nasync function withConnectionRetry(operation, opts = {}) {\n\tconst attempts = opts.attempts ?? 12;\n\tconst delayMs = opts.delayMs ?? 5e3;\n\tconst sleep = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n\tconst shouldRetry = opts.shouldRetry ?? (() => true);\n\tlet lastError;\n\tfor (let attempt = 1; attempt <= attempts; attempt++) try {\n\t\treturn await operation();\n\t} catch (error) {\n\t\tif (!shouldRetry(error)) throw error;\n\t\tlastError = error;\n\t\tif (attempt < attempts) await sleep(delayMs);\n\t}\n\tthrow lastError;\n}\n/** Retries acquiring a connection past a transient cold-start; {@link withConnectionRetry} with {@link isTransientConnectionError} fixed as the predicate. */\nfunction retryTransientConnect(acquire, opts = {}) {\n\treturn withConnectionRetry(acquire, {\n\t\t...opts,\n\t\tshouldRetry: isTransientConnectionError\n\t});\n}\n//#endregion\nexport { withConnectionRetry as i, normalizeSslMode as n, retryTransientConnect as r, isTransientConnectionError as t };\n\n//# sourceMappingURL=pg-connection-CadPZuEK.mjs.map","import { n as normalizeSslMode, r as retryTransientConnect } from \"./pg-connection-CadPZuEK.mjs\";\nimport { ResourceNodeBase, dependency, freezeNode, string } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport pg from \"pg\";\nimport pnPostgresRuntime from \"@prisma-next/postgres/runtime\";\n//#region src/prisma-next.ts\n/**\n* The `prisma-next` resource node: a core Resource node plus `config`, the\n* `prisma-next.config.ts` path the deploy-only migration lowering loads to\n* find the migrations directory — the app build never imports it.\n*/\nvar PnPostgresResourceNode = class extends ResourceNodeBase {\n\tconfig;\n\tconstructor(def) {\n\t\tsuper({\n\t\t\tname: def.name,\n\t\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\t\tprovides: def.contract\n\t\t});\n\t\tthis.config = def.config;\n\t\tif (def.targetRef !== void 0) this.targetRef = def.targetRef;\n\t\tfreezeNode(this);\n\t}\n};\n/** Narrows `ctx.node` to a `pnPostgres` resource node so the deploy lowering reads `config` without a bare cast. Structural, never `instanceof`. */\nfunction isPnPostgresResourceNode(node) {\n\treturn node.kind === \"resource\" && node.type === \"prisma-next\" && \"config\" in node && typeof node.config === \"string\";\n}\nfunction pnContract(contract) {\n\tconst value = {\n\t\tkind: \"prisma-next\",\n\t\t__cmp: { contractJson: contract },\n\t\tsatisfies: (required) => {\n\t\t\tconst requiredHash = storageHashOf(required);\n\t\t\treturn requiredHash !== void 0 && requiredHash === storageHashOf(value);\n\t\t}\n\t};\n\treturn Object.freeze(value);\n}\nfunction pnPostgres(arg) {\n\tif (!isPnPostgresContract(arg)) return new PnPostgresResourceNode(arg);\n\tconst contract = arg;\n\treturn dependency({\n\t\ttype: \"prisma-next\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: ({ url }) => buildClient(contract, url)\n\t\t},\n\t\trequired: contract\n\t});\n}\nfunction isPnPostgresContract(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value && value.kind === \"prisma-next\" && \"__cmp\" in value && \"satisfies\" in value;\n}\n/**\n* Builds the typed Prisma Next client over a connection pool that rides out\n* a transient cold-start (FT-5226). We pass our own `pg.Pool` rather than a\n* bare `url`: the runtime's bare-`url` connect is a one-shot that fails\n* permanently, but a pool connects lazily on first query, so a bounded retry there suffices.\n*/\nfunction buildClient(contract, url) {\n\treturn pnPostgresRuntime({\n\t\tcontractJson: contract.__cmp.contractJson,\n\t\tbinding: {\n\t\t\tkind: \"pgPool\",\n\t\t\tpool: resilientPool(url)\n\t\t}\n\t});\n}\n/**\n* A `pg.Pool` whose connection acquisition retries a transient cold-start\n* (bounded ~1 min). Only `pool.connect()` is wrapped — a real query error\n* still surfaces at once from `client.query()`.\n*/\nfunction resilientPool(url) {\n\tconst pool = new pg.Pool({\n\t\tconnectionString: normalizeSslMode(url),\n\t\tconnectionTimeoutMillis: 2e4,\n\t\tidleTimeoutMillis: 5e3\n\t});\n\tpool.on(\"error\", (err) => console.error(\"pg pool idle client error\", err));\n\tconst acquire = pool.connect.bind(pool);\n\tpool.connect = blindCast(() => retryTransientConnect(() => acquire()));\n\treturn pool;\n}\n/** Reads `__cmp.contractJson.storage.storageHash` off a `prisma-next` Contract, defensively — `__cmp` is opaque to core, so nothing guarantees its shape without a runtime check. */\nfunction storageHashOf(contract) {\n\tif (contract === void 0) return void 0;\n\tconst cmp = contract.__cmp;\n\tif (typeof cmp !== \"object\" || cmp === null || !(\"contractJson\" in cmp)) return void 0;\n\tconst contractJson = cmp.contractJson;\n\tif (typeof contractJson !== \"object\" || contractJson === null || !(\"storage\" in contractJson)) return;\n\tconst storage = contractJson.storage;\n\tif (typeof storage !== \"object\" || storage === null || !(\"storageHash\" in storage)) return void 0;\n\tconst hash = storage.storageHash;\n\treturn typeof hash === \"string\" ? hash : void 0;\n}\n//#endregion\nexport { pnPostgres as i, isPnPostgresResourceNode as n, pnContract as r, PnPostgresResourceNode as t };\n\n//# sourceMappingURL=prisma-next-DlU01kXJ.mjs.map"],"mappings":";;;;;;;AAGA,MAAM,kCAAkC,IAAI,IAAI;CAC/C;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAED,MAAM,8BAA8B;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,SAAS,2BAA2B,OAAO;CAC1C,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,OAAO,UAAU,SAAS,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO,KAAK;CACnF,IAAI,SAAS,KAAK,KAAK,gBAAgB,IAAI,IAAI,GAAG,OAAO;CACzD,MAAM,UAAU,aAAa,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,QAAQ,YAAY,IAAI;CACxG,OAAO,4BAA4B,MAAM,aAAa,QAAQ,SAAS,QAAQ,CAAC;AACjF;;;;;;AAMA,SAAS,iBAAiB,KAAK;CAC9B,IA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AiB,YAAY,iBAAiB,QAAQ,EAAE,aAAa,eAAe;CAC/F,MAAM,UAAU,aAAa;CAC7B,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,EAAE,iBAAiB,UAAU,OAAO,KAAK;CAChG,MAAM,OAAO,QAAQ;CACrB,OAAO,OAAO,SAAS,WAAW,OAAO,KAAK;AAC/C"}
|
package/dist/prisma-next.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Contract, DependencyEnd, ResourceNode, ResourceNodeBase, ServiceNode } from "@prisma/composer";
|
|
2
2
|
import { PostgresClient } from "@prisma-next/postgres/runtime";
|
|
3
3
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
|
|
5
4
|
//#region ../../1-prisma-cloud/1-extensions/target/dist/prisma-next.d.mts
|
|
6
5
|
//#region src/prisma-next.d.ts
|
|
7
6
|
/**
|
|
@@ -66,7 +65,7 @@ declare function pnPostgres<C extends PnPostgresContract>(opts: {
|
|
|
66
65
|
* Postgres. Its binding is the typed Prisma Next client, constructed by the
|
|
67
66
|
* framework in hydrate from the contract plus the injected connection URL.
|
|
68
67
|
*/
|
|
69
|
-
declare function pnPostgres<C extends PnPostgresContract>(contract: C): DependencyEnd<Client<C>, C>;
|
|
68
|
+
declare function pnPostgres<C extends PnPostgresContract>(contract: C): DependencyEnd<Client<C>, C>;
|
|
70
69
|
//#endregion
|
|
71
70
|
export { AnyPnContract, Client, PnCmp, PnContractOf, PnPostgresContract, PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };
|
|
72
71
|
//# sourceMappingURL=prisma-next.d.mts.map
|
package/dist/prisma-next.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as pnPostgres, n as isPnPostgresResourceNode, r as pnContract, t as PnPostgresResourceNode } from "./prisma-next-
|
|
1
|
+
import { i as pnPostgres, n as isPnPostgresResourceNode, r as pnContract, t as PnPostgresResourceNode } from "./prisma-next-DlU01kXJ-2sP5mQb6.mjs";
|
|
2
2
|
export { PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };
|