@prisma/composer-prisma-cloud 0.3.0-dev.8 → 0.3.0
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/compute-main.mjs +4 -20
- package/dist/compute-main.mjs.map +1 -1
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +17 -28
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +26 -33
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +77 -202
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +114 -133
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +76 -200
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/email/email-entrypoint.mjs +126 -162
- package/dist/email/email-entrypoint.mjs.map +1 -1
- package/dist/email/email-service.mjs +79 -230
- package/dist/email/email-service.mjs.map +1 -1
- package/dist/email/index.d.mts +29 -33
- package/dist/email/index.d.mts.map +1 -1
- package/dist/email/index.mjs +84 -236
- package/dist/email/index.mjs.map +1 -1
- package/dist/email/testing.mjs +89 -112
- package/dist/email/testing.mjs.map +1 -1
- package/dist/index.d.mts +43 -51
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +51 -47
- package/dist/index.mjs.map +1 -1
- package/dist/local-target.mjs +1 -1
- package/dist/local-target.mjs.map +1 -1
- package/dist/{secret-BVGxqHxY-DYDfiULl.mjs → param-BTzY0ne5-CW6ojZ3E.mjs} +4 -45
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +1 -0
- package/dist/{preflight-names-CpJUd9ZA-BCU-W3cT.mjs → preflight-names-BPL-qsZF-BfoRgbgb.mjs} +14 -30
- package/dist/{preflight-names-CpJUd9ZA-BCU-W3cT.mjs.map → preflight-names-BPL-qsZF-BfoRgbgb.mjs.map} +1 -1
- package/dist/{provisioned-edges-Cxy18aoh-CUnaY96r.mjs → provisioned-edges-C1wSO3cx-YC5C19f9.mjs} +3 -3
- package/dist/{provisioned-edges-Cxy18aoh-CUnaY96r.mjs.map → provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map} +1 -1
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +47 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +1 -0
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs +251 -0
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +1 -0
- package/dist/{serializer-BD_6nkr4-DWn5NNTC.d.mts → serializer-Cx5slrV4-xJfH6EWS.d.mts} +2 -2
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +1 -0
- package/dist/storage/index.d.mts +26 -31
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +89 -215
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +122 -147
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +87 -212
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/streams/index.d.mts +22 -29
- package/dist/streams/index.d.mts.map +1 -1
- package/dist/streams/index.mjs +88 -213
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +118 -139
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +87 -212
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/testing.d.mts +5 -19
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +3 -11
- package/dist/testing.mjs.map +1 -1
- package/package.json +18 -18
- package/dist/secret-BVGxqHxY-DYDfiULl.mjs.map +0 -1
- package/dist/serializer-BD_6nkr4-DWn5NNTC.d.mts.map +0 -1
- package/dist/serializer-sVE4UAmg-CikRngbR.mjs +0 -475
- package/dist/serializer-sVE4UAmg-CikRngbR.mjs.map +0 -1
|
@@ -1,101 +1,10 @@
|
|
|
1
|
-
import { dependency, hydrateSync, number, resource, service, string } from "@prisma/composer";
|
|
1
|
+
import { dependency, hydrateSecrets, hydrateSync, number, param, resource, secret, 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 ../../
|
|
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
|
|
7
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-CJiOhF2d.mjs
|
|
99
8
|
/**
|
|
100
9
|
* Walks a node's own params, then each dependency input's connection params —
|
|
101
10
|
* the same enumeration order `configOf` uses, but carrying the raw
|
|
@@ -185,7 +94,7 @@ function coerceEnvSourcedParam(raw, d, key) {
|
|
|
185
94
|
/**
|
|
186
95
|
* Boot: read each declared param from env by its key, reverse the param's own
|
|
187
96
|
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
188
|
-
*
|
|
97
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
189
98
|
*/
|
|
190
99
|
const deserialize = (node, address) => {
|
|
191
100
|
const service = {};
|
|
@@ -222,84 +131,40 @@ const stash = (node, config) => {
|
|
|
222
131
|
process.env[configKey("", d)] = encode(d.owner, value);
|
|
223
132
|
}
|
|
224
133
|
};
|
|
225
|
-
/** The
|
|
226
|
-
const
|
|
227
|
-
/** The input document row's key for a service address. */
|
|
228
|
-
const inputKey = (address) => configKey(address, {
|
|
134
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
135
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
229
136
|
owner: "service",
|
|
230
|
-
name:
|
|
137
|
+
name: slot
|
|
231
138
|
});
|
|
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
|
-
}
|
|
244
139
|
/**
|
|
245
|
-
* Boot:
|
|
246
|
-
*
|
|
247
|
-
* platform
|
|
248
|
-
*
|
|
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).
|
|
140
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
141
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
142
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
143
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
251
144
|
*/
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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).`);
|
|
145
|
+
const deserializeSecrets = (node, address) => {
|
|
146
|
+
const values = {};
|
|
147
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
148
|
+
const key = secretKey(address, slot);
|
|
149
|
+
const name = process.env[key];
|
|
150
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
151
|
+
const value = process.env[name];
|
|
152
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
153
|
+
values[slot] = value;
|
|
264
154
|
}
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
}
|
|
155
|
+
return values;
|
|
156
|
+
};
|
|
292
157
|
/**
|
|
293
|
-
* run()'s setup step for
|
|
294
|
-
* address-free key, so the address-free `
|
|
295
|
-
*
|
|
296
|
-
* platform vars.
|
|
158
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
159
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
160
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
297
161
|
*/
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
162
|
+
const stashSecrets = (node, address) => {
|
|
163
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
164
|
+
const name = process.env[secretKey(address, slot)];
|
|
165
|
+
if (name === void 0) continue;
|
|
166
|
+
process.env[secretKey("", slot)] = name;
|
|
167
|
+
}
|
|
303
168
|
};
|
|
304
169
|
/**
|
|
305
170
|
* Boot: for each reserved provider param, read its address-scoped row through
|
|
@@ -364,7 +229,7 @@ function standardValidateSync(schema, value) {
|
|
|
364
229
|
return result.value;
|
|
365
230
|
}
|
|
366
231
|
//#endregion
|
|
367
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-
|
|
232
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-C1wSO3cx.mjs
|
|
368
233
|
/**
|
|
369
234
|
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
370
235
|
* brand and the ONE entry — shared by control.ts (which registers the
|
|
@@ -482,24 +347,20 @@ Object.freeze({
|
|
|
482
347
|
});
|
|
483
348
|
const reservedParams = { port: number({ default: 3e3 }) };
|
|
484
349
|
/**
|
|
485
|
-
* A Prisma Compute service — declarations only (deps +
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
350
|
+
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
351
|
+
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
352
|
+
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
353
|
+
* one fails at authoring, the same way a colliding dependency name does.
|
|
489
354
|
*
|
|
490
355
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
491
356
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
492
|
-
* typed Config, re-emit it
|
|
493
|
-
*
|
|
494
|
-
* · load() /
|
|
495
|
-
* load() hydrates + memoizes the deps,
|
|
496
|
-
*
|
|
497
|
-
* platform var, validates with the declared schema, and memoizes (ADR-0042).
|
|
357
|
+
* typed Config, re-emit it under address-free process-local stash keys,
|
|
358
|
+
* then call boot() to start the app's entry.
|
|
359
|
+
* · load() / config() — called from inside the app's entry: read the stash;
|
|
360
|
+
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
361
|
+
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
498
362
|
* · origin() — this service's platform-assigned public origin, read from the
|
|
499
363
|
* 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.
|
|
503
364
|
*
|
|
504
365
|
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
505
366
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
@@ -509,7 +370,8 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
509
370
|
var ComputeService = class {
|
|
510
371
|
#resolved;
|
|
511
372
|
#loadedDeps;
|
|
512
|
-
#
|
|
373
|
+
#loadedParams;
|
|
374
|
+
#loadedSecrets;
|
|
513
375
|
#origin;
|
|
514
376
|
constructor(node) {
|
|
515
377
|
Object.assign(this, node);
|
|
@@ -522,7 +384,7 @@ var ComputeService = class {
|
|
|
522
384
|
const config = deserialize(this, address);
|
|
523
385
|
stash(this, config);
|
|
524
386
|
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
525
|
-
|
|
387
|
+
stashSecrets(this, address);
|
|
526
388
|
const port = config.service["port"];
|
|
527
389
|
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
528
390
|
return boot();
|
|
@@ -531,9 +393,13 @@ var ComputeService = class {
|
|
|
531
393
|
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
532
394
|
return this.#loadedDeps;
|
|
533
395
|
}
|
|
534
|
-
|
|
535
|
-
if (this.#
|
|
536
|
-
return this.#
|
|
396
|
+
config() {
|
|
397
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
398
|
+
return this.#loadedParams;
|
|
399
|
+
}
|
|
400
|
+
secrets() {
|
|
401
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
402
|
+
return this.#loadedSecrets;
|
|
537
403
|
}
|
|
538
404
|
/** This service's platform-assigned public origin — read from the stash
|
|
539
405
|
* run() populates and memoized per process. Throws if called before run()
|
|
@@ -542,24 +408,26 @@ var ComputeService = class {
|
|
|
542
408
|
this.#origin ??= readOrigin();
|
|
543
409
|
return this.#origin;
|
|
544
410
|
}
|
|
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
|
-
}
|
|
553
411
|
};
|
|
554
412
|
const compute = (def) => {
|
|
555
|
-
|
|
413
|
+
const userParams = def.params ?? blindCast({});
|
|
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
|
+
});
|
|
556
424
|
const instance = new ComputeService(service({
|
|
557
425
|
name: def.name,
|
|
558
426
|
extension: "@prisma/composer-prisma-cloud",
|
|
559
427
|
type: "compute",
|
|
560
428
|
inputs: def.deps,
|
|
561
|
-
params
|
|
562
|
-
...def.
|
|
429
|
+
params,
|
|
430
|
+
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
563
431
|
build: def.build,
|
|
564
432
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
565
433
|
}));
|
|
@@ -602,24 +470,7 @@ Object.freeze({
|
|
|
602
470
|
satisfies: (required) => required.kind === "credentials"
|
|
603
471
|
});
|
|
604
472
|
//#endregion
|
|
605
|
-
//#region ../../
|
|
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
|
|
473
|
+
//#region ../../1-prisma-cloud/2-shared-modules/email/dist/email-service-DD1VF_64.mjs
|
|
623
474
|
const emailStatus = type("'stored'|'queued'|'sent'|'failed'");
|
|
624
475
|
const emailSendContract = contract({ send: rpc({
|
|
625
476
|
input: type({
|
|
@@ -678,27 +529,25 @@ const emailOutboxContract = contract({
|
|
|
678
529
|
});
|
|
679
530
|
/**
|
|
680
531
|
* The email compute service (spec §"Service definition"): a Postgres `db`
|
|
681
|
-
* dependency,
|
|
682
|
-
* `deliveryCredential` secret
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
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.
|
|
532
|
+
* dependency, the `deliveryMode`/`deliveryUrl`/`from` params, the
|
|
533
|
+
* `deliveryCredential` secret, and the two exposed ports (`send`, `outbox`).
|
|
534
|
+
* Build/entry mechanics copied from storage's service file
|
|
535
|
+
* (`storage/src/storage-service.ts`), not re-derived: `build.module` points
|
|
536
|
+
* at this file's own built output so the deploy bootstrap can re-import it
|
|
537
|
+
* as `main` and call `main.run(address, boot)`; `entry` resolves the
|
|
538
|
+
* sibling entrypoint pass in the same dist directory.
|
|
690
539
|
*/
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
deliveryUrl: "string",
|
|
694
|
-
from: "string",
|
|
695
|
-
deliveryCredential: secretString()
|
|
696
|
-
});
|
|
697
|
-
function emailService() {
|
|
540
|
+
const deliveryModeSchema = type("'resend'|'smtp'|'none'");
|
|
541
|
+
function emailService(opts) {
|
|
698
542
|
return compute({
|
|
699
543
|
name: "email",
|
|
700
544
|
deps: { db: postgres() },
|
|
701
|
-
|
|
545
|
+
params: {
|
|
546
|
+
deliveryMode: param(deliveryModeSchema),
|
|
547
|
+
deliveryUrl: string({ default: opts?.deliveryUrl ?? "https://api.resend.com" }),
|
|
548
|
+
from: string()
|
|
549
|
+
},
|
|
550
|
+
secrets: { deliveryCredential: secret() },
|
|
702
551
|
expose: {
|
|
703
552
|
send: emailSendContract,
|
|
704
553
|
outbox: emailOutboxContract
|