@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
|
@@ -797,202 +797,6 @@ const nodeBuild = (opts) => ({
|
|
|
797
797
|
entry: opts.entry,
|
|
798
798
|
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
799
799
|
});
|
|
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
800
|
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
997
801
|
/**
|
|
998
802
|
* Splits an array into two arrays based on the result of a predicate
|
|
@@ -8112,6 +7916,265 @@ ark.schema;
|
|
|
8112
7916
|
ark.define;
|
|
8113
7917
|
ark.declare;
|
|
8114
7918
|
/**
|
|
7919
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
7920
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
7921
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
7922
|
+
* projection.
|
|
7923
|
+
*/
|
|
7924
|
+
function paramEntries(node) {
|
|
7925
|
+
const entries = [];
|
|
7926
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
7927
|
+
if (typeof value !== "object" || value === null) continue;
|
|
7928
|
+
const params = blindCast(value).connection.params;
|
|
7929
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
7930
|
+
owner: { input },
|
|
7931
|
+
name,
|
|
7932
|
+
param
|
|
7933
|
+
});
|
|
7934
|
+
}
|
|
7935
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
7936
|
+
owner: "service",
|
|
7937
|
+
name,
|
|
7938
|
+
param
|
|
7939
|
+
});
|
|
7940
|
+
return entries;
|
|
7941
|
+
}
|
|
7942
|
+
const configKey = (address, d) => {
|
|
7943
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
7944
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
7945
|
+
return [
|
|
7946
|
+
"COMPOSER",
|
|
7947
|
+
...segments,
|
|
7948
|
+
...owner,
|
|
7949
|
+
d.name
|
|
7950
|
+
].join("_").toUpperCase();
|
|
7951
|
+
};
|
|
7952
|
+
/**
|
|
7953
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
7954
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
7955
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
7956
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
7957
|
+
*/
|
|
7958
|
+
function encode(owner, value) {
|
|
7959
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
7960
|
+
}
|
|
7961
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
7962
|
+
function decode(owner, raw) {
|
|
7963
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
7964
|
+
}
|
|
7965
|
+
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
7966
|
+
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
7967
|
+
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
7968
|
+
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
7969
|
+
const decodeParamPointer = (raw) => raw.slice(24);
|
|
7970
|
+
function coerce(raw, d, key) {
|
|
7971
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
7972
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
7973
|
+
if (d.param.optional === true) return void 0;
|
|
7974
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
7975
|
+
}
|
|
7976
|
+
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
7977
|
+
try {
|
|
7978
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
7979
|
+
} catch (cause) {
|
|
7980
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7981
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
7982
|
+
}
|
|
7983
|
+
}
|
|
7984
|
+
/**
|
|
7985
|
+
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
7986
|
+
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
7987
|
+
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
7988
|
+
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
7989
|
+
* not special-cased here — it reaches the schema like any other value, so it
|
|
7990
|
+
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
7991
|
+
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
7992
|
+
*/
|
|
7993
|
+
function coerceEnvSourcedParam(raw, d, key) {
|
|
7994
|
+
const platformVar = decodeParamPointer(raw);
|
|
7995
|
+
const value = process.env[platformVar];
|
|
7996
|
+
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.`);
|
|
7997
|
+
try {
|
|
7998
|
+
return standardValidateSync(d.param.schema, value);
|
|
7999
|
+
} catch (cause) {
|
|
8000
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
8001
|
+
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
8002
|
+
}
|
|
8003
|
+
}
|
|
8004
|
+
/**
|
|
8005
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
8006
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
8007
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
8008
|
+
*/
|
|
8009
|
+
const deserialize = (node, address) => {
|
|
8010
|
+
const service = {};
|
|
8011
|
+
const inputs = {};
|
|
8012
|
+
for (const d of paramEntries(node)) {
|
|
8013
|
+
const key = configKey(address, d);
|
|
8014
|
+
const value = coerce(process.env[key], d, key);
|
|
8015
|
+
if (d.owner === "service") service[d.name] = value;
|
|
8016
|
+
else {
|
|
8017
|
+
let bucket = inputs[d.owner.input];
|
|
8018
|
+
if (bucket === void 0) {
|
|
8019
|
+
bucket = {};
|
|
8020
|
+
inputs[d.owner.input] = bucket;
|
|
8021
|
+
}
|
|
8022
|
+
bucket[d.name] = value;
|
|
8023
|
+
}
|
|
8024
|
+
}
|
|
8025
|
+
return {
|
|
8026
|
+
service,
|
|
8027
|
+
inputs
|
|
8028
|
+
};
|
|
8029
|
+
};
|
|
8030
|
+
/**
|
|
8031
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
8032
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
8033
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
8034
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
8035
|
+
* Writes only these keys; nothing else is touched.
|
|
8036
|
+
*/
|
|
8037
|
+
const stash = (node, config) => {
|
|
8038
|
+
for (const d of paramEntries(node)) {
|
|
8039
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
8040
|
+
if (value === void 0) continue;
|
|
8041
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
8042
|
+
}
|
|
8043
|
+
};
|
|
8044
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
8045
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
8046
|
+
owner: "service",
|
|
8047
|
+
name: slot
|
|
8048
|
+
});
|
|
8049
|
+
/**
|
|
8050
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
8051
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
8052
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
8053
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
8054
|
+
*/
|
|
8055
|
+
const deserializeSecrets = (node, address) => {
|
|
8056
|
+
const values = {};
|
|
8057
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
8058
|
+
const key = secretKey(address, slot);
|
|
8059
|
+
const name = process.env[key];
|
|
8060
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
8061
|
+
const value = process.env[name];
|
|
8062
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
8063
|
+
values[slot] = value;
|
|
8064
|
+
}
|
|
8065
|
+
return values;
|
|
8066
|
+
};
|
|
8067
|
+
/**
|
|
8068
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
8069
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
8070
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
8071
|
+
*/
|
|
8072
|
+
const stashSecrets = (node, address) => {
|
|
8073
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
8074
|
+
const name = process.env[secretKey(address, slot)];
|
|
8075
|
+
if (name === void 0) continue;
|
|
8076
|
+
process.env[secretKey("", slot)] = name;
|
|
8077
|
+
}
|
|
8078
|
+
};
|
|
8079
|
+
/**
|
|
8080
|
+
* Boot: for each reserved provider param, read its address-scoped row through
|
|
8081
|
+
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
8082
|
+
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
8083
|
+
* declaration space. A param is declared optional here unconditionally: an
|
|
8084
|
+
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
8085
|
+
* registered value for this deploy), never a boot failure, so nothing is
|
|
8086
|
+
* stashed and the runtime reader that owns this slot falls back to its own
|
|
8087
|
+
* pass-through behavior.
|
|
8088
|
+
*/
|
|
8089
|
+
function stashProviderParams(entries, address) {
|
|
8090
|
+
for (const entry of entries) {
|
|
8091
|
+
const d = {
|
|
8092
|
+
owner: "service",
|
|
8093
|
+
name: entry.name,
|
|
8094
|
+
param: {
|
|
8095
|
+
schema: entry.schema,
|
|
8096
|
+
optional: true
|
|
8097
|
+
}
|
|
8098
|
+
};
|
|
8099
|
+
const key = configKey(address, d);
|
|
8100
|
+
const value = coerce(process.env[key], d, key);
|
|
8101
|
+
if (value === void 0) continue;
|
|
8102
|
+
process.env[configKey("", d)] = encode("service", value);
|
|
8103
|
+
}
|
|
8104
|
+
}
|
|
8105
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
8106
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
8107
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
8108
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
8109
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
8110
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
8111
|
+
* their other `COMPOSER_*` rows. */
|
|
8112
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
8113
|
+
/**
|
|
8114
|
+
* Reads this service's origin back out of the address-free stash
|
|
8115
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
8116
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
8117
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
8118
|
+
* before run().
|
|
8119
|
+
*/
|
|
8120
|
+
function readOrigin() {
|
|
8121
|
+
const d = {
|
|
8122
|
+
owner: "service",
|
|
8123
|
+
name: ORIGIN_KEY_NAME,
|
|
8124
|
+
param: {
|
|
8125
|
+
schema: type("string"),
|
|
8126
|
+
optional: true
|
|
8127
|
+
}
|
|
8128
|
+
};
|
|
8129
|
+
const key = configKey("", d);
|
|
8130
|
+
const value = coerce(process.env[key], d, key);
|
|
8131
|
+
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).");
|
|
8132
|
+
return blindCast(value);
|
|
8133
|
+
}
|
|
8134
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
8135
|
+
function standardValidateSync(schema, value) {
|
|
8136
|
+
const result = schema["~standard"].validate(value);
|
|
8137
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
8138
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
8139
|
+
return result.value;
|
|
8140
|
+
}
|
|
8141
|
+
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
8142
|
+
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
8143
|
+
/**
|
|
8144
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
8145
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
8146
|
+
* deploy-side value function that resolves the provisioned service's
|
|
8147
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
8148
|
+
* validates and stashes the row at boot through the generic
|
|
8149
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
8150
|
+
*
|
|
8151
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
8152
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
8153
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
8154
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
8155
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
8156
|
+
* service, exposing or not.
|
|
8157
|
+
*
|
|
8158
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
8159
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
8160
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
8161
|
+
* control-plane-only entry).
|
|
8162
|
+
*/
|
|
8163
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
8164
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
8165
|
+
/**
|
|
8166
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
8167
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
8168
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
8169
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
8170
|
+
* its deploy-side value function up by this field.
|
|
8171
|
+
*/
|
|
8172
|
+
const ORIGIN_PARAM = {
|
|
8173
|
+
name: ORIGIN_KEY_NAME,
|
|
8174
|
+
schema: type("string"),
|
|
8175
|
+
brand: SELF_ORIGIN
|
|
8176
|
+
};
|
|
8177
|
+
/**
|
|
8115
8178
|
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
8116
8179
|
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
8117
8180
|
* by `control.ts` (which registers the deploy-side `value(refs)` that mints
|
|
@@ -8155,14 +8218,50 @@ configKey("", {
|
|
|
8155
8218
|
owner: "service",
|
|
8156
8219
|
name: STREAMS_API_KEY_PARAM.name
|
|
8157
8220
|
});
|
|
8158
|
-
|
|
8221
|
+
/**
|
|
8222
|
+
* The list of provider-side reserved params the boot path validates and
|
|
8223
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
8224
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
8225
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
8226
|
+
*
|
|
8227
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
8228
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
8229
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
8230
|
+
* must never import it. This module is reachable from a user service's
|
|
8231
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
8232
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
8233
|
+
*
|
|
8234
|
+
* This is the single source of which reserved provider params exist:
|
|
8235
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
8236
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
8237
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
8238
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
8239
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
8240
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
8241
|
+
* deploy no longer names its own param set independently.
|
|
8242
|
+
*/
|
|
8243
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
8244
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
8245
|
+
STREAMS_API_KEY_PARAM,
|
|
8246
|
+
ORIGIN_PARAM
|
|
8247
|
+
];
|
|
8248
|
+
Object.freeze({
|
|
8249
|
+
kind: "s3",
|
|
8250
|
+
__cmp: {
|
|
8251
|
+
url: "",
|
|
8252
|
+
bucket: "",
|
|
8253
|
+
accessKeyId: "",
|
|
8254
|
+
secretAccessKey: ""
|
|
8255
|
+
},
|
|
8256
|
+
satisfies: (required) => required.kind === "s3"
|
|
8257
|
+
});
|
|
8159
8258
|
const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
8160
8259
|
/**
|
|
8161
8260
|
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
8162
8261
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
8163
8262
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
8164
8263
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
8165
|
-
*
|
|
8264
|
+
*
|
|
8166
8265
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
8167
8266
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
8168
8267
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -8170,23 +8269,69 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
8170
8269
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
8171
8270
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
8172
8271
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
8272
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
8273
|
+
* stash `run()` populates; memoized per process.
|
|
8173
8274
|
*
|
|
8174
|
-
*
|
|
8275
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
8175
8276
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
8176
8277
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
8177
|
-
* deploy time; nodes are pure data.
|
|
8278
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
8178
8279
|
*/
|
|
8280
|
+
var ComputeService = class {
|
|
8281
|
+
#resolved;
|
|
8282
|
+
#loadedDeps;
|
|
8283
|
+
#loadedParams;
|
|
8284
|
+
#loadedSecrets;
|
|
8285
|
+
#origin;
|
|
8286
|
+
constructor(node) {
|
|
8287
|
+
Object.assign(this, node);
|
|
8288
|
+
}
|
|
8289
|
+
#processConfig() {
|
|
8290
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
8291
|
+
return this.#resolved;
|
|
8292
|
+
}
|
|
8293
|
+
async run(address, boot) {
|
|
8294
|
+
const config = deserialize(this, address);
|
|
8295
|
+
stash(this, config);
|
|
8296
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
8297
|
+
stashSecrets(this, address);
|
|
8298
|
+
const port = config.service["port"];
|
|
8299
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
8300
|
+
return boot();
|
|
8301
|
+
}
|
|
8302
|
+
load() {
|
|
8303
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
8304
|
+
return this.#loadedDeps;
|
|
8305
|
+
}
|
|
8306
|
+
config() {
|
|
8307
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
8308
|
+
return this.#loadedParams;
|
|
8309
|
+
}
|
|
8310
|
+
secrets() {
|
|
8311
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
8312
|
+
return this.#loadedSecrets;
|
|
8313
|
+
}
|
|
8314
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
8315
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
8316
|
+
* has stashed it (readOrigin's pinned message). */
|
|
8317
|
+
origin() {
|
|
8318
|
+
this.#origin ??= readOrigin();
|
|
8319
|
+
return this.#origin;
|
|
8320
|
+
}
|
|
8321
|
+
};
|
|
8179
8322
|
const compute = (def) => {
|
|
8180
8323
|
const userParams = def.params ?? blindCast({});
|
|
8181
8324
|
for (const reserved of Object.keys(reservedParams)) {
|
|
8182
8325
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
8183
8326
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
8184
8327
|
}
|
|
8328
|
+
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.`);
|
|
8329
|
+
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.`);
|
|
8185
8330
|
const params = blindCast({
|
|
8186
8331
|
...userParams,
|
|
8187
8332
|
...reservedParams
|
|
8188
8333
|
});
|
|
8189
|
-
const
|
|
8334
|
+
const instance = new ComputeService(service$1({
|
|
8190
8335
|
name: def.name,
|
|
8191
8336
|
extension: "@prisma/composer-prisma-cloud",
|
|
8192
8337
|
type: "compute",
|
|
@@ -8195,40 +8340,9 @@ const compute = (def) => {
|
|
|
8195
8340
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
8196
8341
|
build: def.build,
|
|
8197
8342
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
8198
|
-
});
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
let loadedParams;
|
|
8202
|
-
let loadedSecrets;
|
|
8203
|
-
function processConfig() {
|
|
8204
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
8205
|
-
return resolved;
|
|
8206
|
-
}
|
|
8207
|
-
const runnable = {
|
|
8208
|
-
...node,
|
|
8209
|
-
async run(address, boot) {
|
|
8210
|
-
const config = deserialize(node, address);
|
|
8211
|
-
stash(node, config);
|
|
8212
|
-
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
8213
|
-
stashSecrets(node, address);
|
|
8214
|
-
const port = config.service["port"];
|
|
8215
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
8216
|
-
return boot();
|
|
8217
|
-
},
|
|
8218
|
-
load() {
|
|
8219
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
8220
|
-
return loadedDeps;
|
|
8221
|
-
},
|
|
8222
|
-
config() {
|
|
8223
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
8224
|
-
return loadedParams;
|
|
8225
|
-
},
|
|
8226
|
-
secrets() {
|
|
8227
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
8228
|
-
return loadedSecrets;
|
|
8229
|
-
}
|
|
8230
|
-
};
|
|
8231
|
-
return Object.freeze(blindCast(runnable));
|
|
8343
|
+
}));
|
|
8344
|
+
Object.freeze(instance);
|
|
8345
|
+
return instance;
|
|
8232
8346
|
};
|
|
8233
8347
|
/**
|
|
8234
8348
|
* The contract a Postgres provides — and the contract its consumers require.
|
|
@@ -8299,13 +8413,21 @@ function s3Credentials(opts) {
|
|
|
8299
8413
|
* return type is compute's exactly (including the reserved `port` param). The
|
|
8300
8414
|
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
8301
8415
|
* param, and `expose: { store: s3Contract }`.
|
|
8416
|
+
*
|
|
8417
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
8418
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
8419
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
8420
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
8421
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
8422
|
+
* properties) with `type` overridden keeps every method intact.
|
|
8302
8423
|
*/
|
|
8303
8424
|
function s3StoreService(def) {
|
|
8304
|
-
const
|
|
8305
|
-
|
|
8306
|
-
...node,
|
|
8425
|
+
const instance = new ComputeService({
|
|
8426
|
+
...compute(def),
|
|
8307
8427
|
type: "s3-store"
|
|
8308
|
-
})
|
|
8428
|
+
});
|
|
8429
|
+
Object.freeze(instance);
|
|
8430
|
+
return instance;
|
|
8309
8431
|
}
|
|
8310
8432
|
const s3Contract = Object.freeze({
|
|
8311
8433
|
kind: "s3",
|