@prisma/composer-prisma-cloud 0.1.0-dev.9 → 0.2.0-dev.1
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 +40 -34
- package/dist/control.mjs +512 -105
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +54 -4
- package/dist/cron/index.mjs +154 -42
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +459 -306
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +154 -42
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/index.d.mts +76 -6
- package/dist/index.mjs +108 -45
- package/dist/index.mjs.map +1 -1
- package/dist/{prisma-next-qPB8_Az6.mjs → prisma-next-DlU01kXJ-2sP5mQb6.mjs} +3 -3
- package/dist/prisma-next-DlU01kXJ-2sP5mQb6.mjs.map +1 -0
- package/dist/prisma-next.d.mts +1 -1
- package/dist/prisma-next.mjs +1 -1
- package/dist/{provisioned-edges-DIQAR4q4-Bn9op-JG.mjs → provisioned-edges-B_XS1Mz--NFJgcXK7.mjs} +66 -6
- package/dist/provisioned-edges-B_XS1Mz--NFJgcXK7.mjs.map +1 -0
- package/dist/{serializer-CX4VYdf_-KKGoAxfx.mjs → serializer-D8_84XWO-DA2B6YbX.mjs} +33 -3
- package/dist/serializer-D8_84XWO-DA2B6YbX.mjs.map +1 -0
- package/dist/storage/index.d.mts +62 -14
- package/dist/storage/index.mjs +168 -48
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +361 -239
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +168 -48
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/storage/testing.mjs.map +1 -1
- package/dist/streams/index.d.mts +62 -89
- package/dist/streams/index.mjs +169 -49
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +361 -239
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +168 -48
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/streams/testing.d.mts +1 -1
- package/dist/streams/testing.mjs.map +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +14 -14
- package/dist/prisma-next-qPB8_Az6.mjs.map +0 -1
- package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs.map +0 -1
- package/dist/serializer-CX4VYdf_-KKGoAxfx.mjs.map +0 -1
|
@@ -237,270 +237,6 @@ const nodeBuild = (opts) => ({
|
|
|
237
237
|
entry: opts.entry,
|
|
238
238
|
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
239
239
|
});
|
|
240
|
-
/**
|
|
241
|
-
* Walks a node's own params, then each dependency input's connection params —
|
|
242
|
-
* the same enumeration order `configOf` uses, but carrying the raw
|
|
243
|
-
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
244
|
-
* projection.
|
|
245
|
-
*/
|
|
246
|
-
function paramEntries(node) {
|
|
247
|
-
const entries = [];
|
|
248
|
-
for (const [input, value] of Object.entries(node.inputs)) {
|
|
249
|
-
if (typeof value !== "object" || value === null) continue;
|
|
250
|
-
const params = blindCast(value).connection.params;
|
|
251
|
-
for (const [name, param] of Object.entries(params)) entries.push({
|
|
252
|
-
owner: { input },
|
|
253
|
-
name,
|
|
254
|
-
param
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
258
|
-
owner: "service",
|
|
259
|
-
name,
|
|
260
|
-
param
|
|
261
|
-
});
|
|
262
|
-
return entries;
|
|
263
|
-
}
|
|
264
|
-
const configKey = (address, d) => {
|
|
265
|
-
const segments = address.split(".").filter((s) => s.length > 0);
|
|
266
|
-
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
267
|
-
return [
|
|
268
|
-
"COMPOSER",
|
|
269
|
-
...segments,
|
|
270
|
-
...owner,
|
|
271
|
-
d.name
|
|
272
|
-
].join("_").toUpperCase();
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
276
|
-
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
277
|
-
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
278
|
-
* would break the ordering edge Alchemy resolves through it.
|
|
279
|
-
*/
|
|
280
|
-
function encode(owner, value) {
|
|
281
|
-
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
282
|
-
}
|
|
283
|
-
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
284
|
-
function decode(owner, raw) {
|
|
285
|
-
return owner === "service" ? JSON.parse(raw) : raw;
|
|
286
|
-
}
|
|
287
|
-
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
288
|
-
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
289
|
-
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
290
|
-
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
291
|
-
const decodeParamPointer = (raw) => raw.slice(24);
|
|
292
|
-
function coerce(raw, d, key) {
|
|
293
|
-
if (!(raw !== void 0 && raw !== "")) {
|
|
294
|
-
if (d.param.default !== void 0) return d.param.default;
|
|
295
|
-
if (d.param.optional === true) return void 0;
|
|
296
|
-
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
297
|
-
}
|
|
298
|
-
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
299
|
-
try {
|
|
300
|
-
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
301
|
-
} catch (cause) {
|
|
302
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
303
|
-
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
308
|
-
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
309
|
-
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
310
|
-
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
311
|
-
* not special-cased here — it reaches the schema like any other value, so it
|
|
312
|
-
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
313
|
-
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
314
|
-
*/
|
|
315
|
-
function coerceEnvSourcedParam(raw, d, key) {
|
|
316
|
-
const platformVar = decodeParamPointer(raw);
|
|
317
|
-
const value = process.env[platformVar];
|
|
318
|
-
if (value === void 0) throw new Error(`env-sourced config param "${d.name}" (env ${key} → ${platformVar}) is unset: the platform variable "${platformVar}" was not injected — the deploy did not provision it.`);
|
|
319
|
-
try {
|
|
320
|
-
return standardValidateSync(d.param.schema, value);
|
|
321
|
-
} catch (cause) {
|
|
322
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
323
|
-
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Boot: read each declared param from env by its key, reverse the param's own
|
|
328
|
-
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
329
|
-
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
330
|
-
*/
|
|
331
|
-
const deserialize = (node, address) => {
|
|
332
|
-
const service = {};
|
|
333
|
-
const inputs = {};
|
|
334
|
-
for (const d of paramEntries(node)) {
|
|
335
|
-
const key = configKey(address, d);
|
|
336
|
-
const value = coerce(process.env[key], d, key);
|
|
337
|
-
if (d.owner === "service") service[d.name] = value;
|
|
338
|
-
else {
|
|
339
|
-
let bucket = inputs[d.owner.input];
|
|
340
|
-
if (bucket === void 0) {
|
|
341
|
-
bucket = {};
|
|
342
|
-
inputs[d.owner.input] = bucket;
|
|
343
|
-
}
|
|
344
|
-
bucket[d.name] = value;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return {
|
|
348
|
-
service,
|
|
349
|
-
inputs
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
/**
|
|
353
|
-
* run()'s setup step: write the resolved config to the environment under
|
|
354
|
-
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
355
|
-
* reads back with no address. Uses env, not a module variable, because a
|
|
356
|
-
* framework may fork worker processes that inherit env but not memory.
|
|
357
|
-
* Writes only these keys; nothing else is touched.
|
|
358
|
-
*/
|
|
359
|
-
const stash = (node, config) => {
|
|
360
|
-
for (const d of paramEntries(node)) {
|
|
361
|
-
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
362
|
-
if (value === void 0) continue;
|
|
363
|
-
process.env[configKey("", d)] = encode(d.owner, value);
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
367
|
-
const secretKey = (address, slot) => configKey(address, {
|
|
368
|
-
owner: "service",
|
|
369
|
-
name: slot
|
|
370
|
-
});
|
|
371
|
-
/**
|
|
372
|
-
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
373
|
-
* pointer key (the platform NAME), then read that platform var. A missing
|
|
374
|
-
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
375
|
-
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
376
|
-
*/
|
|
377
|
-
const deserializeSecrets = (node, address) => {
|
|
378
|
-
const values = {};
|
|
379
|
-
for (const slot of Object.keys(node.secretSlots)) {
|
|
380
|
-
const key = secretKey(address, slot);
|
|
381
|
-
const name = process.env[key];
|
|
382
|
-
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
383
|
-
const value = process.env[name];
|
|
384
|
-
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
385
|
-
values[slot] = value;
|
|
386
|
-
}
|
|
387
|
-
return values;
|
|
388
|
-
};
|
|
389
|
-
/**
|
|
390
|
-
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
391
|
-
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
392
|
-
* identically. Never the value — the value stays only in the platform var.
|
|
393
|
-
*/
|
|
394
|
-
const stashSecrets = (node, address) => {
|
|
395
|
-
for (const slot of Object.keys(node.secretSlots)) {
|
|
396
|
-
const name = process.env[secretKey(address, slot)];
|
|
397
|
-
if (name === void 0) continue;
|
|
398
|
-
process.env[secretKey("", slot)] = name;
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
/**
|
|
402
|
-
* Boot: for each reserved provider param, read its address-scoped row through
|
|
403
|
-
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
404
|
-
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
405
|
-
* declaration space. A param is declared optional here unconditionally: an
|
|
406
|
-
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
407
|
-
* registered value for this deploy), never a boot failure, so nothing is
|
|
408
|
-
* stashed and the runtime reader that owns this slot falls back to its own
|
|
409
|
-
* pass-through behavior.
|
|
410
|
-
*/
|
|
411
|
-
function stashProviderParams(entries, address) {
|
|
412
|
-
for (const entry of entries) {
|
|
413
|
-
const d = {
|
|
414
|
-
owner: "service",
|
|
415
|
-
name: entry.name,
|
|
416
|
-
param: {
|
|
417
|
-
schema: entry.schema,
|
|
418
|
-
optional: true
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
const key = configKey(address, d);
|
|
422
|
-
const value = coerce(process.env[key], d, key);
|
|
423
|
-
if (value === void 0) continue;
|
|
424
|
-
process.env[configKey("", d)] = encode("service", value);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
428
|
-
function standardValidateSync(schema, value) {
|
|
429
|
-
const result = schema["~standard"].validate(value);
|
|
430
|
-
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
431
|
-
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
432
|
-
return result.value;
|
|
433
|
-
}
|
|
434
|
-
async function standardValidate(schema, value) {
|
|
435
|
-
const result = await schema["~standard"].validate(value);
|
|
436
|
-
if (result.issues !== void 0) throw new Error(`Schema validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
437
|
-
return result.value;
|
|
438
|
-
}
|
|
439
|
-
/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */
|
|
440
|
-
function methodUrl(base, method) {
|
|
441
|
-
const normalizedBase = base.endsWith("/") ? base : `${base}/`;
|
|
442
|
-
return new URL(`rpc/${method}`, normalizedBase).toString();
|
|
443
|
-
}
|
|
444
|
-
/** The server's `{ error }` body, if the response has one — undefined otherwise. */
|
|
445
|
-
async function errorDetail(res) {
|
|
446
|
-
try {
|
|
447
|
-
const body = await res.json();
|
|
448
|
-
return typeof body === "object" && body !== null && "error" in body ? String(body.error) : void 0;
|
|
449
|
-
} catch {
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
function makeClient(contract, url, opts) {
|
|
454
|
-
const send = opts?.fetch ?? fetch;
|
|
455
|
-
const headers = { "content-type": "application/json" };
|
|
456
|
-
if (opts?.serviceKey !== void 0) headers["Authorization"] = `Bearer ${opts.serviceKey}`;
|
|
457
|
-
const client = {};
|
|
458
|
-
for (const [method, schemas] of Object.entries(blindCast(contract.__cmp))) client[method] = async (input) => {
|
|
459
|
-
const res = await send(new Request(methodUrl(url, method), {
|
|
460
|
-
method: "POST",
|
|
461
|
-
headers,
|
|
462
|
-
body: JSON.stringify(input)
|
|
463
|
-
}));
|
|
464
|
-
if (!res.ok) {
|
|
465
|
-
const detail = await errorDetail(res);
|
|
466
|
-
throw new Error(`RPC call "${method}" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : ""));
|
|
467
|
-
}
|
|
468
|
-
return standardValidate(schemas.output, await res.json());
|
|
469
|
-
};
|
|
470
|
-
return blindCast(client);
|
|
471
|
-
}
|
|
472
|
-
function contract(fns) {
|
|
473
|
-
const value = {
|
|
474
|
-
kind: "rpc",
|
|
475
|
-
__cmp: fns,
|
|
476
|
-
satisfies: (required) => value === required
|
|
477
|
-
};
|
|
478
|
-
return Object.freeze(value);
|
|
479
|
-
}
|
|
480
|
-
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
481
|
-
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
482
|
-
/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */
|
|
483
|
-
const perBindingToken = () => provisionNeed(RPC_PEER_KEY);
|
|
484
|
-
function rpc(arg) {
|
|
485
|
-
if (!isRpcContract(arg)) return arg;
|
|
486
|
-
return dependency({
|
|
487
|
-
type: "rpc",
|
|
488
|
-
connection: {
|
|
489
|
-
params: {
|
|
490
|
-
url: string$1(),
|
|
491
|
-
serviceKey: string$1({
|
|
492
|
-
optional: true,
|
|
493
|
-
provision: perBindingToken()
|
|
494
|
-
})
|
|
495
|
-
},
|
|
496
|
-
hydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })
|
|
497
|
-
},
|
|
498
|
-
required: arg
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
function isRpcContract(value) {
|
|
502
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "rpc" && "__cmp" in value && "satisfies" in value;
|
|
503
|
-
}
|
|
504
240
|
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
505
241
|
/**
|
|
506
242
|
* Splits an array into two arrays based on the result of a predicate
|
|
@@ -7620,9 +7356,375 @@ ark.schema;
|
|
|
7620
7356
|
ark.define;
|
|
7621
7357
|
ark.declare;
|
|
7622
7358
|
/**
|
|
7623
|
-
*
|
|
7624
|
-
*
|
|
7625
|
-
*
|
|
7359
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
7360
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
7361
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
7362
|
+
* projection.
|
|
7363
|
+
*/
|
|
7364
|
+
function paramEntries(node) {
|
|
7365
|
+
const entries = [];
|
|
7366
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
7367
|
+
if (typeof value !== "object" || value === null) continue;
|
|
7368
|
+
const params = blindCast(value).connection.params;
|
|
7369
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
7370
|
+
owner: { input },
|
|
7371
|
+
name,
|
|
7372
|
+
param
|
|
7373
|
+
});
|
|
7374
|
+
}
|
|
7375
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
7376
|
+
owner: "service",
|
|
7377
|
+
name,
|
|
7378
|
+
param
|
|
7379
|
+
});
|
|
7380
|
+
return entries;
|
|
7381
|
+
}
|
|
7382
|
+
const configKey = (address, d) => {
|
|
7383
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
7384
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
7385
|
+
return [
|
|
7386
|
+
"COMPOSER",
|
|
7387
|
+
...segments,
|
|
7388
|
+
...owner,
|
|
7389
|
+
d.name
|
|
7390
|
+
].join("_").toUpperCase();
|
|
7391
|
+
};
|
|
7392
|
+
/**
|
|
7393
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
7394
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
7395
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
7396
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
7397
|
+
*/
|
|
7398
|
+
function encode(owner, value) {
|
|
7399
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
7400
|
+
}
|
|
7401
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
7402
|
+
function decode(owner, raw) {
|
|
7403
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
7404
|
+
}
|
|
7405
|
+
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
7406
|
+
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
7407
|
+
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
7408
|
+
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
7409
|
+
const decodeParamPointer = (raw) => raw.slice(24);
|
|
7410
|
+
function coerce(raw, d, key) {
|
|
7411
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
7412
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
7413
|
+
if (d.param.optional === true) return void 0;
|
|
7414
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
7415
|
+
}
|
|
7416
|
+
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
7417
|
+
try {
|
|
7418
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
7419
|
+
} catch (cause) {
|
|
7420
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7421
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7424
|
+
/**
|
|
7425
|
+
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
7426
|
+
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
7427
|
+
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
7428
|
+
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
7429
|
+
* not special-cased here — it reaches the schema like any other value, so it
|
|
7430
|
+
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
7431
|
+
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
7432
|
+
*/
|
|
7433
|
+
function coerceEnvSourcedParam(raw, d, key) {
|
|
7434
|
+
const platformVar = decodeParamPointer(raw);
|
|
7435
|
+
const value = process.env[platformVar];
|
|
7436
|
+
if (value === void 0) throw new Error(`env-sourced config param "${d.name}" (env ${key} → ${platformVar}) is unset: the platform variable "${platformVar}" was not injected — the deploy did not provision it.`);
|
|
7437
|
+
try {
|
|
7438
|
+
return standardValidateSync(d.param.schema, value);
|
|
7439
|
+
} catch (cause) {
|
|
7440
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7441
|
+
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7444
|
+
/**
|
|
7445
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
7446
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
7447
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
7448
|
+
*/
|
|
7449
|
+
const deserialize = (node, address) => {
|
|
7450
|
+
const service = {};
|
|
7451
|
+
const inputs = {};
|
|
7452
|
+
for (const d of paramEntries(node)) {
|
|
7453
|
+
const key = configKey(address, d);
|
|
7454
|
+
const value = coerce(process.env[key], d, key);
|
|
7455
|
+
if (d.owner === "service") service[d.name] = value;
|
|
7456
|
+
else {
|
|
7457
|
+
let bucket = inputs[d.owner.input];
|
|
7458
|
+
if (bucket === void 0) {
|
|
7459
|
+
bucket = {};
|
|
7460
|
+
inputs[d.owner.input] = bucket;
|
|
7461
|
+
}
|
|
7462
|
+
bucket[d.name] = value;
|
|
7463
|
+
}
|
|
7464
|
+
}
|
|
7465
|
+
return {
|
|
7466
|
+
service,
|
|
7467
|
+
inputs
|
|
7468
|
+
};
|
|
7469
|
+
};
|
|
7470
|
+
/**
|
|
7471
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
7472
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
7473
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
7474
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
7475
|
+
* Writes only these keys; nothing else is touched.
|
|
7476
|
+
*/
|
|
7477
|
+
const stash = (node, config) => {
|
|
7478
|
+
for (const d of paramEntries(node)) {
|
|
7479
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
7480
|
+
if (value === void 0) continue;
|
|
7481
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
7482
|
+
}
|
|
7483
|
+
};
|
|
7484
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
7485
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
7486
|
+
owner: "service",
|
|
7487
|
+
name: slot
|
|
7488
|
+
});
|
|
7489
|
+
/**
|
|
7490
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
7491
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
7492
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
7493
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
7494
|
+
*/
|
|
7495
|
+
const deserializeSecrets = (node, address) => {
|
|
7496
|
+
const values = {};
|
|
7497
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
7498
|
+
const key = secretKey(address, slot);
|
|
7499
|
+
const name = process.env[key];
|
|
7500
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
7501
|
+
const value = process.env[name];
|
|
7502
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
7503
|
+
values[slot] = value;
|
|
7504
|
+
}
|
|
7505
|
+
return values;
|
|
7506
|
+
};
|
|
7507
|
+
/**
|
|
7508
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
7509
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
7510
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
7511
|
+
*/
|
|
7512
|
+
const stashSecrets = (node, address) => {
|
|
7513
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
7514
|
+
const name = process.env[secretKey(address, slot)];
|
|
7515
|
+
if (name === void 0) continue;
|
|
7516
|
+
process.env[secretKey("", slot)] = name;
|
|
7517
|
+
}
|
|
7518
|
+
};
|
|
7519
|
+
/**
|
|
7520
|
+
* Boot: for each reserved provider param, read its address-scoped row through
|
|
7521
|
+
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
7522
|
+
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
7523
|
+
* declaration space. A param is declared optional here unconditionally: an
|
|
7524
|
+
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
7525
|
+
* registered value for this deploy), never a boot failure, so nothing is
|
|
7526
|
+
* stashed and the runtime reader that owns this slot falls back to its own
|
|
7527
|
+
* pass-through behavior.
|
|
7528
|
+
*/
|
|
7529
|
+
function stashProviderParams(entries, address) {
|
|
7530
|
+
for (const entry of entries) {
|
|
7531
|
+
const d = {
|
|
7532
|
+
owner: "service",
|
|
7533
|
+
name: entry.name,
|
|
7534
|
+
param: {
|
|
7535
|
+
schema: entry.schema,
|
|
7536
|
+
optional: true
|
|
7537
|
+
}
|
|
7538
|
+
};
|
|
7539
|
+
const key = configKey(address, d);
|
|
7540
|
+
const value = coerce(process.env[key], d, key);
|
|
7541
|
+
if (value === void 0) continue;
|
|
7542
|
+
process.env[configKey("", d)] = encode("service", value);
|
|
7543
|
+
}
|
|
7544
|
+
}
|
|
7545
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
7546
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
7547
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
7548
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
7549
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
7550
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
7551
|
+
* their other `COMPOSER_*` rows. */
|
|
7552
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
7553
|
+
/**
|
|
7554
|
+
* Reads this service's origin back out of the address-free stash
|
|
7555
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
7556
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
7557
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
7558
|
+
* before run().
|
|
7559
|
+
*/
|
|
7560
|
+
function readOrigin() {
|
|
7561
|
+
const d = {
|
|
7562
|
+
owner: "service",
|
|
7563
|
+
name: ORIGIN_KEY_NAME,
|
|
7564
|
+
param: {
|
|
7565
|
+
schema: type("string"),
|
|
7566
|
+
optional: true
|
|
7567
|
+
}
|
|
7568
|
+
};
|
|
7569
|
+
const key = configKey("", d);
|
|
7570
|
+
const value = coerce(process.env[key], d, key);
|
|
7571
|
+
if (value === void 0) throw new Error("this service's origin is not available (env COMPOSER_ORIGIN is unset) — a deployed environment writes it automatically; a local harness must supply it like any other config value (set COMPOSER_ORIGIN to the JSON-encoded origin URL).");
|
|
7572
|
+
return blindCast(value);
|
|
7573
|
+
}
|
|
7574
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
7575
|
+
function standardValidateSync(schema, value) {
|
|
7576
|
+
const result = schema["~standard"].validate(value);
|
|
7577
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
7578
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
7579
|
+
return result.value;
|
|
7580
|
+
}
|
|
7581
|
+
/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */
|
|
7582
|
+
const RETRY = {
|
|
7583
|
+
initialDelayMs: 250,
|
|
7584
|
+
multiplier: 2,
|
|
7585
|
+
maxDelayMs: 5e3,
|
|
7586
|
+
maxRetries: 5
|
|
7587
|
+
};
|
|
7588
|
+
const IDEMPOTENCY_KEY_HEADER$1 = "Idempotency-Key";
|
|
7589
|
+
function sleep(ms) {
|
|
7590
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7591
|
+
}
|
|
7592
|
+
/** Whether a non-OK response is safe to retry: 429 or any 5xx, never another 4xx. */
|
|
7593
|
+
function isRetryableStatus(status) {
|
|
7594
|
+
return status === 429 || status >= 500;
|
|
7595
|
+
}
|
|
7596
|
+
/** The server's `{ error }` body, if the response has one — undefined otherwise. */
|
|
7597
|
+
async function errorDetail(res) {
|
|
7598
|
+
try {
|
|
7599
|
+
const body = await res.json();
|
|
7600
|
+
return typeof body === "object" && body !== null && "error" in body ? String(body.error) : void 0;
|
|
7601
|
+
} catch {
|
|
7602
|
+
return;
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */
|
|
7606
|
+
function methodUrl(base, method) {
|
|
7607
|
+
const normalizedBase = base.endsWith("/") ? base : `${base}/`;
|
|
7608
|
+
return new URL(`rpc/${method}`, normalizedBase).toString();
|
|
7609
|
+
}
|
|
7610
|
+
/**
|
|
7611
|
+
* Sends one call over `send`, retrying a thrown error, 429, or 5xx with
|
|
7612
|
+
* full-jitter backoff. `buildRequest` runs per attempt but carries the same
|
|
7613
|
+
* idempotency key each time — only the transport call repeats, not the key.
|
|
7614
|
+
*/
|
|
7615
|
+
async function callWithRetry(send, buildRequest, method) {
|
|
7616
|
+
let delay = RETRY.initialDelayMs;
|
|
7617
|
+
let retries = 0;
|
|
7618
|
+
for (;;) {
|
|
7619
|
+
let res;
|
|
7620
|
+
try {
|
|
7621
|
+
res = await send(buildRequest());
|
|
7622
|
+
} catch (err) {
|
|
7623
|
+
if (retries >= RETRY.maxRetries) throw err;
|
|
7624
|
+
retries += 1;
|
|
7625
|
+
await sleep(Math.random() * delay);
|
|
7626
|
+
delay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);
|
|
7627
|
+
continue;
|
|
7628
|
+
}
|
|
7629
|
+
if (res.ok) return res.json();
|
|
7630
|
+
if (!isRetryableStatus(res.status) || retries >= RETRY.maxRetries) {
|
|
7631
|
+
const detail = await errorDetail(res);
|
|
7632
|
+
throw new Error(`RPC call "${method}" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : ""));
|
|
7633
|
+
}
|
|
7634
|
+
retries += 1;
|
|
7635
|
+
await sleep(Math.random() * delay);
|
|
7636
|
+
delay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7639
|
+
function makeClient(contract, url, opts) {
|
|
7640
|
+
const send = opts?.fetch ?? fetch;
|
|
7641
|
+
const baseHeaders = { "content-type": "application/json" };
|
|
7642
|
+
if (opts?.serviceKey !== void 0) baseHeaders["Authorization"] = `Bearer ${opts.serviceKey}`;
|
|
7643
|
+
const client = {};
|
|
7644
|
+
for (const method of Object.keys(contract.__cmp)) client[method] = async (input) => {
|
|
7645
|
+
const idempotencyKey = crypto.randomUUID();
|
|
7646
|
+
const body = JSON.stringify(input);
|
|
7647
|
+
return callWithRetry(send, () => new Request(methodUrl(url, method), {
|
|
7648
|
+
method: "POST",
|
|
7649
|
+
headers: {
|
|
7650
|
+
...baseHeaders,
|
|
7651
|
+
[IDEMPOTENCY_KEY_HEADER$1]: idempotencyKey
|
|
7652
|
+
},
|
|
7653
|
+
body
|
|
7654
|
+
}), method);
|
|
7655
|
+
};
|
|
7656
|
+
return blindCast(client);
|
|
7657
|
+
}
|
|
7658
|
+
function contract(fns) {
|
|
7659
|
+
const value = {
|
|
7660
|
+
kind: "rpc",
|
|
7661
|
+
__cmp: fns,
|
|
7662
|
+
satisfies: (required) => value === required
|
|
7663
|
+
};
|
|
7664
|
+
return Object.freeze(value);
|
|
7665
|
+
}
|
|
7666
|
+
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
7667
|
+
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
7668
|
+
/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */
|
|
7669
|
+
const perBindingToken = () => provisionNeed(RPC_PEER_KEY);
|
|
7670
|
+
function rpc(arg) {
|
|
7671
|
+
if (!isRpcContract(arg)) return arg;
|
|
7672
|
+
return dependency({
|
|
7673
|
+
type: "rpc",
|
|
7674
|
+
connection: {
|
|
7675
|
+
params: {
|
|
7676
|
+
url: string$1(),
|
|
7677
|
+
serviceKey: string$1({
|
|
7678
|
+
optional: true,
|
|
7679
|
+
provision: perBindingToken()
|
|
7680
|
+
})
|
|
7681
|
+
},
|
|
7682
|
+
hydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })
|
|
7683
|
+
},
|
|
7684
|
+
required: arg
|
|
7685
|
+
});
|
|
7686
|
+
}
|
|
7687
|
+
function isRpcContract(value) {
|
|
7688
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "rpc" && "__cmp" in value && "satisfies" in value;
|
|
7689
|
+
}
|
|
7690
|
+
/**
|
|
7691
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
7692
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
7693
|
+
* deploy-side value function that resolves the provisioned service's
|
|
7694
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
7695
|
+
* validates and stashes the row at boot through the generic
|
|
7696
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
7697
|
+
*
|
|
7698
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
7699
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
7700
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
7701
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
7702
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
7703
|
+
* service, exposing or not.
|
|
7704
|
+
*
|
|
7705
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
7706
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
7707
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
7708
|
+
* control-plane-only entry).
|
|
7709
|
+
*/
|
|
7710
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
7711
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
7712
|
+
/**
|
|
7713
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
7714
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
7715
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
7716
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
7717
|
+
* its deploy-side value function up by this field.
|
|
7718
|
+
*/
|
|
7719
|
+
const ORIGIN_PARAM = {
|
|
7720
|
+
name: ORIGIN_KEY_NAME,
|
|
7721
|
+
schema: type("string"),
|
|
7722
|
+
brand: SELF_ORIGIN
|
|
7723
|
+
};
|
|
7724
|
+
/**
|
|
7725
|
+
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
7726
|
+
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
7727
|
+
* by `control.ts` (which registers the deploy-side `value(refs)` that mints
|
|
7626
7728
|
* and aggregates it — see its `rpcAcceptedKeysValue`) and `compute.ts` (which
|
|
7627
7729
|
* validates and stashes it at boot), so writer and reader cannot drift.
|
|
7628
7730
|
* Finding the edges themselves is `provisioned-edges.ts`'s generic,
|
|
@@ -7663,14 +7765,50 @@ configKey("", {
|
|
|
7663
7765
|
owner: "service",
|
|
7664
7766
|
name: STREAMS_API_KEY_PARAM.name
|
|
7665
7767
|
});
|
|
7666
|
-
|
|
7768
|
+
/**
|
|
7769
|
+
* The list of provider-side reserved params the boot path validates and
|
|
7770
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
7771
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
7772
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
7773
|
+
*
|
|
7774
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
7775
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
7776
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
7777
|
+
* must never import it. This module is reachable from a user service's
|
|
7778
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
7779
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
7780
|
+
*
|
|
7781
|
+
* This is the single source of which reserved provider params exist:
|
|
7782
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
7783
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
7784
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
7785
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
7786
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
7787
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
7788
|
+
* deploy no longer names its own param set independently.
|
|
7789
|
+
*/
|
|
7790
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
7791
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
7792
|
+
STREAMS_API_KEY_PARAM,
|
|
7793
|
+
ORIGIN_PARAM
|
|
7794
|
+
];
|
|
7795
|
+
Object.freeze({
|
|
7796
|
+
kind: "s3",
|
|
7797
|
+
__cmp: {
|
|
7798
|
+
url: "",
|
|
7799
|
+
bucket: "",
|
|
7800
|
+
accessKeyId: "",
|
|
7801
|
+
secretAccessKey: ""
|
|
7802
|
+
},
|
|
7803
|
+
satisfies: (required) => required.kind === "s3"
|
|
7804
|
+
});
|
|
7667
7805
|
const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
7668
7806
|
/**
|
|
7669
7807
|
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
7670
7808
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
7671
7809
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
7672
7810
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
7673
|
-
*
|
|
7811
|
+
*
|
|
7674
7812
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
7675
7813
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
7676
7814
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -7678,23 +7816,69 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
7678
7816
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
7679
7817
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
7680
7818
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
7819
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
7820
|
+
* stash `run()` populates; memoized per process.
|
|
7681
7821
|
*
|
|
7682
|
-
*
|
|
7822
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
7683
7823
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
7684
7824
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
7685
|
-
* deploy time; nodes are pure data.
|
|
7825
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
7686
7826
|
*/
|
|
7827
|
+
var ComputeService = class {
|
|
7828
|
+
#resolved;
|
|
7829
|
+
#loadedDeps;
|
|
7830
|
+
#loadedParams;
|
|
7831
|
+
#loadedSecrets;
|
|
7832
|
+
#origin;
|
|
7833
|
+
constructor(node) {
|
|
7834
|
+
Object.assign(this, node);
|
|
7835
|
+
}
|
|
7836
|
+
#processConfig() {
|
|
7837
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
7838
|
+
return this.#resolved;
|
|
7839
|
+
}
|
|
7840
|
+
async run(address, boot) {
|
|
7841
|
+
const config = deserialize(this, address);
|
|
7842
|
+
stash(this, config);
|
|
7843
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
7844
|
+
stashSecrets(this, address);
|
|
7845
|
+
const port = config.service["port"];
|
|
7846
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
7847
|
+
return boot();
|
|
7848
|
+
}
|
|
7849
|
+
load() {
|
|
7850
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
7851
|
+
return this.#loadedDeps;
|
|
7852
|
+
}
|
|
7853
|
+
config() {
|
|
7854
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
7855
|
+
return this.#loadedParams;
|
|
7856
|
+
}
|
|
7857
|
+
secrets() {
|
|
7858
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
7859
|
+
return this.#loadedSecrets;
|
|
7860
|
+
}
|
|
7861
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
7862
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
7863
|
+
* has stashed it (readOrigin's pinned message). */
|
|
7864
|
+
origin() {
|
|
7865
|
+
this.#origin ??= readOrigin();
|
|
7866
|
+
return this.#origin;
|
|
7867
|
+
}
|
|
7868
|
+
};
|
|
7687
7869
|
const compute = (def) => {
|
|
7688
7870
|
const userParams = def.params ?? blindCast({});
|
|
7689
7871
|
for (const reserved of Object.keys(reservedParams)) {
|
|
7690
7872
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
7691
7873
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
7692
7874
|
}
|
|
7875
|
+
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.`);
|
|
7876
|
+
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.`);
|
|
7693
7877
|
const params = blindCast({
|
|
7694
7878
|
...userParams,
|
|
7695
7879
|
...reservedParams
|
|
7696
7880
|
});
|
|
7697
|
-
const
|
|
7881
|
+
const instance = new ComputeService(service$1({
|
|
7698
7882
|
name: def.name,
|
|
7699
7883
|
extension: "@prisma/composer-prisma-cloud",
|
|
7700
7884
|
type: "compute",
|
|
@@ -7703,40 +7887,9 @@ const compute = (def) => {
|
|
|
7703
7887
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
7704
7888
|
build: def.build,
|
|
7705
7889
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
7706
|
-
});
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
let loadedParams;
|
|
7710
|
-
let loadedSecrets;
|
|
7711
|
-
function processConfig() {
|
|
7712
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
7713
|
-
return resolved;
|
|
7714
|
-
}
|
|
7715
|
-
const runnable = {
|
|
7716
|
-
...node,
|
|
7717
|
-
async run(address, boot) {
|
|
7718
|
-
const config = deserialize(node, address);
|
|
7719
|
-
stash(node, config);
|
|
7720
|
-
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
7721
|
-
stashSecrets(node, address);
|
|
7722
|
-
const port = config.service["port"];
|
|
7723
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
7724
|
-
return boot();
|
|
7725
|
-
},
|
|
7726
|
-
load() {
|
|
7727
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
7728
|
-
return loadedDeps;
|
|
7729
|
-
},
|
|
7730
|
-
config() {
|
|
7731
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
7732
|
-
return loadedParams;
|
|
7733
|
-
},
|
|
7734
|
-
secrets() {
|
|
7735
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
7736
|
-
return loadedSecrets;
|
|
7737
|
-
}
|
|
7738
|
-
};
|
|
7739
|
-
return Object.freeze(blindCast(runnable));
|
|
7890
|
+
}));
|
|
7891
|
+
Object.freeze(instance);
|
|
7892
|
+
return instance;
|
|
7740
7893
|
};
|
|
7741
7894
|
Object.freeze({
|
|
7742
7895
|
kind: "postgres",
|