@prisma/composer-prisma-cloud 0.1.0-dev.1 → 0.1.0-dev.10
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 +44 -4
- package/dist/control.mjs +155 -37
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.mjs +73 -8
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +158 -93
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +73 -8
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/index.d.mts +34 -15
- package/dist/index.mjs +4 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{prisma-next-COrwlg3N.mjs → prisma-next-qPB8_Az6.mjs} +2 -2
- package/dist/prisma-next-qPB8_Az6.mjs.map +1 -0
- package/dist/prisma-next.d.mts +1 -1
- package/dist/prisma-next.mjs +1 -1
- package/dist/{param-DB0B8m15-IvzNq9BM.mjs → provisioned-edges-DIQAR4q4-Bn9op-JG.mjs} +87 -28
- package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs.map +1 -0
- package/dist/{serializer-DAEWRfnm-D3GW9dOZ.mjs → serializer-CX4VYdf_-KKGoAxfx.mjs} +29 -3
- package/dist/{serializer-DAEWRfnm-D3GW9dOZ.mjs.map → serializer-CX4VYdf_-KKGoAxfx.mjs.map} +1 -1
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts +36 -0
- package/dist/storage/index.d.mts +11 -11
- package/dist/storage/index.mjs +74 -8
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +7197 -12
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +74 -8
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/storage/testing.mjs.map +1 -1
- package/dist/streams/index.d.mts +224 -22
- package/dist/streams/index.mjs +3637 -37
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +7731 -221
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +400 -21
- 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/param-DB0B8m15-IvzNq9BM.mjs.map +0 -1
- package/dist/prisma-next-COrwlg3N.mjs.map +0 -1
package/dist/control.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as ProviderParamEntry } from "./serializer-Cx5slrV4-xJfH6EWS.mjs";
|
|
1
2
|
import * as Layer from "effect/Layer";
|
|
2
3
|
import { createManagementApiClient } from "@prisma/management-api-sdk";
|
|
3
4
|
import "effect/Context";
|
|
@@ -9,13 +10,14 @@ import { Resource, StackServices } from "alchemy";
|
|
|
9
10
|
import "effect/Schedule";
|
|
10
11
|
import postgres from "postgres";
|
|
11
12
|
import { State, StateStoreError } from "alchemy/State";
|
|
13
|
+
import * as Output from "alchemy/Output";
|
|
12
14
|
import { ExtensionDescriptor } from "@prisma/composer/config";
|
|
13
|
-
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/compute
|
|
15
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/compute.d.mts
|
|
14
16
|
/** Every region Prisma Compute serves — the runtime source of truth; `ComputeRegion` is derived from it so the two can never drift. */
|
|
15
17
|
declare const COMPUTE_REGIONS: readonly ["us-east-1", "us-west-1", "eu-west-3", "eu-central-1", "ap-northeast-1", "ap-southeast-1"];
|
|
16
18
|
type ComputeRegion = (typeof COMPUTE_REGIONS)[number];
|
|
17
19
|
//#endregion
|
|
18
|
-
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/state
|
|
20
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/state.d.mts
|
|
19
21
|
//#endregion
|
|
20
22
|
//#region src/state/layer.d.ts
|
|
21
23
|
/**
|
|
@@ -39,15 +41,53 @@ type ComputeRegion = (typeof COMPUTE_REGIONS)[number];
|
|
|
39
41
|
declare const prismaState: () => Layer.Layer<State, never, StackServices>;
|
|
40
42
|
//#endregion
|
|
41
43
|
//#region ../../1-prisma-cloud/1-extensions/target/dist/control.d.mts
|
|
42
|
-
//#region src/
|
|
44
|
+
//#region src/descriptors/shared.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* The provider-side reserved param for one brand's minted values (ADR-0031:
|
|
47
|
+
* "the provisioner owns mint, size, **aggregation**, stability, and
|
|
48
|
+
* rotation", and ADR-0019: the physical encoding is the target's). `value`
|
|
49
|
+
* is deploy-side: given every inbound edge's minted ref for one provider
|
|
50
|
+
* (possibly empty), it returns the typed value to store, or `undefined` to
|
|
51
|
+
* write no row. The returned value is encoded through the serializer's
|
|
52
|
+
* normal service-own literal path (JSON) — the same path any declared param
|
|
53
|
+
* takes — never a brand-invented wire format.
|
|
54
|
+
*
|
|
55
|
+
* This is the seam that keeps `descriptors/compute.ts` brand-blind: a
|
|
56
|
+
* `ProviderParam` is registered beside its brand's provisioner in
|
|
57
|
+
* `control.ts`; the descriptor asks every registered entry about every
|
|
58
|
+
* exposing service and writes whatever comes back.
|
|
59
|
+
*/
|
|
60
|
+
interface ProviderParam extends ProviderParamEntry {
|
|
61
|
+
/**
|
|
62
|
+
* Every inbound edge's minted ref for this provider — POSSIBLY EMPTY. A
|
|
63
|
+
* provider with no wired consumers is still asked, because "no edges" and
|
|
64
|
+
* "no var" mean different things at boot: an absent var reads as "never
|
|
65
|
+
* provisioned" (local dev, tests). What an empty set means is this param's
|
|
66
|
+
* own call — deny everything, or emit nothing and let its reader fail closed.
|
|
67
|
+
*/
|
|
68
|
+
readonly value: (refs: readonly unknown[]) => Output.Output<unknown> | unknown | undefined;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/exports/control.d.ts
|
|
43
72
|
interface PrismaCloudOptions {
|
|
44
73
|
/** Defaults to the PRISMA_WORKSPACE_ID environment variable. */
|
|
45
74
|
workspaceId?: string;
|
|
46
75
|
/** Defaults to the PRISMA_REGION environment variable when set. */
|
|
47
76
|
region?: ComputeRegion;
|
|
48
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Builds the deploy-side registry from the boot-side list, keyed by brand —
|
|
80
|
+
* throws if a boot-side entry has no registered deploy-side `value(refs)`, so
|
|
81
|
+
* `RESERVED_PROVIDER_PARAMS` stays the single source of which reserved
|
|
82
|
+
* provider params exist: deploy can no longer write a row boot never
|
|
83
|
+
* stashes. Exported (rather than inlined into `PROVIDER_PARAMS` below) so
|
|
84
|
+
* `__tests__/provider-params.test.ts` can drive it directly with a
|
|
85
|
+
* deliberately incomplete value map and watch it throw.
|
|
86
|
+
*/
|
|
87
|
+
declare function buildProviderParams(entries: readonly ProviderParamEntry[], values: ReadonlyMap<symbol, ProviderParam['value']>): ReadonlyMap<symbol, ProviderParam>;
|
|
88
|
+
declare const PROVIDER_PARAMS: ReadonlyMap<symbol, ProviderParam>;
|
|
49
89
|
/** The Prisma Cloud extension descriptor — `prisma-composer.config.ts` lists it under `extensions`. */
|
|
50
90
|
declare const prismaCloud: (opts?: PrismaCloudOptions) => ExtensionDescriptor;
|
|
51
91
|
//#endregion
|
|
52
|
-
export { PrismaCloudOptions, prismaCloud, prismaState };
|
|
92
|
+
export { PROVIDER_PARAMS, PrismaCloudOptions, buildProviderParams, prismaCloud, prismaState };
|
|
53
93
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as encodeParamPointer, c as secretName, i as encode, l as secretPointerRows, s as paramEntries, t as configKey } from "./serializer-
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as normalizeSslMode, n as isPnPostgresResourceNode, o as withConnectionRetry } from "./prisma-next-
|
|
1
|
+
import { a as encodeParamPointer, c as secretName, i as encode, l as secretPointerRows, s as paramEntries, t as configKey } from "./serializer-CX4VYdf_-KKGoAxfx.mjs";
|
|
2
|
+
import { a as isEnvParamSource, c as provisionedEdges, n as STREAMS_API_KEY, o as paramBindingFor, s as paramName, t as RESERVED_PROVIDER_PARAMS } from "./provisioned-edges-DIQAR4q4-Bn9op-JG.mjs";
|
|
3
|
+
import { a as normalizeSslMode, n as isPnPostgresResourceNode, o as withConnectionRetry } from "./prisma-next-qPB8_Az6.mjs";
|
|
4
4
|
import { isParamSource, paramManifest, provisionManifest } from "@prisma/composer";
|
|
5
5
|
import { blindCast } from "@prisma/composer/casts";
|
|
6
|
-
import { RPC_PEER_KEY } from "@prisma/composer/rpc";
|
|
6
|
+
import { RPC_PEER_KEY } from "@prisma/composer/service-rpc";
|
|
7
7
|
import pg from "pg";
|
|
8
8
|
import * as Layer from "effect/Layer";
|
|
9
9
|
import { createManagementApiClient } from "@prisma/management-api-sdk";
|
|
@@ -68,7 +68,7 @@ const callOptional = (f) => attempt$1(f).pipe(Effect.flatMap((r) => r.response.s
|
|
|
68
68
|
/** Fire-and-forget a call, tolerating a 404 (already deleted). */
|
|
69
69
|
const callVoid = (f) => attempt$1(f).pipe(Effect.flatMap((r) => r.response.status === 404 || r.error === void 0 ? Effect.void : fail(r)));
|
|
70
70
|
//#endregion
|
|
71
|
-
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/compute
|
|
71
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/compute.mjs
|
|
72
72
|
/**
|
|
73
73
|
* Stopping a deployment before the app that owns it can be
|
|
74
74
|
* deleted is asynchronous on the platform's side: DELETE can 409 with this
|
|
@@ -431,7 +431,7 @@ const serviceKeyProviderService = {
|
|
|
431
431
|
/** The `ServiceKey` provider layer — merged into the Prisma Cloud extension's `providers()`. */
|
|
432
432
|
const ServiceKeyProvider = () => Provider.effect(ServiceKey, Effect.succeed(serviceKeyProviderService));
|
|
433
433
|
//#endregion
|
|
434
|
-
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/postgres
|
|
434
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/postgres.mjs
|
|
435
435
|
/** A **connection** to a Prisma Postgres database — yields the connection string. */
|
|
436
436
|
const Connection = Resource("Prisma.Connection");
|
|
437
437
|
const ConnectionProvider = () => Provider.effect(Connection, Effect.gen(function* () {
|
|
@@ -470,25 +470,23 @@ const DatabaseProvider = () => Provider.effect(Database, Effect.gen(function* ()
|
|
|
470
470
|
list: () => Effect.succeed([]),
|
|
471
471
|
reconcile: Effect.fn(function* ({ news, output }) {
|
|
472
472
|
const observed = output?.id ? yield* callOptional(() => client.GET("/v1/databases/{databaseId}", { params: { path: { databaseId: output.id } } })) : void 0;
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
name: news.name,
|
|
483
|
-
region: news.region,
|
|
484
|
-
...news.isDefault !== void 0 && { isDefault: news.isDefault }
|
|
485
|
-
}
|
|
486
|
-
}));
|
|
487
|
-
result = {
|
|
473
|
+
if (!observed) {
|
|
474
|
+
const created = yield* call(() => client.POST("/v1/databases", { body: {
|
|
475
|
+
projectId: news.projectId,
|
|
476
|
+
name: news.name,
|
|
477
|
+
region: news.region,
|
|
478
|
+
...news.isDefault !== void 0 && { isDefault: news.isDefault },
|
|
479
|
+
...news.branchId !== void 0 && { branchId: news.branchId }
|
|
480
|
+
} }));
|
|
481
|
+
return {
|
|
488
482
|
id: created.data.id,
|
|
489
483
|
name: created.data.name
|
|
490
484
|
};
|
|
491
485
|
}
|
|
486
|
+
const result = {
|
|
487
|
+
id: observed.data.id,
|
|
488
|
+
name: observed.data.name
|
|
489
|
+
};
|
|
492
490
|
if (news.branchId !== void 0) {
|
|
493
491
|
const branchId = news.branchId;
|
|
494
492
|
yield* call(() => client.PATCH("/v1/databases/{databaseId}", {
|
|
@@ -563,7 +561,7 @@ const providers = () => Layer.effect(Providers, Provider.collection([
|
|
|
563
561
|
EnvironmentVariable
|
|
564
562
|
])).pipe(Layer.provide(Layer.mergeAll(ProjectProvider(), DatabaseProvider(), ConnectionProvider(), ComputeServiceProvider(), DeploymentProvider(), EnvironmentVariableProvider())), Layer.provideMerge(layer()), Layer.provideMerge(fromEnv()), Layer.orDie);
|
|
565
563
|
//#endregion
|
|
566
|
-
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/state
|
|
564
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/state.mjs
|
|
567
565
|
/** The framework-owned database a stage's deploy state lives in — a child of that stage's Branch (ADR-0034). */
|
|
568
566
|
const STATE_DATABASE_NAME = "prisma-composer-state";
|
|
569
567
|
/** Every connection created against a state database carries this prefix — see `cleanupAgedConnections`. */
|
|
@@ -1293,16 +1291,31 @@ function computeDescriptor(o) {
|
|
|
1293
1291
|
...branch
|
|
1294
1292
|
}));
|
|
1295
1293
|
if (svc.expose !== void 0 && Object.keys(svc.expose).length > 0) {
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1294
|
+
const refsByBrand = /* @__PURE__ */ new Map();
|
|
1295
|
+
for (const edge of provisionedEdges(graph)) {
|
|
1296
|
+
if (edge.providerAddress !== address) continue;
|
|
1297
|
+
const ref = ctx.provisioned.get(edge.edgeId);
|
|
1298
|
+
if (ref === void 0) continue;
|
|
1299
|
+
const refs = refsByBrand.get(edge.brand) ?? [];
|
|
1300
|
+
refs.push(ref);
|
|
1301
|
+
refsByBrand.set(edge.brand, refs);
|
|
1302
|
+
}
|
|
1303
|
+
for (const [brand, entry] of o.providerParams) {
|
|
1304
|
+
const raw = entry.value(refsByBrand.get(brand) ?? []);
|
|
1305
|
+
if (raw === void 0) continue;
|
|
1306
|
+
const key = configKey(address, {
|
|
1307
|
+
owner: "service",
|
|
1308
|
+
name: entry.name
|
|
1309
|
+
});
|
|
1310
|
+
const value = Output.isOutput(raw) ? Output.map(raw, (v) => encode("service", v)) : encode("service", raw);
|
|
1311
|
+
records.push(yield* EnvironmentVariable(`${key}-var`, {
|
|
1312
|
+
projectId,
|
|
1313
|
+
key,
|
|
1314
|
+
value,
|
|
1315
|
+
class: cls,
|
|
1316
|
+
...branch
|
|
1317
|
+
}));
|
|
1318
|
+
}
|
|
1306
1319
|
}
|
|
1307
1320
|
return {
|
|
1308
1321
|
environment: records,
|
|
@@ -1957,6 +1970,63 @@ async function runTeardown(input, deps) {
|
|
|
1957
1970
|
const serviceKeyProvisioner = { provision: (edge) => Effect.gen(function* () {
|
|
1958
1971
|
return (yield* ServiceKey(`servicekey-${edge.edgeId}`, {})).value;
|
|
1959
1972
|
}) };
|
|
1973
|
+
/**
|
|
1974
|
+
* `ctx.provisioned`'s refs are typed `unknown` — core forwards a provisioner's
|
|
1975
|
+
* ref without inspecting it. Each provider param below is the sole reader of
|
|
1976
|
+
* its own provisioner's output, so the shape is asserted here, once, rather
|
|
1977
|
+
* than checked.
|
|
1978
|
+
*/
|
|
1979
|
+
const asKeyOutputs = (refs) => refs.map((ref) => blindCast(ref));
|
|
1980
|
+
/**
|
|
1981
|
+
* RPC's deploy-side `value(refs)` (ADR-0030): the provider stores a SET — one
|
|
1982
|
+
* key per inbound edge — into the accepted-keys var `serve()` reads. Paired
|
|
1983
|
+
* with the provisioner above: mint per edge, aggregate every edge.
|
|
1984
|
+
*
|
|
1985
|
+
* Zero consumers still emits, and that is the whole point of #100: an ABSENT
|
|
1986
|
+
* var means "never provisioned" and passes every caller through, so a deployed
|
|
1987
|
+
* provider nobody wired must say "[]" — deny everything — rather than say
|
|
1988
|
+
* nothing. Written as a literal because `Output.all()` with no arguments has
|
|
1989
|
+
* nothing to resolve.
|
|
1990
|
+
*/
|
|
1991
|
+
const rpcAcceptedKeysValue = (refs) => refs.length > 0 ? Output.all(...asKeyOutputs(refs)) : [];
|
|
1992
|
+
/**
|
|
1993
|
+
* ADR-0031's registered provisioner for STREAMS_API_KEY — the same `ServiceKey`
|
|
1994
|
+
* mint, keyed PER PROVIDER instead of per edge: the resource id is the
|
|
1995
|
+
* provider's address, so every consumer edge of one streams module resolves to
|
|
1996
|
+
* the same resource and therefore the same stable value. That is what
|
|
1997
|
+
* `@prisma/streams-server` requires (it authenticates a single `API_KEY`), and
|
|
1998
|
+
* cardinality is exactly what ADR-0031 leaves to the provisioner. Making it
|
|
1999
|
+
* per-edge later is this id's shape plus an accepted-set provider param — no
|
|
2000
|
+
* new resource, no core change.
|
|
2001
|
+
*/
|
|
2002
|
+
const streamsApiKeyProvisioner = { provision: (edge) => Effect.gen(function* () {
|
|
2003
|
+
return (yield* ServiceKey(`streamskey-${edge.providerAddress}`, {})).value;
|
|
2004
|
+
}) };
|
|
2005
|
+
/**
|
|
2006
|
+
* Streams' deploy-side `value(refs)`: ONE value, not a set —
|
|
2007
|
+
* `@prisma/streams-server` authenticates a single `API_KEY`, which is why the
|
|
2008
|
+
* provisioner above mints per provider. That pairing is the invariant this
|
|
2009
|
+
* param depends on, so it asserts rather than trusts it: a future per-edge
|
|
2010
|
+
* flip without a paired accepted-set param here would otherwise ship
|
|
2011
|
+
* whichever key came first and leave every other consumer 401ing, silently.
|
|
2012
|
+
* The refs are lazy Outputs (not comparable at serialize time); inside
|
|
2013
|
+
* `Output.map` they are resolved strings, the same seam RPC's set aggregates
|
|
2014
|
+
* on.
|
|
2015
|
+
*
|
|
2016
|
+
* Zero consumers emits NOTHING — the streams counterpart to RPC's "[]".
|
|
2017
|
+
* `@prisma/streams-server` has no deny-all mode: it either authenticates a key
|
|
2018
|
+
* or runs --no-auth, so there is no value here that means "refuse everyone".
|
|
2019
|
+
* Writing no key is what fails closed — the entrypoint refuses to boot with
|
|
2020
|
+
* a named error rather than serve unauthenticated.
|
|
2021
|
+
*/
|
|
2022
|
+
const streamsApiKeyValue = (refs) => {
|
|
2023
|
+
if (refs.length === 0) return void 0;
|
|
2024
|
+
return Output.map(Output.all(...asKeyOutputs(refs)), (vals) => {
|
|
2025
|
+
const distinct = [...new Set(vals)];
|
|
2026
|
+
if (distinct.length > 1) throw new Error(`a streams provider was provisioned ${distinct.length} distinct keys across its ${refs.length} inbound bindings, but it can only be given one (@prisma/streams-server authenticates a single API_KEY). Its provisioner must mint per provider, not per edge — or this param must store an accepted-key set, once the server accepts one.`);
|
|
2027
|
+
return distinct[0] ?? "";
|
|
2028
|
+
});
|
|
2029
|
+
};
|
|
1960
2030
|
const KNOWN_REGION_SET = new Set(COMPUTE_REGIONS);
|
|
1961
2031
|
function isComputeRegion(value) {
|
|
1962
2032
|
return KNOWN_REGION_SET.has(value);
|
|
@@ -1966,6 +2036,51 @@ function asProvidersLayer(layer) {
|
|
|
1966
2036
|
return layer;
|
|
1967
2037
|
}
|
|
1968
2038
|
/**
|
|
2039
|
+
* This extension's brands, each with the two halves ADR-0031 splits: the
|
|
2040
|
+
* PROVISIONER core resolves a mint through, and the reserved PROVIDER PARAM
|
|
2041
|
+
* that stores the minted values on the provider. So this file stays the only
|
|
2042
|
+
* place a brand is named — `descriptors/compute.ts` just looks a provider
|
|
2043
|
+
* param up by brand.
|
|
2044
|
+
*
|
|
2045
|
+
* `__tests__/provider-params.test.ts` asserts this map's brands are exactly
|
|
2046
|
+
* `PROVIDER_PARAMS`'s brands: a brand minted here with no provider param
|
|
2047
|
+
* below would leave the value it mints written to consumers while no
|
|
2048
|
+
* provider ever stores an accepted-keys row for it — `serve()` (or the
|
|
2049
|
+
* equivalent runtime reader) then sees an absent var and passes every caller
|
|
2050
|
+
* through.
|
|
2051
|
+
*/
|
|
2052
|
+
const PROVISIONERS = /* @__PURE__ */ new Map([[RPC_PEER_KEY, serviceKeyProvisioner], [STREAMS_API_KEY, streamsApiKeyProvisioner]]);
|
|
2053
|
+
/**
|
|
2054
|
+
* Every brand's deploy-side `value(refs)` — the only per-brand thing this
|
|
2055
|
+
* file still holds directly. `PROVIDER_PARAMS` below is built by mapping
|
|
2056
|
+
* `RESERVED_PROVIDER_PARAMS` (`provider-params.ts`, the boot-side list) onto
|
|
2057
|
+
* this map, so a param can exist on the deploy side only if it already
|
|
2058
|
+
* exists on the boot side: `RESERVED_PROVIDER_PARAMS` is the single source of
|
|
2059
|
+
* which reserved provider params exist at all, closing the drift the old
|
|
2060
|
+
* name-comparison test only detected after the fact.
|
|
2061
|
+
*/
|
|
2062
|
+
const PROVIDER_PARAM_VALUES = /* @__PURE__ */ new Map([[RPC_PEER_KEY, rpcAcceptedKeysValue], [STREAMS_API_KEY, streamsApiKeyValue]]);
|
|
2063
|
+
/**
|
|
2064
|
+
* Builds the deploy-side registry from the boot-side list, keyed by brand —
|
|
2065
|
+
* throws if a boot-side entry has no registered deploy-side `value(refs)`, so
|
|
2066
|
+
* `RESERVED_PROVIDER_PARAMS` stays the single source of which reserved
|
|
2067
|
+
* provider params exist: deploy can no longer write a row boot never
|
|
2068
|
+
* stashes. Exported (rather than inlined into `PROVIDER_PARAMS` below) so
|
|
2069
|
+
* `__tests__/provider-params.test.ts` can drive it directly with a
|
|
2070
|
+
* deliberately incomplete value map and watch it throw.
|
|
2071
|
+
*/
|
|
2072
|
+
function buildProviderParams(entries, values) {
|
|
2073
|
+
return new Map(entries.map((entry) => {
|
|
2074
|
+
const value = values.get(entry.brand);
|
|
2075
|
+
if (value === void 0) throw new Error(`prisma-cloud: reserved provider param "${entry.name}" (provider-params.ts) has no registered deploy-side value() in control.ts's PROVIDER_PARAM_VALUES — every param in RESERVED_PROVIDER_PARAMS must have one.`);
|
|
2076
|
+
return [entry.brand, {
|
|
2077
|
+
...entry,
|
|
2078
|
+
value
|
|
2079
|
+
}];
|
|
2080
|
+
}));
|
|
2081
|
+
}
|
|
2082
|
+
const PROVIDER_PARAMS = buildProviderParams(RESERVED_PROVIDER_PARAMS, PROVIDER_PARAM_VALUES);
|
|
2083
|
+
/**
|
|
1969
2084
|
* Resolves the factory's env-or-option inputs, failing fast with the exact
|
|
1970
2085
|
* variable name. `projectId`/`branchId` aren't required here — `prismaCloud()`
|
|
1971
2086
|
* also runs in the CLI parent, before they're set; the required check lives in `application.provision`.
|
|
@@ -1979,20 +2094,23 @@ function resolveOptions(opts) {
|
|
|
1979
2094
|
workspaceId,
|
|
1980
2095
|
region: opts.region,
|
|
1981
2096
|
projectId,
|
|
1982
|
-
branchId
|
|
2097
|
+
branchId,
|
|
2098
|
+
providerParams: PROVIDER_PARAMS
|
|
1983
2099
|
};
|
|
1984
2100
|
const region = process.env["PRISMA_REGION"];
|
|
1985
2101
|
if (region === void 0 || region.length === 0) return {
|
|
1986
2102
|
workspaceId,
|
|
1987
2103
|
projectId,
|
|
1988
|
-
branchId
|
|
2104
|
+
branchId,
|
|
2105
|
+
providerParams: PROVIDER_PARAMS
|
|
1989
2106
|
};
|
|
1990
2107
|
if (!isComputeRegion(region)) throw new Error(`prismaCloud(): environment variable PRISMA_REGION="${region}" is not a known region (expected one of: ${COMPUTE_REGIONS.join(", ")}).`);
|
|
1991
2108
|
return {
|
|
1992
2109
|
workspaceId,
|
|
1993
2110
|
region,
|
|
1994
2111
|
projectId,
|
|
1995
|
-
branchId
|
|
2112
|
+
branchId,
|
|
2113
|
+
providerParams: PROVIDER_PARAMS
|
|
1996
2114
|
};
|
|
1997
2115
|
}
|
|
1998
2116
|
/** The Prisma Cloud extension descriptor — `prisma-composer.config.ts` lists it under `extensions`. */
|
|
@@ -2015,7 +2133,7 @@ const prismaCloud = (opts = {}) => {
|
|
|
2015
2133
|
});
|
|
2016
2134
|
return { projectId };
|
|
2017
2135
|
}) },
|
|
2018
|
-
provisions:
|
|
2136
|
+
provisions: PROVISIONERS,
|
|
2019
2137
|
nodes: {
|
|
2020
2138
|
postgres: postgresDescriptor(o),
|
|
2021
2139
|
"prisma-next": prismaNextDescriptor(o),
|
|
@@ -2026,6 +2144,6 @@ const prismaCloud = (opts = {}) => {
|
|
|
2026
2144
|
};
|
|
2027
2145
|
};
|
|
2028
2146
|
//#endregion
|
|
2029
|
-
export { prismaCloud, prismaState };
|
|
2147
|
+
export { PROVIDER_PARAMS, buildProviderParams, prismaCloud, prismaState };
|
|
2030
2148
|
|
|
2031
2149
|
//# sourceMappingURL=control.mjs.map
|