@prisma/composer-prisma-cloud 0.1.0 → 0.2.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/control.d.mts +79 -36
- package/dist/control.d.mts.map +1 -0
- 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.d.mts.map +1 -0
- package/dist/cron/index.mjs +255 -42
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +578 -300
- 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/email/email-entrypoint.mjs +19738 -0
- package/dist/email/email-entrypoint.mjs.map +1 -0
- package/dist/email/email-service.mjs +566 -0
- package/dist/email/email-service.mjs.map +1 -0
- package/dist/email/index.d.mts +282 -0
- package/dist/email/index.d.mts.map +1 -0
- package/dist/email/index.mjs +653 -0
- package/dist/email/index.mjs.map +1 -0
- package/dist/email/testing.d.mts +22 -0
- package/dist/email/testing.d.mts.map +1 -0
- package/dist/email/testing.mjs +1321 -0
- package/dist/email/testing.mjs.map +1 -0
- package/dist/index.d.mts +152 -26
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +108 -43
- package/dist/index.mjs.map +1 -1
- package/dist/{prisma-next-COrwlg3N.mjs → prisma-next-BvBwGCIt-CSauMX4l.mjs} +20 -4
- package/dist/prisma-next-BvBwGCIt-CSauMX4l.mjs.map +1 -0
- package/dist/prisma-next.d.mts +14 -6
- package/dist/prisma-next.d.mts.map +1 -0
- 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-Cx5slrV4-xJfH6EWS.d.mts.map +1 -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.d.mts.map +1 -0
- package/dist/storage/index.mjs +267 -44
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +7501 -155
- 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.d.mts.map +1 -0
- package/dist/storage/testing.mjs.map +1 -1
- package/dist/streams/index.d.mts +222 -0
- package/dist/streams/index.d.mts.map +1 -0
- package/dist/streams/index.mjs +4170 -0
- package/dist/streams/index.mjs.map +1 -0
- package/dist/streams/streams-entrypoint.mjs +48211 -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.d.mts.map +1 -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.d.mts.map +1 -0
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +35 -23
- package/src/exports/control.ts +1 -0
- package/src/exports/cron.ts +1 -0
- package/src/exports/email-testing.ts +1 -0
- package/src/exports/email.ts +1 -0
- package/src/exports/index.ts +1 -0
- package/src/exports/prisma-next.ts +1 -0
- package/src/exports/storage-testing.ts +1 -0
- package/src/exports/storage.ts +1 -0
- package/src/exports/streams-testing.ts +1 -0
- package/src/exports/streams.ts +1 -0
- package/src/exports/testing.ts +1 -0
- package/dist/prisma-next-COrwlg3N.mjs.map +0 -1
- package/dist/serializer-C2CsA7xm-29Eg2Tjl.mjs.map +0 -1
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":";;;;AAIA,MAAM,iBAAiB,EAAE,MAAM,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;AAoBxD,MAAM,WAAW,QAAQ;CACxB,MAAM,aAAa,IAAI,UAAU,UAAU,CAAC,CAAC;CAC7C,KAAK,MAAM,YAAY,OAAO,KAAK,cAAc,GAAG;EACnD,IAAI,YAAY,IAAI,MAAM,MAAM,IAAI,MAAM,0BAA0B,SAAS,qFAAqF;EAClK,IAAI,YAAY,YAAY,MAAM,IAAI,MAAM,qBAAqB,SAAS,gFAAgF;CAC3J;CACA,MAAM,SAAS,UAAU;EACxB,GAAG;EACH,GAAG;CACJ,CAAC;CACD,MAAM,OAAO,QAAQ;EACpB,MAAM,IAAI;EACV,WAAW;EACX,MAAM;EACN,QAAQ,IAAI;EACZ;EACA,GAAG,IAAI,YAAY,KAAK,IAAI,EAAE,SAAS,IAAI,QAAQ,IAAI,CAAC;EACxD,OAAO,IAAI;EACX,GAAG,IAAI,WAA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,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;;;;;;;;;;;;;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;EACb,iBAAiB;CAClB;CACA,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;AACD,SAAS,OAAO,MAAM;CACrB,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,KAAK,OAAO;IACZ,QAAQ,OAAO;IACf,aAAa,OAAO;IACpB,iBAAiB,OAAO;GACzB;GACA,UAAU,MAAM;EACjB;EACA,UAAU;CACX,CAAC;AACF;AAGA,MAAM,iBAAiB,EAAE,MAAM,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;AAsBxD,IAAI,iBAAiB,MAAM;CAC1B;CACA;CACA;CACA;CACA;CACA,YAAY,MAAM;EACjB,OAAO,OAAO,MAAM,IAAI;CACzB;CACA,iBAAiB;EAChB,IAAI,KAAKA,cAAc,KAAK,GAAG,KA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;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-BvBwGCIt.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
|
|
@@ -119,7 +119,7 @@ function pnPostgres(arg) {
|
|
|
119
119
|
type: "prisma-next",
|
|
120
120
|
connection: {
|
|
121
121
|
params: { url: string() },
|
|
122
|
-
hydrate: ({ url }) =>
|
|
122
|
+
hydrate: ({ url }) => bindLazyClient(contract, url)
|
|
123
123
|
},
|
|
124
124
|
required: contract
|
|
125
125
|
});
|
|
@@ -128,6 +128,22 @@ function isPnPostgresContract(value) {
|
|
|
128
128
|
return typeof value === "object" && value !== null && "kind" in value && value.kind === "prisma-next" && "__cmp" in value && "satisfies" in value;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
+
* The hydrated binding: `url` as delivered, `client` built by `buildClient`
|
|
132
|
+
* on first access. Construction stays out of hydrate because the runtime
|
|
133
|
+
* validates `contractJson` eagerly — deferring it keeps a bad contract from
|
|
134
|
+
* poisoning `load()` and spares URL-only consumers the cost (ADR-0040).
|
|
135
|
+
*/
|
|
136
|
+
function bindLazyClient(contract, url) {
|
|
137
|
+
let client;
|
|
138
|
+
return Object.freeze({
|
|
139
|
+
url,
|
|
140
|
+
get client() {
|
|
141
|
+
client ??= buildClient(contract, url);
|
|
142
|
+
return client;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
131
147
|
* Builds the typed Prisma Next client over a connection pool that rides out
|
|
132
148
|
* a transient cold-start (FT-5226). We pass our own `pg.Pool` rather than a
|
|
133
149
|
* bare `url`: the runtime's bare-`url` connect is a one-shot that fails
|
|
@@ -173,4 +189,4 @@ function storageHashOf(contract) {
|
|
|
173
189
|
//#endregion
|
|
174
190
|
export { normalizeSslMode as a, pnPostgres as i, isPnPostgresResourceNode as n, withConnectionRetry as o, pnContract as r, PnPostgresResourceNode as t };
|
|
175
191
|
|
|
176
|
-
//# sourceMappingURL=prisma-next-
|
|
192
|
+
//# sourceMappingURL=prisma-next-BvBwGCIt-CSauMX4l.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-next-BvBwGCIt-CSauMX4l.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/pg-connection-CadPZuEK.mjs","../../../1-prisma-cloud/1-extensions/target/dist/prisma-next-BvBwGCIt.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 }) => bindLazyClient(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* The hydrated binding: `url` as delivered, `client` built by `buildClient`\n* on first access. Construction stays out of hydrate because the runtime\n* validates `contractJson` eagerly — deferring it keeps a bad contract from\n* poisoning `load()` and spares URL-only consumers the cost (ADR-0040).\n*/\nfunction bindLazyClient(contract, url) {\n\tlet client;\n\treturn Object.freeze({\n\t\turl,\n\t\tget client() {\n\t\t\tclient ??= buildClient(contract, url);\n\t\t\treturn client;\n\t\t}\n\t});\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//#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GACZ,WAAW,YAAY,UAAU,GAAG;GACpC,OAAO;EACR;CACD,CAAC;AACF;;;;;;;AAOA,SAAS,YAAY,UAAU,KAAK;CACnC,OAAO,kBAAkB;EACxB,cAAc,SAAS,MAAM;EAC7B,SAAS;GACR,MAAM;GACN,MAAM,cAAc,GAAG;EACxB;CACD,CAAC;AACF;;;;;;AAMA,SAAS,cAAc,KAAK;CAC3B,MAAM,OAAO,IAAI,GAAG,KAAK;EACxB,kBAAkB,iBAAiB,GAAG;EACtC,yBAAyB;EACzB,mBAAmB;CACpB,CAAC;CACD,KAAK,GAAG,UAAU,QAAQ,QAAQ,MAAM,6BAA6B,GAAG,CAAC;CACzE,MAAM,UAAU,KAAK,QAAQ,KAAK,IAAI;CACtC,KAAK,UAAU,gBAAgB,4BAA4B,QAAQ,CAAC,CAAC;CACrE,OAAO;AACR;;AAEA,SAAS,cAAc,UAAU;CAChC,IAAI,aAAa,KAAK,GAAG,OAAO,KAAK;CACrC,MAAM,MAAM,SAAS;CACrB,IAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,EAAE,kBAAkB,MAAM,OAAO,KAAK;CACrF,MAAM,eAAe,IAAI;CACzB,IAAI,OAAO,iBAAiB,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
|
/**
|
|
@@ -23,8 +22,17 @@ interface PnCmp<C extends AnyPnContract = AnyPnContract> {
|
|
|
23
22
|
type PnPostgresContract<C extends AnyPnContract = AnyPnContract> = Contract<'prisma-next', PnCmp<C>>;
|
|
24
23
|
/** Recovers the emitted contract type `C` a `prisma-next` Contract carries. */
|
|
25
24
|
type PnContractOf<Ct> = Ct extends PnPostgresContract<infer C> ? C : never;
|
|
26
|
-
/** The typed client
|
|
25
|
+
/** The typed Prisma Next client, reachable as `binding.client` on a `pnPostgres(contract)` dependency. */
|
|
27
26
|
type Client<Ct> = PostgresClient<PnContractOf<Ct>>;
|
|
27
|
+
/**
|
|
28
|
+
* The binding a consumer's `pnPostgres(contract)` dependency hydrates to
|
|
29
|
+
* (ADR-0040): the raw connection URL, plus the typed client — constructed on
|
|
30
|
+
* first access, memoized thereafter.
|
|
31
|
+
*/
|
|
32
|
+
interface PnPostgresBinding<Ct> {
|
|
33
|
+
readonly url: string;
|
|
34
|
+
readonly client: Client<Ct>;
|
|
35
|
+
}
|
|
28
36
|
/**
|
|
29
37
|
* The `prisma-next` resource node: a core Resource node plus `config`, the
|
|
30
38
|
* `prisma-next.config.ts` path the deploy-only migration lowering loads to
|
|
@@ -63,10 +71,10 @@ declare function pnPostgres<C extends PnPostgresContract>(opts: {
|
|
|
63
71
|
}): PnPostgresResourceNode<C>;
|
|
64
72
|
/**
|
|
65
73
|
* `pnPostgres(contract)` — a service's dependency on a Prisma Next-typed
|
|
66
|
-
* Postgres. Its binding
|
|
67
|
-
*
|
|
74
|
+
* Postgres. Its binding carries the raw connection URL and the typed Prisma
|
|
75
|
+
* Next client, built lazily on first `client` access (ADR-0040).
|
|
68
76
|
*/
|
|
69
|
-
declare function pnPostgres<C extends PnPostgresContract>(contract: C): DependencyEnd<
|
|
77
|
+
declare function pnPostgres<C extends PnPostgresContract>(contract: C): DependencyEnd<PnPostgresBinding<C>, C>;
|
|
70
78
|
//#endregion
|
|
71
|
-
export { AnyPnContract, Client, PnCmp, PnContractOf, PnPostgresContract, PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };
|
|
79
|
+
export { AnyPnContract, Client, PnCmp, PnContractOf, PnPostgresBinding, PnPostgresContract, PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };
|
|
72
80
|
//# sourceMappingURL=prisma-next.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-next.d.mts","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/prisma-next.d.mts"],"mappings":";;;;;;;;;;KASK,sDAAsD,SAAS;;;;;;UAM1D,MAAM,UAAU,gBAAgB;WAC/B;WACA,YAAY;;;KAGlB,mBAAmB,UAAU,gBAAgB,iBAAiB,wBAAwB,MAAM;;KAE5F,aAAa,MAAM,WAAW,yBAAyB,KAAK;;KAE5D,OAAO,MAAM,eAAe,aAAa;;;;;;UAMpC,kBAAkB;WACjB;WACA,QAAQ,OAAO;;;;;;;cAOZ,uBAAuB,UAAU,qBAAqB,4BAA4B,iBAAiB;WACtG;;WAEA;EACT,YAAY;IACV;IACA,UAAU;IACV;IACA;;;;iBAIa,yBAAyB,MAAM,cAAc,eAAe,QAAQ;;;;;;iBAMpE,iBAAiB,UAAU,eAAe,UAAU,IAAI,mBAAmB;iBAC3E,WAAW,UAAU,eAAe,wBAAwB,mBAAmB;;;;;;iBAM/E,WAAW,UAAU,oBAAoB;EACxD;EACA,UAAU;EACV;EACA;IACE,uBAAuB;;;;;;iBAMV,WAAW,UAAU,oBAAoB,UAAU,IAAI,cAAc,kBAAkB,IAAI"}
|
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-BvBwGCIt-CSauMX4l.mjs";
|
|
2
2
|
export { PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { n as configKey, t as ORIGIN_KEY_NAME } from "./serializer-D8_84XWO-DA2B6YbX.mjs";
|
|
2
|
+
import { isParamSource, paramSource, provisionNeed } from "@prisma/composer";
|
|
3
|
+
import { blindCast } from "@prisma/composer/casts";
|
|
4
|
+
import { type } from "arktype";
|
|
5
|
+
import { RPC_PEER_KEY } from "@prisma/composer/service-rpc";
|
|
6
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-B_XS1Mz-.mjs
|
|
7
|
+
/**
|
|
8
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
9
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
10
|
+
* deploy-side value function that resolves the provisioned service's
|
|
11
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
12
|
+
* validates and stashes the row at boot through the generic
|
|
13
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
14
|
+
*
|
|
15
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
16
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
17
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
18
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
19
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
20
|
+
* service, exposing or not.
|
|
21
|
+
*
|
|
22
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
23
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
24
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
25
|
+
* control-plane-only entry).
|
|
26
|
+
*/
|
|
27
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
28
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
29
|
+
/**
|
|
30
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
31
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
32
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
33
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
34
|
+
* its deploy-side value function up by this field.
|
|
35
|
+
*/
|
|
36
|
+
const ORIGIN_PARAM = {
|
|
37
|
+
name: ORIGIN_KEY_NAME,
|
|
38
|
+
schema: type("string"),
|
|
39
|
+
brand: SELF_ORIGIN
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
43
|
+
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
44
|
+
* by `control.ts` (which registers the deploy-side `value(refs)` that mints
|
|
45
|
+
* and aggregates it — see its `rpcAcceptedKeysValue`) and `compute.ts` (which
|
|
46
|
+
* validates and stashes it at boot), so writer and reader cannot drift.
|
|
47
|
+
* Finding the edges themselves is `provisioned-edges.ts`'s generic,
|
|
48
|
+
* brand-blind scan — RPC is not special-cased anywhere in this target.
|
|
49
|
+
*
|
|
50
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
51
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
52
|
+
* service's bundle (the deploy-side `value(refs)` lives in control.ts, the
|
|
53
|
+
* control-plane-only entry).
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* The reserved provider param for RPC's accepted-keys set: the var name is
|
|
57
|
+
* `RPC_ACCEPTED_KEYS`, derived through `configKey` at both ends
|
|
58
|
+
* (`configKey(address, …)` at deploy, `configKey('', …)` at boot — the
|
|
59
|
+
* address-free form is `@internal/service-rpc`'s `RPC_ACCEPTED_KEYS_ENV`). `brand` is
|
|
60
|
+
* `RPC_PEER_KEY`, the same brand `perBindingToken()`'s need carries — control.ts
|
|
61
|
+
* looks its `value(refs)` up by this field.
|
|
62
|
+
*/
|
|
63
|
+
const RPC_ACCEPTED_KEYS_PARAM = {
|
|
64
|
+
name: "RPC_ACCEPTED_KEYS",
|
|
65
|
+
schema: type("string[]"),
|
|
66
|
+
brand: RPC_PEER_KEY
|
|
67
|
+
};
|
|
68
|
+
/** ADR-0031's need brand for the streams module's bearer key — control.ts registers the provisioner under this. */
|
|
69
|
+
const STREAMS_API_KEY = Symbol.for("prisma:streams/api-key");
|
|
70
|
+
/**
|
|
71
|
+
* The provisioning need `durableStreams()`'s `apiKey` param declares: an
|
|
72
|
+
* unguessable value the target mints ONCE PER PROVIDER (not per edge) —
|
|
73
|
+
* `@prisma/streams-server` authenticates a single `API_KEY`, so every
|
|
74
|
+
* consumer of one streams module must present the same value. Per-provider
|
|
75
|
+
* cardinality is provisioner policy (ADR-0031), invisible to core.
|
|
76
|
+
*/
|
|
77
|
+
const streamsApiKeyNeed = () => provisionNeed(STREAMS_API_KEY);
|
|
78
|
+
/**
|
|
79
|
+
* The reserved provider param for the streams bearer key: the var name is
|
|
80
|
+
* `STREAMS_API_KEY`. `brand` is `STREAMS_API_KEY` itself (the same symbol
|
|
81
|
+
* `streamsApiKeyNeed()`'s need carries) — control.ts looks its `value(refs)`
|
|
82
|
+
* up by this field.
|
|
83
|
+
*/
|
|
84
|
+
const STREAMS_API_KEY_PARAM = {
|
|
85
|
+
name: "STREAMS_API_KEY",
|
|
86
|
+
schema: type("string"),
|
|
87
|
+
brand: STREAMS_API_KEY
|
|
88
|
+
};
|
|
89
|
+
/** The address-free name compute.ts re-stashes to and the streams entrypoint reads. */
|
|
90
|
+
const STREAMS_API_KEY_ENV = configKey("", {
|
|
91
|
+
owner: "service",
|
|
92
|
+
name: STREAMS_API_KEY_PARAM.name
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* The list of provider-side reserved params the boot path validates and
|
|
96
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
97
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
98
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
99
|
+
*
|
|
100
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
101
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
102
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
103
|
+
* must never import it. This module is reachable from a user service's
|
|
104
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
105
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
106
|
+
*
|
|
107
|
+
* This is the single source of which reserved provider params exist:
|
|
108
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
109
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
110
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
111
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
112
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
113
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
114
|
+
* deploy no longer names its own param set independently.
|
|
115
|
+
*/
|
|
116
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
117
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
118
|
+
STREAMS_API_KEY_PARAM,
|
|
119
|
+
ORIGIN_PARAM
|
|
120
|
+
];
|
|
121
|
+
/**
|
|
122
|
+
* Brands the payload `envParam` builds. Core's `paramSource()` is a public
|
|
123
|
+
* SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;
|
|
124
|
+
* the brand lets `paramName` reject such a source (or another target's) with
|
|
125
|
+
* a clear error instead of reading an absent `.name`.
|
|
126
|
+
*/
|
|
127
|
+
const PRISMA_CLOUD_PARAM_SOURCE = blindCast(Symbol.for("prisma:prisma-cloud-param-source"));
|
|
128
|
+
const RESERVED_PARAM_PREFIX = "COMPOSER_";
|
|
129
|
+
const POISONED_PARAM_NAMES = /* @__PURE__ */ new Set(["DATABASE_URL", "DATABASE_URL_POOLED"]);
|
|
130
|
+
/**
|
|
131
|
+
* Binds a param slot to a named Prisma Cloud platform env var — the non-secret
|
|
132
|
+
* sibling of `envSecret` (spec: env-sourced config params). The platform
|
|
133
|
+
* injects the value into the running instance per stage; the param's own
|
|
134
|
+
* schema validates it at boot, unredacted. The name may not use the
|
|
135
|
+
* framework's reserved `COMPOSER_` prefix or the poisoned
|
|
136
|
+
* `DATABASE_URL(_POOLED)` keys — same parity as `envSecret`.
|
|
137
|
+
*/
|
|
138
|
+
function envParam(name) {
|
|
139
|
+
if (typeof name !== "string" || name.length === 0) throw new Error("envParam() requires a non-empty platform env-var name, e.g. envParam('APP_ORIGIN').");
|
|
140
|
+
if (name.startsWith(RESERVED_PARAM_PREFIX)) throw new Error(`envParam name "${name}" may not start with "${RESERVED_PARAM_PREFIX}" — that prefix is reserved for the framework's own generated config keys.`);
|
|
141
|
+
if (POISONED_PARAM_NAMES.has(name)) throw new Error(`envParam name "${name}" is reserved — ${[...POISONED_PARAM_NAMES].join(" and ")} are poisoned at project provision and cannot back a param.`);
|
|
142
|
+
return paramSource({
|
|
143
|
+
[PRISMA_CLOUD_PARAM_SOURCE]: true,
|
|
144
|
+
name
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** True only for a payload that `envParam` built — i.e. one carrying the brand. */
|
|
148
|
+
function isEnvParamPayload(payload) {
|
|
149
|
+
return typeof payload === "object" && payload !== null && blindCast(payload)[PRISMA_CLOUD_PARAM_SOURCE] === true;
|
|
150
|
+
}
|
|
151
|
+
/** True iff a resolved param value is an env-sourced pointer this target built (as opposed to a literal, or a foreign/raw `ParamSource`). */
|
|
152
|
+
function isEnvParamSource(value) {
|
|
153
|
+
return isParamSource(value) && isEnvParamPayload(value.payload);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Reads the Prisma Cloud env-var name back out of a param binding's opaque
|
|
157
|
+
* source. A source not built by `envParam` (a raw `paramSource(...)` or
|
|
158
|
+
* another target's source) carries no name — reject it here. `paramName` runs
|
|
159
|
+
* in preflight and at serialize before any value ever crosses the wire, so a
|
|
160
|
+
* foreign source fails early and clearly rather than producing a broken
|
|
161
|
+
* deploy with an undefined name.
|
|
162
|
+
*/
|
|
163
|
+
function paramName(binding) {
|
|
164
|
+
const { binding: bound } = binding;
|
|
165
|
+
if (!isEnvParamSource(bound)) throw new Error(`param slot "${binding.slot}" of service "${binding.serviceAddress}" is bound to a source not created by envParam() — bind env-sourced params with envParam('NAME') from @prisma/composer-prisma-cloud.`);
|
|
166
|
+
return bound.payload.name;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Finds the manifest entry for one service param slot. `serialize` calls this
|
|
170
|
+
* only after confirming `buildConfig` resolved the slot to a `ParamSource`
|
|
171
|
+
* (`isParamSource(value)`), so a miss here means `graph.params` and the
|
|
172
|
+
* resolved `Config` have drifted — a Load invariant violation, surfaced
|
|
173
|
+
* loudly rather than producing a pointer row with an undefined name.
|
|
174
|
+
*/
|
|
175
|
+
function paramBindingFor(bindings, serviceAddress, slot) {
|
|
176
|
+
const binding = bindings.find((b) => b.serviceAddress === serviceAddress && b.slot === slot);
|
|
177
|
+
if (binding === void 0) throw new Error(`param slot "${slot}" of "${serviceAddress}" resolved to a source but has no bound entry in the manifest — Load should have recorded it.`);
|
|
178
|
+
return binding;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Every provisioned edge in the graph. Core resolves and mints these (one
|
|
182
|
+
* value per edge, keyed by `edgeId`); this scan is how the target finds them
|
|
183
|
+
* again when it gathers a provider's inbound values.
|
|
184
|
+
*/
|
|
185
|
+
function provisionedEdges(graph) {
|
|
186
|
+
const edges = [];
|
|
187
|
+
for (const edge of graph.edges) {
|
|
188
|
+
if (edge.kind !== "dependency") continue;
|
|
189
|
+
const consumer = graph.nodes.find((n) => n.id === edge.to)?.node;
|
|
190
|
+
if (consumer === void 0 || consumer.kind !== "service") continue;
|
|
191
|
+
const slot = consumer.inputs[edge.input];
|
|
192
|
+
if (slot === void 0) continue;
|
|
193
|
+
for (const param of Object.values(slot.connection.params)) {
|
|
194
|
+
const brand = param.provision?.brand;
|
|
195
|
+
if (brand === void 0) continue;
|
|
196
|
+
edges.push({
|
|
197
|
+
edgeId: `${edge.to}.${edge.input}`,
|
|
198
|
+
consumerAddress: edge.to,
|
|
199
|
+
input: edge.input,
|
|
200
|
+
providerAddress: edge.from,
|
|
201
|
+
brand
|
|
202
|
+
});
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return edges;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { envParam as a, paramName as c, STREAMS_API_KEY_ENV as i, provisionedEdges as l, SELF_ORIGIN as n, isEnvParamSource as o, STREAMS_API_KEY as r, paramBindingFor as s, RESERVED_PROVIDER_PARAMS as t, streamsApiKeyNeed as u };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=provisioned-edges-B_XS1Mz--NFJgcXK7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provisioned-edges-B_XS1Mz--NFJgcXK7.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-B_XS1Mz-.mjs"],"sourcesContent":["import { n as configKey, t as ORIGIN_KEY_NAME } from \"./serializer-D8_84XWO.mjs\";\nimport { isParamSource, paramSource, provisionNeed } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport { type } from \"arktype\";\nimport { RPC_PEER_KEY } from \"@internal/service-rpc\";\n//#region src/origin-key.ts\n/**\n* The service's own origin as a reserved provider param (ADR-0031): the ONE\n* brand and the ONE entry — shared by control.ts (which registers the\n* deploy-side value function that resolves the provisioned service's\n* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which\n* validates and stashes the row at boot through the generic\n* `stashProviderParams` loop), so writer and reader cannot drift.\n*\n* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this\n* brand has no provisioner and no consumer edges: the value derives from the\n* service's OWN provisioned attributes, so control.ts registers it as a\n* service-derived provider param (`descriptors/shared.ts`'s\n* `ServiceProviderParam`) and the descriptor writes it for EVERY compute\n* service, exposing or not.\n*\n* This module is reachable from the RUNTIME/authoring side — it must never\n* import `@internal/lowering` or `effect`, or those tokens leak into a user\n* service's bundle (the deploy-side value function lives in control.ts, the\n* control-plane-only entry).\n*/\n/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */\nconst SELF_ORIGIN = Symbol.for(\"prisma:self-origin\");\n/**\n* The reserved provider param for the origin row: the var name is `ORIGIN`,\n* derived through `configKey` at both ends (`configKey(address, …)` at\n* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where\n* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks\n* its deploy-side value function up by this field.\n*/\nconst ORIGIN_PARAM = {\n\tname: ORIGIN_KEY_NAME,\n\tschema: type(\"string\"),\n\tbrand: SELF_ORIGIN\n};\n//#endregion\n//#region src/service-keys.ts\n/**\n* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —\n* name + schema + brand — for the accepted-keys set a provider stores, shared\n* by `control.ts` (which registers the deploy-side `value(refs)` that mints\n* and aggregates it — see its `rpcAcceptedKeysValue`) and `compute.ts` (which\n* validates and stashes it at boot), so writer and reader cannot drift.\n* Finding the edges themselves is `provisioned-edges.ts`'s generic,\n* brand-blind scan — RPC is not special-cased anywhere in this target.\n*\n* This module is reachable from the RUNTIME/authoring side — it must never\n* import `@internal/lowering` or `effect`, or those tokens leak into a user\n* service's bundle (the deploy-side `value(refs)` lives in control.ts, the\n* control-plane-only entry).\n*/\n/**\n* The reserved provider param for RPC's accepted-keys set: the var name is\n* `RPC_ACCEPTED_KEYS`, derived through `configKey` at both ends\n* (`configKey(address, …)` at deploy, `configKey('', …)` at boot — the\n* address-free form is `@internal/service-rpc`'s `RPC_ACCEPTED_KEYS_ENV`). `brand` is\n* `RPC_PEER_KEY`, the same brand `perBindingToken()`'s need carries — control.ts\n* looks its `value(refs)` up by this field.\n*/\nconst RPC_ACCEPTED_KEYS_PARAM = {\n\tname: \"RPC_ACCEPTED_KEYS\",\n\tschema: type(\"string[]\"),\n\tbrand: RPC_PEER_KEY\n};\n//#endregion\n//#region src/streams-keys.ts\n/** ADR-0031's need brand for the streams module's bearer key — control.ts registers the provisioner under this. */\nconst STREAMS_API_KEY = Symbol.for(\"prisma:streams/api-key\");\n/**\n* The provisioning need `durableStreams()`'s `apiKey` param declares: an\n* unguessable value the target mints ONCE PER PROVIDER (not per edge) —\n* `@prisma/streams-server` authenticates a single `API_KEY`, so every\n* consumer of one streams module must present the same value. Per-provider\n* cardinality is provisioner policy (ADR-0031), invisible to core.\n*/\nconst streamsApiKeyNeed = () => provisionNeed(STREAMS_API_KEY);\n/**\n* The reserved provider param for the streams bearer key: the var name is\n* `STREAMS_API_KEY`. `brand` is `STREAMS_API_KEY` itself (the same symbol\n* `streamsApiKeyNeed()`'s need carries) — control.ts looks its `value(refs)`\n* up by this field.\n*/\nconst STREAMS_API_KEY_PARAM = {\n\tname: \"STREAMS_API_KEY\",\n\tschema: type(\"string\"),\n\tbrand: STREAMS_API_KEY\n};\n/** The address-free name compute.ts re-stashes to and the streams entrypoint reads. */\nconst STREAMS_API_KEY_ENV = configKey(\"\", {\n\towner: \"service\",\n\tname: STREAMS_API_KEY_PARAM.name\n});\n//#endregion\n//#region src/provider-params.ts\n/**\n* The list of provider-side reserved params the boot path validates and\n* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,\n* collected from that brand's own module (`service-keys.ts`,\n* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.\n*\n* This list exists separately from `control.ts`'s deploy-side registry\n* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports\n* `@internal/lowering` and `effect` to mint values — and a booted service\n* must never import it. This module is reachable from a user service's\n* bundle through `compute.ts`, so it must never import `@internal/lowering`,\n* `effect`, `alchemy`, or `control.ts`.\n*\n* This is the single source of which reserved provider params exist:\n* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking\n* up each entry's deploy-side value function (edge-derived `value(refs)` or\n* service-derived `valueForService(provisioned, address)`) by its `brand`,\n* throwing at module load if one is missing. Adding a brand means adding its\n* entry here, plus its deploy-side value function in control.ts — a brand\n* registered for deploy but absent here is no longer expressible, because\n* deploy no longer names its own param set independently.\n*/\nconst RESERVED_PROVIDER_PARAMS = [\n\tRPC_ACCEPTED_KEYS_PARAM,\n\tSTREAMS_API_KEY_PARAM,\n\tORIGIN_PARAM\n];\n//#endregion\n//#region src/param.ts\n/**\n* Brands the payload `envParam` builds. Core's `paramSource()` is a public\n* SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;\n* the brand lets `paramName` reject such a source (or another target's) with\n* a clear error instead of reading an absent `.name`.\n*/\nconst PRISMA_CLOUD_PARAM_SOURCE = blindCast(Symbol.for(\"prisma:prisma-cloud-param-source\"));\nconst RESERVED_PARAM_PREFIX = \"COMPOSER_\";\nconst POISONED_PARAM_NAMES = /* @__PURE__ */ new Set([\"DATABASE_URL\", \"DATABASE_URL_POOLED\"]);\n/**\n* Binds a param slot to a named Prisma Cloud platform env var — the non-secret\n* sibling of `envSecret` (spec: env-sourced config params). The platform\n* injects the value into the running instance per stage; the param's own\n* schema validates it at boot, unredacted. The name may not use the\n* framework's reserved `COMPOSER_` prefix or the poisoned\n* `DATABASE_URL(_POOLED)` keys — same parity as `envSecret`.\n*/\nfunction envParam(name) {\n\tif (typeof name !== \"string\" || name.length === 0) throw new Error(\"envParam() requires a non-empty platform env-var name, e.g. envParam('APP_ORIGIN').\");\n\tif (name.startsWith(RESERVED_PARAM_PREFIX)) throw new Error(`envParam name \"${name}\" may not start with \"${RESERVED_PARAM_PREFIX}\" — that prefix is reserved for the framework's own generated config keys.`);\n\tif (POISONED_PARAM_NAMES.has(name)) throw new Error(`envParam name \"${name}\" is reserved — ${[...POISONED_PARAM_NAMES].join(\" and \")} are poisoned at project provision and cannot back a param.`);\n\treturn paramSource({\n\t\t[PRISMA_CLOUD_PARAM_SOURCE]: true,\n\t\tname\n\t});\n}\n/** True only for a payload that `envParam` built — i.e. one carrying the brand. */\nfunction isEnvParamPayload(payload) {\n\treturn typeof payload === \"object\" && payload !== null && blindCast(payload)[PRISMA_CLOUD_PARAM_SOURCE] === true;\n}\n/** True iff a resolved param value is an env-sourced pointer this target built (as opposed to a literal, or a foreign/raw `ParamSource`). */\nfunction isEnvParamSource(value) {\n\treturn isParamSource(value) && isEnvParamPayload(value.payload);\n}\n/**\n* Reads the Prisma Cloud env-var name back out of a param binding's opaque\n* source. A source not built by `envParam` (a raw `paramSource(...)` or\n* another target's source) carries no name — reject it here. `paramName` runs\n* in preflight and at serialize before any value ever crosses the wire, so a\n* foreign source fails early and clearly rather than producing a broken\n* deploy with an undefined name.\n*/\nfunction paramName(binding) {\n\tconst { binding: bound } = binding;\n\tif (!isEnvParamSource(bound)) throw new Error(`param slot \"${binding.slot}\" of service \"${binding.serviceAddress}\" is bound to a source not created by envParam() — bind env-sourced params with envParam('NAME') from @prisma/composer-prisma-cloud.`);\n\treturn bound.payload.name;\n}\n/**\n* Finds the manifest entry for one service param slot. `serialize` calls this\n* only after confirming `buildConfig` resolved the slot to a `ParamSource`\n* (`isParamSource(value)`), so a miss here means `graph.params` and the\n* resolved `Config` have drifted — a Load invariant violation, surfaced\n* loudly rather than producing a pointer row with an undefined name.\n*/\nfunction paramBindingFor(bindings, serviceAddress, slot) {\n\tconst binding = bindings.find((b) => b.serviceAddress === serviceAddress && b.slot === slot);\n\tif (binding === void 0) throw new Error(`param slot \"${slot}\" of \"${serviceAddress}\" resolved to a source but has no bound entry in the manifest — Load should have recorded it.`);\n\treturn binding;\n}\n//#endregion\n//#region src/provisioned-edges.ts\n/**\n* Every provisioned edge in the graph. Core resolves and mints these (one\n* value per edge, keyed by `edgeId`); this scan is how the target finds them\n* again when it gathers a provider's inbound values.\n*/\nfunction provisionedEdges(graph) {\n\tconst edges = [];\n\tfor (const edge of graph.edges) {\n\t\tif (edge.kind !== \"dependency\") continue;\n\t\tconst consumer = graph.nodes.find((n) => n.id === edge.to)?.node;\n\t\tif (consumer === void 0 || consumer.kind !== \"service\") continue;\n\t\tconst slot = consumer.inputs[edge.input];\n\t\tif (slot === void 0) continue;\n\t\tfor (const param of Object.values(slot.connection.params)) {\n\t\t\tconst brand = param.provision?.brand;\n\t\t\tif (brand === void 0) continue;\n\t\t\tedges.push({\n\t\t\t\tedgeId: `${edge.to}.${edge.input}`,\n\t\t\t\tconsumerAddress: edge.to,\n\t\t\t\tinput: edge.input,\n\t\t\t\tproviderAddress: edge.from,\n\t\t\t\tbrand\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn edges;\n}\n//#endregion\nexport { paramName as a, STREAMS_API_KEY_ENV as c, paramBindingFor as i, streamsApiKeyNeed as l, envParam as n, RESERVED_PROVIDER_PARAMS as o, isEnvParamSource as r, STREAMS_API_KEY as s, provisionedEdges as t, SELF_ORIGIN as u };\n\n//# sourceMappingURL=provisioned-edges-B_XS1Mz-.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,cAAc,OAAO,IAAI,oBAAoB;;;;;;;;AAQnD,MAAM,eAAe;CACpB,MAAM;CACN,QAAQ,KAAK,QAAQ;CACrB,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,0BAA0B;CAC/B,MAAM;CACN,QAAQ,KAAK,UAAU;CACvB,OAAO;AACR;;AAIA,MAAM,kBAAkB,OAAO,IAAI,wBAAwB;;;;;;;;AAQ3D,MAAM,0BAA0B,cAAc,eAAe;;;;;;;AAO7D,MAAM,wBAAwB;CAC7B,MAAM;CACN,QAAQ,KAAK,QAAQ;CACrB,OAAO;AACR;;AAEA,MAAM,sBAAsB,UAAU,IAAI;CACzC,OAAO;CACP,MAAM,sBAAs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