@prisma/composer-prisma-cloud 0.3.0-dev.5 → 0.3.0-dev.7
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 +1 -1
- package/dist/control.mjs +28 -17
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +33 -26
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +202 -77
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +133 -114
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +200 -76
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/email/email-entrypoint.mjs +162 -126
- package/dist/email/email-entrypoint.mjs.map +1 -1
- package/dist/email/email-service.mjs +230 -79
- package/dist/email/email-service.mjs.map +1 -1
- package/dist/email/index.d.mts +33 -29
- package/dist/email/index.d.mts.map +1 -1
- package/dist/email/index.mjs +236 -84
- package/dist/email/index.mjs.map +1 -1
- package/dist/email/testing.mjs +112 -89
- package/dist/email/testing.mjs.map +1 -1
- package/dist/index.d.mts +51 -43
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +47 -51
- package/dist/index.mjs.map +1 -1
- package/dist/local-target.mjs +1 -1
- package/dist/local-target.mjs.map +1 -1
- package/dist/{preflight-names-BPL-qsZF-BfoRgbgb.mjs → preflight-names-CpJUd9ZA-BCU-W3cT.mjs} +30 -14
- package/dist/{preflight-names-BPL-qsZF-BfoRgbgb.mjs.map → preflight-names-CpJUd9ZA-BCU-W3cT.mjs.map} +1 -1
- package/dist/{provisioned-edges-C1wSO3cx-YC5C19f9.mjs → provisioned-edges-Cxy18aoh-CUnaY96r.mjs} +3 -3
- package/dist/{provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map → provisioned-edges-Cxy18aoh-CUnaY96r.mjs.map} +1 -1
- package/dist/{param-BTzY0ne5-CW6ojZ3E.mjs → secret-BVGxqHxY-DYDfiULl.mjs} +45 -4
- package/dist/secret-BVGxqHxY-DYDfiULl.mjs.map +1 -0
- package/dist/{serializer-Cx5slrV4-xJfH6EWS.d.mts → serializer-BD_6nkr4-DWn5NNTC.d.mts} +2 -2
- package/dist/serializer-BD_6nkr4-DWn5NNTC.d.mts.map +1 -0
- package/dist/serializer-sVE4UAmg-CikRngbR.mjs +475 -0
- package/dist/serializer-sVE4UAmg-CikRngbR.mjs.map +1 -0
- package/dist/storage/index.d.mts +31 -26
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +215 -89
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +147 -122
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +212 -87
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/streams/index.d.mts +29 -22
- package/dist/streams/index.d.mts.map +1 -1
- package/dist/streams/index.mjs +213 -88
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +139 -118
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +212 -87
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/testing.d.mts +19 -5
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +11 -3
- package/dist/testing.mjs.map +1 -1
- package/package.json +18 -18
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +0 -1
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +0 -47
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +0 -1
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs +0 -251
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +0 -1
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +0 -1
|
@@ -66,14 +66,6 @@ function blindCast(input) {
|
|
|
66
66
|
* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).
|
|
67
67
|
*/
|
|
68
68
|
const NODE = Symbol.for("prisma:node");
|
|
69
|
-
const SECRET_NEED = blindCast(Symbol.for("prisma:secret-need"));
|
|
70
|
-
/** Declares a secret NEED. Nameless — the platform name is bound at the root via `envSecret`. */
|
|
71
|
-
function secret() {
|
|
72
|
-
return Object.freeze({
|
|
73
|
-
[SECRET_NEED]: true,
|
|
74
|
-
kind: "secret"
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
69
|
const PROVISION_NEED = blindCast(Symbol.for("prisma:provision-need"));
|
|
78
70
|
/** Builds an opaque provisioning need — the declaring package's own brand plus whatever payload its provisioner reads back. */
|
|
79
71
|
function provisionNeed(brand, payload) {
|
|
@@ -112,11 +104,6 @@ function freezeParams(params) {
|
|
|
112
104
|
for (const [name, param] of Object.entries(params)) frozen[name] = Object.freeze({ ...param });
|
|
113
105
|
return Object.freeze(frozen);
|
|
114
106
|
}
|
|
115
|
-
function freezeSecrets(secrets) {
|
|
116
|
-
const frozen = {};
|
|
117
|
-
for (const [name, need] of Object.entries(secrets)) frozen[name] = Object.freeze({ ...need });
|
|
118
|
-
return blindCast(Object.freeze(frozen));
|
|
119
|
-
}
|
|
120
107
|
/** A frozen shallow copy that keeps the caller's declared type. */
|
|
121
108
|
function frozenShallowCopy(obj) {
|
|
122
109
|
return blindCast(Object.freeze({ ...obj }));
|
|
@@ -170,7 +157,8 @@ function resource(def) {
|
|
|
170
157
|
}
|
|
171
158
|
/**
|
|
172
159
|
* Constructs a branded, frozen Service node — declarations only (inputs,
|
|
173
|
-
* params, build adapter, and the ports it exposes). Pure;
|
|
160
|
+
* params, the input schema, build adapter, and the ports it exposes). Pure;
|
|
161
|
+
* carries no runtime behavior.
|
|
174
162
|
*/
|
|
175
163
|
function service$1(def) {
|
|
176
164
|
requireName(def.name, "service");
|
|
@@ -178,8 +166,7 @@ function service$1(def) {
|
|
|
178
166
|
requireType(def.type, "service");
|
|
179
167
|
requireConfigKeySegmentNames(Object.keys(def.inputs), "input", "service");
|
|
180
168
|
requireConfigKeySegmentNames(Object.keys(def.params), "param", "service");
|
|
181
|
-
|
|
182
|
-
for (const slot of Object.keys(def.secrets ?? {})) if (Object.hasOwn(def.params, slot)) throw new Error(`service() secret slot "${slot}" collides with a param of the same name — a secret slot and a service param derive the same config key (COMPOSER_<addr>_${slot.toUpperCase()}); rename one.`);
|
|
169
|
+
if (def.input !== void 0 && typeof def.input["~standard"]?.validate !== "function") throw new Error("service() `input` must be a Standard Schema (an object with a \"~standard\".validate function) — see https://standardschema.dev (ADR-0042).");
|
|
183
170
|
return Object.freeze({
|
|
184
171
|
[NODE]: true,
|
|
185
172
|
kind: "service",
|
|
@@ -188,7 +175,7 @@ function service$1(def) {
|
|
|
188
175
|
type: def.type,
|
|
189
176
|
inputs: frozenShallowCopy(def.inputs),
|
|
190
177
|
params: freezeParams(def.params),
|
|
191
|
-
|
|
178
|
+
inputSchema: blindCast(def.input),
|
|
192
179
|
build: Object.freeze({ ...def.build }),
|
|
193
180
|
expose: def.expose !== void 0 ? frozenShallowCopy(def.expose) : void 0
|
|
194
181
|
});
|
|
@@ -221,11 +208,16 @@ function dependency(def) {
|
|
|
221
208
|
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
222
209
|
* a secret can't leak through an accidental log or serialization.
|
|
223
210
|
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
211
|
+
* Every box carries a brand property keyed by the registered symbol
|
|
212
|
+
* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
|
|
213
|
+
* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
|
|
214
|
+
* public shape still matches the platform's own `secrecy` type
|
|
215
|
+
* (pdp-control-plane).
|
|
226
216
|
*/
|
|
227
217
|
const REDACTED = "[REDACTED]";
|
|
218
|
+
const SECRET_BOX = blindCast(Symbol.for("prisma:secret-box"));
|
|
228
219
|
var SecretBox = class {
|
|
220
|
+
[SECRET_BOX] = true;
|
|
229
221
|
#value;
|
|
230
222
|
constructor(value) {
|
|
231
223
|
this.#value = value;
|
|
@@ -250,6 +242,14 @@ var SecretBox = class {
|
|
|
250
242
|
return REDACTED;
|
|
251
243
|
}
|
|
252
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* True for a redacting secret box — what a schema's secret leaf checks
|
|
247
|
+
* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
|
|
248
|
+
* duplicated module copy in a bundle counts and a look-alike does not.
|
|
249
|
+
*/
|
|
250
|
+
function isSecretString(value) {
|
|
251
|
+
return typeof value === "object" && value !== null && blindCast(value)[SECRET_BOX] === true;
|
|
252
|
+
}
|
|
253
253
|
function scalarSchema(name, check) {
|
|
254
254
|
return { "~standard": {
|
|
255
255
|
version: 1,
|
|
@@ -275,10 +275,6 @@ function string$1(opts = {}) {
|
|
|
275
275
|
function number$1(opts = {}) {
|
|
276
276
|
return withFacets(numberSchema, opts);
|
|
277
277
|
}
|
|
278
|
-
/** A param over any caller-supplied Standard Schema — a structured `jobs`, say. */
|
|
279
|
-
function param(schema, opts = {}) {
|
|
280
|
-
return withFacets(schema, opts);
|
|
281
|
-
}
|
|
282
278
|
/**
|
|
283
279
|
* Synchronous hydrate — what the node's `load()` uses so
|
|
284
280
|
* `const { db } = service.load()` reads without `await`. Requires every
|
|
@@ -295,24 +291,6 @@ function hydrateSync(root, config) {
|
|
|
295
291
|
}
|
|
296
292
|
return deps;
|
|
297
293
|
}
|
|
298
|
-
/**
|
|
299
|
-
* Wraps each of a service's resolved secret values in a redacting `SecretBox`
|
|
300
|
-
* — what the node's `secrets()` accessor returns (ADR-0021, sibling to
|
|
301
|
-
* `load()`/`config()`). The RESOLUTION of a secret's value (the boot
|
|
302
|
-
* double-lookup that reads the platform var the pointer names) is the target
|
|
303
|
-
* pack's job; core is handed the already-resolved strings and only boxes them,
|
|
304
|
-
* so a secret is redacted by TYPE from here on. A declared slot missing from
|
|
305
|
-
* `values` is a target contract violation, named loudly.
|
|
306
|
-
*/
|
|
307
|
-
function hydrateSecrets(root, values) {
|
|
308
|
-
const boxed = {};
|
|
309
|
-
for (const slot of Object.keys(root.secretSlots)) {
|
|
310
|
-
const value = values[slot];
|
|
311
|
-
if (value === void 0) throw new Error(`secret slot "${slot}" has no resolved value — the target must resolve every declared secret before hydrateSecrets().`);
|
|
312
|
-
boxed[slot] = new SecretBox(value);
|
|
313
|
-
}
|
|
314
|
-
return blindCast(boxed);
|
|
315
|
-
}
|
|
316
294
|
/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */
|
|
317
295
|
const RETRY = {
|
|
318
296
|
initialDelayMs: 250,
|
|
@@ -11692,13 +11670,6 @@ function smtpAttempt(deliveryUrl, credential) {
|
|
|
11692
11670
|
function createSmtpDelivery(opts) {
|
|
11693
11671
|
return withRetryPolicy(smtpAttempt(opts.deliveryUrl, opts.credential), opts.retryPolicy);
|
|
11694
11672
|
}
|
|
11695
|
-
const nodeBuild = (opts) => ({
|
|
11696
|
-
extension: "@prisma/composer/node",
|
|
11697
|
-
type: "node",
|
|
11698
|
-
module: opts.module,
|
|
11699
|
-
entry: opts.entry,
|
|
11700
|
-
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
11701
|
-
});
|
|
11702
11673
|
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
11703
11674
|
/**
|
|
11704
11675
|
* Splits an array into two arrays based on the result of a predicate
|
|
@@ -18818,6 +18789,28 @@ ark.schema;
|
|
|
18818
18789
|
ark.define;
|
|
18819
18790
|
ark.declare;
|
|
18820
18791
|
/**
|
|
18792
|
+
* ArkType spellings of the framework's schema leaves. Opt-in: the framework
|
|
18793
|
+
* accepts any Standard Schema library (ADR-0042) and nothing outside this
|
|
18794
|
+
* module imports arktype, so an app that uses Zod never loads it.
|
|
18795
|
+
*/
|
|
18796
|
+
/**
|
|
18797
|
+
* A schema leaf that accepts only a redacting `SecretString` box, so
|
|
18798
|
+
* `input().<field>.expose()` type-checks and binding a plain literal there
|
|
18799
|
+
* fails the deploy (ADR-0042).
|
|
18800
|
+
*
|
|
18801
|
+
* ```ts
|
|
18802
|
+
* input: type({ signingKey: secretString() })
|
|
18803
|
+
* ```
|
|
18804
|
+
*/
|
|
18805
|
+
const secretString = () => type("unknown").narrow((value, ctx) => isSecretString(value) || ctx.mustBe("a SecretString box — bind this field to a secret"));
|
|
18806
|
+
const nodeBuild = (opts) => ({
|
|
18807
|
+
extension: "@prisma/composer/node",
|
|
18808
|
+
type: "node",
|
|
18809
|
+
module: opts.module,
|
|
18810
|
+
entry: opts.entry,
|
|
18811
|
+
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
18812
|
+
});
|
|
18813
|
+
/**
|
|
18821
18814
|
* Walks a node's own params, then each dependency input's connection params —
|
|
18822
18815
|
* the same enumeration order `configOf` uses, but carrying the raw
|
|
18823
18816
|
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
@@ -18906,7 +18899,7 @@ function coerceEnvSourcedParam(raw, d, key) {
|
|
|
18906
18899
|
/**
|
|
18907
18900
|
* Boot: read each declared param from env by its key, reverse the param's own
|
|
18908
18901
|
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
18909
|
-
*
|
|
18902
|
+
* The input document rides its own channel (readInput), not this one.
|
|
18910
18903
|
*/
|
|
18911
18904
|
const deserialize = (node, address) => {
|
|
18912
18905
|
const service = {};
|
|
@@ -18943,40 +18936,84 @@ const stash = (node, config) => {
|
|
|
18943
18936
|
process.env[configKey("", d)] = encode(d.owner, value);
|
|
18944
18937
|
}
|
|
18945
18938
|
};
|
|
18946
|
-
/** The
|
|
18947
|
-
const
|
|
18939
|
+
/** The input document's own row name; its full key is COMPOSER_<addr>_INPUT. */
|
|
18940
|
+
const INPUT_KEY_NAME = "INPUT";
|
|
18941
|
+
/** The input document row's key for a service address. */
|
|
18942
|
+
const inputKey = (address) => configKey(address, {
|
|
18948
18943
|
owner: "service",
|
|
18949
|
-
name:
|
|
18944
|
+
name: INPUT_KEY_NAME
|
|
18950
18945
|
});
|
|
18946
|
+
const SECRET_MARKER = "$secret";
|
|
18947
|
+
const ESCAPED_KEY = /^\$\$+secret$/;
|
|
18948
|
+
/** True for the framework's secret pointer: `{ "$secret": "<PLATFORM_VAR>" }` and nothing else. */
|
|
18949
|
+
function isSecretPointer(value) {
|
|
18950
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && SECRET_MARKER in value && typeof value[SECRET_MARKER] === "string";
|
|
18951
|
+
}
|
|
18952
|
+
/** A plain data object (not an array, not a class instance) — the only object shape a binding/document may nest. */
|
|
18953
|
+
function isPlainObject(value) {
|
|
18954
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
18955
|
+
const proto = Object.getPrototypeOf(value);
|
|
18956
|
+
return proto === Object.prototype || proto === null;
|
|
18957
|
+
}
|
|
18951
18958
|
/**
|
|
18952
|
-
* Boot:
|
|
18953
|
-
*
|
|
18954
|
-
*
|
|
18955
|
-
*
|
|
18959
|
+
* Boot: read the one input document row (address-free after run()'s
|
|
18960
|
+
* re-stash), swap each `$secret` pointer for a redacting box over the named
|
|
18961
|
+
* platform var, unescape reserved keys, validate with the service's own
|
|
18962
|
+
* schema, and return the typed object. A missing row is a loud failure naming
|
|
18963
|
+
* the env var — a deployed environment always writes it; a local harness must
|
|
18964
|
+
* supply it (set the row to the serialized input document).
|
|
18956
18965
|
*/
|
|
18957
|
-
|
|
18958
|
-
const
|
|
18959
|
-
|
|
18960
|
-
|
|
18961
|
-
|
|
18962
|
-
|
|
18963
|
-
|
|
18964
|
-
|
|
18965
|
-
|
|
18966
|
-
}
|
|
18967
|
-
|
|
18968
|
-
};
|
|
18966
|
+
function readInput(node, address) {
|
|
18967
|
+
const schema = node.inputSchema;
|
|
18968
|
+
if (schema === void 0) throw new Error(`input() called on service "${node.name}", which declares no input schema — declare \`input: <schema>\` on compute() to use it (ADR-0042).`);
|
|
18969
|
+
const key = inputKey(address);
|
|
18970
|
+
const raw = process.env[key];
|
|
18971
|
+
if (raw === void 0 || raw === "") throw new Error(`this service's input is not available (env ${key} is unset) — a deployed environment writes it automatically; a local harness must supply it like any other config value (set ${key} to the serialized input document).`);
|
|
18972
|
+
let parsed;
|
|
18973
|
+
try {
|
|
18974
|
+
parsed = JSON.parse(raw);
|
|
18975
|
+
} catch (cause) {
|
|
18976
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
18977
|
+
throw new Error(`this service's input document is not valid JSON (env ${key}): ${message} — a deployed environment writes it automatically; a local harness must supply the serialized input document (set ${key} to it).`);
|
|
18978
|
+
}
|
|
18979
|
+
const hydrated = hydrateInputDocument(parsed, key);
|
|
18980
|
+
try {
|
|
18981
|
+
return standardValidateSync(schema, hydrated);
|
|
18982
|
+
} catch (cause) {
|
|
18983
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
18984
|
+
throw new Error(`invalid input document (env ${key}): ${message}`);
|
|
18985
|
+
}
|
|
18986
|
+
}
|
|
18987
|
+
/** Reverses the document encoding: `$secret` pointers become redacting boxes over the named platform vars; escaped reserved keys drop one "$". */
|
|
18988
|
+
function hydrateInputDocument(value, key) {
|
|
18989
|
+
if (isSecretPointer(value)) {
|
|
18990
|
+
const name = value[SECRET_MARKER];
|
|
18991
|
+
const secret = process.env[name];
|
|
18992
|
+
if (secret === void 0 || secret === "") throw new Error(`secret input is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
18993
|
+
return new SecretBox(secret);
|
|
18994
|
+
}
|
|
18995
|
+
if (Array.isArray(value)) return value.map((member) => hydrateInputDocument(member, key));
|
|
18996
|
+
if (isPlainObject(value)) {
|
|
18997
|
+
const out = {};
|
|
18998
|
+
for (const [k, member] of Object.entries(value)) {
|
|
18999
|
+
const read = ESCAPED_KEY.test(k) ? k.slice(1) : k;
|
|
19000
|
+
out[read] = hydrateInputDocument(member, key);
|
|
19001
|
+
}
|
|
19002
|
+
return out;
|
|
19003
|
+
}
|
|
19004
|
+
return value;
|
|
19005
|
+
}
|
|
18969
19006
|
/**
|
|
18970
|
-
* run()'s setup step for
|
|
18971
|
-
* address-free key, so the address-free `
|
|
18972
|
-
*
|
|
19007
|
+
* run()'s setup step for the input document: re-emit the row under its
|
|
19008
|
+
* address-free key, so the address-free `readInput` reads identically. The
|
|
19009
|
+
* document carries pointers, never values — the values stay only in their
|
|
19010
|
+
* platform vars.
|
|
18973
19011
|
*/
|
|
18974
|
-
const
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
}
|
|
19012
|
+
const stashInput = (node, address) => {
|
|
19013
|
+
if (node.inputSchema === void 0) return;
|
|
19014
|
+
const raw = process.env[inputKey(address)];
|
|
19015
|
+
if (raw === void 0) return;
|
|
19016
|
+
process.env[inputKey("")] = raw;
|
|
18980
19017
|
};
|
|
18981
19018
|
/**
|
|
18982
19019
|
* Boot: for each reserved provider param, read its address-scoped row through
|
|
@@ -19157,20 +19194,24 @@ Object.freeze({
|
|
|
19157
19194
|
});
|
|
19158
19195
|
const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
19159
19196
|
/**
|
|
19160
|
-
* A Prisma Compute service — declarations only (deps +
|
|
19161
|
-
* ports it exposes), no descriptor. `
|
|
19162
|
-
*
|
|
19163
|
-
*
|
|
19197
|
+
* A Prisma Compute service — declarations only (deps + one input schema +
|
|
19198
|
+
* build + the ports it exposes), no descriptor. The reserved `port` param
|
|
19199
|
+
* rides its own channel (ADR-0042 leaves it untouched); a dependency named
|
|
19200
|
+
* like it fails at authoring.
|
|
19164
19201
|
*
|
|
19165
19202
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
19166
19203
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
19167
|
-
* typed Config, re-emit it under address-free
|
|
19168
|
-
* then call boot() to start the app's entry.
|
|
19169
|
-
* · load() /
|
|
19170
|
-
* load() hydrates + memoizes the deps,
|
|
19171
|
-
*
|
|
19204
|
+
* typed Config, re-emit it (and the input document row) under address-free
|
|
19205
|
+
* process-local stash keys, then call boot() to start the app's entry.
|
|
19206
|
+
* · load() / input() — called from inside the app's entry: read the stash;
|
|
19207
|
+
* load() hydrates + memoizes the deps, input() parses the input document,
|
|
19208
|
+
* replaces each `$secret` pointer with a redacting box over the named
|
|
19209
|
+
* platform var, validates with the declared schema, and memoizes (ADR-0042).
|
|
19172
19210
|
* · origin() — this service's platform-assigned public origin, read from the
|
|
19173
19211
|
* stash `run()` populates; memoized per process.
|
|
19212
|
+
* · port() — this service's resolved reserved port (the value `run()` routes
|
|
19213
|
+
* to and exports as PORT), read from that same stash via #processConfig();
|
|
19214
|
+
* defaults to 3000 when the platform binds none.
|
|
19174
19215
|
*
|
|
19175
19216
|
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
19176
19217
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
@@ -19180,8 +19221,7 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
19180
19221
|
var ComputeService = class {
|
|
19181
19222
|
#resolved;
|
|
19182
19223
|
#loadedDeps;
|
|
19183
|
-
#
|
|
19184
|
-
#loadedSecrets;
|
|
19224
|
+
#loadedInput;
|
|
19185
19225
|
#origin;
|
|
19186
19226
|
constructor(node) {
|
|
19187
19227
|
Object.assign(this, node);
|
|
@@ -19194,7 +19234,7 @@ var ComputeService = class {
|
|
|
19194
19234
|
const config = deserialize(this, address);
|
|
19195
19235
|
stash(this, config);
|
|
19196
19236
|
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
19197
|
-
|
|
19237
|
+
stashInput(this, address);
|
|
19198
19238
|
const port = config.service["port"];
|
|
19199
19239
|
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
19200
19240
|
return boot();
|
|
@@ -19203,13 +19243,9 @@ var ComputeService = class {
|
|
|
19203
19243
|
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
19204
19244
|
return this.#loadedDeps;
|
|
19205
19245
|
}
|
|
19206
|
-
|
|
19207
|
-
if (this.#
|
|
19208
|
-
return this.#
|
|
19209
|
-
}
|
|
19210
|
-
secrets() {
|
|
19211
|
-
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
19212
|
-
return this.#loadedSecrets;
|
|
19246
|
+
input() {
|
|
19247
|
+
if (this.#loadedInput === void 0) this.#loadedInput = blindCast(readInput(this, ""));
|
|
19248
|
+
return this.#loadedInput;
|
|
19213
19249
|
}
|
|
19214
19250
|
/** This service's platform-assigned public origin — read from the stash
|
|
19215
19251
|
* run() populates and memoized per process. Throws if called before run()
|
|
@@ -19218,26 +19254,24 @@ var ComputeService = class {
|
|
|
19218
19254
|
this.#origin ??= readOrigin();
|
|
19219
19255
|
return this.#origin;
|
|
19220
19256
|
}
|
|
19257
|
+
/** This service's resolved reserved port — the value run() routes to and
|
|
19258
|
+
* exports as PORT — read the same way load() reads the stash. Defaults to
|
|
19259
|
+
* 3000 when the platform binds none. */
|
|
19260
|
+
port() {
|
|
19261
|
+
const port = this.#processConfig().service["port"];
|
|
19262
|
+
if (typeof port !== "number") throw new Error(`service "${this.name}" resolved a non-numeric port — the reserved port param is number({ default: 3000 }), so a stashed config always carries a number here.`);
|
|
19263
|
+
return port;
|
|
19264
|
+
}
|
|
19221
19265
|
};
|
|
19222
19266
|
const compute = (def) => {
|
|
19223
|
-
const
|
|
19224
|
-
for (const reserved of Object.keys(reservedParams)) {
|
|
19225
|
-
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
19226
|
-
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
19227
|
-
}
|
|
19228
|
-
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.`);
|
|
19229
|
-
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.`);
|
|
19230
|
-
const params = blindCast({
|
|
19231
|
-
...userParams,
|
|
19232
|
-
...reservedParams
|
|
19233
|
-
});
|
|
19267
|
+
for (const reserved of Object.keys(reservedParams)) if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
19234
19268
|
const instance = new ComputeService(service$1({
|
|
19235
19269
|
name: def.name,
|
|
19236
19270
|
extension: "@prisma/composer-prisma-cloud",
|
|
19237
19271
|
type: "compute",
|
|
19238
19272
|
inputs: def.deps,
|
|
19239
|
-
params,
|
|
19240
|
-
...def.
|
|
19273
|
+
params: reservedParams,
|
|
19274
|
+
...def.input !== void 0 ? { input: def.input } : {},
|
|
19241
19275
|
build: def.build,
|
|
19242
19276
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
19243
19277
|
}));
|
|
@@ -19337,25 +19371,27 @@ const emailOutboxContract = contract({
|
|
|
19337
19371
|
});
|
|
19338
19372
|
/**
|
|
19339
19373
|
* The email compute service (spec §"Service definition"): a Postgres `db`
|
|
19340
|
-
* dependency,
|
|
19341
|
-
* `deliveryCredential` secret
|
|
19342
|
-
*
|
|
19343
|
-
*
|
|
19344
|
-
*
|
|
19345
|
-
*
|
|
19346
|
-
*
|
|
19374
|
+
* dependency, ONE input schema — `deliveryMode`/`deliveryUrl`/`from` plus the
|
|
19375
|
+
* `deliveryCredential` secret leaf (a `SecretString`-typed field, ADR-0042) —
|
|
19376
|
+
* and the two exposed ports (`send`, `outbox`). The module (`email-module.ts`)
|
|
19377
|
+
* binds the input at provision: forwarded boundary params/secret as leaves,
|
|
19378
|
+
* `deliveryUrl` as a literal. Build/entry mechanics copied from storage's
|
|
19379
|
+
* service file (`storage/src/storage-service.ts`), not re-derived:
|
|
19380
|
+
* `build.module` points at this file's own built output so the deploy
|
|
19381
|
+
* bootstrap can re-import it as `main` and call `main.run(address, boot)`;
|
|
19382
|
+
* `entry` resolves the sibling entrypoint pass in the same dist directory.
|
|
19347
19383
|
*/
|
|
19348
|
-
const
|
|
19349
|
-
|
|
19384
|
+
const emailInputSchema = type({
|
|
19385
|
+
deliveryMode: "'resend'|'smtp'|'none'",
|
|
19386
|
+
deliveryUrl: "string",
|
|
19387
|
+
from: "string",
|
|
19388
|
+
deliveryCredential: secretString()
|
|
19389
|
+
});
|
|
19390
|
+
function emailService() {
|
|
19350
19391
|
return compute({
|
|
19351
19392
|
name: "email",
|
|
19352
19393
|
deps: { db: postgres() },
|
|
19353
|
-
|
|
19354
|
-
deliveryMode: param(deliveryModeSchema),
|
|
19355
|
-
deliveryUrl: string$1({ default: opts?.deliveryUrl ?? "https://api.resend.com" }),
|
|
19356
|
-
from: string$1()
|
|
19357
|
-
},
|
|
19358
|
-
secrets: { deliveryCredential: secret() },
|
|
19394
|
+
input: emailInputSchema,
|
|
19359
19395
|
expose: {
|
|
19360
19396
|
send: emailSendContract,
|
|
19361
19397
|
outbox: emailOutboxContract
|
|
@@ -19704,8 +19740,8 @@ function checkDeliveryUrl(deliveryMode, deliveryUrl) {
|
|
|
19704
19740
|
}
|
|
19705
19741
|
const service = emailService();
|
|
19706
19742
|
const { db } = service.load();
|
|
19707
|
-
const { deliveryMode, deliveryUrl, from,
|
|
19708
|
-
const
|
|
19743
|
+
const { deliveryMode, deliveryUrl, from, deliveryCredential } = service.input();
|
|
19744
|
+
const port = service.port();
|
|
19709
19745
|
const deliveryUrlError = checkDeliveryUrl(deliveryMode, deliveryUrl);
|
|
19710
19746
|
if (deliveryUrlError !== null) throw new Error(deliveryUrlError);
|
|
19711
19747
|
const handlers = createHandlers({
|