@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,92 +1,9 @@
|
|
|
1
|
-
import { dependency, hydrateSync, number, resource, service, string } from "@prisma/composer";
|
|
1
|
+
import { dependency, hydrateSecrets, hydrateSync, number, 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 ../../
|
|
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
|
|
6
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-CJiOhF2d.mjs
|
|
90
7
|
/**
|
|
91
8
|
* Walks a node's own params, then each dependency input's connection params —
|
|
92
9
|
* the same enumeration order `configOf` uses, but carrying the raw
|
|
@@ -176,7 +93,7 @@ function coerceEnvSourcedParam(raw, d, key) {
|
|
|
176
93
|
/**
|
|
177
94
|
* Boot: read each declared param from env by its key, reverse the param's own
|
|
178
95
|
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
179
|
-
*
|
|
96
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
180
97
|
*/
|
|
181
98
|
const deserialize = (node, address) => {
|
|
182
99
|
const service = {};
|
|
@@ -213,84 +130,40 @@ const stash = (node, config) => {
|
|
|
213
130
|
process.env[configKey("", d)] = encode(d.owner, value);
|
|
214
131
|
}
|
|
215
132
|
};
|
|
216
|
-
/** The
|
|
217
|
-
const
|
|
218
|
-
/** The input document row's key for a service address. */
|
|
219
|
-
const inputKey = (address) => configKey(address, {
|
|
133
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
134
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
220
135
|
owner: "service",
|
|
221
|
-
name:
|
|
136
|
+
name: slot
|
|
222
137
|
});
|
|
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
|
-
}
|
|
235
138
|
/**
|
|
236
|
-
* Boot:
|
|
237
|
-
*
|
|
238
|
-
* platform
|
|
239
|
-
*
|
|
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).
|
|
139
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
140
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
141
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
142
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
242
143
|
*/
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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).`);
|
|
255
|
-
}
|
|
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;
|
|
144
|
+
const deserializeSecrets = (node, address) => {
|
|
145
|
+
const values = {};
|
|
146
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
147
|
+
const key = secretKey(address, slot);
|
|
148
|
+
const name = process.env[key];
|
|
149
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
150
|
+
const value = process.env[name];
|
|
151
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
152
|
+
values[slot] = value;
|
|
280
153
|
}
|
|
281
|
-
return
|
|
282
|
-
}
|
|
154
|
+
return values;
|
|
155
|
+
};
|
|
283
156
|
/**
|
|
284
|
-
* run()'s setup step for
|
|
285
|
-
* address-free key, so the address-free `
|
|
286
|
-
*
|
|
287
|
-
* platform vars.
|
|
157
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
158
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
159
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
288
160
|
*/
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
161
|
+
const stashSecrets = (node, address) => {
|
|
162
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
163
|
+
const name = process.env[secretKey(address, slot)];
|
|
164
|
+
if (name === void 0) continue;
|
|
165
|
+
process.env[secretKey("", slot)] = name;
|
|
166
|
+
}
|
|
294
167
|
};
|
|
295
168
|
/**
|
|
296
169
|
* Boot: for each reserved provider param, read its address-scoped row through
|
|
@@ -355,7 +228,7 @@ function standardValidateSync(schema, value) {
|
|
|
355
228
|
return result.value;
|
|
356
229
|
}
|
|
357
230
|
//#endregion
|
|
358
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-
|
|
231
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-C1wSO3cx.mjs
|
|
359
232
|
/**
|
|
360
233
|
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
361
234
|
* brand and the ONE entry — shared by control.ts (which registers the
|
|
@@ -473,24 +346,20 @@ Object.freeze({
|
|
|
473
346
|
});
|
|
474
347
|
const reservedParams = { port: number({ default: 3e3 }) };
|
|
475
348
|
/**
|
|
476
|
-
* A Prisma Compute service — declarations only (deps +
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
349
|
+
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
350
|
+
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
351
|
+
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
352
|
+
* one fails at authoring, the same way a colliding dependency name does.
|
|
480
353
|
*
|
|
481
354
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
482
355
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
483
|
-
* typed Config, re-emit it
|
|
484
|
-
*
|
|
485
|
-
* · load() /
|
|
486
|
-
* load() hydrates + memoizes the deps,
|
|
487
|
-
*
|
|
488
|
-
* platform var, validates with the declared schema, and memoizes (ADR-0042).
|
|
356
|
+
* typed Config, re-emit it under address-free process-local stash keys,
|
|
357
|
+
* then call boot() to start the app's entry.
|
|
358
|
+
* · load() / config() — called from inside the app's entry: read the stash;
|
|
359
|
+
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
360
|
+
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
489
361
|
* · origin() — this service's platform-assigned public origin, read from the
|
|
490
362
|
* stash `run()` populates; memoized per process.
|
|
491
|
-
* · port() — this service's resolved reserved port (the value `run()` routes
|
|
492
|
-
* to and exports as PORT), read from that same stash via #processConfig();
|
|
493
|
-
* defaults to 3000 when the platform binds none.
|
|
494
363
|
*
|
|
495
364
|
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
496
365
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
@@ -500,7 +369,8 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
500
369
|
var ComputeService = class {
|
|
501
370
|
#resolved;
|
|
502
371
|
#loadedDeps;
|
|
503
|
-
#
|
|
372
|
+
#loadedParams;
|
|
373
|
+
#loadedSecrets;
|
|
504
374
|
#origin;
|
|
505
375
|
constructor(node) {
|
|
506
376
|
Object.assign(this, node);
|
|
@@ -513,7 +383,7 @@ var ComputeService = class {
|
|
|
513
383
|
const config = deserialize(this, address);
|
|
514
384
|
stash(this, config);
|
|
515
385
|
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
516
|
-
|
|
386
|
+
stashSecrets(this, address);
|
|
517
387
|
const port = config.service["port"];
|
|
518
388
|
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
519
389
|
return boot();
|
|
@@ -522,9 +392,13 @@ var ComputeService = class {
|
|
|
522
392
|
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
523
393
|
return this.#loadedDeps;
|
|
524
394
|
}
|
|
525
|
-
|
|
526
|
-
if (this.#
|
|
527
|
-
return this.#
|
|
395
|
+
config() {
|
|
396
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
397
|
+
return this.#loadedParams;
|
|
398
|
+
}
|
|
399
|
+
secrets() {
|
|
400
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
401
|
+
return this.#loadedSecrets;
|
|
528
402
|
}
|
|
529
403
|
/** This service's platform-assigned public origin — read from the stash
|
|
530
404
|
* run() populates and memoized per process. Throws if called before run()
|
|
@@ -533,24 +407,26 @@ var ComputeService = class {
|
|
|
533
407
|
this.#origin ??= readOrigin();
|
|
534
408
|
return this.#origin;
|
|
535
409
|
}
|
|
536
|
-
/** This service's resolved reserved port — the value run() routes to and
|
|
537
|
-
* exports as PORT — read the same way load() reads the stash. Defaults to
|
|
538
|
-
* 3000 when the platform binds none. */
|
|
539
|
-
port() {
|
|
540
|
-
const port = this.#processConfig().service["port"];
|
|
541
|
-
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.`);
|
|
542
|
-
return port;
|
|
543
|
-
}
|
|
544
410
|
};
|
|
545
411
|
const compute = (def) => {
|
|
546
|
-
|
|
412
|
+
const userParams = def.params ?? blindCast({});
|
|
413
|
+
for (const reserved of Object.keys(reservedParams)) {
|
|
414
|
+
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
415
|
+
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
416
|
+
}
|
|
417
|
+
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.`);
|
|
418
|
+
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.`);
|
|
419
|
+
const params = blindCast({
|
|
420
|
+
...userParams,
|
|
421
|
+
...reservedParams
|
|
422
|
+
});
|
|
547
423
|
const instance = new ComputeService(service({
|
|
548
424
|
name: def.name,
|
|
549
425
|
extension: "@prisma/composer-prisma-cloud",
|
|
550
426
|
type: "compute",
|
|
551
427
|
inputs: def.deps,
|
|
552
|
-
params
|
|
553
|
-
...def.
|
|
428
|
+
params,
|
|
429
|
+
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
554
430
|
build: def.build,
|
|
555
431
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
556
432
|
}));
|
|
@@ -618,21 +494,21 @@ function s3Credentials(opts) {
|
|
|
618
494
|
/**
|
|
619
495
|
* The storage service authoring factory — a `compute` service routed to the
|
|
620
496
|
* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s
|
|
621
|
-
* runnable (run/load/
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
497
|
+
* runnable (run/load/config, deps, params, build, expose) with the routing
|
|
498
|
+
* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the
|
|
499
|
+
* serializer keys off the deployment address and each param's owner/name, and
|
|
500
|
+
* `load`/`config` off deps/params), so only the deploy-time descriptor lookup
|
|
501
|
+
* sees the override and routes to the extended-output lowering (§ 5). The
|
|
502
|
+
* return type is compute's exactly (including the reserved `port` param). The
|
|
503
|
+
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
504
|
+
* param, and `expose: { store: s3Contract }`.
|
|
629
505
|
*
|
|
630
|
-
* `compute()`'s result is a `ComputeService` instance — its run/load/
|
|
631
|
-
* origin methods live on the class prototype, not as the instance's
|
|
632
|
-
* properties, so a plain object spread (`{ ...node }`) would silently
|
|
633
|
-
* them. Building a fresh `ComputeService` from the same data fields
|
|
634
|
-
* `{ ...node }` DOES copy — they're the node's own enumerable
|
|
635
|
-
* with `type` overridden keeps every method intact.
|
|
506
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
507
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
508
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
509
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
510
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
511
|
+
* properties) with `type` overridden keeps every method intact.
|
|
636
512
|
*/
|
|
637
513
|
function s3StoreService(def) {
|
|
638
514
|
const instance = new ComputeService({
|
|
@@ -643,7 +519,7 @@ function s3StoreService(def) {
|
|
|
643
519
|
return instance;
|
|
644
520
|
}
|
|
645
521
|
//#endregion
|
|
646
|
-
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-
|
|
522
|
+
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-DSaZsAC4.mjs
|
|
647
523
|
const s3Contract = Object.freeze({
|
|
648
524
|
kind: "s3",
|
|
649
525
|
__cmp: {
|
|
@@ -657,22 +533,21 @@ const s3Contract = Object.freeze({
|
|
|
657
533
|
/**
|
|
658
534
|
* The storage service node (like cron's `scheduler.ts` + `scheduler-service.ts`
|
|
659
535
|
* combined): `storageService` builds the `s3-store` service — a Postgres `db`
|
|
660
|
-
* dependency, a minted `credentials` dependency, a `bucket`
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
536
|
+
* dependency, a minted `credentials` dependency, a `bucket` param, and the
|
|
537
|
+
* `store` port exposing `s3Contract`. The deploy bootstrap runs the
|
|
538
|
+
* default-exported bare node (`main.run(address, boot)`); the real bucket comes
|
|
539
|
+
* from serialized config at runtime, so the default's `bucket` is only a
|
|
540
|
+
* placeholder — exactly like `scheduler-service.ts` default-exports
|
|
541
|
+
* `cronScheduler({ jobs: [] })`.
|
|
666
542
|
*/
|
|
667
|
-
|
|
668
|
-
function storageService() {
|
|
543
|
+
function storageService(opts) {
|
|
669
544
|
return s3StoreService({
|
|
670
545
|
name: "storage",
|
|
671
546
|
deps: {
|
|
672
547
|
db: postgres(),
|
|
673
548
|
credentials: s3Credentials()
|
|
674
549
|
},
|
|
675
|
-
|
|
550
|
+
params: { bucket: string({ default: opts.bucket }) },
|
|
676
551
|
build: node({
|
|
677
552
|
module: new URL("./storage-service.mjs", import.meta.url).href,
|
|
678
553
|
entry: "./storage-entrypoint.mjs"
|
|
@@ -680,7 +555,7 @@ function storageService() {
|
|
|
680
555
|
expose: { store: s3Contract }
|
|
681
556
|
});
|
|
682
557
|
}
|
|
683
|
-
var storage_service_default = storageService();
|
|
558
|
+
var storage_service_default = storageService({ bucket: "storage" });
|
|
684
559
|
//#endregion
|
|
685
560
|
export { storage_service_default as default, storageService };
|
|
686
561
|
|