@prisma/composer-prisma-cloud 0.2.0 → 0.3.0-dev.2
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/buckets-main.mjs +795 -0
- package/dist/buckets-main.mjs.map +1 -0
- package/dist/compute-main.mjs +559 -0
- package/dist/compute-main.mjs.map +1 -0
- package/dist/control.d.mts +34 -5
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +98 -1280
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +54 -4
- package/dist/cron/index.d.mts.map +1 -0
- package/dist/cron/index.mjs +145 -42
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +637 -529
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +145 -42
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/email/email-entrypoint.mjs +19738 -0
- package/dist/email/email-entrypoint.mjs.map +1 -0
- package/dist/email/email-service.mjs +565 -0
- package/dist/email/email-service.mjs.map +1 -0
- package/dist/email/index.d.mts +282 -0
- package/dist/email/index.d.mts.map +1 -0
- package/dist/email/index.mjs +652 -0
- package/dist/email/index.mjs.map +1 -0
- package/dist/email/testing.d.mts +22 -0
- package/dist/email/testing.d.mts.map +1 -0
- package/dist/email/testing.mjs +1321 -0
- package/dist/email/testing.mjs.map +1 -0
- package/dist/get-port-BYnpbW5H.mjs +111 -0
- package/dist/get-port-BYnpbW5H.mjs.map +1 -0
- package/dist/index.d.mts +37 -6
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +70 -45
- package/dist/index.mjs.map +1 -1
- package/dist/local-target.d.mts +12 -0
- package/dist/local-target.d.mts.map +1 -0
- package/dist/local-target.mjs +6185 -0
- package/dist/local-target.mjs.map +1 -0
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs +66 -0
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +1 -0
- package/dist/pg-connection-CadPZuEK-CF3FsSQu.mjs +79 -0
- package/dist/pg-connection-CadPZuEK-CF3FsSQu.mjs.map +1 -0
- package/dist/postgres-main.mjs +602 -0
- package/dist/postgres-main.mjs.map +1 -0
- package/dist/preflight-names-BPL-qsZF-BfoRgbgb.mjs +1252 -0
- package/dist/preflight-names-BPL-qsZF-BfoRgbgb.mjs.map +1 -0
- package/dist/{prisma-next-DlU01kXJ-2sP5mQb6.mjs → prisma-next-BvBwGCIt-DssgnctU.mjs} +21 -80
- package/dist/prisma-next-BvBwGCIt-DssgnctU.mjs.map +1 -0
- package/dist/prisma-next.d.mts +14 -5
- package/dist/prisma-next.d.mts.map +1 -0
- package/dist/prisma-next.mjs +1 -1
- package/dist/provisioned-edges-C1wSO3cx-YC5C19f9.mjs +151 -0
- package/dist/provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map +1 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +47 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +1 -0
- package/dist/segments-NpKN-46R-C_LQ2urs.mjs +1454 -0
- package/dist/segments-NpKN-46R-C_LQ2urs.mjs.map +1 -0
- package/dist/{serializer-CX4VYdf_-KKGoAxfx.mjs → serializer-CJiOhF2d-DJUjQj1i.mjs} +34 -44
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +1 -0
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +1 -0
- package/dist/storage/index.d.mts +52 -5
- package/dist/storage/index.d.mts.map +1 -0
- package/dist/storage/index.mjs +158 -47
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +370 -271
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +158 -47
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/storage/testing.d.mts +7 -6
- package/dist/storage/testing.d.mts.map +1 -0
- package/dist/storage/testing.mjs +4 -21
- package/dist/storage/testing.mjs.map +1 -1
- package/dist/streams/index.d.mts +56 -84
- package/dist/streams/index.d.mts.map +1 -0
- package/dist/streams/index.mjs +158 -47
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +366 -250
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +158 -47
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/streams/testing.d.mts.map +1 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +34 -20
- package/src/exports/control.ts +1 -0
- package/src/exports/cron.ts +1 -0
- package/src/exports/email-testing.ts +1 -0
- package/src/exports/email.ts +1 -0
- package/src/exports/index.ts +1 -0
- package/src/exports/local-target.ts +1 -0
- package/src/exports/prisma-next.ts +1 -0
- package/src/exports/storage-testing.ts +1 -0
- package/src/exports/storage.ts +1 -0
- package/src/exports/streams-testing.ts +1 -0
- package/src/exports/streams.ts +1 -0
- package/src/exports/testing.ts +1 -0
- package/dist/prisma-next-DlU01kXJ-2sP5mQb6.mjs.map +0 -1
- package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs +0 -151
- package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs.map +0 -1
- package/dist/serializer-CX4VYdf_-KKGoAxfx.mjs.map +0 -1
|
@@ -66,7 +66,7 @@ function retryTransientConnect(acquire, opts = {}) {
|
|
|
66
66
|
* Runtime engine code (`bun` SQL + `node:crypto`); NOT re-exported from the
|
|
67
67
|
* authoring barrel.
|
|
68
68
|
*/
|
|
69
|
-
const DEFAULT_MAX_KEYS
|
|
69
|
+
const DEFAULT_MAX_KEYS = 1e3;
|
|
70
70
|
function etagOf(bytes) {
|
|
71
71
|
return `"${createHash("sha256").update(bytes).digest("hex")}"`;
|
|
72
72
|
}
|
|
@@ -129,7 +129,7 @@ var PgObjectStore = class {
|
|
|
129
129
|
}
|
|
130
130
|
async list(bucket, opts = {}) {
|
|
131
131
|
const prefix = opts.prefix ?? "";
|
|
132
|
-
const maxKeys = opts.maxKeys ?? DEFAULT_MAX_KEYS
|
|
132
|
+
const maxKeys = opts.maxKeys ?? DEFAULT_MAX_KEYS;
|
|
133
133
|
const token = opts.continuationToken;
|
|
134
134
|
const limit = maxKeys + 1;
|
|
135
135
|
const keys = (token === void 0 ? await this.sql`select key from objects
|
|
@@ -170,13 +170,6 @@ async function createPgStore(url) {
|
|
|
170
170
|
)`);
|
|
171
171
|
return new PgObjectStore(sql);
|
|
172
172
|
}
|
|
173
|
-
/**
|
|
174
|
-
* AWS SigV4 verification for the S3 wire protocol (spec § 2 auth). The payload
|
|
175
|
-
* hash comes from the client — `x-amz-content-sha256` (a real hash or
|
|
176
|
-
* `UNSIGNED-PAYLOAD`) for header auth, `UNSIGNED-PAYLOAD` for presign — and is
|
|
177
|
-
* never re-hashed; the verifier trusts what was signed, like a real S3 endpoint.
|
|
178
|
-
* Runtime engine code (`node:crypto`); not re-exported from the authoring barrel.
|
|
179
|
-
*/
|
|
180
173
|
const ALGORITHM = "AWS4-HMAC-SHA256";
|
|
181
174
|
const UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
|
182
175
|
function sha256Hex(data) {
|
|
@@ -391,12 +384,12 @@ function listXml(bucket, prefix, maxKeys, result) {
|
|
|
391
384
|
const next = result.isTruncated && result.nextContinuationToken !== void 0 ? `<NextContinuationToken>${xmlEscape(result.nextContinuationToken)}</NextContinuationToken>` : "";
|
|
392
385
|
return `<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>${xmlEscape(bucket)}</Name><Prefix>${xmlEscape(prefix)}</Prefix><KeyCount>${result.keys.length}</KeyCount><MaxKeys>${maxKeys}</MaxKeys><IsTruncated>${result.isTruncated}</IsTruncated>` + contents + next + "</ListBucketResult>";
|
|
393
386
|
}
|
|
394
|
-
const DEFAULT_MAX_KEYS = 1e3;
|
|
387
|
+
const DEFAULT_MAX_KEYS$1 = 1e3;
|
|
395
388
|
async function handleList(store, bucket, url) {
|
|
396
389
|
const prefix = url.searchParams.get("prefix") ?? "";
|
|
397
390
|
const continuationToken = url.searchParams.get("continuation-token");
|
|
398
391
|
const maxKeysRaw = url.searchParams.get("max-keys");
|
|
399
|
-
const maxKeys = maxKeysRaw !== null && Number.isFinite(Number(maxKeysRaw)) ? Number(maxKeysRaw) : DEFAULT_MAX_KEYS;
|
|
392
|
+
const maxKeys = maxKeysRaw !== null && Number.isFinite(Number(maxKeysRaw)) ? Number(maxKeysRaw) : DEFAULT_MAX_KEYS$1;
|
|
400
393
|
const result = await store.list(bucket, {
|
|
401
394
|
prefix,
|
|
402
395
|
maxKeys,
|
|
@@ -490,16 +483,6 @@ function createS3Handler(opts) {
|
|
|
490
483
|
}
|
|
491
484
|
};
|
|
492
485
|
}
|
|
493
|
-
/**
|
|
494
|
-
* Boots the S3 wire protocol on `Bun.serve` — the D2 handler over any
|
|
495
|
-
* `ObjectStore`. Binds all interfaces (Compute routes external HTTP to the VM,
|
|
496
|
-
* so a loopback-only listener would be unreachable). Installs the FT-5219
|
|
497
|
-
* process guards so an idle Bun.SQL connection close surfaces as a logged
|
|
498
|
-
* error instead of crash-looping the process on scale-to-zero.
|
|
499
|
-
*
|
|
500
|
-
* Runtime engine code; NOT re-exported from the authoring barrel. The D4
|
|
501
|
-
* entrypoint reads deps via `load()` and calls this.
|
|
502
|
-
*/
|
|
503
486
|
let guardsInstalled = false;
|
|
504
487
|
/** FT-5219: keep the process alive when Bun.SQL surfaces an idle-close as an unawaited async error. Installed once. */
|
|
505
488
|
function installProcessGuards() {
|
|
@@ -578,15 +561,19 @@ function requireExtension(extension, factory) {
|
|
|
578
561
|
if (typeof extension !== "string" || extension.length === 0) throw new Error(`${factory}() requires a non-empty extension (the authoring extension's package name).`);
|
|
579
562
|
}
|
|
580
563
|
/**
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
564
|
+
* Core's grammar for every name that becomes a config-key segment —
|
|
565
|
+
* addresses, input/param/secret names: ASCII letters and digits only.
|
|
566
|
+
* Conservative by design so any target medium — POSIX env-var keys
|
|
567
|
+
* included — can uppercase and "_"-join segments without escaping.
|
|
584
568
|
*/
|
|
585
|
-
function
|
|
586
|
-
|
|
569
|
+
function isConfigKeySegment(name) {
|
|
570
|
+
return /^[A-Za-z0-9]+$/.test(name);
|
|
587
571
|
}
|
|
588
|
-
function
|
|
589
|
-
|
|
572
|
+
function requireConfigKeySegmentName(name, kind, factory) {
|
|
573
|
+
if (!isConfigKeySegment(name)) throw new Error(`${factory}() ${kind} name "${name}" must contain only ASCII letters and digits ([A-Za-z0-9]) — declared names derive deterministic config keys, uppercased and joined with "_" (an input "db"'s param "url" becomes config key "DB_URL"), so an underscore inside a name collides with that separator and any other character has no place in a config key. "${name}" would put "${name.toUpperCase()}" inside the derived key.`);
|
|
574
|
+
}
|
|
575
|
+
function requireConfigKeySegmentNames(names, kind, factory) {
|
|
576
|
+
for (const name of names) requireConfigKeySegmentName(name, kind, factory);
|
|
590
577
|
}
|
|
591
578
|
function freezeParams(params) {
|
|
592
579
|
const frozen = {};
|
|
@@ -657,9 +644,9 @@ function service$1(def) {
|
|
|
657
644
|
requireName(def.name, "service");
|
|
658
645
|
requireExtension(def.extension, "service");
|
|
659
646
|
requireType(def.type, "service");
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
647
|
+
requireConfigKeySegmentNames(Object.keys(def.inputs), "input", "service");
|
|
648
|
+
requireConfigKeySegmentNames(Object.keys(def.params), "param", "service");
|
|
649
|
+
requireConfigKeySegmentNames(Object.keys(def.secrets ?? {}), "secret", "service");
|
|
663
650
|
for (const slot of Object.keys(def.secrets ?? {})) if (Object.hasOwn(def.params, slot)) throw new Error(`service() secret slot "${slot}" collides with a param of the same name — a secret slot and a service param derive the same config key (COMPOSER_<addr>_${slot.toUpperCase()}); rename one.`);
|
|
664
651
|
return Object.freeze({
|
|
665
652
|
[NODE]: true,
|
|
@@ -681,7 +668,7 @@ function service$1(def) {
|
|
|
681
668
|
*/
|
|
682
669
|
function dependency(def) {
|
|
683
670
|
requireType(def.type, "dependency");
|
|
684
|
-
|
|
671
|
+
requireConfigKeySegmentNames(Object.keys(def.connection.params), "param", "dependency");
|
|
685
672
|
const connection = Object.freeze({
|
|
686
673
|
params: freezeParams(def.connection.params),
|
|
687
674
|
hydrate: def.connection.hydrate
|
|
@@ -797,202 +784,6 @@ const nodeBuild = (opts) => ({
|
|
|
797
784
|
entry: opts.entry,
|
|
798
785
|
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
799
786
|
});
|
|
800
|
-
/**
|
|
801
|
-
* Walks a node's own params, then each dependency input's connection params —
|
|
802
|
-
* the same enumeration order `configOf` uses, but carrying the raw
|
|
803
|
-
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
804
|
-
* projection.
|
|
805
|
-
*/
|
|
806
|
-
function paramEntries(node) {
|
|
807
|
-
const entries = [];
|
|
808
|
-
for (const [input, value] of Object.entries(node.inputs)) {
|
|
809
|
-
if (typeof value !== "object" || value === null) continue;
|
|
810
|
-
const params = blindCast(value).connection.params;
|
|
811
|
-
for (const [name, param] of Object.entries(params)) entries.push({
|
|
812
|
-
owner: { input },
|
|
813
|
-
name,
|
|
814
|
-
param
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
818
|
-
owner: "service",
|
|
819
|
-
name,
|
|
820
|
-
param
|
|
821
|
-
});
|
|
822
|
-
return entries;
|
|
823
|
-
}
|
|
824
|
-
const configKey = (address, d) => {
|
|
825
|
-
const segments = address.split(".").filter((s) => s.length > 0);
|
|
826
|
-
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
827
|
-
return [
|
|
828
|
-
"COMPOSER",
|
|
829
|
-
...segments,
|
|
830
|
-
...owner,
|
|
831
|
-
d.name
|
|
832
|
-
].join("_").toUpperCase();
|
|
833
|
-
};
|
|
834
|
-
/**
|
|
835
|
-
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
836
|
-
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
837
|
-
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
838
|
-
* would break the ordering edge Alchemy resolves through it.
|
|
839
|
-
*/
|
|
840
|
-
function encode(owner, value) {
|
|
841
|
-
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
842
|
-
}
|
|
843
|
-
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
844
|
-
function decode(owner, raw) {
|
|
845
|
-
return owner === "service" ? JSON.parse(raw) : raw;
|
|
846
|
-
}
|
|
847
|
-
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
848
|
-
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
849
|
-
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
850
|
-
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
851
|
-
const decodeParamPointer = (raw) => raw.slice(24);
|
|
852
|
-
function coerce(raw, d, key) {
|
|
853
|
-
if (!(raw !== void 0 && raw !== "")) {
|
|
854
|
-
if (d.param.default !== void 0) return d.param.default;
|
|
855
|
-
if (d.param.optional === true) return void 0;
|
|
856
|
-
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
857
|
-
}
|
|
858
|
-
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
859
|
-
try {
|
|
860
|
-
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
861
|
-
} catch (cause) {
|
|
862
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
863
|
-
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
868
|
-
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
869
|
-
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
870
|
-
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
871
|
-
* not special-cased here — it reaches the schema like any other value, so it
|
|
872
|
-
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
873
|
-
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
874
|
-
*/
|
|
875
|
-
function coerceEnvSourcedParam(raw, d, key) {
|
|
876
|
-
const platformVar = decodeParamPointer(raw);
|
|
877
|
-
const value = process.env[platformVar];
|
|
878
|
-
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.`);
|
|
879
|
-
try {
|
|
880
|
-
return standardValidateSync(d.param.schema, value);
|
|
881
|
-
} catch (cause) {
|
|
882
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
883
|
-
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Boot: read each declared param from env by its key, reverse the param's own
|
|
888
|
-
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
889
|
-
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
890
|
-
*/
|
|
891
|
-
const deserialize = (node, address) => {
|
|
892
|
-
const service = {};
|
|
893
|
-
const inputs = {};
|
|
894
|
-
for (const d of paramEntries(node)) {
|
|
895
|
-
const key = configKey(address, d);
|
|
896
|
-
const value = coerce(process.env[key], d, key);
|
|
897
|
-
if (d.owner === "service") service[d.name] = value;
|
|
898
|
-
else {
|
|
899
|
-
let bucket = inputs[d.owner.input];
|
|
900
|
-
if (bucket === void 0) {
|
|
901
|
-
bucket = {};
|
|
902
|
-
inputs[d.owner.input] = bucket;
|
|
903
|
-
}
|
|
904
|
-
bucket[d.name] = value;
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
return {
|
|
908
|
-
service,
|
|
909
|
-
inputs
|
|
910
|
-
};
|
|
911
|
-
};
|
|
912
|
-
/**
|
|
913
|
-
* run()'s setup step: write the resolved config to the environment under
|
|
914
|
-
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
915
|
-
* reads back with no address. Uses env, not a module variable, because a
|
|
916
|
-
* framework may fork worker processes that inherit env but not memory.
|
|
917
|
-
* Writes only these keys; nothing else is touched.
|
|
918
|
-
*/
|
|
919
|
-
const stash = (node, config) => {
|
|
920
|
-
for (const d of paramEntries(node)) {
|
|
921
|
-
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
922
|
-
if (value === void 0) continue;
|
|
923
|
-
process.env[configKey("", d)] = encode(d.owner, value);
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
927
|
-
const secretKey = (address, slot) => configKey(address, {
|
|
928
|
-
owner: "service",
|
|
929
|
-
name: slot
|
|
930
|
-
});
|
|
931
|
-
/**
|
|
932
|
-
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
933
|
-
* pointer key (the platform NAME), then read that platform var. A missing
|
|
934
|
-
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
935
|
-
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
936
|
-
*/
|
|
937
|
-
const deserializeSecrets = (node, address) => {
|
|
938
|
-
const values = {};
|
|
939
|
-
for (const slot of Object.keys(node.secretSlots)) {
|
|
940
|
-
const key = secretKey(address, slot);
|
|
941
|
-
const name = process.env[key];
|
|
942
|
-
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
943
|
-
const value = process.env[name];
|
|
944
|
-
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
945
|
-
values[slot] = value;
|
|
946
|
-
}
|
|
947
|
-
return values;
|
|
948
|
-
};
|
|
949
|
-
/**
|
|
950
|
-
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
951
|
-
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
952
|
-
* identically. Never the value — the value stays only in the platform var.
|
|
953
|
-
*/
|
|
954
|
-
const stashSecrets = (node, address) => {
|
|
955
|
-
for (const slot of Object.keys(node.secretSlots)) {
|
|
956
|
-
const name = process.env[secretKey(address, slot)];
|
|
957
|
-
if (name === void 0) continue;
|
|
958
|
-
process.env[secretKey("", slot)] = name;
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
/**
|
|
962
|
-
* Boot: for each reserved provider param, read its address-scoped row through
|
|
963
|
-
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
964
|
-
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
965
|
-
* declaration space. A param is declared optional here unconditionally: an
|
|
966
|
-
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
967
|
-
* registered value for this deploy), never a boot failure, so nothing is
|
|
968
|
-
* stashed and the runtime reader that owns this slot falls back to its own
|
|
969
|
-
* pass-through behavior.
|
|
970
|
-
*/
|
|
971
|
-
function stashProviderParams(entries, address) {
|
|
972
|
-
for (const entry of entries) {
|
|
973
|
-
const d = {
|
|
974
|
-
owner: "service",
|
|
975
|
-
name: entry.name,
|
|
976
|
-
param: {
|
|
977
|
-
schema: entry.schema,
|
|
978
|
-
optional: true
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
const key = configKey(address, d);
|
|
982
|
-
const value = coerce(process.env[key], d, key);
|
|
983
|
-
if (value === void 0) continue;
|
|
984
|
-
process.env[configKey("", d)] = encode("service", value);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
988
|
-
function standardValidateSync(schema, value) {
|
|
989
|
-
const result = schema["~standard"].validate(value);
|
|
990
|
-
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
991
|
-
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
992
|
-
return result.value;
|
|
993
|
-
}
|
|
994
|
-
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
995
|
-
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
996
787
|
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
997
788
|
/**
|
|
998
789
|
* Splits an array into two arrays based on the result of a predicate
|
|
@@ -8112,6 +7903,265 @@ ark.schema;
|
|
|
8112
7903
|
ark.define;
|
|
8113
7904
|
ark.declare;
|
|
8114
7905
|
/**
|
|
7906
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
7907
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
7908
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
7909
|
+
* projection.
|
|
7910
|
+
*/
|
|
7911
|
+
function paramEntries(node) {
|
|
7912
|
+
const entries = [];
|
|
7913
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
7914
|
+
if (typeof value !== "object" || value === null) continue;
|
|
7915
|
+
const params = blindCast(value).connection.params;
|
|
7916
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
7917
|
+
owner: { input },
|
|
7918
|
+
name,
|
|
7919
|
+
param
|
|
7920
|
+
});
|
|
7921
|
+
}
|
|
7922
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
7923
|
+
owner: "service",
|
|
7924
|
+
name,
|
|
7925
|
+
param
|
|
7926
|
+
});
|
|
7927
|
+
return entries;
|
|
7928
|
+
}
|
|
7929
|
+
const configKey = (address, d) => {
|
|
7930
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
7931
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
7932
|
+
return [
|
|
7933
|
+
"COMPOSER",
|
|
7934
|
+
...segments,
|
|
7935
|
+
...owner,
|
|
7936
|
+
d.name
|
|
7937
|
+
].join("_").toUpperCase();
|
|
7938
|
+
};
|
|
7939
|
+
/**
|
|
7940
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
7941
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
7942
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
7943
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
7944
|
+
*/
|
|
7945
|
+
function encode(owner, value) {
|
|
7946
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
7947
|
+
}
|
|
7948
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
7949
|
+
function decode(owner, raw) {
|
|
7950
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
7951
|
+
}
|
|
7952
|
+
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
7953
|
+
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
7954
|
+
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
7955
|
+
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
7956
|
+
const decodeParamPointer = (raw) => raw.slice(24);
|
|
7957
|
+
function coerce(raw, d, key) {
|
|
7958
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
7959
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
7960
|
+
if (d.param.optional === true) return void 0;
|
|
7961
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
7962
|
+
}
|
|
7963
|
+
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
7964
|
+
try {
|
|
7965
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
7966
|
+
} catch (cause) {
|
|
7967
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7968
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
/**
|
|
7972
|
+
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
7973
|
+
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
7974
|
+
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
7975
|
+
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
7976
|
+
* not special-cased here — it reaches the schema like any other value, so it
|
|
7977
|
+
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
7978
|
+
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
7979
|
+
*/
|
|
7980
|
+
function coerceEnvSourcedParam(raw, d, key) {
|
|
7981
|
+
const platformVar = decodeParamPointer(raw);
|
|
7982
|
+
const value = process.env[platformVar];
|
|
7983
|
+
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.`);
|
|
7984
|
+
try {
|
|
7985
|
+
return standardValidateSync(d.param.schema, value);
|
|
7986
|
+
} catch (cause) {
|
|
7987
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7988
|
+
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
7989
|
+
}
|
|
7990
|
+
}
|
|
7991
|
+
/**
|
|
7992
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
7993
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
7994
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
7995
|
+
*/
|
|
7996
|
+
const deserialize = (node, address) => {
|
|
7997
|
+
const service = {};
|
|
7998
|
+
const inputs = {};
|
|
7999
|
+
for (const d of paramEntries(node)) {
|
|
8000
|
+
const key = configKey(address, d);
|
|
8001
|
+
const value = coerce(process.env[key], d, key);
|
|
8002
|
+
if (d.owner === "service") service[d.name] = value;
|
|
8003
|
+
else {
|
|
8004
|
+
let bucket = inputs[d.owner.input];
|
|
8005
|
+
if (bucket === void 0) {
|
|
8006
|
+
bucket = {};
|
|
8007
|
+
inputs[d.owner.input] = bucket;
|
|
8008
|
+
}
|
|
8009
|
+
bucket[d.name] = value;
|
|
8010
|
+
}
|
|
8011
|
+
}
|
|
8012
|
+
return {
|
|
8013
|
+
service,
|
|
8014
|
+
inputs
|
|
8015
|
+
};
|
|
8016
|
+
};
|
|
8017
|
+
/**
|
|
8018
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
8019
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
8020
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
8021
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
8022
|
+
* Writes only these keys; nothing else is touched.
|
|
8023
|
+
*/
|
|
8024
|
+
const stash = (node, config) => {
|
|
8025
|
+
for (const d of paramEntries(node)) {
|
|
8026
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
8027
|
+
if (value === void 0) continue;
|
|
8028
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
8029
|
+
}
|
|
8030
|
+
};
|
|
8031
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
8032
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
8033
|
+
owner: "service",
|
|
8034
|
+
name: slot
|
|
8035
|
+
});
|
|
8036
|
+
/**
|
|
8037
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
8038
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
8039
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
8040
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
8041
|
+
*/
|
|
8042
|
+
const deserializeSecrets = (node, address) => {
|
|
8043
|
+
const values = {};
|
|
8044
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
8045
|
+
const key = secretKey(address, slot);
|
|
8046
|
+
const name = process.env[key];
|
|
8047
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
8048
|
+
const value = process.env[name];
|
|
8049
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
8050
|
+
values[slot] = value;
|
|
8051
|
+
}
|
|
8052
|
+
return values;
|
|
8053
|
+
};
|
|
8054
|
+
/**
|
|
8055
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
8056
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
8057
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
8058
|
+
*/
|
|
8059
|
+
const stashSecrets = (node, address) => {
|
|
8060
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
8061
|
+
const name = process.env[secretKey(address, slot)];
|
|
8062
|
+
if (name === void 0) continue;
|
|
8063
|
+
process.env[secretKey("", slot)] = name;
|
|
8064
|
+
}
|
|
8065
|
+
};
|
|
8066
|
+
/**
|
|
8067
|
+
* Boot: for each reserved provider param, read its address-scoped row through
|
|
8068
|
+
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
8069
|
+
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
8070
|
+
* declaration space. A param is declared optional here unconditionally: an
|
|
8071
|
+
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
8072
|
+
* registered value for this deploy), never a boot failure, so nothing is
|
|
8073
|
+
* stashed and the runtime reader that owns this slot falls back to its own
|
|
8074
|
+
* pass-through behavior.
|
|
8075
|
+
*/
|
|
8076
|
+
function stashProviderParams(entries, address) {
|
|
8077
|
+
for (const entry of entries) {
|
|
8078
|
+
const d = {
|
|
8079
|
+
owner: "service",
|
|
8080
|
+
name: entry.name,
|
|
8081
|
+
param: {
|
|
8082
|
+
schema: entry.schema,
|
|
8083
|
+
optional: true
|
|
8084
|
+
}
|
|
8085
|
+
};
|
|
8086
|
+
const key = configKey(address, d);
|
|
8087
|
+
const value = coerce(process.env[key], d, key);
|
|
8088
|
+
if (value === void 0) continue;
|
|
8089
|
+
process.env[configKey("", d)] = encode("service", value);
|
|
8090
|
+
}
|
|
8091
|
+
}
|
|
8092
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
8093
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
8094
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
8095
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
8096
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
8097
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
8098
|
+
* their other `COMPOSER_*` rows. */
|
|
8099
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
8100
|
+
/**
|
|
8101
|
+
* Reads this service's origin back out of the address-free stash
|
|
8102
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
8103
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
8104
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
8105
|
+
* before run().
|
|
8106
|
+
*/
|
|
8107
|
+
function readOrigin() {
|
|
8108
|
+
const d = {
|
|
8109
|
+
owner: "service",
|
|
8110
|
+
name: ORIGIN_KEY_NAME,
|
|
8111
|
+
param: {
|
|
8112
|
+
schema: type("string"),
|
|
8113
|
+
optional: true
|
|
8114
|
+
}
|
|
8115
|
+
};
|
|
8116
|
+
const key = configKey("", d);
|
|
8117
|
+
const value = coerce(process.env[key], d, key);
|
|
8118
|
+
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).");
|
|
8119
|
+
return blindCast(value);
|
|
8120
|
+
}
|
|
8121
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
8122
|
+
function standardValidateSync(schema, value) {
|
|
8123
|
+
const result = schema["~standard"].validate(value);
|
|
8124
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
8125
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
8126
|
+
return result.value;
|
|
8127
|
+
}
|
|
8128
|
+
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
8129
|
+
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
8130
|
+
/**
|
|
8131
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
8132
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
8133
|
+
* deploy-side value function that resolves the provisioned service's
|
|
8134
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
8135
|
+
* validates and stashes the row at boot through the generic
|
|
8136
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
8137
|
+
*
|
|
8138
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
8139
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
8140
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
8141
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
8142
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
8143
|
+
* service, exposing or not.
|
|
8144
|
+
*
|
|
8145
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
8146
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
8147
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
8148
|
+
* control-plane-only entry).
|
|
8149
|
+
*/
|
|
8150
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
8151
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
8152
|
+
/**
|
|
8153
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
8154
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
8155
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
8156
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
8157
|
+
* its deploy-side value function up by this field.
|
|
8158
|
+
*/
|
|
8159
|
+
const ORIGIN_PARAM = {
|
|
8160
|
+
name: ORIGIN_KEY_NAME,
|
|
8161
|
+
schema: type("string"),
|
|
8162
|
+
brand: SELF_ORIGIN
|
|
8163
|
+
};
|
|
8164
|
+
/**
|
|
8115
8165
|
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
8116
8166
|
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
8117
8167
|
* by `control.ts` (which registers the deploy-side `value(refs)` that mints
|
|
@@ -8155,7 +8205,33 @@ configKey("", {
|
|
|
8155
8205
|
owner: "service",
|
|
8156
8206
|
name: STREAMS_API_KEY_PARAM.name
|
|
8157
8207
|
});
|
|
8158
|
-
|
|
8208
|
+
/**
|
|
8209
|
+
* The list of provider-side reserved params the boot path validates and
|
|
8210
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
8211
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
8212
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
8213
|
+
*
|
|
8214
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
8215
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
8216
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
8217
|
+
* must never import it. This module is reachable from a user service's
|
|
8218
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
8219
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
8220
|
+
*
|
|
8221
|
+
* This is the single source of which reserved provider params exist:
|
|
8222
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
8223
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
8224
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
8225
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
8226
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
8227
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
8228
|
+
* deploy no longer names its own param set independently.
|
|
8229
|
+
*/
|
|
8230
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
8231
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
8232
|
+
STREAMS_API_KEY_PARAM,
|
|
8233
|
+
ORIGIN_PARAM
|
|
8234
|
+
];
|
|
8159
8235
|
Object.freeze({
|
|
8160
8236
|
kind: "s3",
|
|
8161
8237
|
__cmp: {
|
|
@@ -8172,7 +8248,7 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
8172
8248
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
8173
8249
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
8174
8250
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
8175
|
-
*
|
|
8251
|
+
*
|
|
8176
8252
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
8177
8253
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
8178
8254
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -8180,23 +8256,69 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
8180
8256
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
8181
8257
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
8182
8258
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
8259
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
8260
|
+
* stash `run()` populates; memoized per process.
|
|
8183
8261
|
*
|
|
8184
|
-
*
|
|
8262
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
8185
8263
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
8186
8264
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
8187
|
-
* deploy time; nodes are pure data.
|
|
8265
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
8188
8266
|
*/
|
|
8267
|
+
var ComputeService = class {
|
|
8268
|
+
#resolved;
|
|
8269
|
+
#loadedDeps;
|
|
8270
|
+
#loadedParams;
|
|
8271
|
+
#loadedSecrets;
|
|
8272
|
+
#origin;
|
|
8273
|
+
constructor(node) {
|
|
8274
|
+
Object.assign(this, node);
|
|
8275
|
+
}
|
|
8276
|
+
#processConfig() {
|
|
8277
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
8278
|
+
return this.#resolved;
|
|
8279
|
+
}
|
|
8280
|
+
async run(address, boot) {
|
|
8281
|
+
const config = deserialize(this, address);
|
|
8282
|
+
stash(this, config);
|
|
8283
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
8284
|
+
stashSecrets(this, address);
|
|
8285
|
+
const port = config.service["port"];
|
|
8286
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
8287
|
+
return boot();
|
|
8288
|
+
}
|
|
8289
|
+
load() {
|
|
8290
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
8291
|
+
return this.#loadedDeps;
|
|
8292
|
+
}
|
|
8293
|
+
config() {
|
|
8294
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
8295
|
+
return this.#loadedParams;
|
|
8296
|
+
}
|
|
8297
|
+
secrets() {
|
|
8298
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
8299
|
+
return this.#loadedSecrets;
|
|
8300
|
+
}
|
|
8301
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
8302
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
8303
|
+
* has stashed it (readOrigin's pinned message). */
|
|
8304
|
+
origin() {
|
|
8305
|
+
this.#origin ??= readOrigin();
|
|
8306
|
+
return this.#origin;
|
|
8307
|
+
}
|
|
8308
|
+
};
|
|
8189
8309
|
const compute = (def) => {
|
|
8190
8310
|
const userParams = def.params ?? blindCast({});
|
|
8191
8311
|
for (const reserved of Object.keys(reservedParams)) {
|
|
8192
8312
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
8193
8313
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
8194
8314
|
}
|
|
8315
|
+
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.`);
|
|
8316
|
+
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.`);
|
|
8195
8317
|
const params = blindCast({
|
|
8196
8318
|
...userParams,
|
|
8197
8319
|
...reservedParams
|
|
8198
8320
|
});
|
|
8199
|
-
const
|
|
8321
|
+
const instance = new ComputeService(service$1({
|
|
8200
8322
|
name: def.name,
|
|
8201
8323
|
extension: "@prisma/composer-prisma-cloud",
|
|
8202
8324
|
type: "compute",
|
|
@@ -8205,40 +8327,9 @@ const compute = (def) => {
|
|
|
8205
8327
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
8206
8328
|
build: def.build,
|
|
8207
8329
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
8208
|
-
});
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
let loadedParams;
|
|
8212
|
-
let loadedSecrets;
|
|
8213
|
-
function processConfig() {
|
|
8214
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
8215
|
-
return resolved;
|
|
8216
|
-
}
|
|
8217
|
-
const runnable = {
|
|
8218
|
-
...node,
|
|
8219
|
-
async run(address, boot) {
|
|
8220
|
-
const config = deserialize(node, address);
|
|
8221
|
-
stash(node, config);
|
|
8222
|
-
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
8223
|
-
stashSecrets(node, address);
|
|
8224
|
-
const port = config.service["port"];
|
|
8225
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
8226
|
-
return boot();
|
|
8227
|
-
},
|
|
8228
|
-
load() {
|
|
8229
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
8230
|
-
return loadedDeps;
|
|
8231
|
-
},
|
|
8232
|
-
config() {
|
|
8233
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
8234
|
-
return loadedParams;
|
|
8235
|
-
},
|
|
8236
|
-
secrets() {
|
|
8237
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
8238
|
-
return loadedSecrets;
|
|
8239
|
-
}
|
|
8240
|
-
};
|
|
8241
|
-
return Object.freeze(blindCast(runnable));
|
|
8330
|
+
}));
|
|
8331
|
+
Object.freeze(instance);
|
|
8332
|
+
return instance;
|
|
8242
8333
|
};
|
|
8243
8334
|
/**
|
|
8244
8335
|
* The contract a Postgres provides — and the contract its consumers require.
|
|
@@ -8309,13 +8400,21 @@ function s3Credentials(opts) {
|
|
|
8309
8400
|
* return type is compute's exactly (including the reserved `port` param). The
|
|
8310
8401
|
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
8311
8402
|
* param, and `expose: { store: s3Contract }`.
|
|
8403
|
+
*
|
|
8404
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
8405
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
8406
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
8407
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
8408
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
8409
|
+
* properties) with `type` overridden keeps every method intact.
|
|
8312
8410
|
*/
|
|
8313
8411
|
function s3StoreService(def) {
|
|
8314
|
-
const
|
|
8315
|
-
|
|
8316
|
-
...node,
|
|
8412
|
+
const instance = new ComputeService({
|
|
8413
|
+
...compute(def),
|
|
8317
8414
|
type: "s3-store"
|
|
8318
|
-
})
|
|
8415
|
+
});
|
|
8416
|
+
Object.freeze(instance);
|
|
8417
|
+
return instance;
|
|
8319
8418
|
}
|
|
8320
8419
|
const s3Contract = Object.freeze({
|
|
8321
8420
|
kind: "s3",
|