@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
|
@@ -323,202 +323,6 @@ function hydrateSecrets(root, values) {
|
|
|
323
323
|
}
|
|
324
324
|
return blindCast(boxed);
|
|
325
325
|
}
|
|
326
|
-
/**
|
|
327
|
-
* Walks a node's own params, then each dependency input's connection params —
|
|
328
|
-
* the same enumeration order `configOf` uses, but carrying the raw
|
|
329
|
-
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
330
|
-
* projection.
|
|
331
|
-
*/
|
|
332
|
-
function paramEntries(node) {
|
|
333
|
-
const entries = [];
|
|
334
|
-
for (const [input, value] of Object.entries(node.inputs)) {
|
|
335
|
-
if (typeof value !== "object" || value === null) continue;
|
|
336
|
-
const params = blindCast(value).connection.params;
|
|
337
|
-
for (const [name, param] of Object.entries(params)) entries.push({
|
|
338
|
-
owner: { input },
|
|
339
|
-
name,
|
|
340
|
-
param
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
344
|
-
owner: "service",
|
|
345
|
-
name,
|
|
346
|
-
param
|
|
347
|
-
});
|
|
348
|
-
return entries;
|
|
349
|
-
}
|
|
350
|
-
const configKey = (address, d) => {
|
|
351
|
-
const segments = address.split(".").filter((s) => s.length > 0);
|
|
352
|
-
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
353
|
-
return [
|
|
354
|
-
"COMPOSER",
|
|
355
|
-
...segments,
|
|
356
|
-
...owner,
|
|
357
|
-
d.name
|
|
358
|
-
].join("_").toUpperCase();
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
362
|
-
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
363
|
-
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
364
|
-
* would break the ordering edge Alchemy resolves through it.
|
|
365
|
-
*/
|
|
366
|
-
function encode(owner, value) {
|
|
367
|
-
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
368
|
-
}
|
|
369
|
-
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
370
|
-
function decode(owner, raw) {
|
|
371
|
-
return owner === "service" ? JSON.parse(raw) : raw;
|
|
372
|
-
}
|
|
373
|
-
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
374
|
-
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
375
|
-
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
376
|
-
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
377
|
-
const decodeParamPointer = (raw) => raw.slice(24);
|
|
378
|
-
function coerce(raw, d, key) {
|
|
379
|
-
if (!(raw !== void 0 && raw !== "")) {
|
|
380
|
-
if (d.param.default !== void 0) return d.param.default;
|
|
381
|
-
if (d.param.optional === true) return void 0;
|
|
382
|
-
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
383
|
-
}
|
|
384
|
-
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
385
|
-
try {
|
|
386
|
-
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
387
|
-
} catch (cause) {
|
|
388
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
389
|
-
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
394
|
-
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
395
|
-
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
396
|
-
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
397
|
-
* not special-cased here — it reaches the schema like any other value, so it
|
|
398
|
-
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
399
|
-
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
400
|
-
*/
|
|
401
|
-
function coerceEnvSourcedParam(raw, d, key) {
|
|
402
|
-
const platformVar = decodeParamPointer(raw);
|
|
403
|
-
const value = process.env[platformVar];
|
|
404
|
-
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.`);
|
|
405
|
-
try {
|
|
406
|
-
return standardValidateSync(d.param.schema, value);
|
|
407
|
-
} catch (cause) {
|
|
408
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
409
|
-
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Boot: read each declared param from env by its key, reverse the param's own
|
|
414
|
-
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
415
|
-
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
416
|
-
*/
|
|
417
|
-
const deserialize = (node, address) => {
|
|
418
|
-
const service = {};
|
|
419
|
-
const inputs = {};
|
|
420
|
-
for (const d of paramEntries(node)) {
|
|
421
|
-
const key = configKey(address, d);
|
|
422
|
-
const value = coerce(process.env[key], d, key);
|
|
423
|
-
if (d.owner === "service") service[d.name] = value;
|
|
424
|
-
else {
|
|
425
|
-
let bucket = inputs[d.owner.input];
|
|
426
|
-
if (bucket === void 0) {
|
|
427
|
-
bucket = {};
|
|
428
|
-
inputs[d.owner.input] = bucket;
|
|
429
|
-
}
|
|
430
|
-
bucket[d.name] = value;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return {
|
|
434
|
-
service,
|
|
435
|
-
inputs
|
|
436
|
-
};
|
|
437
|
-
};
|
|
438
|
-
/**
|
|
439
|
-
* run()'s setup step: write the resolved config to the environment under
|
|
440
|
-
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
441
|
-
* reads back with no address. Uses env, not a module variable, because a
|
|
442
|
-
* framework may fork worker processes that inherit env but not memory.
|
|
443
|
-
* Writes only these keys; nothing else is touched.
|
|
444
|
-
*/
|
|
445
|
-
const stash = (node, config) => {
|
|
446
|
-
for (const d of paramEntries(node)) {
|
|
447
|
-
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
448
|
-
if (value === void 0) continue;
|
|
449
|
-
process.env[configKey("", d)] = encode(d.owner, value);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
453
|
-
const secretKey = (address, slot) => configKey(address, {
|
|
454
|
-
owner: "service",
|
|
455
|
-
name: slot
|
|
456
|
-
});
|
|
457
|
-
/**
|
|
458
|
-
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
459
|
-
* pointer key (the platform NAME), then read that platform var. A missing
|
|
460
|
-
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
461
|
-
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
462
|
-
*/
|
|
463
|
-
const deserializeSecrets = (node, address) => {
|
|
464
|
-
const values = {};
|
|
465
|
-
for (const slot of Object.keys(node.secretSlots)) {
|
|
466
|
-
const key = secretKey(address, slot);
|
|
467
|
-
const name = process.env[key];
|
|
468
|
-
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
469
|
-
const value = process.env[name];
|
|
470
|
-
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
471
|
-
values[slot] = value;
|
|
472
|
-
}
|
|
473
|
-
return values;
|
|
474
|
-
};
|
|
475
|
-
/**
|
|
476
|
-
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
477
|
-
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
478
|
-
* identically. Never the value — the value stays only in the platform var.
|
|
479
|
-
*/
|
|
480
|
-
const stashSecrets = (node, address) => {
|
|
481
|
-
for (const slot of Object.keys(node.secretSlots)) {
|
|
482
|
-
const name = process.env[secretKey(address, slot)];
|
|
483
|
-
if (name === void 0) continue;
|
|
484
|
-
process.env[secretKey("", slot)] = name;
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
/**
|
|
488
|
-
* Boot: for each reserved provider param, read its address-scoped row through
|
|
489
|
-
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
490
|
-
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
491
|
-
* declaration space. A param is declared optional here unconditionally: an
|
|
492
|
-
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
493
|
-
* registered value for this deploy), never a boot failure, so nothing is
|
|
494
|
-
* stashed and the runtime reader that owns this slot falls back to its own
|
|
495
|
-
* pass-through behavior.
|
|
496
|
-
*/
|
|
497
|
-
function stashProviderParams(entries, address) {
|
|
498
|
-
for (const entry of entries) {
|
|
499
|
-
const d = {
|
|
500
|
-
owner: "service",
|
|
501
|
-
name: entry.name,
|
|
502
|
-
param: {
|
|
503
|
-
schema: entry.schema,
|
|
504
|
-
optional: true
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
const key = configKey(address, d);
|
|
508
|
-
const value = coerce(process.env[key], d, key);
|
|
509
|
-
if (value === void 0) continue;
|
|
510
|
-
process.env[configKey("", d)] = encode("service", value);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
514
|
-
function standardValidateSync(schema, value) {
|
|
515
|
-
const result = schema["~standard"].validate(value);
|
|
516
|
-
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
517
|
-
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
518
|
-
return result.value;
|
|
519
|
-
}
|
|
520
|
-
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
521
|
-
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
522
326
|
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
523
327
|
/**
|
|
524
328
|
* Splits an array into two arrays based on the result of a predicate
|
|
@@ -7638,6 +7442,265 @@ ark.schema;
|
|
|
7638
7442
|
ark.define;
|
|
7639
7443
|
ark.declare;
|
|
7640
7444
|
/**
|
|
7445
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
7446
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
7447
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
7448
|
+
* projection.
|
|
7449
|
+
*/
|
|
7450
|
+
function paramEntries(node) {
|
|
7451
|
+
const entries = [];
|
|
7452
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
7453
|
+
if (typeof value !== "object" || value === null) continue;
|
|
7454
|
+
const params = blindCast(value).connection.params;
|
|
7455
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
7456
|
+
owner: { input },
|
|
7457
|
+
name,
|
|
7458
|
+
param
|
|
7459
|
+
});
|
|
7460
|
+
}
|
|
7461
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
7462
|
+
owner: "service",
|
|
7463
|
+
name,
|
|
7464
|
+
param
|
|
7465
|
+
});
|
|
7466
|
+
return entries;
|
|
7467
|
+
}
|
|
7468
|
+
const configKey = (address, d) => {
|
|
7469
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
7470
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
7471
|
+
return [
|
|
7472
|
+
"COMPOSER",
|
|
7473
|
+
...segments,
|
|
7474
|
+
...owner,
|
|
7475
|
+
d.name
|
|
7476
|
+
].join("_").toUpperCase();
|
|
7477
|
+
};
|
|
7478
|
+
/**
|
|
7479
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
7480
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
7481
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
7482
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
7483
|
+
*/
|
|
7484
|
+
function encode(owner, value) {
|
|
7485
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
7486
|
+
}
|
|
7487
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
7488
|
+
function decode(owner, raw) {
|
|
7489
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
7490
|
+
}
|
|
7491
|
+
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
7492
|
+
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
7493
|
+
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
7494
|
+
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
7495
|
+
const decodeParamPointer = (raw) => raw.slice(24);
|
|
7496
|
+
function coerce(raw, d, key) {
|
|
7497
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
7498
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
7499
|
+
if (d.param.optional === true) return void 0;
|
|
7500
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
7501
|
+
}
|
|
7502
|
+
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
7503
|
+
try {
|
|
7504
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
7505
|
+
} catch (cause) {
|
|
7506
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7507
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
7508
|
+
}
|
|
7509
|
+
}
|
|
7510
|
+
/**
|
|
7511
|
+
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
7512
|
+
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
7513
|
+
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
7514
|
+
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
7515
|
+
* not special-cased here — it reaches the schema like any other value, so it
|
|
7516
|
+
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
7517
|
+
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
7518
|
+
*/
|
|
7519
|
+
function coerceEnvSourcedParam(raw, d, key) {
|
|
7520
|
+
const platformVar = decodeParamPointer(raw);
|
|
7521
|
+
const value = process.env[platformVar];
|
|
7522
|
+
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.`);
|
|
7523
|
+
try {
|
|
7524
|
+
return standardValidateSync(d.param.schema, value);
|
|
7525
|
+
} catch (cause) {
|
|
7526
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7527
|
+
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
7528
|
+
}
|
|
7529
|
+
}
|
|
7530
|
+
/**
|
|
7531
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
7532
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
7533
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
7534
|
+
*/
|
|
7535
|
+
const deserialize = (node, address) => {
|
|
7536
|
+
const service = {};
|
|
7537
|
+
const inputs = {};
|
|
7538
|
+
for (const d of paramEntries(node)) {
|
|
7539
|
+
const key = configKey(address, d);
|
|
7540
|
+
const value = coerce(process.env[key], d, key);
|
|
7541
|
+
if (d.owner === "service") service[d.name] = value;
|
|
7542
|
+
else {
|
|
7543
|
+
let bucket = inputs[d.owner.input];
|
|
7544
|
+
if (bucket === void 0) {
|
|
7545
|
+
bucket = {};
|
|
7546
|
+
inputs[d.owner.input] = bucket;
|
|
7547
|
+
}
|
|
7548
|
+
bucket[d.name] = value;
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
return {
|
|
7552
|
+
service,
|
|
7553
|
+
inputs
|
|
7554
|
+
};
|
|
7555
|
+
};
|
|
7556
|
+
/**
|
|
7557
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
7558
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
7559
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
7560
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
7561
|
+
* Writes only these keys; nothing else is touched.
|
|
7562
|
+
*/
|
|
7563
|
+
const stash = (node, config) => {
|
|
7564
|
+
for (const d of paramEntries(node)) {
|
|
7565
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
7566
|
+
if (value === void 0) continue;
|
|
7567
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
7568
|
+
}
|
|
7569
|
+
};
|
|
7570
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
7571
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
7572
|
+
owner: "service",
|
|
7573
|
+
name: slot
|
|
7574
|
+
});
|
|
7575
|
+
/**
|
|
7576
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
7577
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
7578
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
7579
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
7580
|
+
*/
|
|
7581
|
+
const deserializeSecrets = (node, address) => {
|
|
7582
|
+
const values = {};
|
|
7583
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
7584
|
+
const key = secretKey(address, slot);
|
|
7585
|
+
const name = process.env[key];
|
|
7586
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
7587
|
+
const value = process.env[name];
|
|
7588
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
7589
|
+
values[slot] = value;
|
|
7590
|
+
}
|
|
7591
|
+
return values;
|
|
7592
|
+
};
|
|
7593
|
+
/**
|
|
7594
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
7595
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
7596
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
7597
|
+
*/
|
|
7598
|
+
const stashSecrets = (node, address) => {
|
|
7599
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
7600
|
+
const name = process.env[secretKey(address, slot)];
|
|
7601
|
+
if (name === void 0) continue;
|
|
7602
|
+
process.env[secretKey("", slot)] = name;
|
|
7603
|
+
}
|
|
7604
|
+
};
|
|
7605
|
+
/**
|
|
7606
|
+
* Boot: for each reserved provider param, read its address-scoped row through
|
|
7607
|
+
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
7608
|
+
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
7609
|
+
* declaration space. A param is declared optional here unconditionally: an
|
|
7610
|
+
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
7611
|
+
* registered value for this deploy), never a boot failure, so nothing is
|
|
7612
|
+
* stashed and the runtime reader that owns this slot falls back to its own
|
|
7613
|
+
* pass-through behavior.
|
|
7614
|
+
*/
|
|
7615
|
+
function stashProviderParams(entries, address) {
|
|
7616
|
+
for (const entry of entries) {
|
|
7617
|
+
const d = {
|
|
7618
|
+
owner: "service",
|
|
7619
|
+
name: entry.name,
|
|
7620
|
+
param: {
|
|
7621
|
+
schema: entry.schema,
|
|
7622
|
+
optional: true
|
|
7623
|
+
}
|
|
7624
|
+
};
|
|
7625
|
+
const key = configKey(address, d);
|
|
7626
|
+
const value = coerce(process.env[key], d, key);
|
|
7627
|
+
if (value === void 0) continue;
|
|
7628
|
+
process.env[configKey("", d)] = encode("service", value);
|
|
7629
|
+
}
|
|
7630
|
+
}
|
|
7631
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
7632
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
7633
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
7634
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
7635
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
7636
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
7637
|
+
* their other `COMPOSER_*` rows. */
|
|
7638
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
7639
|
+
/**
|
|
7640
|
+
* Reads this service's origin back out of the address-free stash
|
|
7641
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
7642
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
7643
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
7644
|
+
* before run().
|
|
7645
|
+
*/
|
|
7646
|
+
function readOrigin() {
|
|
7647
|
+
const d = {
|
|
7648
|
+
owner: "service",
|
|
7649
|
+
name: ORIGIN_KEY_NAME,
|
|
7650
|
+
param: {
|
|
7651
|
+
schema: type("string"),
|
|
7652
|
+
optional: true
|
|
7653
|
+
}
|
|
7654
|
+
};
|
|
7655
|
+
const key = configKey("", d);
|
|
7656
|
+
const value = coerce(process.env[key], d, key);
|
|
7657
|
+
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).");
|
|
7658
|
+
return blindCast(value);
|
|
7659
|
+
}
|
|
7660
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
7661
|
+
function standardValidateSync(schema, value) {
|
|
7662
|
+
const result = schema["~standard"].validate(value);
|
|
7663
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
7664
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
7665
|
+
return result.value;
|
|
7666
|
+
}
|
|
7667
|
+
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
7668
|
+
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
7669
|
+
/**
|
|
7670
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
7671
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
7672
|
+
* deploy-side value function that resolves the provisioned service's
|
|
7673
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
7674
|
+
* validates and stashes the row at boot through the generic
|
|
7675
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
7676
|
+
*
|
|
7677
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
7678
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
7679
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
7680
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
7681
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
7682
|
+
* service, exposing or not.
|
|
7683
|
+
*
|
|
7684
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
7685
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
7686
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
7687
|
+
* control-plane-only entry).
|
|
7688
|
+
*/
|
|
7689
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
7690
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
7691
|
+
/**
|
|
7692
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
7693
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
7694
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
7695
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
7696
|
+
* its deploy-side value function up by this field.
|
|
7697
|
+
*/
|
|
7698
|
+
const ORIGIN_PARAM = {
|
|
7699
|
+
name: ORIGIN_KEY_NAME,
|
|
7700
|
+
schema: type("string"),
|
|
7701
|
+
brand: SELF_ORIGIN
|
|
7702
|
+
};
|
|
7703
|
+
/**
|
|
7641
7704
|
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
7642
7705
|
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
7643
7706
|
* by `control.ts` (which registers the deploy-side `value(refs)` that mints
|
|
@@ -7690,14 +7753,50 @@ const STREAMS_API_KEY_ENV = configKey("", {
|
|
|
7690
7753
|
owner: "service",
|
|
7691
7754
|
name: STREAMS_API_KEY_PARAM.name
|
|
7692
7755
|
});
|
|
7693
|
-
|
|
7756
|
+
/**
|
|
7757
|
+
* The list of provider-side reserved params the boot path validates and
|
|
7758
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
7759
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
7760
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
7761
|
+
*
|
|
7762
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
7763
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
7764
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
7765
|
+
* must never import it. This module is reachable from a user service's
|
|
7766
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
7767
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
7768
|
+
*
|
|
7769
|
+
* This is the single source of which reserved provider params exist:
|
|
7770
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
7771
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
7772
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
7773
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
7774
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
7775
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
7776
|
+
* deploy no longer names its own param set independently.
|
|
7777
|
+
*/
|
|
7778
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
7779
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
7780
|
+
STREAMS_API_KEY_PARAM,
|
|
7781
|
+
ORIGIN_PARAM
|
|
7782
|
+
];
|
|
7783
|
+
Object.freeze({
|
|
7784
|
+
kind: "s3",
|
|
7785
|
+
__cmp: {
|
|
7786
|
+
url: "",
|
|
7787
|
+
bucket: "",
|
|
7788
|
+
accessKeyId: "",
|
|
7789
|
+
secretAccessKey: ""
|
|
7790
|
+
},
|
|
7791
|
+
satisfies: (required) => required.kind === "s3"
|
|
7792
|
+
});
|
|
7694
7793
|
const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
7695
7794
|
/**
|
|
7696
7795
|
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
7697
7796
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
7698
7797
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
7699
7798
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
7700
|
-
*
|
|
7799
|
+
*
|
|
7701
7800
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
7702
7801
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
7703
7802
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -7705,23 +7804,69 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
7705
7804
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
7706
7805
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
7707
7806
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
7807
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
7808
|
+
* stash `run()` populates; memoized per process.
|
|
7708
7809
|
*
|
|
7709
|
-
*
|
|
7810
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
7710
7811
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
7711
7812
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
7712
|
-
* deploy time; nodes are pure data.
|
|
7813
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
7713
7814
|
*/
|
|
7815
|
+
var ComputeService = class {
|
|
7816
|
+
#resolved;
|
|
7817
|
+
#loadedDeps;
|
|
7818
|
+
#loadedParams;
|
|
7819
|
+
#loadedSecrets;
|
|
7820
|
+
#origin;
|
|
7821
|
+
constructor(node) {
|
|
7822
|
+
Object.assign(this, node);
|
|
7823
|
+
}
|
|
7824
|
+
#processConfig() {
|
|
7825
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
7826
|
+
return this.#resolved;
|
|
7827
|
+
}
|
|
7828
|
+
async run(address, boot) {
|
|
7829
|
+
const config = deserialize(this, address);
|
|
7830
|
+
stash(this, config);
|
|
7831
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
7832
|
+
stashSecrets(this, address);
|
|
7833
|
+
const port = config.service["port"];
|
|
7834
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
7835
|
+
return boot();
|
|
7836
|
+
}
|
|
7837
|
+
load() {
|
|
7838
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
7839
|
+
return this.#loadedDeps;
|
|
7840
|
+
}
|
|
7841
|
+
config() {
|
|
7842
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
7843
|
+
return this.#loadedParams;
|
|
7844
|
+
}
|
|
7845
|
+
secrets() {
|
|
7846
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
7847
|
+
return this.#loadedSecrets;
|
|
7848
|
+
}
|
|
7849
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
7850
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
7851
|
+
* has stashed it (readOrigin's pinned message). */
|
|
7852
|
+
origin() {
|
|
7853
|
+
this.#origin ??= readOrigin();
|
|
7854
|
+
return this.#origin;
|
|
7855
|
+
}
|
|
7856
|
+
};
|
|
7714
7857
|
const compute = (def) => {
|
|
7715
7858
|
const userParams = def.params ?? blindCast({});
|
|
7716
7859
|
for (const reserved of Object.keys(reservedParams)) {
|
|
7717
7860
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
7718
7861
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
7719
7862
|
}
|
|
7863
|
+
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.`);
|
|
7864
|
+
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.`);
|
|
7720
7865
|
const params = blindCast({
|
|
7721
7866
|
...userParams,
|
|
7722
7867
|
...reservedParams
|
|
7723
7868
|
});
|
|
7724
|
-
const
|
|
7869
|
+
const instance = new ComputeService(service$1({
|
|
7725
7870
|
name: def.name,
|
|
7726
7871
|
extension: "@prisma/composer-prisma-cloud",
|
|
7727
7872
|
type: "compute",
|
|
@@ -7730,40 +7875,9 @@ const compute = (def) => {
|
|
|
7730
7875
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
7731
7876
|
build: def.build,
|
|
7732
7877
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
7733
|
-
});
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
let loadedParams;
|
|
7737
|
-
let loadedSecrets;
|
|
7738
|
-
function processConfig() {
|
|
7739
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
7740
|
-
return resolved;
|
|
7741
|
-
}
|
|
7742
|
-
const runnable = {
|
|
7743
|
-
...node,
|
|
7744
|
-
async run(address, boot) {
|
|
7745
|
-
const config = deserialize(node, address);
|
|
7746
|
-
stash(node, config);
|
|
7747
|
-
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
7748
|
-
stashSecrets(node, address);
|
|
7749
|
-
const port = config.service["port"];
|
|
7750
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
7751
|
-
return boot();
|
|
7752
|
-
},
|
|
7753
|
-
load() {
|
|
7754
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
7755
|
-
return loadedDeps;
|
|
7756
|
-
},
|
|
7757
|
-
config() {
|
|
7758
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
7759
|
-
return loadedParams;
|
|
7760
|
-
},
|
|
7761
|
-
secrets() {
|
|
7762
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
7763
|
-
return loadedSecrets;
|
|
7764
|
-
}
|
|
7765
|
-
};
|
|
7766
|
-
return Object.freeze(blindCast(runnable));
|
|
7878
|
+
}));
|
|
7879
|
+
Object.freeze(instance);
|
|
7880
|
+
return instance;
|
|
7767
7881
|
};
|
|
7768
7882
|
/**
|
|
7769
7883
|
* The contract a Postgres provides — and the contract its consumers require.
|
|
@@ -7834,13 +7948,21 @@ function s3Credentials(opts) {
|
|
|
7834
7948
|
* return type is compute's exactly (including the reserved `port` param). The
|
|
7835
7949
|
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
7836
7950
|
* param, and `expose: { store: s3Contract }`.
|
|
7951
|
+
*
|
|
7952
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
7953
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
7954
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
7955
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
7956
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
7957
|
+
* properties) with `type` overridden keeps every method intact.
|
|
7837
7958
|
*/
|
|
7838
7959
|
function s3StoreService(def) {
|
|
7839
|
-
const
|
|
7840
|
-
|
|
7841
|
-
...node,
|
|
7960
|
+
const instance = new ComputeService({
|
|
7961
|
+
...compute(def),
|
|
7842
7962
|
type: "s3-store"
|
|
7843
|
-
})
|
|
7963
|
+
});
|
|
7964
|
+
Object.freeze(instance);
|
|
7965
|
+
return instance;
|
|
7844
7966
|
}
|
|
7845
7967
|
const nodeBuild = (opts) => ({
|
|
7846
7968
|
extension: "@prisma/composer/node",
|