@prisma/composer-prisma-cloud 0.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/control.d.mts +53 -0
- package/dist/control.mjs +2031 -0
- package/dist/control.mjs.map +1 -0
- package/dist/cron/index.d.mts +99 -0
- package/dist/cron/index.mjs +392 -0
- package/dist/cron/index.mjs.map +1 -0
- package/dist/cron/scheduler-entrypoint.mjs +7769 -0
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -0
- package/dist/cron/scheduler-service.mjs +318 -0
- package/dist/cron/scheduler-service.mjs.map +1 -0
- package/dist/index.d.mts +205 -0
- package/dist/index.mjs +182 -0
- package/dist/index.mjs.map +1 -0
- package/dist/param-DB0B8m15-IvzNq9BM.mjs +92 -0
- package/dist/param-DB0B8m15-IvzNq9BM.mjs.map +1 -0
- package/dist/prisma-next-COrwlg3N.mjs +176 -0
- package/dist/prisma-next-COrwlg3N.mjs.map +1 -0
- package/dist/prisma-next.d.mts +71 -0
- package/dist/prisma-next.mjs +2 -0
- package/dist/serializer-DAEWRfnm-D3GW9dOZ.mjs +235 -0
- package/dist/serializer-DAEWRfnm-D3GW9dOZ.mjs.map +1 -0
- package/dist/storage/index.d.mts +55 -0
- package/dist/storage/index.mjs +411 -0
- package/dist/storage/index.mjs.map +1 -0
- package/dist/storage/storage-entrypoint.mjs +1173 -0
- package/dist/storage/storage-entrypoint.mjs.map +1 -0
- package/dist/storage/storage-service.mjs +377 -0
- package/dist/storage/storage-service.mjs.map +1 -0
- package/dist/storage/testing.d.mts +85 -0
- package/dist/storage/testing.mjs +531 -0
- package/dist/storage/testing.mjs.map +1 -0
- package/dist/streams/index.d.mts +47 -0
- package/dist/streams/index.mjs +450 -0
- package/dist/streams/index.mjs.map +1 -0
- package/dist/streams/streams-entrypoint.mjs +40575 -0
- package/dist/streams/streams-entrypoint.mjs.map +1 -0
- package/dist/streams/streams-service.mjs +424 -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 +25 -0
- package/dist/testing.mjs +32 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +74 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { c as secretName, d as stashSecrets, n as deserialize, o as envSecret, r as deserializeSecrets, t as configKey, u as stash } from "./serializer-DAEWRfnm-D3GW9dOZ.mjs";
|
|
2
|
+
import { i as paramName, o as serviceKeyEnvName, t as envParam } from "./param-DB0B8m15-IvzNq9BM.mjs";
|
|
3
|
+
import { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from "@prisma/composer";
|
|
4
|
+
import { blindCast } from "@prisma/composer/casts";
|
|
5
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/index.mjs
|
|
6
|
+
const reservedParams = { port: number({ default: 3e3 }) };
|
|
7
|
+
/**
|
|
8
|
+
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
9
|
+
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
10
|
+
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
11
|
+
* one fails at authoring, the same way a colliding dependency name does.
|
|
12
|
+
* Returns the extension's runnable/loadable node:
|
|
13
|
+
* · run(address, boot) — the process controller: deserialize the platform
|
|
14
|
+
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
15
|
+
* typed Config, re-emit it under address-free process-local stash keys,
|
|
16
|
+
* then call boot() to start the app's entry.
|
|
17
|
+
* · load() / config() — called from inside the app's entry: read the stash;
|
|
18
|
+
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
19
|
+
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
20
|
+
*
|
|
21
|
+
* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
22
|
+
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
23
|
+
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
24
|
+
* deploy time; nodes are pure data.
|
|
25
|
+
*/
|
|
26
|
+
const compute = (def) => {
|
|
27
|
+
const userParams = def.params ?? blindCast({});
|
|
28
|
+
for (const reserved of Object.keys(reservedParams)) {
|
|
29
|
+
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
30
|
+
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
31
|
+
}
|
|
32
|
+
const params = blindCast({
|
|
33
|
+
...userParams,
|
|
34
|
+
...reservedParams
|
|
35
|
+
});
|
|
36
|
+
const node = service({
|
|
37
|
+
name: def.name,
|
|
38
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
39
|
+
type: "compute",
|
|
40
|
+
inputs: def.deps,
|
|
41
|
+
params,
|
|
42
|
+
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
43
|
+
build: def.build,
|
|
44
|
+
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
45
|
+
});
|
|
46
|
+
let resolved;
|
|
47
|
+
let loadedDeps;
|
|
48
|
+
let loadedParams;
|
|
49
|
+
let loadedSecrets;
|
|
50
|
+
function processConfig() {
|
|
51
|
+
if (resolved === void 0) resolved = deserialize(node, "");
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
54
|
+
const runnable = {
|
|
55
|
+
...node,
|
|
56
|
+
async run(address, boot) {
|
|
57
|
+
const config = deserialize(node, address);
|
|
58
|
+
stash(node, config);
|
|
59
|
+
stashSecrets(node, address);
|
|
60
|
+
const accepted = process.env[serviceKeyEnvName(address)];
|
|
61
|
+
if (accepted !== void 0) process.env[serviceKeyEnvName("")] = accepted;
|
|
62
|
+
const port = config.service["port"];
|
|
63
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
64
|
+
return boot();
|
|
65
|
+
},
|
|
66
|
+
load() {
|
|
67
|
+
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
68
|
+
return loadedDeps;
|
|
69
|
+
},
|
|
70
|
+
config() {
|
|
71
|
+
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
72
|
+
return loadedParams;
|
|
73
|
+
},
|
|
74
|
+
secrets() {
|
|
75
|
+
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
76
|
+
return loadedSecrets;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return Object.freeze(blindCast(runnable));
|
|
80
|
+
};
|
|
81
|
+
const defaultHttpClient = (cfg) => ({
|
|
82
|
+
url: cfg.url,
|
|
83
|
+
fetch: (path, init) => fetch(new URL(path, cfg.url), init)
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* A service-to-service dependency. Its binding (what `load()` returns) is a
|
|
87
|
+
* derived HttpClient — a thin URL-anchored fetch wrapper (fetch is standard
|
|
88
|
+
* across runtimes — no driver, no runtime coupling). http() is a
|
|
89
|
+
* protocol-owned kind: the framework owns the transport, so the client is
|
|
90
|
+
* kind-canonical and derived from the contract, with no user client in the
|
|
91
|
+
* declaration (ADR-0015). The typed generated client arrives with the
|
|
92
|
+
* interface primitive (a later extension point).
|
|
93
|
+
*/
|
|
94
|
+
const http = (opts) => dependency({
|
|
95
|
+
name: opts.name,
|
|
96
|
+
type: "http",
|
|
97
|
+
connection: {
|
|
98
|
+
params: { url: string() },
|
|
99
|
+
hydrate: (v) => defaultHttpClient({ url: v.url })
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* The contract a Postgres provides — and the contract its consumers require.
|
|
104
|
+
* `satisfies` compares KIND, not identity: an extension module can be duplicated
|
|
105
|
+
* across a workspace (same rationale as the Symbol.for node brand), and every
|
|
106
|
+
* duplicate's contract must still satisfy. `__cmp` is the connection config a
|
|
107
|
+
* postgres offers; core never inspects it.
|
|
108
|
+
*/
|
|
109
|
+
const postgresContract = Object.freeze({
|
|
110
|
+
kind: "postgres",
|
|
111
|
+
__cmp: { url: "" },
|
|
112
|
+
satisfies: (required) => required.kind === "postgres"
|
|
113
|
+
});
|
|
114
|
+
function postgres(opts) {
|
|
115
|
+
if (opts?.name !== void 0) return resource({
|
|
116
|
+
name: opts.name,
|
|
117
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
118
|
+
provides: postgresContract
|
|
119
|
+
});
|
|
120
|
+
return dependency({
|
|
121
|
+
type: "postgres",
|
|
122
|
+
connection: {
|
|
123
|
+
params: { url: string() },
|
|
124
|
+
hydrate: (v) => v
|
|
125
|
+
},
|
|
126
|
+
required: postgresContract
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The contract the `s3-credentials` resource provides — a minted SigV4 key
|
|
131
|
+
* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is
|
|
132
|
+
* the config the resource offers, which core never inspects.
|
|
133
|
+
*/
|
|
134
|
+
const credentialsContract = Object.freeze({
|
|
135
|
+
kind: "credentials",
|
|
136
|
+
__cmp: {
|
|
137
|
+
accessKeyId: "",
|
|
138
|
+
secretAccessKey: ""
|
|
139
|
+
},
|
|
140
|
+
satisfies: (required) => required.kind === "credentials"
|
|
141
|
+
});
|
|
142
|
+
function s3Credentials(opts) {
|
|
143
|
+
if (opts?.name !== void 0) return resource({
|
|
144
|
+
name: opts.name,
|
|
145
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
146
|
+
provides: credentialsContract
|
|
147
|
+
});
|
|
148
|
+
return dependency({
|
|
149
|
+
type: "credentials",
|
|
150
|
+
connection: {
|
|
151
|
+
params: {
|
|
152
|
+
accessKeyId: string(),
|
|
153
|
+
secretAccessKey: string()
|
|
154
|
+
},
|
|
155
|
+
hydrate: (v) => v
|
|
156
|
+
},
|
|
157
|
+
required: credentialsContract
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The storage service authoring factory — a `compute` service routed to the
|
|
162
|
+
* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s
|
|
163
|
+
* runnable (run/load/config, deps, params, build, expose) with the routing
|
|
164
|
+
* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the
|
|
165
|
+
* serializer keys off the deployment address and each param's owner/name, and
|
|
166
|
+
* `load`/`config` off deps/params), so only the deploy-time descriptor lookup
|
|
167
|
+
* sees the override and routes to the extended-output lowering (§ 5). The
|
|
168
|
+
* return type is compute's exactly (including the reserved `port` param). The
|
|
169
|
+
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
170
|
+
* param, and `expose: { store: s3Contract }`.
|
|
171
|
+
*/
|
|
172
|
+
function s3StoreService(def) {
|
|
173
|
+
const node = compute(def);
|
|
174
|
+
return Object.freeze(blindCast({
|
|
175
|
+
...node,
|
|
176
|
+
type: "s3-store"
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, s3Credentials, s3StoreService, secretName };
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/index.mjs"],"sourcesContent":["import { c as stash, d as secretName, l as stashSecrets, n as deserialize, r as deserializeSecrets, t as configKey, u as envSecret } from \"./serializer-DAEWRfnm.mjs\";\nimport { i as paramName, o as serviceKeyEnvName, t as envParam } from \"./param-DB0B8m15.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 accepted = process.env[serviceKeyEnvName(address)];\n\t\t\tif (accepted !== void 0) process.env[serviceKeyEnvName(\"\")] = accepted;\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, envParam, envSecret, http, paramName, postgres, postgresContract, s3Credentials, s3StoreService, secretName };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;AAKA,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,WAAW,KAAK,IAAI,EAAE,QAAQ,IAAI,OAAO,IAAI,CAAC;CACtD,CAAC;CACD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,SAAS,gBAAgB;EACxB,IAAI,aAAa,KAAK,GAAG,WAAW,YAAY,MAAM,EAAE;EACxD,OAAO;CACR;CACA,MAAM,WAAW;EAChB,GAAG;EACH,MAAM,IAAI,SAAS,MAAM;GACxB,MAAM,SAAS,YAAY,MAAM,OAAO;GACxC,MAAM,MAAM,MAAM;GAClB,aAAa,MAAM,OAAO;GAC1B,MAAM,WAAW,QAAQ,IAAI,kBAAkB,OAAO;GACtD,IAAI,aAAa,KAAK,GAAG,QAAQ,IAAI,kBAAkB,EAAE,KAAK;GAC9D,MAAM,OAAO,OAAO,QAAQ;GAC5B,IAAI,OAAO,SAAS,UAAU,Q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AC5C,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"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { t as configKey } from "./serializer-DAEWRfnm-D3GW9dOZ.mjs";
|
|
2
|
+
import { isParamSource, paramSource } from "@prisma/composer";
|
|
3
|
+
import { blindCast } from "@prisma/composer/casts";
|
|
4
|
+
import { RPC_PEER_KEY } from "@prisma/composer/rpc";
|
|
5
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/param-DB0B8m15.mjs
|
|
6
|
+
/** Every faceted RPC edge in the graph — scans each dependency edge's consumer-side input for the need. */
|
|
7
|
+
function serviceKeyEdges(graph) {
|
|
8
|
+
const edges = [];
|
|
9
|
+
for (const edge of graph.edges) {
|
|
10
|
+
if (edge.kind !== "dependency") continue;
|
|
11
|
+
const consumer = graph.nodes.find((n) => n.id === edge.to)?.node;
|
|
12
|
+
if (consumer === void 0 || consumer.kind !== "service") continue;
|
|
13
|
+
const slot = consumer.inputs[edge.input];
|
|
14
|
+
if (slot === void 0) continue;
|
|
15
|
+
if (slot.connection.params["serviceKey"]?.provision?.brand !== RPC_PEER_KEY) continue;
|
|
16
|
+
edges.push({
|
|
17
|
+
edgeId: `${edge.to}.${edge.input}`,
|
|
18
|
+
consumerAddress: edge.to,
|
|
19
|
+
input: edge.input,
|
|
20
|
+
providerAddress: edge.from
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return edges;
|
|
24
|
+
}
|
|
25
|
+
/** The reserved accepted-keys env var: COMPOSER_<addr>_RPC_ACCEPTED_KEYS ("" ↦ @internal/rpc's RPC_ACCEPTED_KEYS_ENV). */
|
|
26
|
+
const serviceKeyEnvName = (address) => configKey(address, {
|
|
27
|
+
owner: "service",
|
|
28
|
+
name: "RPC_ACCEPTED_KEYS"
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Brands the payload `envParam` builds. Core's `paramSource()` is a public
|
|
32
|
+
* SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;
|
|
33
|
+
* the brand lets `paramName` reject such a source (or another target's) with
|
|
34
|
+
* a clear error instead of reading an absent `.name`.
|
|
35
|
+
*/
|
|
36
|
+
const PRISMA_CLOUD_PARAM_SOURCE = blindCast(Symbol.for("prisma:prisma-cloud-param-source"));
|
|
37
|
+
const RESERVED_PARAM_PREFIX = "COMPOSER_";
|
|
38
|
+
const POISONED_PARAM_NAMES = /* @__PURE__ */ new Set(["DATABASE_URL", "DATABASE_URL_POOLED"]);
|
|
39
|
+
/**
|
|
40
|
+
* Binds a param slot to a named Prisma Cloud platform env var — the non-secret
|
|
41
|
+
* sibling of `envSecret` (spec: env-sourced config params). The platform
|
|
42
|
+
* injects the value into the running instance per stage; the param's own
|
|
43
|
+
* schema validates it at boot, unredacted. The name may not use the
|
|
44
|
+
* framework's reserved `COMPOSER_` prefix or the poisoned
|
|
45
|
+
* `DATABASE_URL(_POOLED)` keys — same parity as `envSecret`.
|
|
46
|
+
*/
|
|
47
|
+
function envParam(name) {
|
|
48
|
+
if (typeof name !== "string" || name.length === 0) throw new Error("envParam() requires a non-empty platform env-var name, e.g. envParam('APP_ORIGIN').");
|
|
49
|
+
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.`);
|
|
50
|
+
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.`);
|
|
51
|
+
return paramSource({
|
|
52
|
+
[PRISMA_CLOUD_PARAM_SOURCE]: true,
|
|
53
|
+
name
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** True only for a payload that `envParam` built — i.e. one carrying the brand. */
|
|
57
|
+
function isEnvParamPayload(payload) {
|
|
58
|
+
return typeof payload === "object" && payload !== null && blindCast(payload)[PRISMA_CLOUD_PARAM_SOURCE] === true;
|
|
59
|
+
}
|
|
60
|
+
/** True iff a resolved param value is an env-sourced pointer this target built (as opposed to a literal, or a foreign/raw `ParamSource`). */
|
|
61
|
+
function isEnvParamSource(value) {
|
|
62
|
+
return isParamSource(value) && isEnvParamPayload(value.payload);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reads the Prisma Cloud env-var name back out of a param binding's opaque
|
|
66
|
+
* source. A source not built by `envParam` (a raw `paramSource(...)` or
|
|
67
|
+
* another target's source) carries no name — reject it here. `paramName` runs
|
|
68
|
+
* in preflight and at serialize before any value ever crosses the wire, so a
|
|
69
|
+
* foreign source fails early and clearly rather than producing a broken
|
|
70
|
+
* deploy with an undefined name.
|
|
71
|
+
*/
|
|
72
|
+
function paramName(binding) {
|
|
73
|
+
const { binding: bound } = binding;
|
|
74
|
+
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.`);
|
|
75
|
+
return bound.payload.name;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Finds the manifest entry for one service param slot. `serialize` calls this
|
|
79
|
+
* only after confirming `buildConfig` resolved the slot to a `ParamSource`
|
|
80
|
+
* (`isParamSource(value)`), so a miss here means `graph.params` and the
|
|
81
|
+
* resolved `Config` have drifted — a Load invariant violation, surfaced
|
|
82
|
+
* loudly rather than producing a pointer row with an undefined name.
|
|
83
|
+
*/
|
|
84
|
+
function paramBindingFor(bindings, serviceAddress, slot) {
|
|
85
|
+
const binding = bindings.find((b) => b.serviceAddress === serviceAddress && b.slot === slot);
|
|
86
|
+
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.`);
|
|
87
|
+
return binding;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { serviceKeyEdges as a, paramName as i, isEnvParamSource as n, serviceKeyEnvName as o, paramBindingFor as r, envParam as t };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=param-DB0B8m15-IvzNq9BM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param-DB0B8m15-IvzNq9BM.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/param-DB0B8m15.mjs"],"sourcesContent":["import { t as configKey } from \"./serializer-DAEWRfnm.mjs\";\nimport { isParamSource, paramSource } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport { RPC_PEER_KEY } from \"@internal/rpc\";\n//#region src/service-keys.ts\n/** Every faceted RPC edge in the graph — scans each dependency edge's consumer-side input for the need. */\nfunction serviceKeyEdges(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\tif (slot.connection.params[\"serviceKey\"]?.provision?.brand !== RPC_PEER_KEY) continue;\n\t\tedges.push({\n\t\t\tedgeId: `${edge.to}.${edge.input}`,\n\t\t\tconsumerAddress: edge.to,\n\t\t\tinput: edge.input,\n\t\t\tproviderAddress: edge.from\n\t\t});\n\t}\n\treturn edges;\n}\n/** The reserved accepted-keys env var: COMPOSER_<addr>_RPC_ACCEPTED_KEYS (\"\" ↦ @internal/rpc's RPC_ACCEPTED_KEYS_ENV). */\nconst serviceKeyEnvName = (address) => configKey(address, {\n\towner: \"service\",\n\tname: \"RPC_ACCEPTED_KEYS\"\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\nexport { serviceKeyEdges as a, paramName as i, isEnvParamSource as n, serviceKeyEnvName as o, paramBindingFor as r, envParam as t };\n\n//# sourceMappingURL=param-DB0B8m15.mjs.map"],"mappings":";;;;;;AAMA,SAAS,gBAAgB,OAAO;CAC/B,MAAM,QAAQ,CAAC;CACf,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC/B,IAAI,KAAK,SAAS,cAAc;EAChC,MAAM,WAAW,MAAM,MAAM,MAAM,MAAM,EAAE,OAAO,KAAK,EAAE,CAAC,EAAE;EAC5D,IAA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AAG,MAAM,IAAI,MAAM,eAAe,QAAQ,KAAK,gBAAgB,QAAQ,eAAe,qIAAqI;CACtP,OAAO,MAAM,QAAQ;AACtB;;;;;;;;AAQA,SAAS,gBAAgB,UAAU,gBAAgB,MAAM;CACxD,MAAM,UAAU,SAAS,MAAM,MAAM,EAAE,mBAAmB,kBAAkB,EAAE,SAAS,IAAI;CAC3F,IAAI,YAAY,KAAK,GAAG,MAAM,IAAI,MAAM,eAAe,KAAK,QAAQ,eAAe,8FAA8F;CACjL,OAAO;AACR"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { ResourceNodeBase, dependency, freezeNode, string } from "@prisma/composer";
|
|
2
|
+
import { blindCast } from "@prisma/composer/casts";
|
|
3
|
+
import pg from "pg";
|
|
4
|
+
import pnPostgresRuntime from "@prisma-next/postgres/runtime";
|
|
5
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/pg-connection.mjs
|
|
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
|
+
/** Network-level socket failures node-postgres surfaces as `err.code`. */
|
|
8
|
+
const TRANSIENT_CODES = /* @__PURE__ */ new Set([
|
|
9
|
+
"ECONNREFUSED",
|
|
10
|
+
"ECONNRESET",
|
|
11
|
+
"ETIMEDOUT",
|
|
12
|
+
"EPIPE",
|
|
13
|
+
"ENOTFOUND",
|
|
14
|
+
"EAI_AGAIN"
|
|
15
|
+
]);
|
|
16
|
+
/** Connection-establishment failure messages (no useful `err.code`). */
|
|
17
|
+
const TRANSIENT_MESSAGE_FRAGMENTS = [
|
|
18
|
+
"upstream database",
|
|
19
|
+
"connection terminated",
|
|
20
|
+
"connection refused",
|
|
21
|
+
"terminating connection",
|
|
22
|
+
"server closed the connection",
|
|
23
|
+
"connection timeout",
|
|
24
|
+
"timeout expired"
|
|
25
|
+
];
|
|
26
|
+
/** Whether an error is a transient connection failure worth retrying, as opposed to a real query error that must surface at once. */
|
|
27
|
+
function isTransientConnectionError(error) {
|
|
28
|
+
if (typeof error !== "object" || error === null) return false;
|
|
29
|
+
const code = "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
30
|
+
if (code !== void 0 && TRANSIENT_CODES.has(code)) return true;
|
|
31
|
+
const message = "message" in error && typeof error.message === "string" ? error.message.toLowerCase() : "";
|
|
32
|
+
return TRANSIENT_MESSAGE_FRAGMENTS.some((fragment) => message.includes(fragment));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Rewrites a deprecating `sslmode` (`require`/`prefer`/`verify-ca`) to the
|
|
36
|
+
* explicit `verify-full` these already mean, silencing node-postgres's
|
|
37
|
+
* deprecation warning. `disable`/`no-verify`/unset are left untouched.
|
|
38
|
+
*/
|
|
39
|
+
function normalizeSslMode(url) {
|
|
40
|
+
let parsed;
|
|
41
|
+
try {
|
|
42
|
+
parsed = new URL(url);
|
|
43
|
+
} catch {
|
|
44
|
+
return url;
|
|
45
|
+
}
|
|
46
|
+
const sslmode = parsed.searchParams.get("sslmode");
|
|
47
|
+
if (sslmode === "require" || sslmode === "prefer" || sslmode === "verify-ca") {
|
|
48
|
+
parsed.searchParams.set("sslmode", "verify-full");
|
|
49
|
+
return parsed.toString();
|
|
50
|
+
}
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Retries an operation past a transient connection failure, bounded (default
|
|
55
|
+
* ~1 min). `shouldRetry` decides what's transient — defaults to retrying
|
|
56
|
+
* everything; the runtime client passes {@link isTransientConnectionError}.
|
|
57
|
+
*/
|
|
58
|
+
async function withConnectionRetry(operation, opts = {}) {
|
|
59
|
+
const attempts = opts.attempts ?? 12;
|
|
60
|
+
const delayMs = opts.delayMs ?? 5e3;
|
|
61
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
62
|
+
const shouldRetry = opts.shouldRetry ?? (() => true);
|
|
63
|
+
let lastError;
|
|
64
|
+
for (let attempt = 1; attempt <= attempts; attempt++) try {
|
|
65
|
+
return await operation();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (!shouldRetry(error)) throw error;
|
|
68
|
+
lastError = error;
|
|
69
|
+
if (attempt < attempts) await sleep(delayMs);
|
|
70
|
+
}
|
|
71
|
+
throw lastError;
|
|
72
|
+
}
|
|
73
|
+
/** Retries acquiring a connection past a transient cold-start; {@link withConnectionRetry} with {@link isTransientConnectionError} fixed as the predicate. */
|
|
74
|
+
function retryTransientConnect(acquire, opts = {}) {
|
|
75
|
+
return withConnectionRetry(acquire, {
|
|
76
|
+
...opts,
|
|
77
|
+
shouldRetry: isTransientConnectionError
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/prisma-next.mjs
|
|
82
|
+
/**
|
|
83
|
+
* The `prisma-next` resource node: a core Resource node plus `config`, the
|
|
84
|
+
* `prisma-next.config.ts` path the deploy-only migration lowering loads to
|
|
85
|
+
* find the migrations directory — the app build never imports it.
|
|
86
|
+
*/
|
|
87
|
+
var PnPostgresResourceNode = class extends ResourceNodeBase {
|
|
88
|
+
config;
|
|
89
|
+
constructor(def) {
|
|
90
|
+
super({
|
|
91
|
+
name: def.name,
|
|
92
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
93
|
+
provides: def.contract
|
|
94
|
+
});
|
|
95
|
+
this.config = def.config;
|
|
96
|
+
if (def.targetRef !== void 0) this.targetRef = def.targetRef;
|
|
97
|
+
freezeNode(this);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/** Narrows `ctx.node` to a `pnPostgres` resource node so the deploy lowering reads `config` without a bare cast. Structural, never `instanceof`. */
|
|
101
|
+
function isPnPostgresResourceNode(node) {
|
|
102
|
+
return node.kind === "resource" && node.type === "prisma-next" && "config" in node && typeof node.config === "string";
|
|
103
|
+
}
|
|
104
|
+
function pnContract(contract) {
|
|
105
|
+
const value = {
|
|
106
|
+
kind: "prisma-next",
|
|
107
|
+
__cmp: { contractJson: contract },
|
|
108
|
+
satisfies: (required) => {
|
|
109
|
+
const requiredHash = storageHashOf(required);
|
|
110
|
+
return requiredHash !== void 0 && requiredHash === storageHashOf(value);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return Object.freeze(value);
|
|
114
|
+
}
|
|
115
|
+
function pnPostgres(arg) {
|
|
116
|
+
if (!isPnPostgresContract(arg)) return new PnPostgresResourceNode(arg);
|
|
117
|
+
const contract = arg;
|
|
118
|
+
return dependency({
|
|
119
|
+
type: "prisma-next",
|
|
120
|
+
connection: {
|
|
121
|
+
params: { url: string() },
|
|
122
|
+
hydrate: ({ url }) => buildClient(contract, url)
|
|
123
|
+
},
|
|
124
|
+
required: contract
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function isPnPostgresContract(value) {
|
|
128
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "prisma-next" && "__cmp" in value && "satisfies" in value;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Builds the typed Prisma Next client over a connection pool that rides out
|
|
132
|
+
* a transient cold-start (FT-5226). We pass our own `pg.Pool` rather than a
|
|
133
|
+
* bare `url`: the runtime's bare-`url` connect is a one-shot that fails
|
|
134
|
+
* permanently, but a pool connects lazily on first query, so a bounded retry there suffices.
|
|
135
|
+
*/
|
|
136
|
+
function buildClient(contract, url) {
|
|
137
|
+
return pnPostgresRuntime({
|
|
138
|
+
contractJson: contract.__cmp.contractJson,
|
|
139
|
+
binding: {
|
|
140
|
+
kind: "pgPool",
|
|
141
|
+
pool: resilientPool(url)
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A `pg.Pool` whose connection acquisition retries a transient cold-start
|
|
147
|
+
* (bounded ~1 min). Only `pool.connect()` is wrapped — a real query error
|
|
148
|
+
* still surfaces at once from `client.query()`.
|
|
149
|
+
*/
|
|
150
|
+
function resilientPool(url) {
|
|
151
|
+
const pool = new pg.Pool({
|
|
152
|
+
connectionString: normalizeSslMode(url),
|
|
153
|
+
connectionTimeoutMillis: 2e4,
|
|
154
|
+
idleTimeoutMillis: 5e3
|
|
155
|
+
});
|
|
156
|
+
pool.on("error", (err) => console.error("pg pool idle client error", err));
|
|
157
|
+
const acquire = pool.connect.bind(pool);
|
|
158
|
+
pool.connect = blindCast(() => retryTransientConnect(() => acquire()));
|
|
159
|
+
return pool;
|
|
160
|
+
}
|
|
161
|
+
/** 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. */
|
|
162
|
+
function storageHashOf(contract) {
|
|
163
|
+
if (contract === void 0) return void 0;
|
|
164
|
+
const cmp = contract.__cmp;
|
|
165
|
+
if (typeof cmp !== "object" || cmp === null || !("contractJson" in cmp)) return void 0;
|
|
166
|
+
const contractJson = cmp.contractJson;
|
|
167
|
+
if (typeof contractJson !== "object" || contractJson === null || !("storage" in contractJson)) return;
|
|
168
|
+
const storage = contractJson.storage;
|
|
169
|
+
if (typeof storage !== "object" || storage === null || !("storageHash" in storage)) return void 0;
|
|
170
|
+
const hash = storage.storageHash;
|
|
171
|
+
return typeof hash === "string" ? hash : void 0;
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
export { normalizeSslMode as a, pnPostgres as i, isPnPostgresResourceNode as n, withConnectionRetry as o, pnContract as r, PnPostgresResourceNode as t };
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=prisma-next-COrwlg3N.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-next-COrwlg3N.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/pg-connection.mjs","../../../1-prisma-cloud/1-extensions/target/dist/prisma-next.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 { isTransientConnectionError, normalizeSslMode, retryTransientConnect, withConnectionRetry };\n\n//# sourceMappingURL=pg-connection.mjs.map","import { normalizeSslMode, retryTransientConnect } from \"./pg-connection.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 { PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };\n\n//# sourceMappingURL=prisma-next.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,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,GAAG;CACrB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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"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Contract, DependencyEnd, ResourceNode, ResourceNodeBase, ServiceNode } from "@prisma/composer";
|
|
2
|
+
import { PostgresClient } from "@prisma-next/postgres/runtime";
|
|
3
|
+
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/prisma-next.d.mts
|
|
5
|
+
//#region src/prisma-next.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Any Prisma Next contract this primitive can carry — the bound both
|
|
8
|
+
* authoring modes (TS no-emit `defineContract()`, or PSL/emitted
|
|
9
|
+
* `contract.d.ts`) satisfy.
|
|
10
|
+
*/
|
|
11
|
+
type AnyPnContract = import('@prisma-next/contract/types').Contract<SqlStorage>;
|
|
12
|
+
/**
|
|
13
|
+
* The comparison payload behind a `prisma-next` Contract. `_contract` is a
|
|
14
|
+
* type-only anchor so plain assignability between two `PnCmp`s means the
|
|
15
|
+
* branded `storageHash` literals match.
|
|
16
|
+
*/
|
|
17
|
+
interface PnCmp<C extends AnyPnContract = AnyPnContract> {
|
|
18
|
+
readonly contractJson: unknown;
|
|
19
|
+
readonly _contract?: C;
|
|
20
|
+
}
|
|
21
|
+
/** The `prisma-next` kind: a Contract whose `Cmp` is `PnCmp`. */
|
|
22
|
+
type PnPostgresContract<C extends AnyPnContract = AnyPnContract> = Contract<'prisma-next', PnCmp<C>>;
|
|
23
|
+
/** Recovers the emitted contract type `C` a `prisma-next` Contract carries. */
|
|
24
|
+
type PnContractOf<Ct> = Ct extends PnPostgresContract<infer C> ? C : never;
|
|
25
|
+
/** The typed client a consumer's `pnPostgres(contract)` dependency hydrates to. */
|
|
26
|
+
type Client<Ct> = PostgresClient<PnContractOf<Ct>>;
|
|
27
|
+
/**
|
|
28
|
+
* The `prisma-next` resource node: a core Resource node plus `config`, the
|
|
29
|
+
* `prisma-next.config.ts` path the deploy-only migration lowering loads to
|
|
30
|
+
* find the migrations directory — the app build never imports it.
|
|
31
|
+
*/
|
|
32
|
+
declare class PnPostgresResourceNode<C extends PnPostgresContract = PnPostgresContract> extends ResourceNodeBase<C> {
|
|
33
|
+
readonly config: string;
|
|
34
|
+
/** Optional target ref NAME (`migrations/app/refs/<name>.json`) — see `pnPostgres`. */
|
|
35
|
+
readonly targetRef?: string;
|
|
36
|
+
constructor(def: {
|
|
37
|
+
name: string;
|
|
38
|
+
contract: C;
|
|
39
|
+
config: string;
|
|
40
|
+
targetRef?: string;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Narrows `ctx.node` to a `pnPostgres` resource node so the deploy lowering reads `config` without a bare cast. Structural, never `instanceof`. */
|
|
44
|
+
declare function isPnPostgresResourceNode(node: ServiceNode | ResourceNode): node is PnPostgresResourceNode;
|
|
45
|
+
/**
|
|
46
|
+
* Wraps a resolved Prisma Next contract value into the framework's
|
|
47
|
+
* `prisma-next` Contract kind. Two overloads: TS-authored (`C` inferred) vs.
|
|
48
|
+
* emitted JSON (`C` passed explicitly, e.g. `pnContract<Contract>(contractJson)`).
|
|
49
|
+
*/
|
|
50
|
+
declare function pnContract<const C extends AnyPnContract>(contract: C): PnPostgresContract<C>;
|
|
51
|
+
declare function pnContract<C extends AnyPnContract>(contractJson: unknown): PnPostgresContract<C>;
|
|
52
|
+
/**
|
|
53
|
+
* `{ name, contract, config, targetRef? }` — the resource identity a module
|
|
54
|
+
* provisions. `config` is the deploy-only `prisma-next.config.ts` path;
|
|
55
|
+
* `targetRef` optionally names a ref as the migration target.
|
|
56
|
+
*/
|
|
57
|
+
declare function pnPostgres<C extends PnPostgresContract>(opts: {
|
|
58
|
+
name: string;
|
|
59
|
+
contract: C;
|
|
60
|
+
config: string;
|
|
61
|
+
targetRef?: string;
|
|
62
|
+
}): PnPostgresResourceNode<C>;
|
|
63
|
+
/**
|
|
64
|
+
* `pnPostgres(contract)` — a service's dependency on a Prisma Next-typed
|
|
65
|
+
* Postgres. Its binding is the typed Prisma Next client, constructed by the
|
|
66
|
+
* framework in hydrate from the contract plus the injected connection URL.
|
|
67
|
+
*/
|
|
68
|
+
declare function pnPostgres<C extends PnPostgresContract>(contract: C): DependencyEnd<Client<C>, C>;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { AnyPnContract, Client, PnCmp, PnContractOf, PnPostgresContract, PnPostgresResourceNode, isPnPostgresResourceNode, pnContract, pnPostgres };
|
|
71
|
+
//# sourceMappingURL=prisma-next.d.mts.map
|