@prisma/composer-prisma-cloud 0.14.0-dev.3 → 0.14.0-dev.5
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/auth/pack.mjs +1 -1
- package/dist/auth/pack.mjs.map +1 -1
- package/dist/auth/testing.mjs +1 -1
- package/dist/auth/testing.mjs.map +1 -1
- package/dist/control.d.mts +1 -0
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +52 -30
- package/dist/control.mjs.map +1 -1
- package/dist/local-target.mjs +3 -2
- package/dist/local-target.mjs.map +1 -1
- package/dist/{s3-credentials-resource-C0A8Q7aA-Dcl7iuHj.mjs → s3-credentials-resource-CZHsvOOZ-CDexsqlX.mjs} +10 -5
- package/dist/{s3-credentials-resource-C0A8Q7aA-Dcl7iuHj.mjs.map → s3-credentials-resource-CZHsvOOZ-CDexsqlX.mjs.map} +1 -1
- package/package.json +18 -18
package/dist/control.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as ProviderParamEntry } from "./serializer-BD_6nkr4-DWn5NNTC.mjs";
|
|
2
|
+
import "effect/Effect";
|
|
2
3
|
import * as Output from "alchemy/Output";
|
|
3
4
|
import * as AlchemyPrisma from "alchemy/Prisma";
|
|
4
5
|
import { ExtensionDescriptor, StateDescriptor } from "@prisma/composer/config";
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/control.d.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/control.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;UAqBU,sBAAsB;;;;;;;;WAQrB,QAAQ,6BAA6B,OAAO;;;;;;;;UAQ7C;WACC,gBAAgB,OAAO;;;;;;;;;;;;UAYxB,6BAA6B;WAC5B,kBAAkB,aAAa,8BAA8B,oBAAoB,OAAO;;;;;cAKrF,mBAAmB;UACvB;;EAER;;EAEA,SAAS,cAAc,MAAM;;;;;;;;KAQ1B,qBAAqB,KAAK,0BAA0B,KAAK;;;;;;;;;;iBAU7C,oBAAoB,kBAAkB,sBAAsB,QAAQ,oBAAoB,sBAAsB,oBAAoB,gBAAgB;cACrJ,iBAAiB,oBAAoB,gBAAgB;;cAErD,cAAc,OAAO,uBAAuB"}
|
package/dist/control.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { o as paramBindingFor, s as paramName } from "./secret-Dgyg1WyG-Dzz95fGI
|
|
|
2
2
|
import { a as encode, c as paramEntries, d as serializeInput, n as configKey, o as encodeParamPointer, r as decodeParamPointer, s as isParamPointerRow } from "./serializer-DTCrRl7S-CN0q1ZFB.mjs";
|
|
3
3
|
import { a as provisionedEdges, n as SELF_ORIGIN, r as STREAMS_API_KEY, t as RESERVED_PROVIDER_PARAMS } from "./provisioned-edges-DKsBi7uK-BmsYKWZI.mjs";
|
|
4
4
|
import { n as requiredPackHeadOf } from "./required-pack-head-BrrJarzc-DeP50pBu.mjs";
|
|
5
|
-
import { A as collectPages, C as appAfterEnvironment, D as RESERVED_DATABASE_URL_KEYS, E as PrismaApiError, F as fromEnv, I as managementApiBaseUrl, M as layer, N as resolveDefaultBranchId, O as call, P as PrismaCredentials, S as ServiceKeyProvider, T as ManagementClient, _ as resolveTargetRef, a as PgWarmProvider, b as providers, d as collectPreflightNames, f as containerDescriptor, g as resolvePrismaNextConfig, h as prismaCloudContainerOf, i as PgWarm, j as drivePagesAsync, k as claimDatabaseUrlKeys, l as S3Credentials, m as packHeadRefHashes, n as GeneratedParamProvider, o as PnMigration, r as PRISMA_CLOUD_EXTENSION_ID, s as PnMigrationProvider, t as GeneratedParam, u as S3CredentialsProvider, w as isWithin, x as ServiceKey } from "./s3-credentials-resource-
|
|
5
|
+
import { A as collectPages, C as appAfterEnvironment, D as RESERVED_DATABASE_URL_KEYS, E as PrismaApiError, F as fromEnv, I as managementApiBaseUrl, M as layer, N as resolveDefaultBranchId, O as call, P as PrismaCredentials, S as ServiceKeyProvider, T as ManagementClient, _ as resolveTargetRef, a as PgWarmProvider, b as providers, d as collectPreflightNames, f as containerDescriptor, g as resolvePrismaNextConfig, h as prismaCloudContainerOf, i as PgWarm, j as drivePagesAsync, k as claimDatabaseUrlKeys, l as S3Credentials, m as packHeadRefHashes, n as GeneratedParamProvider, o as PnMigration, r as PRISMA_CLOUD_EXTENSION_ID, s as PnMigrationProvider, t as GeneratedParam, u as S3CredentialsProvider, w as isWithin, x as ServiceKey } from "./s3-credentials-resource-CZHsvOOZ-CDexsqlX.mjs";
|
|
6
6
|
import { n as isPnPostgresResourceNode } from "./prisma-next-hB3CQxKI-BYVc-k-F.mjs";
|
|
7
7
|
import { isParamSource } from "@prisma/composer";
|
|
8
8
|
import { blindCast } from "@prisma/composer/casts";
|
|
@@ -1452,7 +1452,7 @@ function validateName(value, source) {
|
|
|
1452
1452
|
if (value.length < PRISMA_NAME_MIN || value.length > PRISMA_NAME_MAX) throw new Error(`prisma-cloud: ${source} "${value}" (${value.length} characters) is not a valid Prisma resource name — Prisma requires ${PRISMA_NAME_MIN}–${PRISMA_NAME_MAX} characters. Rename the provision id (or the deploy --name) to fit.`);
|
|
1453
1453
|
}
|
|
1454
1454
|
function isCloudApplication(value) {
|
|
1455
|
-
return typeof value === "object" && value !== null && "projectId" in value && typeof value.projectId === "string" && "branchId" in value && (value.branchId === void 0 || typeof value.branchId === "string");
|
|
1455
|
+
return typeof value === "object" && value !== null && "projectId" in value && typeof value.projectId === "string" && "branchId" in value && (value.branchId === void 0 || typeof value.branchId === "string") && "defaultBranchId" in value && (value.defaultBranchId === void 0 || typeof value.defaultBranchId === "string") && "branchless" in value && typeof value.branchless === "boolean";
|
|
1456
1456
|
}
|
|
1457
1457
|
/** Narrows `ctx.application`, which core hands over as `unknown`, to this extension's own product; throws naming the hook when it hasn't run. */
|
|
1458
1458
|
function cloudApplicationOf(application) {
|
|
@@ -1463,6 +1463,44 @@ function projectIdOf(application) {
|
|
|
1463
1463
|
return cloudApplicationOf(application).projectId;
|
|
1464
1464
|
}
|
|
1465
1465
|
/**
|
|
1466
|
+
* The Branch a database attaches to. Upstream treats an omitted branch as
|
|
1467
|
+
* desired-unassigned (`branchId` PATCHed back to `null` on reconcile), so a
|
|
1468
|
+
* deploy container carrying neither id is a broken transport; only a
|
|
1469
|
+
* `branchless` (dev) container returns `undefined`.
|
|
1470
|
+
*/
|
|
1471
|
+
function attachmentBranchIdOf(application, id) {
|
|
1472
|
+
const app = cloudApplicationOf(application);
|
|
1473
|
+
const branchId = app.branchId ?? app.defaultBranchId;
|
|
1474
|
+
if (branchId === void 0 && !app.branchless) throw new Error(`prisma-cloud: cannot attach database "${id}" to a Branch — the resolved container carries neither a stage Branch id nor the project's default Branch id. Container resolution (ADR-0019) always provides one for a deploy; this is a bug in the container transport.`);
|
|
1475
|
+
return branchId;
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Upstream refuses an explicit display name combined with branch attachment
|
|
1479
|
+
* at create (create-then-attach, no idempotency key), so attached databases
|
|
1480
|
+
* take the generated physical name; only the branchless (dev) container takes
|
|
1481
|
+
* the `name` arm. The returned `url` is direct, not pooled — PgWarm and the
|
|
1482
|
+
* migration flows need a direct connection.
|
|
1483
|
+
*/
|
|
1484
|
+
const stageDatabase = ({ id, application, region }) => Effect.gen(function* () {
|
|
1485
|
+
const branchId = attachmentBranchIdOf(application, id);
|
|
1486
|
+
const db = yield* Prisma$1.Database(`${id}-db`, {
|
|
1487
|
+
project: projectIdOf(application),
|
|
1488
|
+
region: region ?? "us-east-1",
|
|
1489
|
+
...branchId !== void 0 ? { branchId } : { name: id }
|
|
1490
|
+
});
|
|
1491
|
+
const conn = yield* Prisma$1.Connection(`${id}-conn`, {
|
|
1492
|
+
database: db,
|
|
1493
|
+
name: id
|
|
1494
|
+
});
|
|
1495
|
+
return {
|
|
1496
|
+
db,
|
|
1497
|
+
url: Output.map(conn.directConnectionString, (value) => {
|
|
1498
|
+
if (value === void 0) throw new Error(`prisma-cloud: connection "${id}-conn" returned no direct connection string.`);
|
|
1499
|
+
return Redacted.value(value);
|
|
1500
|
+
})
|
|
1501
|
+
};
|
|
1502
|
+
});
|
|
1503
|
+
/**
|
|
1466
1504
|
* One Bucket per module-provisioned bucket resource — `id` is the module
|
|
1467
1505
|
* provision id, so a resource shared by several consumers is created exactly
|
|
1468
1506
|
* once. A BucketAccessKey is minted for the bucket: it is the reveal-once
|
|
@@ -1681,19 +1719,10 @@ function computeDescriptor(o) {
|
|
|
1681
1719
|
function postgresDescriptor(o) {
|
|
1682
1720
|
const lowering = ({ id, application }) => Effect.gen(function* () {
|
|
1683
1721
|
validateName(id, "resource name (from provision id)");
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
region: o().region
|
|
1688
|
-
...branchId !== void 0 ? { branchId } : { name: id }
|
|
1689
|
-
});
|
|
1690
|
-
const conn = yield* Prisma$1.Connection(`${id}-conn`, {
|
|
1691
|
-
database: db,
|
|
1692
|
-
name: id
|
|
1693
|
-
});
|
|
1694
|
-
const url = Output.map(conn.directConnectionString, (value) => {
|
|
1695
|
-
if (value === void 0) throw new Error(`prisma-cloud: connection "${id}-conn" returned no direct connection string.`);
|
|
1696
|
-
return Redacted.value(value);
|
|
1722
|
+
const { db, url } = yield* stageDatabase({
|
|
1723
|
+
id,
|
|
1724
|
+
application,
|
|
1725
|
+
region: o().region
|
|
1697
1726
|
});
|
|
1698
1727
|
return {
|
|
1699
1728
|
outputs: { url: (yield* PgWarm(`${id}-warm`, { url })).url },
|
|
@@ -1876,19 +1905,10 @@ async function runPackPreflight(graph) {
|
|
|
1876
1905
|
function prismaNextDescriptor(o) {
|
|
1877
1906
|
const lowering = ({ id, node, application, graph }) => Effect.gen(function* () {
|
|
1878
1907
|
validateName(id, "resource name (from provision id)");
|
|
1879
|
-
const
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
region: o().region
|
|
1883
|
-
...branchId !== void 0 ? { branchId } : { name: id }
|
|
1884
|
-
});
|
|
1885
|
-
const conn = yield* Prisma$1.Connection(`${id}-conn`, {
|
|
1886
|
-
database: db,
|
|
1887
|
-
name: id
|
|
1888
|
-
});
|
|
1889
|
-
const url = Output.map(conn.directConnectionString, (value) => {
|
|
1890
|
-
if (value === void 0) throw new Error(`prisma-cloud: connection "${id}-conn" returned no direct connection string.`);
|
|
1891
|
-
return Redacted.value(value);
|
|
1908
|
+
const { db, url } = yield* stageDatabase({
|
|
1909
|
+
id,
|
|
1910
|
+
application,
|
|
1911
|
+
region: o().region
|
|
1892
1912
|
});
|
|
1893
1913
|
if (!isPnPostgresResourceNode(node)) throw new Error(`prisma-next lowering received a non-prisma-next node (${id}).`);
|
|
1894
1914
|
const contractJson = node.provides.__cmp.contractJson;
|
|
@@ -2252,11 +2272,13 @@ const prismaCloud = (opts = {}) => {
|
|
|
2252
2272
|
}),
|
|
2253
2273
|
reporter: prismaCloudReporter(),
|
|
2254
2274
|
application: { provision: (ctx) => Effect.gen(function* () {
|
|
2255
|
-
const { projectId, branchId } = prismaCloudContainerOf(ctx.container);
|
|
2275
|
+
const { projectId, branchId, defaultBranchId, branchless } = prismaCloudContainerOf(ctx.container);
|
|
2256
2276
|
yield* claimDatabaseUrlKeys(projectId);
|
|
2257
2277
|
return {
|
|
2258
2278
|
projectId,
|
|
2259
|
-
branchId
|
|
2279
|
+
branchId,
|
|
2280
|
+
defaultBranchId,
|
|
2281
|
+
branchless
|
|
2260
2282
|
};
|
|
2261
2283
|
}) },
|
|
2262
2284
|
provisions: PROVISIONERS,
|