@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
|
@@ -1,10 +1,101 @@
|
|
|
1
|
-
import { dependency,
|
|
1
|
+
import { dependency, hydrateSync, number, resource, service, string } from "@prisma/composer";
|
|
2
2
|
import "@prisma/composer/assertions";
|
|
3
3
|
import { blindCast } from "@prisma/composer/casts";
|
|
4
4
|
import { RPC_PEER_KEY, contract, rpc } from "@prisma/composer/service-rpc";
|
|
5
5
|
import { type } from "arktype";
|
|
6
6
|
import node from "@prisma/composer/node";
|
|
7
|
-
//#region ../../
|
|
7
|
+
//#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
|
|
8
|
+
/**
|
|
9
|
+
* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
|
|
10
|
+
*
|
|
11
|
+
* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes
|
|
12
|
+
* unnecessary**: tighten an input type, add a runtime check that narrows via a type
|
|
13
|
+
* predicate, restructure a generic so the compiler can see the relationship you're
|
|
14
|
+
* asserting, or use {@link castAs} when the value already satisfies the target type.
|
|
15
|
+
* Only when no rewrite is feasible does `blindCast` become the right answer — and at
|
|
16
|
+
* that point, the `Reason` literal you supply must articulate the compromise in
|
|
17
|
+
* language a reviewer can evaluate.
|
|
18
|
+
*
|
|
19
|
+
* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,
|
|
20
|
+
* that is not a signal to soften the reason; it is a signal to go back and solve the
|
|
21
|
+
* underlying type-system problem properly. An unconvincing justification is rework,
|
|
22
|
+
* not a free pass.
|
|
23
|
+
*
|
|
24
|
+
* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses
|
|
25
|
+
* the compiler's checks (the input type is `unknown`, the output type is whatever the
|
|
26
|
+
* caller asks for), but it forces the unsafety to be named at the call site instead of
|
|
27
|
+
* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile
|
|
28
|
+
* time — it is not present in the emitted JavaScript — but it is grep-able and
|
|
29
|
+
* visible to future readers.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const stringValue = blindCast<
|
|
34
|
+
* string,
|
|
35
|
+
* "JSON.parse returns `unknown`; this field is documented to be a string in the API contract"
|
|
36
|
+
* >(parsed[key]);
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @typeParam TargetType - The type the caller is asserting the input has.
|
|
40
|
+
* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.
|
|
41
|
+
* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.
|
|
42
|
+
*/
|
|
43
|
+
function blindCast$1(input) {
|
|
44
|
+
return input;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
|
|
48
|
+
/**
|
|
49
|
+
* A value wrapper that redacts everywhere except the one explicit reader,
|
|
50
|
+
* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
|
|
51
|
+
* sink must remember to check: `String(box)`, template interpolation,
|
|
52
|
+
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
53
|
+
* a secret can't leak through an accidental log or serialization.
|
|
54
|
+
*
|
|
55
|
+
* Every box carries a brand property keyed by the registered symbol
|
|
56
|
+
* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
|
|
57
|
+
* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
|
|
58
|
+
* public shape still matches the platform's own `secrecy` type
|
|
59
|
+
* (pdp-control-plane).
|
|
60
|
+
*/
|
|
61
|
+
const REDACTED = "[REDACTED]";
|
|
62
|
+
const SECRET_BOX = blindCast$1(Symbol.for("prisma:secret-box"));
|
|
63
|
+
var SecretBox = class {
|
|
64
|
+
[SECRET_BOX] = true;
|
|
65
|
+
#value;
|
|
66
|
+
constructor(value) {
|
|
67
|
+
this.#value = value;
|
|
68
|
+
}
|
|
69
|
+
/** The sole explicit door to the wrapped value. */
|
|
70
|
+
expose() {
|
|
71
|
+
return this.#value;
|
|
72
|
+
}
|
|
73
|
+
toString() {
|
|
74
|
+
return REDACTED;
|
|
75
|
+
}
|
|
76
|
+
toJSON() {
|
|
77
|
+
return REDACTED;
|
|
78
|
+
}
|
|
79
|
+
valueOf() {
|
|
80
|
+
return REDACTED;
|
|
81
|
+
}
|
|
82
|
+
[Symbol.toPrimitive]() {
|
|
83
|
+
return REDACTED;
|
|
84
|
+
}
|
|
85
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
86
|
+
return REDACTED;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* True for a redacting secret box — what a schema's secret leaf checks
|
|
91
|
+
* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
|
|
92
|
+
* duplicated module copy in a bundle counts and a look-alike does not.
|
|
93
|
+
*/
|
|
94
|
+
function isSecretString(value) {
|
|
95
|
+
return typeof value === "object" && value !== null && blindCast$1(value)[SECRET_BOX] === true;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-sVE4UAmg.mjs
|
|
8
99
|
/**
|
|
9
100
|
* Walks a node's own params, then each dependency input's connection params —
|
|
10
101
|
* the same enumeration order `configOf` uses, but carrying the raw
|
|
@@ -94,7 +185,7 @@ function coerceEnvSourcedParam(raw, d, key) {
|
|
|
94
185
|
/**
|
|
95
186
|
* Boot: read each declared param from env by its key, reverse the param's own
|
|
96
187
|
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
97
|
-
*
|
|
188
|
+
* The input document rides its own channel (readInput), not this one.
|
|
98
189
|
*/
|
|
99
190
|
const deserialize = (node, address) => {
|
|
100
191
|
const service = {};
|
|
@@ -131,40 +222,84 @@ const stash = (node, config) => {
|
|
|
131
222
|
process.env[configKey("", d)] = encode(d.owner, value);
|
|
132
223
|
}
|
|
133
224
|
};
|
|
134
|
-
/** The
|
|
135
|
-
const
|
|
225
|
+
/** The input document's own row name; its full key is COMPOSER_<addr>_INPUT. */
|
|
226
|
+
const INPUT_KEY_NAME = "INPUT";
|
|
227
|
+
/** The input document row's key for a service address. */
|
|
228
|
+
const inputKey = (address) => configKey(address, {
|
|
136
229
|
owner: "service",
|
|
137
|
-
name:
|
|
230
|
+
name: INPUT_KEY_NAME
|
|
138
231
|
});
|
|
232
|
+
const SECRET_MARKER = "$secret";
|
|
233
|
+
const ESCAPED_KEY = /^\$\$+secret$/;
|
|
234
|
+
/** True for the framework's secret pointer: `{ "$secret": "<PLATFORM_VAR>" }` and nothing else. */
|
|
235
|
+
function isSecretPointer(value) {
|
|
236
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && SECRET_MARKER in value && typeof value[SECRET_MARKER] === "string";
|
|
237
|
+
}
|
|
238
|
+
/** A plain data object (not an array, not a class instance) — the only object shape a binding/document may nest. */
|
|
239
|
+
function isPlainObject(value) {
|
|
240
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
241
|
+
const proto = Object.getPrototypeOf(value);
|
|
242
|
+
return proto === Object.prototype || proto === null;
|
|
243
|
+
}
|
|
139
244
|
/**
|
|
140
|
-
* Boot:
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
245
|
+
* Boot: read the one input document row (address-free after run()'s
|
|
246
|
+
* re-stash), swap each `$secret` pointer for a redacting box over the named
|
|
247
|
+
* platform var, unescape reserved keys, validate with the service's own
|
|
248
|
+
* schema, and return the typed object. A missing row is a loud failure naming
|
|
249
|
+
* the env var — a deployed environment always writes it; a local harness must
|
|
250
|
+
* supply it (set the row to the serialized input document).
|
|
144
251
|
*/
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
252
|
+
function readInput(node, address) {
|
|
253
|
+
const schema = node.inputSchema;
|
|
254
|
+
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).`);
|
|
255
|
+
const key = inputKey(address);
|
|
256
|
+
const raw = process.env[key];
|
|
257
|
+
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).`);
|
|
258
|
+
let parsed;
|
|
259
|
+
try {
|
|
260
|
+
parsed = JSON.parse(raw);
|
|
261
|
+
} catch (cause) {
|
|
262
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
263
|
+
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).`);
|
|
154
264
|
}
|
|
155
|
-
|
|
156
|
-
|
|
265
|
+
const hydrated = hydrateInputDocument(parsed, key);
|
|
266
|
+
try {
|
|
267
|
+
return standardValidateSync(schema, hydrated);
|
|
268
|
+
} catch (cause) {
|
|
269
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
270
|
+
throw new Error(`invalid input document (env ${key}): ${message}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/** Reverses the document encoding: `$secret` pointers become redacting boxes over the named platform vars; escaped reserved keys drop one "$". */
|
|
274
|
+
function hydrateInputDocument(value, key) {
|
|
275
|
+
if (isSecretPointer(value)) {
|
|
276
|
+
const name = value[SECRET_MARKER];
|
|
277
|
+
const secret = process.env[name];
|
|
278
|
+
if (secret === void 0 || secret === "") throw new Error(`secret input is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
279
|
+
return new SecretBox(secret);
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(value)) return value.map((member) => hydrateInputDocument(member, key));
|
|
282
|
+
if (isPlainObject(value)) {
|
|
283
|
+
const out = {};
|
|
284
|
+
for (const [k, member] of Object.entries(value)) {
|
|
285
|
+
const read = ESCAPED_KEY.test(k) ? k.slice(1) : k;
|
|
286
|
+
out[read] = hydrateInputDocument(member, key);
|
|
287
|
+
}
|
|
288
|
+
return out;
|
|
289
|
+
}
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
157
292
|
/**
|
|
158
|
-
* run()'s setup step for
|
|
159
|
-
* address-free key, so the address-free `
|
|
160
|
-
*
|
|
293
|
+
* run()'s setup step for the input document: re-emit the row under its
|
|
294
|
+
* address-free key, so the address-free `readInput` reads identically. The
|
|
295
|
+
* document carries pointers, never values — the values stay only in their
|
|
296
|
+
* platform vars.
|
|
161
297
|
*/
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
298
|
+
const stashInput = (node, address) => {
|
|
299
|
+
if (node.inputSchema === void 0) return;
|
|
300
|
+
const raw = process.env[inputKey(address)];
|
|
301
|
+
if (raw === void 0) return;
|
|
302
|
+
process.env[inputKey("")] = raw;
|
|
168
303
|
};
|
|
169
304
|
/**
|
|
170
305
|
* Boot: for each reserved provider param, read its address-scoped row through
|
|
@@ -229,7 +364,7 @@ function standardValidateSync(schema, value) {
|
|
|
229
364
|
return result.value;
|
|
230
365
|
}
|
|
231
366
|
//#endregion
|
|
232
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-
|
|
367
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-Cxy18aoh.mjs
|
|
233
368
|
/**
|
|
234
369
|
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
235
370
|
* brand and the ONE entry — shared by control.ts (which registers the
|
|
@@ -347,20 +482,24 @@ Object.freeze({
|
|
|
347
482
|
});
|
|
348
483
|
const reservedParams = { port: number({ default: 3e3 }) };
|
|
349
484
|
/**
|
|
350
|
-
* A Prisma Compute service — declarations only (deps +
|
|
351
|
-
* ports it exposes), no descriptor. `
|
|
352
|
-
*
|
|
353
|
-
*
|
|
485
|
+
* A Prisma Compute service — declarations only (deps + one input schema +
|
|
486
|
+
* build + the ports it exposes), no descriptor. The reserved `port` param
|
|
487
|
+
* rides its own channel (ADR-0042 leaves it untouched); a dependency named
|
|
488
|
+
* like it fails at authoring.
|
|
354
489
|
*
|
|
355
490
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
356
491
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
357
|
-
* typed Config, re-emit it under address-free
|
|
358
|
-
* then call boot() to start the app's entry.
|
|
359
|
-
* · load() /
|
|
360
|
-
* load() hydrates + memoizes the deps,
|
|
361
|
-
*
|
|
492
|
+
* typed Config, re-emit it (and the input document row) under address-free
|
|
493
|
+
* process-local stash keys, then call boot() to start the app's entry.
|
|
494
|
+
* · load() / input() — called from inside the app's entry: read the stash;
|
|
495
|
+
* load() hydrates + memoizes the deps, input() parses the input document,
|
|
496
|
+
* replaces each `$secret` pointer with a redacting box over the named
|
|
497
|
+
* platform var, validates with the declared schema, and memoizes (ADR-0042).
|
|
362
498
|
* · origin() — this service's platform-assigned public origin, read from the
|
|
363
499
|
* stash `run()` populates; memoized per process.
|
|
500
|
+
* · port() — this service's resolved reserved port (the value `run()` routes
|
|
501
|
+
* to and exports as PORT), read from that same stash via #processConfig();
|
|
502
|
+
* defaults to 3000 when the platform binds none.
|
|
364
503
|
*
|
|
365
504
|
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
366
505
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
@@ -370,8 +509,7 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
370
509
|
var ComputeService = class {
|
|
371
510
|
#resolved;
|
|
372
511
|
#loadedDeps;
|
|
373
|
-
#
|
|
374
|
-
#loadedSecrets;
|
|
512
|
+
#loadedInput;
|
|
375
513
|
#origin;
|
|
376
514
|
constructor(node) {
|
|
377
515
|
Object.assign(this, node);
|
|
@@ -384,7 +522,7 @@ var ComputeService = class {
|
|
|
384
522
|
const config = deserialize(this, address);
|
|
385
523
|
stash(this, config);
|
|
386
524
|
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
387
|
-
|
|
525
|
+
stashInput(this, address);
|
|
388
526
|
const port = config.service["port"];
|
|
389
527
|
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
390
528
|
return boot();
|
|
@@ -393,13 +531,9 @@ var ComputeService = class {
|
|
|
393
531
|
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
394
532
|
return this.#loadedDeps;
|
|
395
533
|
}
|
|
396
|
-
|
|
397
|
-
if (this.#
|
|
398
|
-
return this.#
|
|
399
|
-
}
|
|
400
|
-
secrets() {
|
|
401
|
-
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
402
|
-
return this.#loadedSecrets;
|
|
534
|
+
input() {
|
|
535
|
+
if (this.#loadedInput === void 0) this.#loadedInput = blindCast(readInput(this, ""));
|
|
536
|
+
return this.#loadedInput;
|
|
403
537
|
}
|
|
404
538
|
/** This service's platform-assigned public origin — read from the stash
|
|
405
539
|
* run() populates and memoized per process. Throws if called before run()
|
|
@@ -408,26 +542,24 @@ var ComputeService = class {
|
|
|
408
542
|
this.#origin ??= readOrigin();
|
|
409
543
|
return this.#origin;
|
|
410
544
|
}
|
|
545
|
+
/** This service's resolved reserved port — the value run() routes to and
|
|
546
|
+
* exports as PORT — read the same way load() reads the stash. Defaults to
|
|
547
|
+
* 3000 when the platform binds none. */
|
|
548
|
+
port() {
|
|
549
|
+
const port = this.#processConfig().service["port"];
|
|
550
|
+
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.`);
|
|
551
|
+
return port;
|
|
552
|
+
}
|
|
411
553
|
};
|
|
412
554
|
const compute = (def) => {
|
|
413
|
-
const
|
|
414
|
-
for (const reserved of Object.keys(reservedParams)) {
|
|
415
|
-
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
416
|
-
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
417
|
-
}
|
|
418
|
-
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.`);
|
|
419
|
-
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.`);
|
|
420
|
-
const params = blindCast({
|
|
421
|
-
...userParams,
|
|
422
|
-
...reservedParams
|
|
423
|
-
});
|
|
555
|
+
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.`);
|
|
424
556
|
const instance = new ComputeService(service({
|
|
425
557
|
name: def.name,
|
|
426
558
|
extension: "@prisma/composer-prisma-cloud",
|
|
427
559
|
type: "compute",
|
|
428
560
|
inputs: def.deps,
|
|
429
|
-
params,
|
|
430
|
-
...def.
|
|
561
|
+
params: reservedParams,
|
|
562
|
+
...def.input !== void 0 ? { input: def.input } : {},
|
|
431
563
|
build: def.build,
|
|
432
564
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
433
565
|
}));
|
|
@@ -470,7 +602,24 @@ Object.freeze({
|
|
|
470
602
|
satisfies: (required) => required.kind === "credentials"
|
|
471
603
|
});
|
|
472
604
|
//#endregion
|
|
473
|
-
//#region ../../
|
|
605
|
+
//#region ../../0-framework/0-foundation/foundation/dist/arktype.mjs
|
|
606
|
+
/**
|
|
607
|
+
* ArkType spellings of the framework's schema leaves. Opt-in: the framework
|
|
608
|
+
* accepts any Standard Schema library (ADR-0042) and nothing outside this
|
|
609
|
+
* module imports arktype, so an app that uses Zod never loads it.
|
|
610
|
+
*/
|
|
611
|
+
/**
|
|
612
|
+
* A schema leaf that accepts only a redacting `SecretString` box, so
|
|
613
|
+
* `input().<field>.expose()` type-checks and binding a plain literal there
|
|
614
|
+
* fails the deploy (ADR-0042).
|
|
615
|
+
*
|
|
616
|
+
* ```ts
|
|
617
|
+
* input: type({ signingKey: secretString() })
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
const secretString = () => type("unknown").narrow((value, ctx) => isSecretString(value) || ctx.mustBe("a SecretString box — bind this field to a secret"));
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region ../../1-prisma-cloud/2-shared-modules/email/dist/email-service-CTqLUEQV.mjs
|
|
474
623
|
const emailStatus = type("'stored'|'queued'|'sent'|'failed'");
|
|
475
624
|
const emailSendContract = contract({ send: rpc({
|
|
476
625
|
input: type({
|
|
@@ -529,25 +678,27 @@ const emailOutboxContract = contract({
|
|
|
529
678
|
});
|
|
530
679
|
/**
|
|
531
680
|
* The email compute service (spec §"Service definition"): a Postgres `db`
|
|
532
|
-
* dependency,
|
|
533
|
-
* `deliveryCredential` secret
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
681
|
+
* dependency, ONE input schema — `deliveryMode`/`deliveryUrl`/`from` plus the
|
|
682
|
+
* `deliveryCredential` secret leaf (a `SecretString`-typed field, ADR-0042) —
|
|
683
|
+
* and the two exposed ports (`send`, `outbox`). The module (`email-module.ts`)
|
|
684
|
+
* binds the input at provision: forwarded boundary params/secret as leaves,
|
|
685
|
+
* `deliveryUrl` as a literal. Build/entry mechanics copied from storage's
|
|
686
|
+
* service file (`storage/src/storage-service.ts`), not re-derived:
|
|
687
|
+
* `build.module` points at this file's own built output so the deploy
|
|
688
|
+
* bootstrap can re-import it as `main` and call `main.run(address, boot)`;
|
|
689
|
+
* `entry` resolves the sibling entrypoint pass in the same dist directory.
|
|
539
690
|
*/
|
|
540
|
-
const
|
|
541
|
-
|
|
691
|
+
const emailInputSchema = type({
|
|
692
|
+
deliveryMode: "'resend'|'smtp'|'none'",
|
|
693
|
+
deliveryUrl: "string",
|
|
694
|
+
from: "string",
|
|
695
|
+
deliveryCredential: secretString()
|
|
696
|
+
});
|
|
697
|
+
function emailService() {
|
|
542
698
|
return compute({
|
|
543
699
|
name: "email",
|
|
544
700
|
deps: { db: postgres() },
|
|
545
|
-
|
|
546
|
-
deliveryMode: param(deliveryModeSchema),
|
|
547
|
-
deliveryUrl: string({ default: opts?.deliveryUrl ?? "https://api.resend.com" }),
|
|
548
|
-
from: string()
|
|
549
|
-
},
|
|
550
|
-
secrets: { deliveryCredential: secret() },
|
|
701
|
+
input: emailInputSchema,
|
|
551
702
|
expose: {
|
|
552
703
|
send: emailSendContract,
|
|
553
704
|
outbox: emailOutboxContract
|