@prisma/composer-prisma-cloud 0.3.0-dev.6 → 0.3.0-dev.8
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 +17 -17
- 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,9 +1,92 @@
|
|
|
1
|
-
import { dependency,
|
|
1
|
+
import { dependency, hydrateSync, number, provisionNeed, resource, service, string } from "@prisma/composer";
|
|
2
2
|
import { blindCast } from "@prisma/composer/casts";
|
|
3
3
|
import { type } from "arktype";
|
|
4
4
|
import { RPC_PEER_KEY } from "@prisma/composer/service-rpc";
|
|
5
5
|
import node from "@prisma/composer/node";
|
|
6
|
-
//#region ../../
|
|
6
|
+
//#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
|
|
7
|
+
/**
|
|
8
|
+
* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
|
|
9
|
+
*
|
|
10
|
+
* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes
|
|
11
|
+
* unnecessary**: tighten an input type, add a runtime check that narrows via a type
|
|
12
|
+
* predicate, restructure a generic so the compiler can see the relationship you're
|
|
13
|
+
* asserting, or use {@link castAs} when the value already satisfies the target type.
|
|
14
|
+
* Only when no rewrite is feasible does `blindCast` become the right answer — and at
|
|
15
|
+
* that point, the `Reason` literal you supply must articulate the compromise in
|
|
16
|
+
* language a reviewer can evaluate.
|
|
17
|
+
*
|
|
18
|
+
* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,
|
|
19
|
+
* that is not a signal to soften the reason; it is a signal to go back and solve the
|
|
20
|
+
* underlying type-system problem properly. An unconvincing justification is rework,
|
|
21
|
+
* not a free pass.
|
|
22
|
+
*
|
|
23
|
+
* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses
|
|
24
|
+
* the compiler's checks (the input type is `unknown`, the output type is whatever the
|
|
25
|
+
* caller asks for), but it forces the unsafety to be named at the call site instead of
|
|
26
|
+
* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile
|
|
27
|
+
* time — it is not present in the emitted JavaScript — but it is grep-able and
|
|
28
|
+
* visible to future readers.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const stringValue = blindCast<
|
|
33
|
+
* string,
|
|
34
|
+
* "JSON.parse returns `unknown`; this field is documented to be a string in the API contract"
|
|
35
|
+
* >(parsed[key]);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @typeParam TargetType - The type the caller is asserting the input has.
|
|
39
|
+
* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.
|
|
40
|
+
* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.
|
|
41
|
+
*/
|
|
42
|
+
function blindCast$1(input) {
|
|
43
|
+
return input;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
|
|
47
|
+
/**
|
|
48
|
+
* A value wrapper that redacts everywhere except the one explicit reader,
|
|
49
|
+
* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
|
|
50
|
+
* sink must remember to check: `String(box)`, template interpolation,
|
|
51
|
+
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
52
|
+
* a secret can't leak through an accidental log or serialization.
|
|
53
|
+
*
|
|
54
|
+
* Every box carries a brand property keyed by the registered symbol
|
|
55
|
+
* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
|
|
56
|
+
* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
|
|
57
|
+
* public shape still matches the platform's own `secrecy` type
|
|
58
|
+
* (pdp-control-plane).
|
|
59
|
+
*/
|
|
60
|
+
const REDACTED = "[REDACTED]";
|
|
61
|
+
const SECRET_BOX = blindCast$1(Symbol.for("prisma:secret-box"));
|
|
62
|
+
var SecretBox = class {
|
|
63
|
+
[SECRET_BOX] = true;
|
|
64
|
+
#value;
|
|
65
|
+
constructor(value) {
|
|
66
|
+
this.#value = value;
|
|
67
|
+
}
|
|
68
|
+
/** The sole explicit door to the wrapped value. */
|
|
69
|
+
expose() {
|
|
70
|
+
return this.#value;
|
|
71
|
+
}
|
|
72
|
+
toString() {
|
|
73
|
+
return REDACTED;
|
|
74
|
+
}
|
|
75
|
+
toJSON() {
|
|
76
|
+
return REDACTED;
|
|
77
|
+
}
|
|
78
|
+
valueOf() {
|
|
79
|
+
return REDACTED;
|
|
80
|
+
}
|
|
81
|
+
[Symbol.toPrimitive]() {
|
|
82
|
+
return REDACTED;
|
|
83
|
+
}
|
|
84
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
85
|
+
return REDACTED;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-sVE4UAmg.mjs
|
|
7
90
|
/**
|
|
8
91
|
* Walks a node's own params, then each dependency input's connection params —
|
|
9
92
|
* the same enumeration order `configOf` uses, but carrying the raw
|
|
@@ -93,7 +176,7 @@ function coerceEnvSourcedParam(raw, d, key) {
|
|
|
93
176
|
/**
|
|
94
177
|
* Boot: read each declared param from env by its key, reverse the param's own
|
|
95
178
|
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
96
|
-
*
|
|
179
|
+
* The input document rides its own channel (readInput), not this one.
|
|
97
180
|
*/
|
|
98
181
|
const deserialize = (node, address) => {
|
|
99
182
|
const service = {};
|
|
@@ -130,40 +213,84 @@ const stash = (node, config) => {
|
|
|
130
213
|
process.env[configKey("", d)] = encode(d.owner, value);
|
|
131
214
|
}
|
|
132
215
|
};
|
|
133
|
-
/** The
|
|
134
|
-
const
|
|
216
|
+
/** The input document's own row name; its full key is COMPOSER_<addr>_INPUT. */
|
|
217
|
+
const INPUT_KEY_NAME = "INPUT";
|
|
218
|
+
/** The input document row's key for a service address. */
|
|
219
|
+
const inputKey = (address) => configKey(address, {
|
|
135
220
|
owner: "service",
|
|
136
|
-
name:
|
|
221
|
+
name: INPUT_KEY_NAME
|
|
137
222
|
});
|
|
223
|
+
const SECRET_MARKER = "$secret";
|
|
224
|
+
const ESCAPED_KEY = /^\$\$+secret$/;
|
|
225
|
+
/** True for the framework's secret pointer: `{ "$secret": "<PLATFORM_VAR>" }` and nothing else. */
|
|
226
|
+
function isSecretPointer(value) {
|
|
227
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && SECRET_MARKER in value && typeof value[SECRET_MARKER] === "string";
|
|
228
|
+
}
|
|
229
|
+
/** A plain data object (not an array, not a class instance) — the only object shape a binding/document may nest. */
|
|
230
|
+
function isPlainObject(value) {
|
|
231
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
232
|
+
const proto = Object.getPrototypeOf(value);
|
|
233
|
+
return proto === Object.prototype || proto === null;
|
|
234
|
+
}
|
|
138
235
|
/**
|
|
139
|
-
* Boot:
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
236
|
+
* Boot: read the one input document row (address-free after run()'s
|
|
237
|
+
* re-stash), swap each `$secret` pointer for a redacting box over the named
|
|
238
|
+
* platform var, unescape reserved keys, validate with the service's own
|
|
239
|
+
* schema, and return the typed object. A missing row is a loud failure naming
|
|
240
|
+
* the env var — a deployed environment always writes it; a local harness must
|
|
241
|
+
* supply it (set the row to the serialized input document).
|
|
143
242
|
*/
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
243
|
+
function readInput(node, address) {
|
|
244
|
+
const schema = node.inputSchema;
|
|
245
|
+
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).`);
|
|
246
|
+
const key = inputKey(address);
|
|
247
|
+
const raw = process.env[key];
|
|
248
|
+
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).`);
|
|
249
|
+
let parsed;
|
|
250
|
+
try {
|
|
251
|
+
parsed = JSON.parse(raw);
|
|
252
|
+
} catch (cause) {
|
|
253
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
254
|
+
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).`);
|
|
153
255
|
}
|
|
154
|
-
|
|
155
|
-
|
|
256
|
+
const hydrated = hydrateInputDocument(parsed, key);
|
|
257
|
+
try {
|
|
258
|
+
return standardValidateSync(schema, hydrated);
|
|
259
|
+
} catch (cause) {
|
|
260
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
261
|
+
throw new Error(`invalid input document (env ${key}): ${message}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/** Reverses the document encoding: `$secret` pointers become redacting boxes over the named platform vars; escaped reserved keys drop one "$". */
|
|
265
|
+
function hydrateInputDocument(value, key) {
|
|
266
|
+
if (isSecretPointer(value)) {
|
|
267
|
+
const name = value[SECRET_MARKER];
|
|
268
|
+
const secret = process.env[name];
|
|
269
|
+
if (secret === void 0 || secret === "") throw new Error(`secret input is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
270
|
+
return new SecretBox(secret);
|
|
271
|
+
}
|
|
272
|
+
if (Array.isArray(value)) return value.map((member) => hydrateInputDocument(member, key));
|
|
273
|
+
if (isPlainObject(value)) {
|
|
274
|
+
const out = {};
|
|
275
|
+
for (const [k, member] of Object.entries(value)) {
|
|
276
|
+
const read = ESCAPED_KEY.test(k) ? k.slice(1) : k;
|
|
277
|
+
out[read] = hydrateInputDocument(member, key);
|
|
278
|
+
}
|
|
279
|
+
return out;
|
|
280
|
+
}
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
156
283
|
/**
|
|
157
|
-
* run()'s setup step for
|
|
158
|
-
* address-free key, so the address-free `
|
|
159
|
-
*
|
|
284
|
+
* run()'s setup step for the input document: re-emit the row under its
|
|
285
|
+
* address-free key, so the address-free `readInput` reads identically. The
|
|
286
|
+
* document carries pointers, never values — the values stay only in their
|
|
287
|
+
* platform vars.
|
|
160
288
|
*/
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
289
|
+
const stashInput = (node, address) => {
|
|
290
|
+
if (node.inputSchema === void 0) return;
|
|
291
|
+
const raw = process.env[inputKey(address)];
|
|
292
|
+
if (raw === void 0) return;
|
|
293
|
+
process.env[inputKey("")] = raw;
|
|
167
294
|
};
|
|
168
295
|
/**
|
|
169
296
|
* Boot: for each reserved provider param, read its address-scoped row through
|
|
@@ -228,7 +355,7 @@ function standardValidateSync(schema, value) {
|
|
|
228
355
|
return result.value;
|
|
229
356
|
}
|
|
230
357
|
//#endregion
|
|
231
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-
|
|
358
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-Cxy18aoh.mjs
|
|
232
359
|
/**
|
|
233
360
|
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
234
361
|
* brand and the ONE entry — shared by control.ts (which registers the
|
|
@@ -354,20 +481,24 @@ Object.freeze({
|
|
|
354
481
|
});
|
|
355
482
|
const reservedParams = { port: number({ default: 3e3 }) };
|
|
356
483
|
/**
|
|
357
|
-
* A Prisma Compute service — declarations only (deps +
|
|
358
|
-
* ports it exposes), no descriptor. `
|
|
359
|
-
*
|
|
360
|
-
*
|
|
484
|
+
* A Prisma Compute service — declarations only (deps + one input schema +
|
|
485
|
+
* build + the ports it exposes), no descriptor. The reserved `port` param
|
|
486
|
+
* rides its own channel (ADR-0042 leaves it untouched); a dependency named
|
|
487
|
+
* like it fails at authoring.
|
|
361
488
|
*
|
|
362
489
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
363
490
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
364
|
-
* typed Config, re-emit it under address-free
|
|
365
|
-
* then call boot() to start the app's entry.
|
|
366
|
-
* · load() /
|
|
367
|
-
* load() hydrates + memoizes the deps,
|
|
368
|
-
*
|
|
491
|
+
* typed Config, re-emit it (and the input document row) under address-free
|
|
492
|
+
* process-local stash keys, then call boot() to start the app's entry.
|
|
493
|
+
* · load() / input() — called from inside the app's entry: read the stash;
|
|
494
|
+
* load() hydrates + memoizes the deps, input() parses the input document,
|
|
495
|
+
* replaces each `$secret` pointer with a redacting box over the named
|
|
496
|
+
* platform var, validates with the declared schema, and memoizes (ADR-0042).
|
|
369
497
|
* · origin() — this service's platform-assigned public origin, read from the
|
|
370
498
|
* stash `run()` populates; memoized per process.
|
|
499
|
+
* · port() — this service's resolved reserved port (the value `run()` routes
|
|
500
|
+
* to and exports as PORT), read from that same stash via #processConfig();
|
|
501
|
+
* defaults to 3000 when the platform binds none.
|
|
371
502
|
*
|
|
372
503
|
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
373
504
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
@@ -377,8 +508,7 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
377
508
|
var ComputeService = class {
|
|
378
509
|
#resolved;
|
|
379
510
|
#loadedDeps;
|
|
380
|
-
#
|
|
381
|
-
#loadedSecrets;
|
|
511
|
+
#loadedInput;
|
|
382
512
|
#origin;
|
|
383
513
|
constructor(node) {
|
|
384
514
|
Object.assign(this, node);
|
|
@@ -391,7 +521,7 @@ var ComputeService = class {
|
|
|
391
521
|
const config = deserialize(this, address);
|
|
392
522
|
stash(this, config);
|
|
393
523
|
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
394
|
-
|
|
524
|
+
stashInput(this, address);
|
|
395
525
|
const port = config.service["port"];
|
|
396
526
|
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
397
527
|
return boot();
|
|
@@ -400,13 +530,9 @@ var ComputeService = class {
|
|
|
400
530
|
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
401
531
|
return this.#loadedDeps;
|
|
402
532
|
}
|
|
403
|
-
|
|
404
|
-
if (this.#
|
|
405
|
-
return this.#
|
|
406
|
-
}
|
|
407
|
-
secrets() {
|
|
408
|
-
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
409
|
-
return this.#loadedSecrets;
|
|
533
|
+
input() {
|
|
534
|
+
if (this.#loadedInput === void 0) this.#loadedInput = blindCast(readInput(this, ""));
|
|
535
|
+
return this.#loadedInput;
|
|
410
536
|
}
|
|
411
537
|
/** This service's platform-assigned public origin — read from the stash
|
|
412
538
|
* run() populates and memoized per process. Throws if called before run()
|
|
@@ -415,26 +541,24 @@ var ComputeService = class {
|
|
|
415
541
|
this.#origin ??= readOrigin();
|
|
416
542
|
return this.#origin;
|
|
417
543
|
}
|
|
544
|
+
/** This service's resolved reserved port — the value run() routes to and
|
|
545
|
+
* exports as PORT — read the same way load() reads the stash. Defaults to
|
|
546
|
+
* 3000 when the platform binds none. */
|
|
547
|
+
port() {
|
|
548
|
+
const port = this.#processConfig().service["port"];
|
|
549
|
+
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.`);
|
|
550
|
+
return port;
|
|
551
|
+
}
|
|
418
552
|
};
|
|
419
553
|
const compute = (def) => {
|
|
420
|
-
const
|
|
421
|
-
for (const reserved of Object.keys(reservedParams)) {
|
|
422
|
-
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
423
|
-
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
424
|
-
}
|
|
425
|
-
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.`);
|
|
426
|
-
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.`);
|
|
427
|
-
const params = blindCast({
|
|
428
|
-
...userParams,
|
|
429
|
-
...reservedParams
|
|
430
|
-
});
|
|
554
|
+
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.`);
|
|
431
555
|
const instance = new ComputeService(service({
|
|
432
556
|
name: def.name,
|
|
433
557
|
extension: "@prisma/composer-prisma-cloud",
|
|
434
558
|
type: "compute",
|
|
435
559
|
inputs: def.deps,
|
|
436
|
-
params,
|
|
437
|
-
...def.
|
|
560
|
+
params: reservedParams,
|
|
561
|
+
...def.input !== void 0 ? { input: def.input } : {},
|
|
438
562
|
build: def.build,
|
|
439
563
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
440
564
|
}));
|
|
@@ -502,21 +626,21 @@ function s3Credentials(opts) {
|
|
|
502
626
|
/**
|
|
503
627
|
* The storage service authoring factory — a `compute` service routed to the
|
|
504
628
|
* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s
|
|
505
|
-
* runnable (run/load/
|
|
506
|
-
* `type` overridden to `'s3-store'`: nothing at runtime keys off
|
|
507
|
-
* serializer keys off the deployment address and each param's
|
|
508
|
-
* `load`/`
|
|
509
|
-
* sees the override and routes to the
|
|
510
|
-
* return type is compute's exactly
|
|
511
|
-
* storage module (D4b) calls this
|
|
512
|
-
*
|
|
629
|
+
* runnable (run/load/input, deps, input schema, build, expose) with the
|
|
630
|
+
* routing `type` overridden to `'s3-store'`: nothing at runtime keys off
|
|
631
|
+
* `type` (the serializer keys off the deployment address and each param's
|
|
632
|
+
* owner/name, and `load`/`input` off deps/the input schema), so only the
|
|
633
|
+
* deploy-time descriptor lookup sees the override and routes to the
|
|
634
|
+
* extended-output lowering (§ 5). The return type is compute's exactly
|
|
635
|
+
* (including the reserved `port` param). The storage module (D4b) calls this
|
|
636
|
+
* with its `db`/`credentials` deps and `expose: { store: s3Contract }`.
|
|
513
637
|
*
|
|
514
|
-
* `compute()`'s result is a `ComputeService` instance — its run/load/
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
638
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/input/
|
|
639
|
+
* origin methods live on the class prototype, not as the instance's own
|
|
640
|
+
* properties, so a plain object spread (`{ ...node }`) would silently drop
|
|
641
|
+
* them. Building a fresh `ComputeService` from the same data fields (which
|
|
642
|
+
* `{ ...node }` DOES copy — they're the node's own enumerable properties)
|
|
643
|
+
* with `type` overridden keeps every method intact.
|
|
520
644
|
*/
|
|
521
645
|
function s3StoreService(def) {
|
|
522
646
|
const instance = new ComputeService({
|
|
@@ -527,7 +651,7 @@ function s3StoreService(def) {
|
|
|
527
651
|
return instance;
|
|
528
652
|
}
|
|
529
653
|
//#endregion
|
|
530
|
-
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-
|
|
654
|
+
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-DQmgu7v3.mjs
|
|
531
655
|
const s3Contract = Object.freeze({
|
|
532
656
|
kind: "s3",
|
|
533
657
|
__cmp: {
|
|
@@ -560,21 +684,22 @@ function s3() {
|
|
|
560
684
|
/**
|
|
561
685
|
* The storage service node (like cron's `scheduler.ts` + `scheduler-service.ts`
|
|
562
686
|
* combined): `storageService` builds the `s3-store` service — a Postgres `db`
|
|
563
|
-
* dependency, a minted `credentials` dependency, a `bucket`
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
* `cronScheduler(
|
|
687
|
+
* dependency, a minted `credentials` dependency, a `bucket` input key
|
|
688
|
+
* (bound at provision by `storage()`, ADR-0042), and the `store` port exposing
|
|
689
|
+
* `s3Contract`. The deploy bootstrap runs the default-exported bare node
|
|
690
|
+
* (`main.run(address, boot)`); the real bucket comes from the stashed input
|
|
691
|
+
* document at runtime — exactly like `scheduler-service.ts` default-exports a
|
|
692
|
+
* schedule-free `cronScheduler()`.
|
|
569
693
|
*/
|
|
570
|
-
|
|
694
|
+
const storageInputSchema = type({ bucket: "string" });
|
|
695
|
+
function storageService() {
|
|
571
696
|
return s3StoreService({
|
|
572
697
|
name: "storage",
|
|
573
698
|
deps: {
|
|
574
699
|
db: postgres(),
|
|
575
700
|
credentials: s3Credentials()
|
|
576
701
|
},
|
|
577
|
-
|
|
702
|
+
input: storageInputSchema,
|
|
578
703
|
build: node({
|
|
579
704
|
module: new URL("./storage-service.mjs", import.meta.url).href,
|
|
580
705
|
entry: "./storage-entrypoint.mjs"
|
|
@@ -582,7 +707,7 @@ function storageService(opts) {
|
|
|
582
707
|
expose: { store: s3Contract }
|
|
583
708
|
});
|
|
584
709
|
}
|
|
585
|
-
storageService(
|
|
710
|
+
storageService();
|
|
586
711
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
587
712
|
var require_reusify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
588
713
|
function reusify(Constructor) {
|