@prisma/composer-prisma-cloud 0.9.0-dev.1 → 0.10.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/auth/pack.mjs +1 -1
- package/dist/auth/pack.mjs.map +1 -1
- package/dist/auth/testing.mjs +1496 -982
- package/dist/auth/testing.mjs.map +1 -1
- package/dist/control.mjs +1 -1
- package/dist/control.mjs.map +1 -1
- package/dist/local-target.mjs +1 -1
- package/dist/local-target.mjs.map +1 -1
- package/dist/{s3-credentials-resource-BltGd-gG-BJIY99QX.mjs → s3-credentials-resource-vElUxfYi-Bb7ILl1X.mjs} +6 -4
- package/dist/{s3-credentials-resource-BltGd-gG-BJIY99QX.mjs.map → s3-credentials-resource-vElUxfYi-Bb7ILl1X.mjs.map} +1 -1
- package/package.json +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-credentials-resource-BltGd-gG-BJIY99QX.mjs","names":["Config","fs","path","os","randomBytes","managementClientLayer"],"sources":["../../../1-prisma-cloud/0-lowering/lowering/dist/client-I552wJ2o.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/http-d1HGunF-.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/container-BdSTYN8l.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/buckets.mjs","../../../0-framework/2-authoring/bundle-paths/dist/index.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/compute.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/postgres.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/index.mjs","../../../1-prisma-cloud/0-lowering/s3-protocol/dist/index.mjs","../../../1-prisma-cloud/1-extensions/target/dist/s3-credentials-resource-BltGd-gG.mjs"],"sourcesContent":["import { createManagementApiClient } from \"@prisma/management-api-sdk\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Config from \"effect/Config\";\n//#region src/credentials.ts\n/**\n* The Prisma service token used to authenticate Management API calls. Kept\n* as a Redacted value so it never lands in logs or error output.\n*/\nvar PrismaCredentials = class extends Context.Service()(\"PrismaCredentials\") {};\n/** Resolve the token from the `PRISMA_SERVICE_TOKEN` environment variable. */\nconst fromEnv = () => Layer.effect(PrismaCredentials, Effect.gen(function* () {\n\treturn { token: yield* Config.redacted(\"PRISMA_SERVICE_TOKEN\") };\n}));\n//#endregion\n//#region src/client.ts\n/** The origin every Management API call targets — also the origin the hosted Alchemy state API lives under. */\nconst MANAGEMENT_API_ORIGIN = \"https://api.prisma.io\";\n/**\n* The typed Prisma Management API client, built once from the resolved\n* credentials. Providers yield this in their outer Effect and call it inside\n* `reconcile` / `delete`.\n*/\nvar ManagementClient = class extends Context.Service()(\"PrismaManagementClient\") {};\nconst layer = (options) => Layer.effect(ManagementClient, Effect.gen(function* () {\n\tconst { token } = yield* PrismaCredentials;\n\treturn createManagementApiClient({\n\t\ttoken: Redacted.value(token),\n\t\tbaseUrl: options?.apiOrigin ?? \"https://api.prisma.io\"\n\t});\n}));\n//#endregion\nexport { fromEnv as a, PrismaCredentials as i, ManagementClient as n, layer as r, MANAGEMENT_API_ORIGIN as t };\n\n//# sourceMappingURL=client-I552wJ2o.mjs.map","import * as Effect from \"effect/Effect\";\nimport * as Data from \"effect/Data\";\n//#region src/http.ts\n/** A non-2xx response from the Management API (or a transport failure). */\nvar PrismaApiError = class extends Data.TaggedError(\"PrismaApiError\") {};\nconst attempt = (f) => Effect.tryPromise({\n\ttry: f,\n\tcatch: (cause) => new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: String(cause)\n\t})\n});\nconst fail = (r) => Effect.fail(new PrismaApiError({\n\tstatus: r.response.status,\n\tmessage: JSON.stringify(r.error)\n}));\n/** Unwrap `data`, failing on any API error. Preserves the SDK's response type. */\nconst call = (f) => attempt(f).pipe(Effect.flatMap((r) => r.error !== void 0 || r.data === void 0 ? fail(r) : Effect.succeed(r.data)));\n/** Unwrap `data`, mapping a 404 to `undefined` (resource gone / not found). */\nconst callOptional = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 404 ? Effect.succeed(void 0) : r.error !== void 0 ? fail(r) : Effect.succeed(r.data)));\n/** Fire-and-forget a call, tolerating a 404 (already deleted). */\nconst callVoid = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 404 || r.error === void 0 ? Effect.void : fail(r)));\n//#endregion\nexport { callVoid as i, call as n, callOptional as r, PrismaApiError as t };\n\n//# sourceMappingURL=http-d1HGunF-.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, t as PrismaApiError } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Data from \"effect/Data\";\n//#region src/pagination.ts\n/** Far beyond any real collection size per listing; hitting it means the API's pagination is broken. */\nconst MAX_PAGES = 1e3;\nconst brokenPaginationError = (description, reason) => new PrismaApiError({\n\tstatus: 0,\n\tmessage: `listing ${description} ${reason} — the Management API pagination appears broken; refusing to continue with a possibly incomplete listing.`\n});\n/** {@link drivePages} in its most common shape: every page's rows, accumulated. */\nconst collectPages = (description, fetchPage) => Effect.gen(function* () {\n\tconst rows = [];\n\tyield* drivePages(description, fetchPage, (data) => {\n\t\trows.push(...data);\n\t\treturn false;\n\t});\n\treturn rows;\n});\n/**\n* Drives a cursor-paginated Management API listing with a guard against\n* broken pagination: a cursor that does not advance, more pages reported\n* without a cursor to fetch them with, or more than {@link MAX_PAGES} pages,\n* FAILS instead of hanging forever or returning a listing known to be\n* incomplete. `onPage` receives each page's rows as they arrive; returning\n* `true` stops early (the caller found what it wanted).\n*/\nconst drivePages = (description, fetchPage, onPage) => Effect.gen(function* () {\n\tlet cursor;\n\tfor (let pageCount = 0;; pageCount++) {\n\t\tif (pageCount >= MAX_PAGES) return yield* Effect.fail(brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`));\n\t\tconst page = yield* fetchPage(cursor);\n\t\tif (onPage(page.data)) return;\n\t\tif (!page.pagination.hasMore) return;\n\t\tconst next = page.pagination.nextCursor;\n\t\tif (next === null) return yield* Effect.fail(brokenPaginationError(description, \"reported more pages but returned no cursor\"));\n\t\tif (next === cursor) return yield* Effect.fail(brokenPaginationError(description, \"returned a non-advancing cursor\"));\n\t\tcursor = next;\n\t}\n});\n/**\n* {@link drivePages} for Promise-based callers (e.g. target's preflight,\n* which speaks the SDK's `{data, error}` shape directly). Same guard, same\n* errors; deliberately a sibling loop rather than a wrapper, because routing\n* a Promise fetch through Effect and back (`Effect.tryPromise` +\n* `runPromise`) would re-wrap the caller's own thrown errors. `fetchPage`\n* rejections propagate untouched.\n*/\nasync function drivePagesAsync(description, fetchPage, onPage) {\n\tlet cursor;\n\tfor (let pageCount = 0;; pageCount++) {\n\t\tif (pageCount >= MAX_PAGES) throw brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`);\n\t\tconst page = await fetchPage(cursor);\n\t\tif (onPage(page.data)) return;\n\t\tif (!page.pagination.hasMore) return;\n\t\tconst next = page.pagination.nextCursor;\n\t\tif (next === null) throw brokenPaginationError(description, \"reported more pages but returned no cursor\");\n\t\tif (next === cursor) throw brokenPaginationError(description, \"returned a non-advancing cursor\");\n\t\tcursor = next;\n\t}\n}\n//#endregion\n//#region src/container.ts\n/** Raised with `ensure: false` when the app's Project (or a named stage's Branch) doesn't exist. */\nvar ContainerNotFoundError = class extends Data.TaggedError(\"ContainerNotFoundError\") {};\nconst listAllProjects = (client) => collectPages(\"projects\", (cursor) => call(() => client.GET(\"/v1/projects\", { params: { query: cursor === void 0 ? {} : { cursor } } })));\n/**\n* Workspace ids circulate in two shapes: `wksp_`-prefixed and bare. Compare\n* bare-to-bare so a `wksp_`-prefixed API id still matches a bare configured\n* one (the same normalization `state/bootstrap.ts` applies to the same\n* `/v1/projects` listing).\n*/\nconst bareWorkspaceId = (id) => id.startsWith(\"wksp_\") ? id.slice(5) : id;\n/**\n* Finds the app's Project by logical id or name in the workspace, creating\n* one if absent. Logical id match (exact, workspace-unique) is preferred over\n* display-name match (oldest-wins fallback for projects without a logical id).\n* Creates one if none match, unless `ensure` is `false` (find-only —\n* `destroy`), in which case an absent Project fails with\n* `ContainerNotFoundError`. No ownership marker and no `--project` override\n* (both deferred — see ADR-0019).\n*/\nconst resolveProject = (client, workspaceId, appName, ensure) => Effect.gen(function* () {\n\tconst workspaceProjects = (yield* listAllProjects(client)).filter((p) => bareWorkspaceId(p.workspace.id) === bareWorkspaceId(workspaceId));\n\tconst logicalIdMatch = workspaceProjects.find((p) => p.logicalId != null && p.logicalId === appName);\n\tif (logicalIdMatch !== void 0) return logicalIdMatch.id;\n\tconst nameMatch = workspaceProjects.filter((p) => p.name === appName).sort((a, b) => a.createdAt.localeCompare(b.createdAt))[0];\n\tif (nameMatch !== void 0) return nameMatch.id;\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({ appName }));\n\treturn (yield* call(() => client.POST(\"/v1/projects\", { body: {\n\t\tname: appName,\n\t\tworkspaceId,\n\t\tcreateDatabase: false,\n\t\tlogicalId: appName\n\t} })).pipe(Effect.catch((err) => err.status === 409 ? Effect.fail(new PrismaApiError({\n\t\tstatus: 409,\n\t\tmessage: \"a project with this name already exists in the workspace; rename your Composer module or free the name.\"\n\t})) : Effect.fail(err)))).data.id;\n});\n/**\n* The project's implicit default Branch — every live Project owns exactly\n* one (a platform invariant). The list endpoint has no `isDefault` filter,\n* so this pages through the Branches (bounded — drivePages) and returns as\n* soon as a page contains it. Never creates one: its absence means the\n* platform's invariant is broken, which is not something a deploy can\n* repair.\n*/\nconst resolveDefaultBranchId = (client, projectId) => Effect.gen(function* () {\n\tlet found;\n\tyield* drivePages(`branches of project ${projectId}`, (cursor) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\t\tpath: { projectId },\n\t\tquery: cursor === void 0 ? {} : { cursor }\n\t} })), (data) => {\n\t\tfound = data.find((b) => b.isDefault)?.id;\n\t\treturn found !== void 0;\n\t});\n\tif (found !== void 0) return found;\n\treturn yield* Effect.fail(new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: `project ${projectId} has no default Branch — the platform guarantees every live Project owns one; contact support.`\n\t}));\n});\nconst findBranchId = (client, projectId, gitName) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\tpath: { projectId },\n\tquery: { gitName }\n} })).pipe(Effect.map((page) => page.data[0]?.id));\n/**\n* Finds the stage's Branch by its exact `gitName`, creating it if absent\n* unless `ensure` is `false` (find-only — `destroy`), in which case an\n* absent Branch fails with `ContainerNotFoundError`. The Management API has\n* no server-side \"create-or-return\" idempotency (`POST\n* /v1/projects/:id/branches` 409s on a duplicate `gitName`, with no request\n* field to make that a no-op), so idempotency is client-side: observe\n* first, and on a racing 409 from create, re-observe rather than fail.\n*/\nconst resolveBranch = (client, projectId, gitName, appName, ensure) => Effect.gen(function* () {\n\tconst existing = yield* findBranchId(client, projectId, gitName);\n\tif (existing !== void 0) return existing;\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({\n\t\tappName,\n\t\tstage: gitName\n\t}));\n\treturn yield* call(() => client.POST(\"/v1/projects/{projectId}/branches\", {\n\t\tparams: { path: { projectId } },\n\t\tbody: { gitName }\n\t})).pipe(Effect.map((r) => r.data.id), Effect.catch((err) => err.status === 409 ? findBranchId(client, projectId, gitName).pipe(Effect.flatMap((id) => id === void 0 ? Effect.fail(err) : Effect.succeed(id))) : Effect.fail(err)));\n});\n/**\n* Resolves the two containers a stage's deploy runs into (ADR-0019): the\n* app's **Project**, found-or-created by name, and — for a named stage\n* only — its **Branch**, found-or-created by `gitName`. The default stage\n* (no `stage`) creates no Branch; `branchId` is omitted, and the project's\n* default Branch's id is read into `defaultBranchId` instead. With `ensure:\n* false` (`destroy`), nothing is created — an absent Project or Branch\n* fails with `ContainerNotFoundError` instead.\n*/\nconst resolveContainer = (opts) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tconst ensure = opts.ensure ?? true;\n\tconst projectId = yield* resolveProject(client, opts.workspaceId, opts.appName, ensure);\n\tif (opts.stage === void 0) return {\n\t\tprojectId,\n\t\tdefaultBranchId: yield* resolveDefaultBranchId(client, projectId)\n\t};\n\treturn {\n\t\tprojectId,\n\t\tbranchId: yield* resolveBranch(client, projectId, opts.stage, opts.appName, ensure)\n\t};\n});\n/**\n* Soft-deletes a Branch. Tolerates a 404 (already gone). The API refuses if\n* the Branch still has live members or is the production/default Branch —\n* that surfaces as a `PrismaApiError`.\n*/\nconst deleteBranch = (branchId) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tyield* callVoid(() => client.DELETE(\"/v1/branches/{branchId}\", { params: { path: { branchId } } }));\n});\n/**\n* Deletes a Project. Tolerates a 404 (already gone). The API refuses with a\n* 400 if the Project still has live dependencies (e.g. another stage's\n* Branch/resources) — that surfaces as a `PrismaApiError`.\n*/\nconst deleteProject = (projectId) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tyield* callVoid(() => client.DELETE(\"/v1/projects/{id}\", { params: { path: { id: projectId } } }));\n});\n//#endregion\nexport { resolveDefaultBranchId as a, drivePagesAsync as c, resolveContainer as i, deleteBranch as n, collectPages as o, deleteProject as r, drivePages as s, ContainerNotFoundError as t };\n\n//# sourceMappingURL=container-BdSTYN8l.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, r as callOptional } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy\";\n//#region src/buckets/Bucket.ts\n/** A Prisma **Object Store bucket** inside a project. */\nconst Bucket = Resource(\"Prisma.Bucket\");\nconst BucketProvider = () => Provider.effect(Bucket, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/buckets/{bucketId}\", { params: { path: { bucketId: output.id } } })) : void 0;\n\t\t\tif (observed) return {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name\n\t\t\t};\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/buckets\", { body: {\n\t\t\t\tprojectId: news.projectId,\n\t\t\t\tname: news.name,\n\t\t\t\t...news.branchId !== void 0 ? { branchId: news.branchId } : {}\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tname: created.data.name\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/buckets/{bucketId}\", { params: { path: { bucketId: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst b = yield* callOptional(() => client.GET(\"/v1/buckets/{bucketId}\", { params: { path: { bucketId: output.id } } }));\n\t\t\treturn b ? {\n\t\t\t\tid: b.data.id,\n\t\t\t\tname: b.data.name\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/buckets/BucketKey.ts\n/** A **bucket access key** for a Prisma Object Store bucket — yields the S3 credentials. */\nconst BucketKey = Resource(\"Prisma.BucketKey\");\nconst BucketKeyProvider = () => Provider.effect(BucketKey, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\n\t\t\t\"id\",\n\t\t\t\"bucketId\",\n\t\t\t\"secretAccessKey\",\n\t\t\t\"accessKeyId\",\n\t\t\t\"endpoint\",\n\t\t\t\"bucketName\"\n\t\t],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tif (output?.id) return output;\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/buckets/{bucketId}/keys\", {\n\t\t\t\tparams: { path: { bucketId: news.bucketId } },\n\t\t\t\tbody: {\n\t\t\t\t\tname: news.name,\n\t\t\t\t\trole: news.role\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tbucketId: news.bucketId,\n\t\t\t\taccessKeyId: created.data.accessKeyId,\n\t\t\t\tsecretAccessKey: Redacted.make(created.data.secretAccessKey),\n\t\t\t\tendpoint: created.data.endpoint,\n\t\t\t\tbucketName: created.data.bucketName\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/buckets/{bucketId}/keys/{keyId}\", { params: { path: {\n\t\t\t\tbucketId: output.bucketId,\n\t\t\t\tkeyId: output.id\n\t\t\t} } }));\n\t\t})\n\t};\n}));\n//#endregion\nexport { Bucket, BucketKey, BucketKeyProvider, BucketProvider };\n\n//# sourceMappingURL=buckets.mjs.map","import fs from \"node:fs\";\nimport path from \"node:path\";\n//#region src/bundle-paths.ts\n/**\n* The path-containment predicate and bundle-link validation shared by every\n* assembly and packaging seam (node/nextjs adapters, the compute artifact\n* writer, the local extractor). This predicate is the enforcement point of\n* ADR-0047's boundary — a symlink may be preserved only while its target\n* stays inside the assembled bundle — so it exists exactly once.\n*/\n/** Lexical containment: `candidate` is `root` itself or below it. Both paths\n* must already be absolute or share a resolution base; no filesystem access. */\nfunction isWithin(root, candidate) {\n\tconst relative = path.relative(root, candidate);\n\treturn relative === \"\" || !relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative);\n}\n/** Walks the assembled bundle and rejects a dangling symlink or one whose\n* resolved target escapes the bundle root. Symlinked directories are not\n* descended: their targets are validated, and their contents belong to the\n* target's own location. */\nasync function assertBundleSymlinksStayInside(bundleDir) {\n\tconst realRoot = await fs.promises.realpath(bundleDir);\n\tconst walk = async (directory) => {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst full = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tlet realTarget;\n\t\t\t\ttry {\n\t\t\t\t\trealTarget = await fs.promises.realpath(full);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new Error(`the assembled bundle contains a dangling symlink: ${full}`);\n\t\t\t\t}\n\t\t\t\tif (!isWithin(realRoot, realTarget)) throw new Error(`the assembled bundle contains a symlink whose target escapes the bundle: ${full} -> ${await fs.promises.readlink(full)}`);\n\t\t\t} else if (entry.isDirectory()) await walk(full);\n\t\t}\n\t};\n\tawait walk(bundleDir);\n}\n//#endregion\nexport { assertBundleSymlinksStayInside, isWithin };\n\n//# sourceMappingURL=index.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, r as callOptional, t as PrismaApiError } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy\";\nimport * as Schedule from \"effect/Schedule\";\nimport * as fs from \"node:fs\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport * as crypto$1 from \"node:crypto\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport * as zlib from \"node:zlib\";\nimport { isWithin } from \"@internal/bundle-paths\";\n//#region src/compute/ComputeService.ts\n/**\n* Stopping a deployment before the app that owns it can be\n* deleted is asynchronous on the platform's side: DELETE can 409 with this\n* message while the deployment is still winding down. Retrying blindly on\n* every API error would mask real failures (bad auth, a genuinely conflicting\n* state, etc.), so this only matches the platform's specific \"not delete-safe\n* yet\" wording — everything else fails immediately, as before.\n*/\nconst isDeleteNotSafeYet = (error) => error.message.includes(\"did not reach a delete-safe state\");\n/**\n* Backs off exponentially from 2s, capped at 5 minutes total — long enough\n* for the platform to finish stopping the deployment, short enough to still\n* fail loudly (rather than hang forever) if it never does.\n*/\nconst deleteSafeRetrySchedule = Schedule.exponential(\"2 seconds\", 2).pipe(Schedule.upTo({ duration: \"5 minutes\" }));\n/** Every region Prisma Compute serves — the runtime source of truth; `ComputeRegion` is derived from it so the two can never drift. */\nconst COMPUTE_REGIONS = [\n\t\"us-east-1\",\n\t\"us-west-1\",\n\t\"eu-west-3\",\n\t\"eu-central-1\",\n\t\"ap-northeast-1\",\n\t\"ap-southeast-1\"\n];\n/** A Prisma **Compute service** — the stable app identity behind a project. */\nconst ComputeService = Resource(\"Prisma.ComputeService\");\nconst ComputeServiceProvider = () => Provider.effect(ComputeService, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/apps/{appId}\", { params: { path: { appId: output.id } } })) : void 0;\n\t\t\tif (observed) return {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name,\n\t\t\t\tendpointDomain: observed.data.appEndpointDomain\n\t\t\t};\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/apps\", { body: {\n\t\t\t\tdisplayName: news.name,\n\t\t\t\tprojectId: news.projectId,\n\t\t\t\t...news.region && { regionId: news.region },\n\t\t\t\t...news.branchId !== void 0 && { branchId: news.branchId }\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tname: created.data.name,\n\t\t\t\tendpointDomain: created.data.appEndpointDomain\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/apps/{appId}\", { params: { path: { appId: output.id } } })).pipe(Effect.retry({\n\t\t\t\tschedule: deleteSafeRetrySchedule,\n\t\t\t\twhile: isDeleteNotSafeYet\n\t\t\t}));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst s = yield* callOptional(() => client.GET(\"/v1/apps/{appId}\", { params: { path: { appId: output.id } } }));\n\t\t\treturn s ? {\n\t\t\t\tid: s.data.id,\n\t\t\t\tname: s.data.name,\n\t\t\t\tendpointDomain: s.data.appEndpointDomain\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/compute/Deployment.ts\n/**\n* A **deployment** of a Prisma app — creates a deployment, uploads\n* its artifact, starts the VM, waits for it to run, then promotes it to the\n* app's stable endpoint.\n*/\nconst Deployment = Resource(\"Prisma.Deployment\");\nconst DeploymentProvider = () => Provider.effect(Deployment, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tconst waitForRunning = (deploymentId) => call(() => client.GET(\"/v1/deployments/{deploymentId}\", { params: { path: { deploymentId } } })).pipe(Effect.flatMap((v) => v.data.status === \"running\" ? Effect.void : Effect.fail(new PrismaApiError({\n\t\tstatus: 409,\n\t\tmessage: `deployment ${deploymentId} is ${v.data.status}, not running`\n\t}))), Effect.retry(Schedule.spaced(\"2 seconds\").pipe(Schedule.upTo({ duration: \"2 minutes\" }))));\n\treturn {\n\t\tstables: [],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news }) {\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/apps/{appId}/deployments\", {\n\t\t\t\tparams: { path: { appId: news.computeServiceId } },\n\t\t\t\tbody: news.port !== void 0 ? { portMapping: { http: news.port } } : {}\n\t\t\t}));\n\t\t\tconst deploymentId = created.data.id;\n\t\t\tif (created.data.uploadUrl) {\n\t\t\t\tconst uploadUrl = created.data.uploadUrl;\n\t\t\t\tconst artifact = yield* Effect.try({\n\t\t\t\t\ttry: () => fs.readFileSync(news.artifactPath),\n\t\t\t\t\tcatch: (cause) => new PrismaApiError({\n\t\t\t\t\t\tstatus: 0,\n\t\t\t\t\t\tmessage: `failed to read artifact ${news.artifactPath}: ${String(cause)}`\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t\tyield* Effect.tryPromise({\n\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\tconst res = await fetch(uploadUrl, {\n\t\t\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\t\t\tbody: artifact\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!res.ok) throw new PrismaApiError({\n\t\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\t\tmessage: `artifact upload failed: ${res.status} ${res.statusText}`\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tcatch: (cause) => cause instanceof PrismaApiError ? cause : new PrismaApiError({\n\t\t\t\t\t\tstatus: 0,\n\t\t\t\t\t\tmessage: String(cause)\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t}\n\t\t\tyield* call(() => client.POST(\"/v1/deployments/{deploymentId}/start\", { params: { path: { deploymentId } } }));\n\t\t\tyield* waitForRunning(deploymentId);\n\t\t\tconst deployedUrl = (yield* call(() => client.POST(\"/v1/apps/{appId}/promote\", {\n\t\t\t\tparams: { path: { appId: news.computeServiceId } },\n\t\t\t\tbody: { deploymentId }\n\t\t\t}))).data.appEndpointDomain;\n\t\t\treturn {\n\t\t\t\tdeploymentId,\n\t\t\t\t...deployedUrl !== void 0 && { deployedUrl }\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* () {}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.deploymentId) return void 0;\n\t\t\tconst v = yield* callOptional(() => client.GET(\"/v1/deployments/{deploymentId}\", { params: { path: { deploymentId: output.deploymentId } } }));\n\t\t\treturn v ? {\n\t\t\t\tdeploymentId: v.data.id,\n\t\t\t\t...v.data.previewDomain && { deployedUrl: v.data.previewDomain }\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/compute/EnvironmentVariable.ts\n/**\n* A project-scoped **environment variable** that Compute injects into the\n* project's services from their attached branch (e.g. wiring one module's URL into\n* another).\n*/\nconst EnvironmentVariable = Resource(\"Prisma.EnvironmentVariable\");\nconst EnvironmentVariableProvider = () => Provider.effect(EnvironmentVariable, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst cls = news.class ?? \"production\";\n\t\t\tlet id = output?.id;\n\t\t\tif (id !== void 0) {\n\t\t\t\tconst priorId = id;\n\t\t\t\tif (!(yield* callOptional(() => client.GET(\"/v1/environment-variables/{envVarId}\", { params: { path: { envVarId: priorId } } })))) id = void 0;\n\t\t\t}\n\t\t\tif (id === void 0) {\n\t\t\t\tconst matchId = blindCast(yield* call(() => client.GET(\"/v1/environment-variables\", { params: { query: blindCast({\n\t\t\t\t\tprojectId: news.projectId,\n\t\t\t\t\tclass: cls,\n\t\t\t\t\tkey: news.key,\n\t\t\t\t\t...news.branchId !== void 0 ? { branchId: news.branchId } : {}\n\t\t\t\t}) } }))).data?.find((row) => (row.branchId ?? null) === (news.branchId ?? null))?.id;\n\t\t\t\tif (matchId !== void 0) {\n\t\t\t\t\tif (!(news.key === \"DATABASE_URL\" || news.key === \"DATABASE_URL_POOLED\")) {\n\t\t\t\t\t\tconst scope = news.branchId !== void 0 ? `class \"${cls}\", branch \"${news.branchId}\"` : `class \"${cls}\"`;\n\t\t\t\t\t\tthrow new Error(`EnvironmentVariable \"${news.key}\" (project \"${news.projectId}\", ${scope}) exists but is untracked in this deploy state — refusing to overwrite a reserved COMPOSER_ key. Restore this deploy's hosted state, or remove the variable to let this deploy recreate it.`);\n\t\t\t\t\t}\n\t\t\t\t\tid = matchId;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (id !== void 0) {\n\t\t\t\tconst targetId = id;\n\t\t\t\tyield* call(() => client.PATCH(\"/v1/environment-variables/{envVarId}\", {\n\t\t\t\t\tparams: { path: { envVarId: targetId } },\n\t\t\t\t\tbody: { value: news.value }\n\t\t\t\t}));\n\t\t\t\treturn {\n\t\t\t\t\tid,\n\t\t\t\t\tkey: news.key\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/environment-variables\", { body: {\n\t\t\t\tprojectId: news.projectId,\n\t\t\t\tclass: cls,\n\t\t\t\tkey: news.key,\n\t\t\t\tvalue: news.value,\n\t\t\t\t...news.branchId ? { branchId: news.branchId } : {}\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tkey: created.data.key\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/environment-variables/{envVarId}\", { params: { path: { envVarId: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst v = yield* callOptional(() => client.GET(\"/v1/environment-variables/{envVarId}\", { params: { path: { envVarId: output.id } } }));\n\t\t\treturn v ? {\n\t\t\t\tid: v.data.id,\n\t\t\t\tkey: v.data.key\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/compute/artifact.ts\n/**\n* Assembles a Prisma Compute artifact: the app-built bundle plus the\n* extension-printed bootstrap and manifest, tarred and gzipped deterministically\n* (fixed mtimes, sorted entry order) so an unchanged service noops on\n* redeploy — a rebuild is the only thing that changes the hash. Lives here\n* (not in @prisma/composer-prisma-cloud/control) because it needs node:fs/node:zlib,\n* which the extension's shipped src may never import (invariant 5).\n*/\nconst MANIFEST_VERSION = \"1\";\n/** Finds main.js/main.mjs in a bundle dir when no explicit entry is given. */\nfunction resolveEntry(bundleDir, entry) {\n\tif (entry !== void 0) return entry;\n\tconst found = fs.readdirSync(bundleDir).find((f) => /^main\\.m?js$/.test(f));\n\tif (found === void 0) throw new Error(`no main.js/main.mjs found in bundle dir ${bundleDir}`);\n\treturn found;\n}\nfunction compareArchivePaths(left, right) {\n\treturn Buffer.compare(Buffer.from(left.relPath, \"utf8\"), Buffer.from(right.relPath, \"utf8\"));\n}\n/** All files and safe symlinks under `dir`, as dir-relative POSIX paths, in\n* sorted order. Symlinks are preserved as links — never dereferenced — after\n* their real target is proven to remain inside the bundle root. This accepts\n* framework-produced trees such as Next standalone while retaining ADR-0005's\n* boundary against packaging arbitrary files from the deploy machine. */\nfunction walkEntries(dir) {\n\tconst out = [];\n\tconst realRoot = fs.realpathSync(dir);\n\tconst visit = (sub) => {\n\t\tfor (const entry of fs.readdirSync(path.join(dir, sub), { withFileTypes: true })) {\n\t\t\tconst rel = sub.length > 0 ? `${sub}/${entry.name}` : entry.name;\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tconst symlinkPath = path.join(dir, ...rel.split(\"/\"));\n\t\t\t\tconst target = fs.readlinkSync(symlinkPath);\n\t\t\t\tif (path.sep === \"/\" && target.includes(\"\\\\\")) throw new Error(`bundle symlink at ${rel} has an unsupported backslash target: ${target}`);\n\t\t\t\tlet realTarget;\n\t\t\t\ttry {\n\t\t\t\t\trealTarget = fs.realpathSync(path.resolve(path.dirname(symlinkPath), target));\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new Error(`bundle symlink at ${rel} is dangling: ${target}`);\n\t\t\t\t}\n\t\t\t\tif (!isWithin(realRoot, realTarget)) throw new Error(`bundle symlink at ${rel} escapes the bundle root: ${target} — deploy artifacts may only preserve links whose targets are inside the assembled bundle.`);\n\t\t\t\tconst linkname = (path.isAbsolute(target) ? path.relative(fs.realpathSync(path.dirname(symlinkPath)), realTarget) : target).split(path.sep).join(\"/\");\n\t\t\t\tif (!isWithin(dir, path.resolve(path.dirname(symlinkPath), ...linkname.split(\"/\")))) throw new Error(`bundle symlink at ${rel} has a target that leaves the bundle: ${linkname} — its resolved target is inside the bundle, but the link path itself walks outside and re-enters, which every extractor rejects. Point the link at the in-bundle path directly.`);\n\t\t\t\tout.push({\n\t\t\t\t\trelPath: rel,\n\t\t\t\t\ttype: \"symlink\",\n\t\t\t\t\tlinkname\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) visit(rel);\n\t\t\telse if (entry.isFile()) {\n\t\t\t\tconst mode = fs.statSync(path.join(dir, ...rel.split(\"/\"))).mode;\n\t\t\t\tout.push({\n\t\t\t\t\trelPath: rel,\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\texecutable: (mode & 64) !== 0\n\t\t\t\t});\n\t\t\t} else throw new Error(`bundle contains an unsupported filesystem entry: ${rel}`);\n\t\t}\n\t};\n\tvisit(\"\");\n\treturn out.sort(compareArchivePaths);\n}\nfunction octal(value, length) {\n\treturn `${value.toString(8).padStart(length - 1, \"0\")}\\0`;\n}\n/** Splits a path into ustar's name (<=100 bytes) + prefix (<=155 bytes) fields. */\nfunction splitUstarPath(relPath) {\n\tif (Buffer.byteLength(relPath, \"utf8\") <= 100) return {\n\t\tname: relPath,\n\t\tprefix: \"\"\n\t};\n\tfor (let i = relPath.length - 1; i >= 0; i--) {\n\t\tif (relPath[i] !== \"/\") continue;\n\t\tconst prefix = relPath.slice(0, i);\n\t\tconst name = relPath.slice(i + 1);\n\t\tif (Buffer.byteLength(prefix, \"utf8\") <= 155 && Buffer.byteLength(name, \"utf8\") <= 100) return {\n\t\t\tname,\n\t\t\tprefix\n\t\t};\n\t}\n\tthrow new Error(`path too long for a ustar tar entry: ${relPath}`);\n}\nfunction paxRecord(key, value) {\n\tconst payload = ` ${key}=${value}\\n`;\n\tlet length = Buffer.byteLength(payload, \"utf8\") + 1;\n\twhile (true) {\n\t\tconst record = `${length}${payload}`;\n\t\tconst actualLength = Buffer.byteLength(record, \"utf8\");\n\t\tif (actualLength === length) return record;\n\t\tlength = actualLength;\n\t}\n}\nfunction ustarPathOrPlaceholder(relPath) {\n\ttry {\n\t\tsplitUstarPath(relPath);\n\t\treturn { path: relPath };\n\t} catch {\n\t\treturn {\n\t\t\tpath: `PaxEntries/${crypto$1.createHash(\"sha256\").update(relPath).digest(\"hex\").slice(0, 32)}`,\n\t\t\tpaxPath: relPath\n\t\t};\n\t}\n}\nfunction ustarHeader(relPath, size, options) {\n\tconst { name, prefix } = splitUstarPath(relPath);\n\tconst buf = Buffer.alloc(512);\n\tbuf.write(name, 0, 100, \"utf8\");\n\tbuf.write(octal(options.mode, 8), 100, 8, \"utf8\");\n\tbuf.write(octal(0, 8), 108, 8, \"utf8\");\n\tbuf.write(octal(0, 8), 116, 8, \"utf8\");\n\tbuf.write(octal(size, 12), 124, 12, \"utf8\");\n\tbuf.write(octal(0, 12), 136, 12, \"utf8\");\n\tbuf.write(\" \", 148, 8, \"utf8\");\n\tbuf.write(options.typeflag, 156, 1, \"utf8\");\n\tif (options.linkname !== void 0) buf.write(options.linkname, 157, 100, \"utf8\");\n\tbuf.write(\"ustar\\0\", 257, 6, \"utf8\");\n\tbuf.write(\"00\", 263, 2, \"utf8\");\n\tbuf.write(prefix, 345, 155, \"utf8\");\n\tlet sum = 0;\n\tfor (const b of buf) sum += b;\n\tbuf.write(`${sum.toString(8).padStart(6, \"0\")}\\0 `, 148, 8, \"utf8\");\n\treturn buf;\n}\nfunction createDeterministicTarGz(entries) {\n\tconst sorted = [...entries].sort(compareArchivePaths);\n\tconst chunks = [];\n\tfor (const entry of sorted) {\n\t\tconst archivePath = ustarPathOrPlaceholder(entry.relPath);\n\t\tconst pax = [archivePath.paxPath === void 0 ? \"\" : paxRecord(\"path\", archivePath.paxPath)];\n\t\tif (entry.type === \"symlink\" && Buffer.byteLength(entry.linkname, \"utf8\") > 100) pax.push(paxRecord(\"linkpath\", entry.linkname));\n\t\tconst paxContent = Buffer.from(pax.join(\"\"), \"utf8\");\n\t\tif (paxContent.length > 0) {\n\t\t\tconst digest = crypto$1.createHash(\"sha256\").update(entry.relPath).digest(\"hex\").slice(0, 32);\n\t\t\tchunks.push(ustarHeader(`PaxHeaders/${digest}`, paxContent.length, {\n\t\t\t\tmode: 420,\n\t\t\t\ttypeflag: \"x\"\n\t\t\t}));\n\t\t\tchunks.push(paxContent);\n\t\t\tconst paxPad = (512 - paxContent.length % 512) % 512;\n\t\t\tif (paxPad > 0) chunks.push(Buffer.alloc(paxPad));\n\t\t}\n\t\tif (entry.type === \"symlink\") chunks.push(ustarHeader(archivePath.path, 0, {\n\t\t\tmode: 511,\n\t\t\ttypeflag: \"2\",\n\t\t\tlinkname: Buffer.byteLength(entry.linkname, \"utf8\") <= 100 ? entry.linkname : \"././@LongSymLink\"\n\t\t}));\n\t\telse {\n\t\t\tchunks.push(ustarHeader(archivePath.path, entry.content.length, {\n\t\t\t\tmode: entry.mode,\n\t\t\t\ttypeflag: \"0\"\n\t\t\t}));\n\t\t\tchunks.push(entry.content);\n\t\t\tconst pad = (512 - entry.content.length % 512) % 512;\n\t\t\tif (pad > 0) chunks.push(Buffer.alloc(pad));\n\t\t}\n\t}\n\tchunks.push(Buffer.alloc(1024));\n\treturn zlib.gzipSync(Buffer.concat(chunks));\n}\n/**\n* Prints the bootstrap + manifest and tars them with the bundle into a\n* deterministic artifact. If bundleDir doesn't exist (e.g. `alchemy destroy`\n* run before any build), returns a placeholder rather than throwing — the\n* artifact is never read on destroy.\n*/\nfunction packageComputeArtifact(opts) {\n\tif (!fs.existsSync(opts.bundleDir)) return {\n\t\tpath: \"\",\n\t\tsha256: \"absent\"\n\t};\n\tconst entryFile = resolveEntry(opts.bundleDir, opts.bundleEntry);\n\tconst bootstrapData = `${JSON.stringify({\n\t\tmoduleEntrypoint: `./${entryFile}`,\n\t\tappEntrypoint: `./${opts.appEntry}`,\n\t\taddress: opts.address\n\t}, null, 2)}\\n`;\n\tconst bootstrap = `import { readFile } from \"node:fs/promises\";\n\nconst boot = JSON.parse(\n await readFile(new URL(\"./compute.bootstrap.json\", import.meta.url), \"utf8\"),\n);\n\n// Compute currently boots JavaScript with Bun. Its URL and URLSearchParams\n// implementations accept Object.defineProperty but reject assignment to\n// Node's custom-inspect symbol. SvelteKit assigns that symbol while creating a\n// tracked request URL, so install a narrow setter that materializes the same\n// own property Node would. Remove this compatibility shim when the upstream\n// Alchemy Compute runtime owns the equivalent normalization.\nif (process.versions.bun !== undefined) {\n const inspect = Symbol.for(\"nodejs.util.inspect.custom\");\n for (const constructor of [URL, URLSearchParams]) {\n const inherited = constructor.prototype[inspect];\n Object.defineProperty(constructor.prototype, inspect, {\n configurable: true,\n get() { return inherited; },\n set(value) {\n Object.defineProperty(this, inspect, { configurable: true, value, writable: true });\n },\n });\n }\n}\n\nconst main = (await import(boot.moduleEntrypoint)).default;\nawait main.run(boot.address, () => import(boot.appEntrypoint));\n`;\n\tconst manifest = `${JSON.stringify({\n\t\tmanifestVersion: MANIFEST_VERSION,\n\t\tentrypoint: \"bootstrap.js\",\n\t\taddress: opts.address\n\t}, null, 2)}\\n`;\n\tconst files = walkEntries(opts.bundleDir).map((entry) => entry.type === \"symlink\" ? entry : {\n\t\trelPath: entry.relPath,\n\t\ttype: \"file\",\n\t\tcontent: fs.readFileSync(path.join(opts.bundleDir, ...entry.relPath.split(\"/\"))),\n\t\tmode: entry.executable ? 493 : 420\n\t});\n\tfiles.push({\n\t\trelPath: \"bootstrap.js\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(bootstrap, \"utf8\"),\n\t\tmode: 420\n\t});\n\tfiles.push({\n\t\trelPath: \"compute.bootstrap.json\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(bootstrapData, \"utf8\"),\n\t\tmode: 420\n\t});\n\tfiles.push({\n\t\trelPath: \"compute.manifest.json\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(manifest, \"utf8\"),\n\t\tmode: 420\n\t});\n\tfiles.push({\n\t\trelPath: \"bunfig.toml\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(\"[install]\\nauto = \\\"disable\\\"\\n\", \"utf8\"),\n\t\tmode: 420\n\t});\n\tconst gz = createDeterministicTarGz(files);\n\tconst sha256 = crypto$1.createHash(\"sha256\").update(gz).digest(\"hex\");\n\tconst outDir = path.join(os.tmpdir(), `prisma-composer-compute-${String(os.userInfo().uid)}`, sha256.slice(0, 16));\n\tfs.mkdirSync(outDir, { recursive: true });\n\tconst outPath = path.join(outDir, `${opts.id}.tar.gz`);\n\tconst tmpPath = path.join(outDir, `.${opts.id}.${crypto$1.randomUUID()}.tmp`);\n\tfs.writeFileSync(tmpPath, gz);\n\tfs.renameSync(tmpPath, outPath);\n\treturn {\n\t\tpath: outPath,\n\t\tsha256\n\t};\n}\n//#endregion\n//#region src/compute/ServiceKey.ts\n/**\n* The `ServiceKey` Alchemy resource (ADR-0030) — mints a random 256-bit key\n* ONCE at create and keeps it STABLE across deploys, so an unchanged edge\n* no-ops on redeploy. Same mint-once-stable lifecycle as `S3Credentials`\n* (`packages/1-prisma-cloud/1-extensions/target/src/s3-credentials-resource.ts`):\n* Web Crypto only (`crypto.getRandomValues` — no `node:` import), persisted in\n* Alchemy state; on every later apply the provider returns the persisted\n* attributes (`reconcile`'s `output`) unchanged. One resource per RPC edge;\n* rotation is destroy/recreate.\n*/\n/** The `ServiceKey` resource constructor — `yield* Prisma.ServiceKey(id, {})` in the lowering. */\nconst ServiceKey = Resource(\"PrismaCloud.ServiceKey\");\n/** A fresh 256-bit key as 64 lowercase hex chars (Web Crypto — no node import). */\nfunction mintServiceKey() {\n\tconst bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32));\n\treturn { value: Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\") };\n}\n/**\n* The `ServiceKey` provider service. `reconcile` runs for create and update;\n* it returns the persisted `output` when present (a redeploy reuses the\n* stored key — the no-op property) and mints a fresh key only on first\n* create. Nothing to enumerate (`list` → `[]`) or tear down (`delete` →\n* no-op; the key lives only in state).\n*/\nconst serviceKeyProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ output }) => Effect.sync(() => output ?? mintServiceKey()),\n\tdelete: () => Effect.void\n};\n/** The `ServiceKey` provider layer — merged into the Prisma Cloud extension's `providers()`. */\nconst ServiceKeyProvider = () => Provider.effect(ServiceKey, Effect.succeed(serviceKeyProviderService));\n//#endregion\nexport { COMPUTE_REGIONS, ComputeService, ComputeServiceProvider, Deployment, DeploymentProvider, EnvironmentVariable, EnvironmentVariableProvider, ServiceKey, ServiceKeyProvider, deleteSafeRetrySchedule, isDeleteNotSafeYet, mintServiceKey, packageComputeArtifact, serviceKeyProviderService };\n\n//# sourceMappingURL=compute.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, r as callOptional, t as PrismaApiError } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy\";\n//#region src/postgres/Connection.ts\n/** A **connection** to a Prisma Postgres database — yields the connection string. */\nconst Connection = Resource(\"Prisma.Connection\");\nconst ConnectionProvider = () => Provider.effect(Connection, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\", \"connectionString\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tif (output?.id) return output;\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/databases/{databaseId}/connections\", {\n\t\t\t\tparams: { path: { databaseId: news.databaseId } },\n\t\t\t\tbody: { name: news.name }\n\t\t\t}));\n\t\t\tconst endpoints = created.data.endpoints;\n\t\t\tconst dsn = endpoints?.direct?.connectionString ?? endpoints?.pooled?.connectionString;\n\t\t\tif (dsn === void 0) return yield* Effect.fail(new PrismaApiError({\n\t\t\t\tstatus: 0,\n\t\t\t\tmessage: `connection ${created.data.id} returned no direct/pooled connection string`\n\t\t\t}));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tconnectionString: Redacted.make(dsn)\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/connections/{id}\", { params: { path: { id: output.id } } }));\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/postgres/Database.ts\n/** A Prisma **Postgres database** inside a project. */\nconst Database = Resource(\"Prisma.Database\");\nconst DatabaseProvider = () => Provider.effect(Database, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/databases/{databaseId}\", { params: { path: { databaseId: output.id } } })) : void 0;\n\t\t\tif (!observed) {\n\t\t\t\tconst created = yield* call(() => client.POST(\"/v1/databases\", { body: {\n\t\t\t\t\tprojectId: news.projectId,\n\t\t\t\t\tname: news.name,\n\t\t\t\t\tregion: news.region,\n\t\t\t\t\t...news.isDefault !== void 0 && { isDefault: news.isDefault },\n\t\t\t\t\t...news.branchId !== void 0 && { branchId: news.branchId }\n\t\t\t\t} }));\n\t\t\t\treturn {\n\t\t\t\t\tid: created.data.id,\n\t\t\t\t\tname: created.data.name\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name\n\t\t\t};\n\t\t\tif (news.branchId !== void 0) {\n\t\t\t\tconst branchId = news.branchId;\n\t\t\t\tyield* call(() => client.PATCH(\"/v1/databases/{databaseId}\", {\n\t\t\t\t\tparams: { path: { databaseId: result.id } },\n\t\t\t\t\tbody: { branchId }\n\t\t\t\t}));\n\t\t\t}\n\t\t\treturn result;\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/databases/{databaseId}\", { params: { path: { databaseId: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst d = yield* callOptional(() => client.GET(\"/v1/databases/{databaseId}\", { params: { path: { databaseId: output.id } } }));\n\t\t\treturn d ? {\n\t\t\t\tid: d.data.id,\n\t\t\t\tname: d.data.name\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/postgres/Project.ts\n/** A Prisma Developer Platform **Project** — the container for databases and compute services. */\nconst Project = Resource(\"Prisma.Project\");\nconst ProjectProvider = () => Provider.effect(Project, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/projects/{id}\", { params: { path: { id: output.id } } })) : void 0;\n\t\t\tif (observed) return {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name\n\t\t\t};\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/projects\", { body: {\n\t\t\t\tname: news.name,\n\t\t\t\tworkspaceId: news.workspaceId\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tname: created.data.name\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/projects/{id}\", { params: { path: { id: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst p = yield* callOptional(() => client.GET(\"/v1/projects/{id}\", { params: { path: { id: output.id } } }));\n\t\t\treturn p ? {\n\t\t\t\tid: p.data.id,\n\t\t\t\tname: p.data.name\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\nexport { Connection, ConnectionProvider, Database, DatabaseProvider, Project, ProjectProvider };\n\n//# sourceMappingURL=postgres.mjs.map","import { a as fromEnv, i as PrismaCredentials, n as ManagementClient, r as layer, t as MANAGEMENT_API_ORIGIN } from \"./client-I552wJ2o.mjs\";\nimport { a as resolveDefaultBranchId, c as drivePagesAsync, i as resolveContainer, n as deleteBranch, o as collectPages, r as deleteProject, s as drivePages, t as ContainerNotFoundError } from \"./container-BdSTYN8l.mjs\";\nimport { Bucket, BucketKey, BucketKeyProvider, BucketProvider } from \"./buckets.mjs\";\nimport { COMPUTE_REGIONS, ComputeService, ComputeServiceProvider, Deployment, DeploymentProvider, EnvironmentVariable, EnvironmentVariableProvider, ServiceKey, ServiceKeyProvider, deleteSafeRetrySchedule, isDeleteNotSafeYet, mintServiceKey, packageComputeArtifact, serviceKeyProviderService } from \"./compute.mjs\";\nimport { Connection, ConnectionProvider, Database, DatabaseProvider, Project, ProjectProvider } from \"./postgres.mjs\";\nimport * as Layer from \"effect/Layer\";\nimport * as Provider from \"alchemy/Provider\";\n//#region src/providers.ts\n/** The collection of Prisma resource providers. */\nvar Providers = class extends Provider.ProviderCollection()(\"Prisma\") {};\n/**\n* The Prisma provider bundle: every resource provider, the Management API\n* client, and env-based credentials. Plug into a stack with\n* `{ providers: Prisma.providers() }`.\n*/\nconst providers = () => Layer.effect(Providers, Provider.collection([\n\tProject,\n\tDatabase,\n\tConnection,\n\tComputeService,\n\tDeployment,\n\tEnvironmentVariable,\n\tBucket,\n\tBucketKey\n])).pipe(Layer.provide(Layer.mergeAll(ProjectProvider(), DatabaseProvider(), ConnectionProvider(), ComputeServiceProvider(), DeploymentProvider(), EnvironmentVariableProvider(), BucketProvider(), BucketKeyProvider())), Layer.provideMerge(layer()), Layer.provideMerge(fromEnv()), Layer.orDie);\n//#endregion\nexport { Bucket, BucketKey, BucketKeyProvider, BucketProvider, COMPUTE_REGIONS, ComputeService, ComputeServiceProvider, Connection, ConnectionProvider, ContainerNotFoundError, Database, DatabaseProvider, Deployment, DeploymentProvider, EnvironmentVariable, EnvironmentVariableProvider, MANAGEMENT_API_ORIGIN, ManagementClient, PrismaCredentials, Project, ProjectProvider, Providers, ServiceKey, ServiceKeyProvider, collectPages, deleteBranch, deleteProject, deleteSafeRetrySchedule, drivePages, drivePagesAsync, fromEnv, isDeleteNotSafeYet, layer as managementClientLayer, mintServiceKey, packageComputeArtifact, providers, resolveContainer, resolveDefaultBranchId, serviceKeyProviderService };\n\n//# sourceMappingURL=index.mjs.map","import { createHash, createHmac, randomUUID, timingSafeEqual } from \"node:crypto\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nconst DEFAULT_CONTENT_TYPE$1 = \"application/octet-stream\";\nconst TMP_DIR_NAME = \".tmp\";\nconst META_DIR_NAME = \".meta\";\nconst RESERVED_SEGMENTS = /* @__PURE__ */ new Set([TMP_DIR_NAME, META_DIR_NAME]);\nconst BUCKET_NAME_RE = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;\nfunction etagOf$1(bytes) {\n\treturn `\"${createHash(\"sha256\").update(bytes).digest(\"hex\")}\"`;\n}\nfunction isErrnoException(err) {\n\treturn err instanceof Error && \"code\" in err;\n}\nfunction isEnoent(err) {\n\treturn isErrnoException(err) && err.code === \"ENOENT\";\n}\n/**\n* Splits a key into its `/` segments, rejecting anything that could escape\n* the bucket dir or collide with the reserved `.tmp`/`.meta` namespaces:\n* `..` segments, an empty segment (leading/trailing/doubled `/`, which also\n* catches a leading-slash \"absolute\" key), or a segment literally `.tmp` or\n* `.meta` at any depth.\n*/\nfunction keySegments(key) {\n\tconst segments = key.split(\"/\");\n\tfor (const segment of segments) if (segment === \"\" || segment === \".\" || segment === \"..\" || RESERVED_SEGMENTS.has(segment)) throw new Error(`invalid object key: \"${key}\"`);\n\treturn segments;\n}\n/** `<bucketDir>/<key's segments>`, double-checked to still resolve inside `bucketDir`. */\nfunction objectPath(bucketDir, key) {\n\tconst target = path.join(bucketDir, ...keySegments(key));\n\tconst resolvedRoot = path.resolve(bucketDir) + path.sep;\n\tif (!(path.resolve(target) + path.sep).startsWith(resolvedRoot)) throw new Error(`invalid object key: \"${key}\"`);\n\treturn target;\n}\n/** `<bucketDir>/.meta/<key's segments>.json` — mirrors `objectPath`'s tree under `.meta`. */\nfunction sidecarPath(bucketDir, key) {\n\tconst segments = keySegments(key);\n\tconst last = segments[segments.length - 1];\n\tconst dirs = segments.slice(0, -1);\n\treturn path.join(bucketDir, META_DIR_NAME, ...dirs, `${last}.json`);\n}\n/** Write-temp-then-rename: never leaves a reader observing a partial file. */\nasync function writeAtomic(finalPath, tmpRoot, bytes) {\n\tawait fs.mkdir(tmpRoot, { recursive: true });\n\tconst tmpPath = path.join(tmpRoot, randomUUID());\n\tawait fs.writeFile(tmpPath, bytes);\n\tawait fs.mkdir(path.dirname(finalPath), { recursive: true });\n\tawait fs.rename(tmpPath, finalPath);\n}\nfunction isSidecar(value) {\n\treturn typeof value === \"object\" && value !== null && \"contentType\" in value && typeof value.contentType === \"string\" && \"etag\" in value && typeof value.etag === \"string\";\n}\nasync function readSidecar(sidecar) {\n\tlet raw;\n\ttry {\n\t\traw = await fs.readFile(sidecar, \"utf8\");\n\t} catch (err) {\n\t\tif (isEnoent(err)) return null;\n\t\tthrow err;\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (isSidecar(parsed)) return parsed;\n\t} catch {}\n\treturn null;\n}\n/** Read the object's bytes plus its metadata — adopting a sidecar-less file (dropped in by a developer) by computing and lazily persisting one. `null` when the object is missing. */\nasync function readObject(bucketDir, key) {\n\tconst target = objectPath(bucketDir, key);\n\tlet bytes;\n\ttry {\n\t\tbytes = await fs.readFile(target);\n\t} catch (err) {\n\t\tif (isEnoent(err)) return null;\n\t\tthrow err;\n\t}\n\tconst existing = await readSidecar(sidecarPath(bucketDir, key));\n\tif (existing) return {\n\t\tbytes,\n\t\tmeta: existing\n\t};\n\tconst meta = {\n\t\tcontentType: DEFAULT_CONTENT_TYPE$1,\n\t\tetag: etagOf$1(bytes)\n\t};\n\tawait writeAtomic(sidecarPath(bucketDir, key), path.join(bucketDir, TMP_DIR_NAME), Buffer.from(JSON.stringify(meta)));\n\treturn {\n\t\tbytes,\n\t\tmeta\n\t};\n}\n/** Remove now-empty directories from `startDir` up to (never including) `root`. */\nasync function pruneEmptyDirs(root, startDir) {\n\tconst resolvedRoot = path.resolve(root);\n\tlet dir = path.resolve(startDir);\n\twhile (dir !== resolvedRoot && dir.startsWith(resolvedRoot + path.sep)) {\n\t\tlet entries;\n\t\ttry {\n\t\t\tentries = await fs.readdir(dir);\n\t\t} catch (err) {\n\t\t\tif (isEnoent(err)) {\n\t\t\t\tdir = path.dirname(dir);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t\tif (entries.length > 0) break;\n\t\ttry {\n\t\t\tawait fs.rmdir(dir);\n\t\t} catch (err) {\n\t\t\tif (!isEnoent(err)) throw err;\n\t\t}\n\t\tdir = path.dirname(dir);\n\t}\n}\n/** Recursively lists every object key under `dir`, skipping `.tmp`/`.meta` at any depth. */\nasync function walkKeys(dir) {\n\tconst keys = [];\n\tasync function walk(current, prefix) {\n\t\tlet entries;\n\t\ttry {\n\t\t\tentries = await fs.readdir(current, { withFileTypes: true });\n\t\t} catch (err) {\n\t\t\tif (isEnoent(err)) return;\n\t\t\tthrow err;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (RESERVED_SEGMENTS.has(entry.name)) continue;\n\t\t\tconst rel = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`;\n\t\t\tif (entry.isDirectory()) await walk(path.join(current, entry.name), rel);\n\t\t\telse if (entry.isFile()) keys.push(rel);\n\t\t}\n\t}\n\tawait walk(dir, \"\");\n\treturn keys;\n}\n/**\n* A disk-backed `ObjectStore`: object bytes and a metadata sidecar under a\n* per-bucket directory the caller resolves. See the module doc for the\n* unknown-bucket / invalid-key failure shapes.\n*/\nfunction fsStore(resolveBucketDir) {\n\tfunction resolveDir(bucket) {\n\t\tif (!BUCKET_NAME_RE.test(bucket)) return void 0;\n\t\treturn resolveBucketDir(bucket);\n\t}\n\treturn {\n\t\tasync put(bucket, key, bytes, opts = {}) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) throw new Error(`no such bucket: \"${bucket}\"`);\n\t\t\tconst target = objectPath(dir, key);\n\t\t\tconst tmpRoot = path.join(dir, TMP_DIR_NAME);\n\t\t\tconst etag = etagOf$1(bytes);\n\t\t\tconst contentType = opts.contentType ?? DEFAULT_CONTENT_TYPE$1;\n\t\t\tawait writeAtomic(target, tmpRoot, bytes);\n\t\t\tawait writeAtomic(sidecarPath(dir, key), tmpRoot, Buffer.from(JSON.stringify({\n\t\t\t\tcontentType,\n\t\t\t\tetag\n\t\t\t})));\n\t\t\treturn { etag };\n\t\t},\n\t\tasync get(bucket, key, opts = {}) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return null;\n\t\t\tconst found = await readObject(dir, key);\n\t\t\tif (!found) return null;\n\t\t\tconst { bytes, meta } = found;\n\t\t\tconst size = bytes.byteLength;\n\t\t\tif (opts.range) {\n\t\t\t\tconst start = opts.range.start;\n\t\t\t\tconst end = opts.range.end === void 0 ? size - 1 : Math.min(opts.range.end, size - 1);\n\t\t\t\treturn {\n\t\t\t\t\tbytes: start > end ? /* @__PURE__ */ new Uint8Array(0) : bytes.subarray(start, end + 1),\n\t\t\t\t\tetag: meta.etag,\n\t\t\t\t\tcontentType: meta.contentType,\n\t\t\t\t\tsize\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tbytes: new Uint8Array(bytes),\n\t\t\t\tetag: meta.etag,\n\t\t\t\tcontentType: meta.contentType,\n\t\t\t\tsize\n\t\t\t};\n\t\t},\n\t\tasync head(bucket, key) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return null;\n\t\t\tconst found = await readObject(dir, key);\n\t\t\tif (!found) return null;\n\t\t\treturn {\n\t\t\t\tetag: found.meta.etag,\n\t\t\t\tsize: found.bytes.byteLength,\n\t\t\t\tcontentType: found.meta.contentType\n\t\t\t};\n\t\t},\n\t\tasync delete(bucket, key) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return;\n\t\t\tconst target = objectPath(dir, key);\n\t\t\tconst sidecar = sidecarPath(dir, key);\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(target);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isEnoent(err)) throw err;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(sidecar);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isEnoent(err)) throw err;\n\t\t\t}\n\t\t\tawait pruneEmptyDirs(dir, path.dirname(target));\n\t\t\tawait pruneEmptyDirs(path.join(dir, META_DIR_NAME), path.dirname(sidecar));\n\t\t},\n\t\tasync list(bucket, opts = {}) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return {\n\t\t\t\tkeys: [],\n\t\t\t\tisTruncated: false\n\t\t\t};\n\t\t\tconst prefix = opts.prefix ?? \"\";\n\t\t\tconst maxKeys = opts.maxKeys ?? 1e3;\n\t\t\tconst token = opts.continuationToken;\n\t\t\tconst matching = (await walkKeys(dir)).filter((key) => key.startsWith(prefix)).sort().filter((key) => token === void 0 ? true : key > token);\n\t\t\tconst page = matching.slice(0, maxKeys);\n\t\t\tconst isTruncated = matching.length > maxKeys;\n\t\t\tconst last = page.at(-1);\n\t\t\treturn {\n\t\t\t\tkeys: page,\n\t\t\t\tisTruncated,\n\t\t\t\t...isTruncated && last !== void 0 ? { nextContinuationToken: last } : {}\n\t\t\t};\n\t\t}\n\t};\n}\n//#endregion\n//#region src/sigv4.ts\n/**\n* AWS SigV4 verification for the S3 wire protocol (spec § 2 auth). The payload\n* hash comes from the client — `x-amz-content-sha256` (a real hash or\n* `UNSIGNED-PAYLOAD`) for header auth, `UNSIGNED-PAYLOAD` for presign — and is\n* never re-hashed; the verifier trusts what was signed, like a real S3 endpoint.\n* Runtime engine code (`node:crypto`); not re-exported from the authoring barrel.\n*\n* Also owns `mintKeyPair` (local-dev spec § 1) — the one key-pair generator\n* both the deploy-time `S3Credentials` resource and the local dev bucket\n* emulator's credential provisioning use.\n*/\nfunction randomBytes(n) {\n\treturn crypto.getRandomValues(new Uint8Array(n));\n}\nfunction toHexUpper(bytes) {\n\treturn Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\").toUpperCase();\n}\n/** A fresh SigV4 key pair: an AKIA-prefixed id and a 40-char base64 secret. */\nfunction mintKeyPair() {\n\treturn {\n\t\taccessKeyId: `AKIA${toHexUpper(randomBytes(8))}`,\n\t\tsecretAccessKey: btoa(String.fromCharCode(...randomBytes(30)))\n\t};\n}\nconst ALGORITHM = \"AWS4-HMAC-SHA256\";\nconst UNSIGNED_PAYLOAD = \"UNSIGNED-PAYLOAD\";\nfunction sha256Hex(data) {\n\treturn createHash(\"sha256\").update(data).digest(\"hex\");\n}\nfunction hmac(key, data) {\n\treturn createHmac(\"sha256\", key).update(data).digest();\n}\n/** AWS canonical URI encoding: every byte except the unreserved set is %XX. */\nfunction awsUriEncode(value) {\n\treturn encodeURIComponent(value).replace(/[!'()*]/g, (ch) => `%${ch.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%7E/g, \"~\");\n}\nfunction parseCredential(credential) {\n\tconst parts = credential.split(\"/\");\n\tif (parts.length !== 5 || parts[4] !== \"aws4_request\") return null;\n\tconst [accessKeyId, date, region, service] = parts;\n\tif (!accessKeyId || !date || !region || !service) return null;\n\treturn {\n\t\taccessKeyId,\n\t\tdate,\n\t\tregion,\n\t\tservice\n\t};\n}\nfunction signingKey(secret, scope) {\n\treturn hmac(hmac(hmac(hmac(`AWS4${secret}`, scope.date), scope.region), scope.service), \"aws4_request\");\n}\nfunction canonicalHeaders(url, req, signedHeaders) {\n\treturn signedHeaders.map((name) => {\n\t\treturn `${name}:${(name === \"host\" ? url.host : req.headers.get(name) ?? \"\").trim().replace(/\\s+/g, \" \")}\\n`;\n\t}).join(\"\");\n}\nfunction canonicalQuery(url, exclude) {\n\tconst entries = [];\n\tfor (const [key, value] of url.searchParams.entries()) {\n\t\tif (exclude !== void 0 && key === exclude) continue;\n\t\tentries.push([awsUriEncode(key), awsUriEncode(value)]);\n\t}\n\tconst cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;\n\tentries.sort(([ak, av], [bk, bv]) => cmp(ak, bk) || cmp(av, bv));\n\treturn entries.map(([k, v]) => `${k}=${v}`).join(\"&\");\n}\nfunction stringToSign(amzDate, scope, canonicalRequest) {\n\tconst scopeString = `${scope.date}/${scope.region}/${scope.service}/aws4_request`;\n\treturn [\n\t\tALGORITHM,\n\t\tamzDate,\n\t\tscopeString,\n\t\tsha256Hex(canonicalRequest)\n\t].join(\"\\n\");\n}\nfunction signatureMatches(expected, provided) {\n\tconst a = Buffer.from(expected, \"hex\");\n\tconst b = Buffer.from(provided, \"hex\");\n\treturn a.length === b.length && a.length > 0 && timingSafeEqual(a, b);\n}\n/** `YYYYMMDDTHHMMSSZ` → epoch ms, or null when malformed. */\nfunction parseAmzDate(amzDate) {\n\tconst match = /^(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})Z$/.exec(amzDate);\n\tif (!match) return null;\n\tconst [, y, mo, d, h, mi, s] = match;\n\treturn Date.UTC(Number(y), Number(mo) - 1, Number(d), Number(h), Number(mi), Number(s));\n}\nfunction parseAuthorizationHeader(header) {\n\tif (!header.startsWith(`${ALGORITHM} `)) return null;\n\tconst rest = header.slice(17);\n\tconst fields = /* @__PURE__ */ new Map();\n\tfor (const part of rest.split(\",\")) {\n\t\tconst eq = part.indexOf(\"=\");\n\t\tif (eq === -1) continue;\n\t\tfields.set(part.slice(0, eq).trim(), part.slice(eq + 1).trim());\n\t}\n\tconst credential = fields.get(\"Credential\");\n\tconst signedHeaders = fields.get(\"SignedHeaders\");\n\tconst signature = fields.get(\"Signature\");\n\tif (!credential || !signedHeaders || !signature) return null;\n\treturn {\n\t\tcredential,\n\t\tsignedHeaders: signedHeaders.split(\";\"),\n\t\tsignature\n\t};\n}\n/** The one signing core both auth forms share: check the access key, rebuild the canonical request, derive the key, compare in constant time. */\nfunction verifySignature(req, url, credentials, params) {\n\tif (params.scope.accessKeyId !== credentials.accessKeyId) return {\n\t\tok: false,\n\t\treason: \"unknown access key\"\n\t};\n\tconst canonicalRequest = [\n\t\treq.method,\n\t\turl.pathname,\n\t\tcanonicalQuery(url, params.excludeQuery),\n\t\tcanonicalHeaders(url, req, params.signedHeaders),\n\t\tparams.signedHeaders.join(\";\"),\n\t\tparams.payloadHash\n\t].join(\"\\n\");\n\treturn signatureMatches(hmac(signingKey(credentials.secretAccessKey, params.scope), stringToSign(params.amzDate, params.scope, canonicalRequest)).toString(\"hex\"), params.signature) ? { ok: true } : {\n\t\tok: false,\n\t\treason: \"signature mismatch\"\n\t};\n}\nfunction verifyHeader(req, url, credentials) {\n\tconst auth = parseAuthorizationHeader(req.headers.get(\"authorization\") ?? \"\");\n\tif (!auth) return {\n\t\tok: false,\n\t\treason: \"malformed Authorization header\"\n\t};\n\tconst scope = parseCredential(auth.credential);\n\tif (!scope) return {\n\t\tok: false,\n\t\treason: \"malformed credential scope\"\n\t};\n\tconst amzDate = req.headers.get(\"x-amz-date\");\n\tif (!amzDate) return {\n\t\tok: false,\n\t\treason: \"missing x-amz-date\"\n\t};\n\tconst payloadHash = req.headers.get(\"x-amz-content-sha256\");\n\tif (!payloadHash) return {\n\t\tok: false,\n\t\treason: \"missing x-amz-content-sha256\"\n\t};\n\treturn verifySignature(req, url, credentials, {\n\t\tscope,\n\t\tamzDate,\n\t\tsignedHeaders: auth.signedHeaders,\n\t\tpayloadHash,\n\t\tsignature: auth.signature\n\t});\n}\nfunction verifyPresigned(req, url, credentials, now) {\n\tconst q = url.searchParams;\n\tif (q.get(\"X-Amz-Algorithm\") !== ALGORITHM) return {\n\t\tok: false,\n\t\treason: \"unsupported presign algorithm\"\n\t};\n\tconst credentialRaw = q.get(\"X-Amz-Credential\");\n\tconst amzDate = q.get(\"X-Amz-Date\");\n\tconst expiresRaw = q.get(\"X-Amz-Expires\");\n\tconst signedHeadersRaw = q.get(\"X-Amz-SignedHeaders\");\n\tconst signature = q.get(\"X-Amz-Signature\");\n\tif (!credentialRaw || !amzDate || !expiresRaw || !signedHeadersRaw || !signature) return {\n\t\tok: false,\n\t\treason: \"incomplete presign parameters\"\n\t};\n\tconst scope = parseCredential(credentialRaw);\n\tif (!scope) return {\n\t\tok: false,\n\t\treason: \"malformed credential scope\"\n\t};\n\tconst signedAt = parseAmzDate(amzDate);\n\tconst expires = Number(expiresRaw);\n\tif (signedAt === null || !Number.isFinite(expires)) return {\n\t\tok: false,\n\t\treason: \"malformed presign date\"\n\t};\n\tif (now.getTime() > signedAt + expires * 1e3) return {\n\t\tok: false,\n\t\treason: \"presign expired\"\n\t};\n\treturn verifySignature(req, url, credentials, {\n\t\tscope,\n\t\tamzDate,\n\t\tsignedHeaders: signedHeadersRaw.split(\";\"),\n\t\tpayloadHash: UNSIGNED_PAYLOAD,\n\t\tsignature,\n\t\texcludeQuery: \"X-Amz-Signature\"\n\t});\n}\n/**\n* Verify a request's SigV4 signature against a single credential pair. Picks\n* the presigned form when `X-Amz-Signature` is present, otherwise the\n* `Authorization`-header form. `now` is injectable for deterministic\n* expiry tests.\n*/\nfunction verifyRequest(req, credentials, now = /* @__PURE__ */ new Date()) {\n\tconst url = new URL(req.url);\n\tif (url.searchParams.has(\"X-Amz-Signature\")) return verifyPresigned(req, url, credentials, now);\n\tif (req.headers.has(\"authorization\")) return verifyHeader(req, url, credentials);\n\treturn {\n\t\tok: false,\n\t\treason: \"unsigned request\"\n\t};\n}\n//#endregion\n//#region src/handler.ts\nconst DEFAULT_CONTENT_TYPE = \"application/octet-stream\";\n/** Path-style: `/{bucket}/{key…}`. Each segment is percent-decoded. */\nfunction parseTarget(url) {\n\tconst segments = url.pathname.split(\"/\").filter((s) => s.length > 0);\n\tif (segments.length === 0) return null;\n\tconst [bucket, ...keyParts] = segments;\n\treturn {\n\t\tbucket: decodeURIComponent(bucket ?? \"\"),\n\t\tkey: keyParts.map(decodeURIComponent).join(\"/\")\n\t};\n}\n/** `bytes=a-b` (inclusive) or `bytes=a-` (open-ended). Null when absent/malformed. */\nfunction parseRange(header) {\n\tif (!header) return null;\n\tconst match = /^bytes=(\\d+)-(\\d*)$/.exec(header.trim());\n\tif (!match) return null;\n\tconst start = Number(match[1]);\n\treturn match[2] ? {\n\t\tstart,\n\t\tend: Number(match[2])\n\t} : { start };\n}\nfunction xmlEscape(value) {\n\treturn value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\").replace(/'/g, \"'\");\n}\nfunction listXml(bucket, prefix, maxKeys, result) {\n\tconst contents = result.keys.map((k) => `<Contents><Key>${xmlEscape(k)}</Key></Contents>`).join(\"\");\n\tconst next = result.isTruncated && result.nextContinuationToken !== void 0 ? `<NextContinuationToken>${xmlEscape(result.nextContinuationToken)}</NextContinuationToken>` : \"\";\n\treturn `<?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>\";\n}\nconst DEFAULT_MAX_KEYS$1 = 1e3;\nasync function handleList(store, bucket, url) {\n\tconst prefix = url.searchParams.get(\"prefix\") ?? \"\";\n\tconst continuationToken = url.searchParams.get(\"continuation-token\");\n\tconst maxKeysRaw = url.searchParams.get(\"max-keys\");\n\tconst maxKeys = maxKeysRaw !== null && Number.isFinite(Number(maxKeysRaw)) ? Number(maxKeysRaw) : DEFAULT_MAX_KEYS$1;\n\tconst result = await store.list(bucket, {\n\t\tprefix,\n\t\tmaxKeys,\n\t\t...continuationToken !== null ? { continuationToken } : {}\n\t});\n\treturn new Response(listXml(bucket, prefix, maxKeys, result), {\n\t\tstatus: 200,\n\t\theaders: { \"content-type\": \"application/xml\" }\n\t});\n}\n/** aws-chunked / flexible-checksum PUTs frame the body as chunks + a trailer (signalled by `x-amz-content-sha256: STREAMING-…` or `content-encoding: aws-chunked`); the seed signature still verifies, so reject them (501) rather than store the raw framing as the object bytes. Decoding is out of scope. */\nfunction isStreamingPut(req) {\n\tconst contentSha = req.headers.get(\"x-amz-content-sha256\") ?? \"\";\n\tconst contentEncoding = req.headers.get(\"content-encoding\") ?? \"\";\n\treturn contentSha.startsWith(\"STREAMING-\") || contentEncoding.split(\",\").some((e) => e.trim() === \"aws-chunked\");\n}\nasync function handlePut(store, t, req) {\n\tif (isStreamingPut(req)) return new Response(\"aws-chunked / flexible checksums not supported; set requestChecksumCalculation: 'WHEN_REQUIRED'\", { status: 501 });\n\tconst body = new Uint8Array(await req.arrayBuffer());\n\tconst contentType = req.headers.get(\"content-type\") ?? DEFAULT_CONTENT_TYPE;\n\tconst { etag } = await store.put(t.bucket, t.key, body, { contentType });\n\treturn new Response(null, {\n\t\tstatus: 200,\n\t\theaders: { etag }\n\t});\n}\n/** The etag/content-type/content-length/accept-ranges headers GET and HEAD share — `contentLength` is the slice length for GET, the total object size for HEAD. */\nfunction metaHeaders(meta) {\n\treturn new Headers({\n\t\tetag: meta.etag,\n\t\t\"content-type\": meta.contentType,\n\t\t\"content-length\": String(meta.contentLength),\n\t\t\"accept-ranges\": \"bytes\"\n\t});\n}\nasync function handleGet(store, t, req) {\n\tconst range = parseRange(req.headers.get(\"range\"));\n\tconst object = await store.get(t.bucket, t.key, range ? { range } : void 0);\n\tif (!object) return new Response(null, { status: 404 });\n\tconst headers = metaHeaders({\n\t\tetag: object.etag,\n\t\tcontentType: object.contentType,\n\t\tcontentLength: object.bytes.byteLength\n\t});\n\tif (!range) return new Response(object.bytes, {\n\t\tstatus: 200,\n\t\theaders\n\t});\n\tif (range.start >= object.size && object.size > 0) return new Response(null, {\n\t\tstatus: 416,\n\t\theaders: { \"content-range\": `bytes */${object.size}` }\n\t});\n\tconst end = range.end === void 0 ? object.size - 1 : Math.min(range.end, object.size - 1);\n\theaders.set(\"content-range\", `bytes ${range.start}-${end}/${object.size}`);\n\treturn new Response(object.bytes, {\n\t\tstatus: 206,\n\t\theaders\n\t});\n}\nasync function handleHead(store, t) {\n\tconst meta = await store.head(t.bucket, t.key);\n\tif (!meta) return new Response(null, { status: 404 });\n\treturn new Response(null, {\n\t\tstatus: 200,\n\t\theaders: metaHeaders({\n\t\t\tetag: meta.etag,\n\t\t\tcontentType: meta.contentType,\n\t\t\tcontentLength: meta.size\n\t\t})\n\t});\n}\nasync function handleDelete(store, t) {\n\tawait store.delete(t.bucket, t.key);\n\treturn new Response(null, { status: 204 });\n}\nfunction createS3Handler(opts) {\n\tconst { store, credentials } = opts;\n\treturn async (req) => {\n\t\tif (!verifyRequest(req, credentials).ok) return new Response(null, { status: 403 });\n\t\tconst url = new URL(req.url);\n\t\tconst target = parseTarget(url);\n\t\tif (!target) return new Response(null, { status: 400 });\n\t\tif (req.method === \"GET\" && url.searchParams.get(\"list-type\") === \"2\" && target.key === \"\") return handleList(store, target.bucket, url);\n\t\tif (target.key === \"\") return new Response(null, { status: 400 });\n\t\tswitch (req.method) {\n\t\t\tcase \"PUT\": return handlePut(store, target, req);\n\t\t\tcase \"GET\": return handleGet(store, target, req);\n\t\t\tcase \"HEAD\": return handleHead(store, target);\n\t\t\tcase \"DELETE\": return handleDelete(store, target);\n\t\t\tdefault: return new Response(null, { status: 405 });\n\t\t}\n\t};\n}\n//#endregion\n//#region src/memory-store.ts\n/**\n* An in-memory `ObjectStore` for the protocol tests — the same contract the\n* Postgres store (D3) implements. Test-only; never wired into a deployed\n* service. Not re-exported from the authoring barrel.\n*/\nconst DEFAULT_MAX_KEYS = 1e3;\nfunction etagOf(bytes) {\n\treturn `\"${createHash(\"sha256\").update(bytes).digest(\"hex\")}\"`;\n}\nvar MemoryObjectStore = class {\n\tentries = /* @__PURE__ */ new Map();\n\tid(bucket, key) {\n\t\treturn `${bucket}\\x00${key}`;\n\t}\n\tasync put(bucket, key, bytes, opts = {}) {\n\t\tconst copy = bytes.slice();\n\t\tconst etag = etagOf(copy);\n\t\tthis.entries.set(this.id(bucket, key), {\n\t\t\tbytes: copy,\n\t\t\tetag,\n\t\t\tcontentType: opts.contentType ?? \"application/octet-stream\"\n\t\t});\n\t\treturn { etag };\n\t}\n\tasync get(bucket, key, opts = {}) {\n\t\tconst entry = this.entries.get(this.id(bucket, key));\n\t\tif (!entry) return null;\n\t\tconst size = entry.bytes.byteLength;\n\t\tif (opts.range) {\n\t\t\tconst start = opts.range.start;\n\t\t\tconst end = opts.range.end === void 0 ? size - 1 : Math.min(opts.range.end, size - 1);\n\t\t\treturn {\n\t\t\t\tbytes: start > end ? /* @__PURE__ */ new Uint8Array(0) : entry.bytes.slice(start, end + 1),\n\t\t\t\tetag: entry.etag,\n\t\t\t\tcontentType: entry.contentType,\n\t\t\t\tsize\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tbytes: entry.bytes.slice(),\n\t\t\tetag: entry.etag,\n\t\t\tcontentType: entry.contentType,\n\t\t\tsize\n\t\t};\n\t}\n\tasync head(bucket, key) {\n\t\tconst entry = this.entries.get(this.id(bucket, key));\n\t\tif (!entry) return null;\n\t\treturn {\n\t\t\tetag: entry.etag,\n\t\t\tsize: entry.bytes.byteLength,\n\t\t\tcontentType: entry.contentType\n\t\t};\n\t}\n\tasync delete(bucket, key) {\n\t\tthis.entries.delete(this.id(bucket, key));\n\t}\n\tasync list(bucket, opts = {}) {\n\t\tconst prefix = opts.prefix ?? \"\";\n\t\tconst maxKeys = opts.maxKeys ?? DEFAULT_MAX_KEYS;\n\t\tconst token = opts.continuationToken;\n\t\tconst prefixHit = `${bucket}\\x00${prefix}`;\n\t\tconst matching = [...this.entries.keys()].filter((id) => id.startsWith(prefixHit)).map((id) => id.slice(bucket.length + 1)).sort().filter((key) => token === void 0 ? true : key > token);\n\t\tconst page = matching.slice(0, maxKeys);\n\t\tconst isTruncated = matching.length > maxKeys;\n\t\tconst last = page.at(-1);\n\t\treturn {\n\t\t\tkeys: page,\n\t\t\tisTruncated,\n\t\t\t...isTruncated && last !== void 0 ? { nextContinuationToken: last } : {}\n\t\t};\n\t}\n};\n//#endregion\nexport { MemoryObjectStore, createS3Handler, fsStore, mintKeyPair, verifyRequest };\n\n//# sourceMappingURL=index.mjs.map","import { a as isEnvParamSource, c as paramName, n as secretName, o as isGeneratedParamSource } from \"./secret-Doubjztg.mjs\";\nimport { i as withConnectionRetry, n as normalizeSslMode } from \"./pg-connection-CadPZuEK.mjs\";\nimport { inputManifest, isSecretSource, paramManifest } from \"@internal/core\";\nimport { ManagementClient, deleteBranch, deleteProject, fromEnv, managementClientLayer, resolveContainer } from \"@internal/lowering\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { Resource } from \"alchemy\";\nimport * as Provider from \"alchemy/Provider\";\nimport pg from \"pg\";\nimport { loadConfig } from \"@prisma/orm-toolchain/config-loader\";\nimport { resolve } from \"pathe\";\nimport { createPostgresControlClient } from \"@prisma/orm-postgres/control\";\nimport { readRef } from \"@prisma/orm-toolchain/migration-tools/refs\";\nimport { APP_SPACE_ID, readContractSpaceHeadRef, spaceMigrationDirectory, spaceRefsDirectory } from \"@prisma/orm-toolchain/migration-tools/spaces\";\nimport { mintKeyPair } from \"@internal/s3-protocol\";\n//#region src/container.ts\nconst PRISMA_CLOUD_EXTENSION_ID = \"@prisma/composer-prisma-cloud\";\n/** Accepts exactly what Alchemy's own `--stage` validation accepts (pinned 2.0.0-beta.59, `Cli/commands/_shared.ts`), rewritten without overlapping quantifiers so it cannot backtrack catastrophically. Asserted before a Branch id is exposed as a stage. */\nconst ALCHEMY_STAGE_PATTERN = /^[a-z0-9][-_a-z0-9]*$/i;\nfunction invalidAlchemyStageError(branchId) {\n\treturn /* @__PURE__ */ new Error(`${PRISMA_CLOUD_EXTENSION_ID}: the resolved Branch id \"${branchId}\" does not match Alchemy's stage pattern ^[a-z0-9][-_a-z0-9]*\\$ (case-insensitive) — it cannot scope the deploy state. The platform should never return such an id; contact support.`);\n}\nvar PrismaCloudContainer = class {\n\tinput;\n\tprojectId;\n\tbranchId;\n\tdefaultBranchId;\n\t/** The deterministic Alchemy stage (ContainerInstance SPI): the stage Branch's id, or the default Branch's id for the default stage. Absent only for the dev container, which resolves no Branch. */\n\talchemyStage;\n\tconstructor(input, projectId, branchId, defaultBranchId) {\n\t\tthis.input = input;\n\t\tthis.projectId = projectId;\n\t\tthis.branchId = branchId;\n\t\tthis.defaultBranchId = defaultBranchId;\n\t\tconst stageBranchId = branchId ?? defaultBranchId;\n\t\tif (stageBranchId !== void 0 && !ALCHEMY_STAGE_PATTERN.test(stageBranchId)) throw invalidAlchemyStageError(stageBranchId);\n\t\tthis.alchemyStage = stageBranchId;\n\t}\n\tserialize() {\n\t\treturn JSON.stringify({\n\t\t\tinput: this.input,\n\t\t\tprojectId: this.projectId,\n\t\t\t...this.branchId !== void 0 ? { branchId: this.branchId } : {},\n\t\t\t...this.defaultBranchId !== void 0 ? { defaultBranchId: this.defaultBranchId } : {}\n\t\t});\n\t}\n};\n/** `instanceof` — parent-side instances and child-side deserialized instances are both constructed by this module. */\nfunction isPrismaCloudContainer(value) {\n\treturn value instanceof PrismaCloudContainer;\n}\n/** Narrow-or-throw for hook inputs. */\nfunction prismaCloudContainerOf(value) {\n\tif (!isPrismaCloudContainer(value)) throw new Error(\"the Prisma Cloud container was not resolved — the extension's container descriptor did not run.\");\n\treturn value;\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction invalidPayloadError(reason) {\n\treturn /* @__PURE__ */ new Error(`${PRISMA_CLOUD_EXTENSION_ID}: invalid container transport payload — ${reason}.`);\n}\n/**\n* Reconstructs a `PrismaCloudContainer` from `serialize()`'s JSON output —\n* real narrowing, no casts. Exported so `dev/container.ts`'s\n* `devContainerDescriptor` can reuse it verbatim (local-dev spec § 5) — the\n* dev and deploy container descriptors deserialize the identical wire shape.\n*/\nfunction deserialize(serialized) {\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(serialized);\n\t} catch (error) {\n\t\tthrow invalidPayloadError(`not valid JSON (${error instanceof Error ? error.message : String(error)})`);\n\t}\n\tif (!isRecord(parsed)) throw invalidPayloadError(\"not an object\");\n\tconst input = parsed[\"input\"];\n\tif (!isRecord(input)) throw invalidPayloadError(\"\\\"input\\\" is not an object\");\n\tconst appName = input[\"appName\"];\n\tif (typeof appName !== \"string\") throw invalidPayloadError(\"\\\"input.appName\\\" is not a string\");\n\tconst stage = input[\"stage\"];\n\tif (stage !== void 0 && typeof stage !== \"string\") throw invalidPayloadError(\"\\\"input.stage\\\" is not a string or absent\");\n\tconst projectId = parsed[\"projectId\"];\n\tif (typeof projectId !== \"string\") throw invalidPayloadError(\"\\\"projectId\\\" is not a string\");\n\tconst branchId = parsed[\"branchId\"];\n\tif (branchId !== void 0 && typeof branchId !== \"string\") throw invalidPayloadError(\"\\\"branchId\\\" is not a string or absent\");\n\tconst defaultBranchId = parsed[\"defaultBranchId\"];\n\tif (defaultBranchId !== void 0 && typeof defaultBranchId !== \"string\") throw invalidPayloadError(\"\\\"defaultBranchId\\\" is not a string or absent\");\n\treturn new PrismaCloudContainer({\n\t\tappName,\n\t\tstage\n\t}, projectId, branchId, defaultBranchId);\n}\nconst workspaceRequiredError = () => /* @__PURE__ */ new Error(\"environment variable PRISMA_WORKSPACE_ID is required.\");\nconst tokenRequiredError = () => /* @__PURE__ */ new Error(\"environment variable PRISMA_SERVICE_TOKEN is required.\");\n/**\n* The caller's workspace id, or — only when the caller passed no credentials\n* at all — the env protocol, which is what the alchemy child process and\n* existing programmatic hosts have set.\n*/\nfunction requireWorkspaceId(credentials) {\n\tconst workspaceId = credentials === void 0 ? process.env[\"PRISMA_WORKSPACE_ID\"] : credentials.workspaceId;\n\tif (workspaceId === void 0 || workspaceId.length === 0) throw workspaceRequiredError();\n\treturn workspaceId;\n}\nfunction requireTokenUnlessInjected(client) {\n\tif (client === void 0 && (process.env[\"PRISMA_SERVICE_TOKEN\"] ?? \"\").length === 0) throw tokenRequiredError();\n}\nfunction clientFor(credentials, deps) {\n\treturn credentials?.client ?? deps?.client;\n}\n/** Runs against the injected client when there is one, and against an env-built one otherwise. */\nfunction runWithClient(program, client) {\n\treturn Effect.runPromise(client !== void 0 ? program.pipe(Effect.provideService(ManagementClient, client)) : program.pipe(Effect.provide(managementClientLayer().pipe(Layer.provide(fromEnv())))));\n}\nasync function ensureContainer(input, credentials, deps) {\n\tconst workspaceId = requireWorkspaceId(credentials);\n\tconst client = clientFor(credentials, deps);\n\trequireTokenUnlessInjected(client);\n\tconst outcome = await runWithClient(resolveContainer({\n\t\tworkspaceId,\n\t\tappName: input.appName,\n\t\t...input.stage !== void 0 ? { stage: input.stage } : {},\n\t\tensure: true\n\t}).pipe(Effect.map((c) => ({\n\t\tok: true,\n\t\tcontainer: c\n\t})), Effect.catchTag(\"PrismaApiError\", (e) => Effect.succeed({\n\t\tok: false,\n\t\tmessage: `Prisma Management API error resolving containers: ${e.message}.`\n\t}))), client);\n\tif (!outcome.ok) throw new Error(outcome.message);\n\treturn new PrismaCloudContainer(input, outcome.container.projectId, outcome.container.branchId, outcome.container.defaultBranchId);\n}\nasync function locateContainer(input, credentials, deps) {\n\tconst workspaceId = requireWorkspaceId(credentials);\n\tconst client = clientFor(credentials, deps);\n\trequireTokenUnlessInjected(client);\n\tconst outcome = await runWithClient(resolveContainer({\n\t\tworkspaceId,\n\t\tappName: input.appName,\n\t\t...input.stage !== void 0 ? { stage: input.stage } : {},\n\t\tensure: false\n\t}).pipe(Effect.map((c) => ({\n\t\tok: true,\n\t\tcontainer: c\n\t})), Effect.catchTag(\"ContainerNotFoundError\", () => Effect.succeed({ ok: false })), Effect.catchTag(\"PrismaApiError\", (e) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error resolving containers: ${e.message}.`)))), client);\n\tif (!outcome.ok) return void 0;\n\treturn new PrismaCloudContainer(input, outcome.container.projectId, outcome.container.branchId, outcome.container.defaultBranchId);\n}\n/**\n* Soft-deletes a named stage's Branch after a successful `alchemy destroy`\n* has removed its members — the Management API refuses to delete a Branch\n* that still has live members.\n*/\nasync function removeStageBranch(branchId, credentials, deps) {\n\tconst client = clientFor(credentials, deps);\n\trequireTokenUnlessInjected(client);\n\tconst outcome = await runWithClient(deleteBranch(branchId).pipe(Effect.map(() => ({ ok: true })), Effect.catchTag(\"PrismaApiError\", (e) => Effect.succeed({\n\t\tok: false,\n\t\tmessage: `Failed to delete the stage Branch: ${e.message}.`\n\t}))), client);\n\tif (!outcome.ok) throw new Error(outcome.message);\n}\n/**\n* Best-effort cleanup after a successful `--production` destroy: removes\n* the app's Project so hand-run stacks don't accumulate as empty Projects\n* (they eventually hit the workspace's plan limit). Unlike `removeStageBranch`,\n* this never throws: the destroy itself already succeeded, and the API's own\n* 400 (\"still has dependencies\") is the only check that matters — failing\n* the command over a cleanup step would be worse than leaving a Project shell.\n*/\nasync function removeAppProject(projectId, credentials, deps) {\n\tconst client = clientFor(credentials, deps);\n\tif (client === void 0 && (process.env[\"PRISMA_SERVICE_TOKEN\"] ?? \"\").length === 0) {\n\t\tconsole.warn(`Skipped removing the Project (${projectId}): PRISMA_SERVICE_TOKEN is not set.`);\n\t\treturn;\n\t}\n\tconst outcome = await runWithClient(deleteProject(projectId).pipe(Effect.map(() => ({ ok: true })), Effect.catchTag(\"PrismaApiError\", (e) => Effect.succeed({\n\t\tok: false,\n\t\terror: e\n\t}))), client);\n\tif (outcome.ok) {\n\t\tconsole.log(`Removed the Project (${projectId}) — nothing was left in it.`);\n\t\treturn;\n\t}\n\tif (outcome.error.status === 400) {\n\t\tconsole.log(`Kept the Project (${projectId}) — it still has another stage's resources.`);\n\t\treturn;\n\t}\n\tconsole.warn(`Could not remove the Project (${projectId}) after destroy: ${outcome.error.message}.`);\n}\nfunction containerDescriptor(deps) {\n\treturn {\n\t\tensure: (input, credentials) => ensureContainer(input, credentials, deps),\n\t\tlocate: (input, credentials) => locateContainer(input, credentials, deps),\n\t\tremove: (instance, credentials) => instance.input.stage !== void 0 ? removeStageBranch(instance.branchId ?? missingBranchId(instance), credentials, deps) : removeAppProject(instance.projectId, credentials, deps),\n\t\tdeserialize\n\t};\n}\n/** Defensive: a named-stage container always resolves a Branch together with its stage — `ensure`/`locate`/`deserialize` never produce one without the other. */\nfunction missingBranchId(instance) {\n\tthrow new Error(`${PRISMA_CLOUD_EXTENSION_ID}: a named-stage (\"${instance.input.stage}\") container instance is missing its branchId — this is a bug in ensure/locate/deserialize.`);\n}\n//#endregion\n//#region src/generated-param-resource.ts\n/**\n* The `GeneratedParam` Alchemy resource — generates a random value ONCE at\n* create and keeps it STABLE across deploys, so an unchanged service no-ops on\n* redeploy. The value is `bytes` random bytes produced with the Web Crypto\n* global (`crypto.getRandomValues` — no `node:` import, matching this package's\n* runtime-coupling invariant), base64-encoded, and persisted in Alchemy state;\n* on every later apply the provider returns the persisted attributes\n* (`reconcile`'s `output`) unchanged — the same way `S3Credentials` keeps its\n* pair stable. Changing `bytes` on an existing resource KEEPS the old value\n* (reconcile short-circuits on the persisted output); rotation is\n* destroy/recreate.\n*\n* One resource per `generatedParam()`-bound input leaf, provisioned by the\n* compute descriptor's serialize step; the resource id derives from the input\n* document row key and the leaf path, so the value is stable per service+leaf.\n*\n* Deploy-time only: imports `alchemy`. Imported by `control/extension.ts` and\n* tests, never by `index.ts` / the authoring entry.\n*/\n/** The `GeneratedParam` resource constructor — `yield* GeneratedParam(id, { bytes })` in the lowering. */\nconst GeneratedParam = Resource(\"PrismaCloud.GeneratedParam\");\n/** A fresh generated value: `bytes` random bytes, base64. */\nfunction generateValue(bytes) {\n\tconst random = crypto.getRandomValues(new Uint8Array(bytes));\n\treturn { value: btoa(String.fromCharCode(...random)) };\n}\n/**\n* The `GeneratedParam` provider service. `reconcile` runs for create and\n* update; it returns the persisted `output` when present (a redeploy reuses the\n* stored value — the no-op property, and the reason a `bytes` change does not\n* re-generate) and generates a fresh value only on first create. Nothing to\n* enumerate (`list` → `[]`) or tear down (`delete` → no-op; the value lives\n* only in state). Exported so tests can drive it directly.\n*/\nconst generatedParamProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ news, output }) => Effect.sync(() => output ?? generateValue(news.bytes)),\n\tdelete: () => Effect.void\n};\n/** The `GeneratedParam` provider layer — merged into the extension descriptor's `providers()`. */\nconst GeneratedParamProvider = () => Provider.effect(GeneratedParam, Effect.succeed(generatedParamProviderService));\n//#endregion\n//#region src/pg-warm-resource.ts\n/**\n* The `PgWarm` Alchemy resource (slice 3, FT-5226) — warm a freshly-provisioned\n* Prisma Postgres database at apply-time so it is ready by deploy-end, and the\n* first real connection (a service's runtime client, or the migration) doesn't\n* eat the cold-start reject.\n*\n* The DB `url` is a lazy `Output` at lowering time, so warming must be an\n* apply-time tracked resource (same pattern as `PnMigration`): its `reconcile`\n* receives the RESOLVED url and connects with `withConnectionRetry` + `select 1`,\n* riding out the cold-start. Shared by BOTH the bare-`postgres` and the\n* `prisma-next` lowerings; keyed on the connection `url`, so an unchanged\n* redeploy is a no-op (warming is idempotent anyway).\n*\n* Deploy-time only: imports `pg` directly + `alchemy`. Imported by `control.ts`\n* and tests, never by `index.ts` / the `./prisma-next` authoring entry — the\n* isolation invariants hold.\n*/\n/** The `PgWarm` resource constructor — `yield* PgWarm(id, { url })` in a lowering. */\nconst PgWarm = Resource(\"PrismaCloud.PgWarm\");\n/**\n* Connect (retrying the cold-start) and run `select 1`, then release the\n* connection. Exported so tests can drive it directly; `retry` overrides the\n* bounded retry's defaults.\n*/\nasync function warmDatabase(url, retry = {}) {\n\tawait withConnectionRetry(async () => {\n\t\tconst client = new pg.Client({ connectionString: normalizeSslMode(url) });\n\t\tclient.on(\"error\", (error) => console.error(\"pg warm client socket error\", error));\n\t\tawait client.connect();\n\t\ttry {\n\t\t\tawait client.query(\"select 1\");\n\t\t} finally {\n\t\t\tawait client.end();\n\t\t}\n\t}, retry);\n}\n/**\n* The `PgWarm` provider service. `reconcile` warms the DB (retrying the\n* cold-start) and echoes the `url` so a downstream resource that reads\n* `warm.url` runs only after the DB is warm. Idempotent — safe on redeploy;\n* nothing to enumerate (`list` → `[]`) or tear down (`delete` → no-op; the DB's\n* own deletion handles teardown). Exported so tests can drive it directly.\n*/\nconst pgWarmProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ news }) => Effect.tryPromise({\n\t\ttry: () => warmDatabase(news.url),\n\t\tcatch: (error) => error\n\t}).pipe(Effect.map(() => ({ url: news.url }))),\n\tdelete: () => Effect.void\n};\n/** The `PgWarm` provider layer — merged into the extension descriptor's `providers()`. */\nconst PgWarmProvider = () => Provider.effect(PgWarm, Effect.succeed(pgWarmProviderService));\n//#endregion\n//#region src/pn-config.ts\n/**\n* Resolves a `pnPostgres` resource's `prisma-next.config.ts` path to the\n* project facts the deploy needs (ADR-0022, slice 2): the on-disk migrations\n* directory the control client's `migrate`/`dbInit` read, and the declared\n* extension packs. Deploy-time only: loads PN's config (via c12) and applies\n* PN's own convention — `migrations.dir`, or the default `migrations/`,\n* relative to the config file's directory (mirrors the CLI's\n* `resolveMigrationPaths`). Imported by `control.ts` + tests, never by\n* `index.ts` / the `./prisma-next` authoring entry.\n*\n* `pathe` (not `node:path`) does the path work so the shipped source carries no\n* `node:` import — the same discipline `control.ts` already follows by\n* delegating fs/tar to `@internal/lowering` (invariant 5).\n*/\n/** Loads the config at `configPath` and resolves the facts the deploy consumes. */\nasync function resolvePrismaNextConfig(configPath) {\n\tconst config = await loadConfig(configPath);\n\treturn {\n\t\tmigrationsDir: resolve(configPath, \"..\", config.migrations?.dir ?? \"migrations\"),\n\t\textensionPacks: config.extensions ?? []\n\t};\n}\n/**\n* The pack-head identity entries the `PnMigration` resource folds into its\n* diff key: `\"<packId>:<headRefHash>\"` — each pack's contract-space head ref,\n* identified by its storage hash — sorted by pack id, so a pack upgrade (or a\n* pack added/removed) produces a distinct deploy step. A pack without a\n* `contractSpace` contributes `\"-\"` for its head — it declares no migratable\n* space, but its presence still belongs in the key.\n*/\nfunction packHeadRefHashes(packs) {\n\treturn packs.map((pack) => `${pack.id}:${pack.contractSpace?.headRef.hash ?? \"-\"}`).sort();\n}\n//#endregion\n//#region src/prisma-next-migrate.ts\n/**\n* The Prisma Next migration step of the deploy lowering (ADR-0022, slice 2) —\n* the safety-critical decision that brings a live database to a target REF\n* using ONLY Prisma Next's authored migrations.\n*\n* Deploy-time only: this module imports `@prisma/orm-postgres/control` (which\n* transitively pulls PN's control/migration machinery + `pg`). It is imported\n* by the deploy descriptors and this package's tests, NEVER by `index.ts` / the\n* `./prisma-next` authoring entry — so it never lands in an app runtime bundle\n* (the index-isolation invariant holds).\n*\n* The target is a ref `{ hash, invariants }` — not a bare `storageHash`. A\n* ref's `invariants` are named postconditions established by `data`-class\n* migration steps (e.g. a backfill), recorded monotonically on the live\n* marker. Keying on the hash alone would make a pure data-invariant change an\n* A→A self-edge the deploy wrongly skips. The decision, given the live marker\n* and the target ref (see {@link decideMigrationAction}):\n* - marker at ref.hash AND ref.invariants ⊆ marker.invariants → no-op\n* - no marker (fresh DB) AND no required invariants → `dbInit`\n* - otherwise → `migrate`\n*\n* `dbInit` is additive-only synthesis — it NEVER runs app-space data steps —\n* so it is only correct when the ref requires no invariants; a fresh DB whose\n* target carries invariants goes through `migrate`, which walks the AUTHORED\n* graph (including the invariant-bearing data migrations) from empty.\n*\n* Never `dbUpdate`: synthesized diff-and-apply plans are never run against a\n* deployed database. A no-authored-path (`MIGRATION_PATH_NOT_FOUND`) or a\n* runner failure fails the deploy as a typed `PnMigrationError` (not swallowed).\n* PN applies each migration in its own transaction, so a failed apply is atomic\n* and resume-safe — the marker and schema are left as the last committed step.\n*/\n/** A deploy-failing migration error — surfaced, never swallowed. */\nvar PnMigrationError = class extends Error {\n\tcode;\n\t/** PN's structured explanation, when present. */\n\twhy;\n\tconstructor(code, summary, why) {\n\t\tsuper(`prisma-next migrate (${code}): ${summary}`);\n\t\tthis.name = \"PnMigrationError\";\n\t\tthis.code = code;\n\t\tthis.why = why;\n\t}\n};\n/**\n* The target `storageHash` a contract heads to — `contractJson.storage.storageHash`.\n* Read defensively: `contractJson` crosses the boundary as `unknown`.\n*/\nfunction targetStorageHash(contractJson) {\n\tif (typeof contractJson === \"object\" && contractJson !== null && \"storage\" in contractJson) {\n\t\tconst storage = contractJson.storage;\n\t\tif (typeof storage === \"object\" && storage !== null && \"storageHash\" in storage) {\n\t\t\tconst hash = storage.storageHash;\n\t\t\tif (typeof hash === \"string\" && hash.length > 0) return hash;\n\t\t}\n\t}\n\tthrow new PnMigrationError(\"INIT_FAILED\", \"the contract has no storage.storageHash — cannot determine the target schema version\");\n}\n/**\n* Resolve the deploy's target ref from the migrations dir.\n*\n* - `targetRef` named: read `migrations/app/refs/<name>.json` — fail loudly\n* (`TARGET_REF_NOT_FOUND`) when the ref doesn't exist or can't be parsed.\n* - Default: the app space's head. PN synthesizes the app head from the\n* emitted contract — `{ hash: contract.storage.storageHash, invariants: [] }`\n* (`contract emit` writes no app-space `refs/head.json` today; extension\n* spaces have one on disk). When a future PN version does emit one, the\n* on-disk `head.json` wins — read via `readContractSpaceHeadRef`, exactly\n* the loader PN's own migrate uses.\n*/\nasync function resolveTargetRef(migrationsDir, contractJson, targetRef) {\n\tif (targetRef !== void 0) {\n\t\tconst refsDir = spaceRefsDirectory(spaceMigrationDirectory(migrationsDir, APP_SPACE_ID));\n\t\ttry {\n\t\t\tconst ref = await readRef(refsDir, targetRef);\n\t\t\treturn {\n\t\t\t\thash: ref.hash,\n\t\t\t\tinvariants: ref.invariants\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new PnMigrationError(\"TARGET_REF_NOT_FOUND\", `targetRef \"${targetRef}\" could not be read from ${refsDir}`, error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\tconst head = await readContractSpaceHeadRef(migrationsDir, APP_SPACE_ID);\n\tif (head !== null) return {\n\t\thash: head.hash,\n\t\tinvariants: head.invariants\n\t};\n\treturn {\n\t\thash: targetStorageHash(contractJson),\n\t\tinvariants: []\n\t};\n}\n/**\n* The pure migration decision, mirroring PN's own verifier: the database is\n* AT the target when the marker's hash equals the ref's hash AND every ref\n* invariant is on the marker (marker invariants are monotonic). `dbInit` is\n* additive-only synthesis, so it is chosen only for a fresh DB whose\n* effective required invariants (`ref.invariants − marker.invariants`) are\n* empty; anything else — different hash, missing invariant (the A→A\n* data-only self-edge), or a fresh DB with required invariants — walks the\n* authored graph via `migrate`.\n*/\nfunction decideMigrationAction(marker, ref) {\n\tconst markerInvariants = new Set(marker?.invariants ?? []);\n\tconst missing = ref.invariants.filter((id) => !markerInvariants.has(id));\n\tif (marker !== null && marker.storageHash === ref.hash && missing.length === 0) return \"noop\";\n\tif (marker === null && missing.length === 0) return \"init\";\n\treturn \"migrate\";\n}\n/**\n* Bring the database at `url` to the target ref via PN's authored migrations.\n* Reads the live marker, decides no-op / init / migrate\n* ({@link decideMigrationAction}), applies, and throws a typed\n* {@link PnMigrationError} on a no-path or runner failure. `migrationsDir` is\n* the on-disk migrations root and `ref` the resolved target\n* ({@link resolveTargetRef} — both resolved by the lowering, which also keys\n* the PnMigration resource on them). `refName` (the resource's `targetRef`,\n* when set) is threaded into `migrate` so PN targets the named ref's hash and\n* plans an invariant-bearing path.\n*/\nasync function applyPnMigration(opts) {\n\tconst connection = normalizeSslMode(opts.url);\n\treturn withConnectionRetry(() => runMigration(connection, opts.contractJson, opts.migrationsDir, opts.ref, opts.refName, opts.extensionPacks ?? []), { shouldRetry: (error) => !(error instanceof PnMigrationError) });\n}\nasync function runMigration(connection, contractJson, migrationsDir, ref, refName, extensionPacks) {\n\tconst client = createPostgresControlClient({\n\t\tconnection,\n\t\textensions: extensionPacks\n\t});\n\tawait client.connect();\n\ttry {\n\t\tconst marker = await client.readMarker();\n\t\tconst markerHashBefore = marker?.storageHash ?? null;\n\t\tlet action = decideMigrationAction(marker, ref);\n\t\tif (action === \"noop\") {\n\t\t\tif (extensionPacks.length === 0) return {\n\t\t\t\taction,\n\t\t\t\ttargetHash: ref.hash,\n\t\t\t\tmarkerHashBefore\n\t\t\t};\n\t\t\taction = \"migrate\";\n\t\t}\n\t\tif (action === \"init\") {\n\t\t\tconst result = await client.dbInit({\n\t\t\t\tcontract: contractJson,\n\t\t\t\tmode: \"apply\",\n\t\t\t\tmigrationsDir\n\t\t\t});\n\t\t\tif (!result.ok) throw new PnMigrationError(\"INIT_FAILED\", result.failure.summary, result.failure.why);\n\t\t\treturn {\n\t\t\t\taction,\n\t\t\t\ttargetHash: ref.hash,\n\t\t\t\tmarkerHashBefore\n\t\t\t};\n\t\t}\n\t\tconst result = await client.migrate({\n\t\t\tcontract: contractJson,\n\t\t\tmigrationsDir,\n\t\t\t...refName !== void 0 ? {\n\t\t\t\trefHash: ref.hash,\n\t\t\t\trefInvariants: ref.invariants,\n\t\t\t\trefName\n\t\t\t} : {}\n\t\t});\n\t\tif (!result.ok) throw new PnMigrationError(result.failure.code === \"MIGRATION_PATH_NOT_FOUND\" ? \"MIGRATION_PATH_NOT_FOUND\" : \"RUNNER_FAILED\", result.failure.summary, result.failure.why);\n\t\treturn {\n\t\t\taction,\n\t\t\ttargetHash: ref.hash,\n\t\t\tmarkerHashBefore\n\t\t};\n\t} finally {\n\t\tawait client.close();\n\t}\n}\n//#endregion\n//#region src/pn-migration-resource.ts\n/**\n* The `PnMigration` Alchemy resource (ADR-0022) — the migration\n* step modeled as a tracked resource so it participates in deploy state: keyed\n* on the target REF identity (`targetHash` + sorted `invariants`), an\n* unchanged redeploy is an Alchemy-level no-op (on top of the marker read),\n* and a contract change — or a DATA-ONLY change that adds a ref invariant at\n* the same hash — re-runs the migration.\n*\n* Its provider's `reconcile` receives the RESOLVED props at apply-time — in\n* particular the concrete DB `url` (a lazy `Output` until the Connection\n* provisions) — and delegates to the proven `applyPnMigration` decision. The\n* provider is a standalone `Provider<PnMigration>` layer; the extension\n* descriptor merges it into its `providers()` (`Layer.merge(Prisma.providers(),\n* PnMigrationProvider())`), and Alchemy resolves it at apply via a direct\n* provider-tag lookup (`tryFindProviderByType`) — no change to `@internal/lowering`.\n*\n* Deploy-time only: imports `@prisma/orm-postgres/control` (via the helper) +\n* `alchemy`. Imported by `control.ts` and tests, never by `index.ts` / the\n* `./prisma-next` authoring entry — index isolation holds.\n*/\n/** The `PnMigration` resource constructor — `yield* PnMigration(id, props)` in the lowering. */\nconst PnMigration = Resource(\"PrismaNext.Migration\");\n/**\n* The `PnMigration` provider service. `reconcile` runs for both create and\n* update (Alchemy's unified lifecycle); `applyPnMigration` is idempotent via\n* the live marker read, so it is safe to run for either — the marker decides\n* no-op / init / migrate. A migration has nothing to enumerate (`list` → `[]`)\n* and nothing to tear down on its own (`delete` → no-op; the DB's own deletion\n* handles teardown). Exported so tests can drive `reconcile` directly, without\n* building an Effect layer.\n*/\nconst pnMigrationProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ news }) => Effect.tryPromise({\n\t\ttry: async () => {\n\t\t\tconst extensionPacks = news.packHeadRefHashes.length > 0 ? (await resolvePrismaNextConfig(news.configPath)).extensionPacks : [];\n\t\t\treturn applyPnMigration({\n\t\t\t\turl: news.url,\n\t\t\t\tcontractJson: news.contractJson,\n\t\t\t\tmigrationsDir: news.migrationsDir,\n\t\t\t\tref: {\n\t\t\t\t\thash: news.targetHash,\n\t\t\t\t\tinvariants: news.invariants\n\t\t\t\t},\n\t\t\t\textensionPacks,\n\t\t\t\t...news.refName !== void 0 ? { refName: news.refName } : {}\n\t\t\t});\n\t\t},\n\t\tcatch: (error) => error\n\t}).pipe(Effect.map((outcome) => ({\n\t\tstorageHash: outcome.targetHash,\n\t\tinvariants: news.invariants\n\t}))),\n\tdelete: () => Effect.void\n};\n/** The `PnMigration` provider layer — merged into the extension descriptor's `providers()`. */\nconst PnMigrationProvider = () => Provider.effect(PnMigration, Effect.succeed(pnMigrationProviderService));\n//#endregion\n//#region src/preflight-names.ts\nfunction dedupedNames(entries) {\n\tconst byName = /* @__PURE__ */ new Map();\n\tfor (const entry of entries) if (!byName.has(entry.name)) byName.set(entry.name, entry);\n\treturn [...byName.values()];\n}\n/** Every `envSecret` leaf of one input binding: its platform name, found by the same dumb recursive descent the serializer uses (ADR-0042). */\nfunction collectSecretLeafNames(binding, serviceAddress, out) {\n\tif (isGeneratedParamSource(binding)) return;\n\tif (isSecretSource(binding)) {\n\t\tout.push(secretName(binding, `an input-binding secret leaf of service \"${serviceAddress}\"`));\n\t\treturn;\n\t}\n\tif (typeof binding !== \"object\" || binding === null) return;\n\tconst members = Array.isArray(binding) ? binding : Object.values(binding);\n\tfor (const member of members) collectSecretLeafNames(member, serviceAddress, out);\n}\n/** Walks each service's input binding for `envSecret` leaves, and `graph.params` for env-sourced params (ADR-0042). */\nfunction collectPreflightNames(graph) {\n\tconst secretEntries = [];\n\tfor (const { serviceAddress, binding } of inputManifest(graph)) {\n\t\tconst leafNames = [];\n\t\tcollectSecretLeafNames(binding, serviceAddress, leafNames);\n\t\tfor (const name of leafNames) secretEntries.push({\n\t\t\tname,\n\t\t\tserviceAddress\n\t\t});\n\t}\n\tconst envParams = dedupedNames(paramManifest(graph).filter((binding) => isEnvParamSource(binding.binding)).map((binding) => ({\n\t\tname: paramName(binding),\n\t\tserviceAddress: binding.serviceAddress\n\t})));\n\treturn {\n\t\tsecrets: dedupedNames(secretEntries),\n\t\tenvParams\n\t};\n}\n//#endregion\n//#region src/s3-credentials-resource.ts\n/**\n* The `S3Credentials` Alchemy resource (S5) — mints a random SigV4 key pair\n* ONCE at create and keeps it STABLE across deploys, so an unchanged module\n* no-ops on redeploy. The pair is generated by `@internal/s3-protocol`'s\n* `mintKeyPair` (moved there per the local-dev spec § 1, so deploy and local\n* dev credential minting share one implementation) and persisted in Alchemy\n* state; on every later apply the provider returns the persisted attributes\n* (`reconcile`'s `output`) unchanged — the same way the postgres resource\n* keeps a Connection stable. Rotation is destroy/recreate (a platform ask,\n* not solved here).\n*\n* Deploy-time only: imports `alchemy`. Imported by `control.ts` and tests,\n* never by `index.ts` / the authoring entry.\n*/\n/** The `S3Credentials` resource constructor — `yield* S3Credentials(id, {})` in the lowering. */\nconst S3Credentials = Resource(\"PrismaCloud.S3Credentials\");\n/**\n* The `S3Credentials` provider service. `reconcile` runs for create and update;\n* it returns the persisted `output` when present (a redeploy reuses the stored\n* pair — the no-op property) and mints a fresh pair only on first create.\n* Nothing to enumerate (`list` → `[]`) or tear down (`delete` → no-op; the pair\n* lives only in state). Exported so tests can drive it directly.\n*/\nconst s3CredentialsProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ output }) => Effect.sync(() => output ?? mintKeyPair()),\n\tdelete: () => Effect.void\n};\n/** The `S3Credentials` provider layer — merged into the extension descriptor's `providers()`. */\nconst S3CredentialsProvider = () => Provider.effect(S3Credentials, Effect.succeed(s3CredentialsProviderService));\n//#endregion\nexport { prismaCloudContainerOf as _, PnMigrationProvider as a, resolvePrismaNextConfig as c, GeneratedParam as d, GeneratedParamProvider as f, deserialize as g, containerDescriptor as h, PnMigration as i, PgWarm as l, PrismaCloudContainer as m, S3CredentialsProvider as n, resolveTargetRef as o, PRISMA_CLOUD_EXTENSION_ID as p, collectPreflightNames as r, packHeadRefHashes as s, S3Credentials as t, PgWarmProvider as u };\n\n//# sourceMappingURL=s3-credentials-resource-BltGd-gG.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAI,oBAAoB,cAAc,QAAQ,QAAQ,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;;AAE9E,MAAM,gBAAgB,MAAM,OAAO,mBAAmB,OAAO,IAAI,aAAa;CAC7E,OAAO,EAAE,OAAO,OAAOA,SAAO,SAAS,sBAAsB,EAAE;AAChE,CAAC,CAAC;;AAIF,MAAM,wBAAwB;;;;;;AAM9B,IAAI,mBAAmB,cAAc,QAAQ,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAClF,MAAM,SAAS,YAAY,MAAM,OAAO,kBAAkB,OAAO,IAAI,aAAa;CACjF,MAAM,EAAE,UAAU,OAAO;CACzB,OAAO,0BAA0B;EAChC,OAAO,SAAS,MAAM,KAAK;EAC3B,SAAS,SAAS,aAAa;CAChC,CAAC;AACF,CAAC,CAAC;;;;AC5BF,IAAI,iBAAiB,cAAc,KAAK,YAAY,gBAAgB,CAAC,CAAC,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,KAAK,aAAa;EAC5H,MAAM,UAAU,OAAO;EACvB,gBAAgB,QAAQ;CACzB,EAAE,CAAC;CACH,OAAO;EACN,SAAS,aAAa,aAAa;EACnC;CACD;AACD;;;;;;;;;;;;;;;;AAkBA,MAAM,gBAAgB,SAAS,2BAA2B;;;;;;;;AAQ1D,MAAM,+BAA+B;CACpC,YAAY,OAAO,QAAQ,CAAC,CAAC;CAC7B,YAAY,EAAE,aAAa,OAAO,WAAW,UAAU,YAAY,CAAC;CACpE,cAAc,OAAO;AACtB;;AAEA,MAAM,8BAA8B,SAAS,OAAO,eAAe,OAAO,QAAQ,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"s3-credentials-resource-vElUxfYi-Bb7ILl1X.mjs","names":["Config","fs","path","os","randomBytes","managementClientLayer"],"sources":["../../../1-prisma-cloud/0-lowering/lowering/dist/client-I552wJ2o.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/http-d1HGunF-.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/container-BdSTYN8l.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/buckets.mjs","../../../0-framework/2-authoring/bundle-paths/dist/index.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/compute.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/postgres.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/index.mjs","../../../1-prisma-cloud/0-lowering/s3-protocol/dist/index.mjs","../../../1-prisma-cloud/1-extensions/target/dist/s3-credentials-resource-vElUxfYi.mjs"],"sourcesContent":["import { createManagementApiClient } from \"@prisma/management-api-sdk\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Config from \"effect/Config\";\n//#region src/credentials.ts\n/**\n* The Prisma service token used to authenticate Management API calls. Kept\n* as a Redacted value so it never lands in logs or error output.\n*/\nvar PrismaCredentials = class extends Context.Service()(\"PrismaCredentials\") {};\n/** Resolve the token from the `PRISMA_SERVICE_TOKEN` environment variable. */\nconst fromEnv = () => Layer.effect(PrismaCredentials, Effect.gen(function* () {\n\treturn { token: yield* Config.redacted(\"PRISMA_SERVICE_TOKEN\") };\n}));\n//#endregion\n//#region src/client.ts\n/** The origin every Management API call targets — also the origin the hosted Alchemy state API lives under. */\nconst MANAGEMENT_API_ORIGIN = \"https://api.prisma.io\";\n/**\n* The typed Prisma Management API client, built once from the resolved\n* credentials. Providers yield this in their outer Effect and call it inside\n* `reconcile` / `delete`.\n*/\nvar ManagementClient = class extends Context.Service()(\"PrismaManagementClient\") {};\nconst layer = (options) => Layer.effect(ManagementClient, Effect.gen(function* () {\n\tconst { token } = yield* PrismaCredentials;\n\treturn createManagementApiClient({\n\t\ttoken: Redacted.value(token),\n\t\tbaseUrl: options?.apiOrigin ?? \"https://api.prisma.io\"\n\t});\n}));\n//#endregion\nexport { fromEnv as a, PrismaCredentials as i, ManagementClient as n, layer as r, MANAGEMENT_API_ORIGIN as t };\n\n//# sourceMappingURL=client-I552wJ2o.mjs.map","import * as Effect from \"effect/Effect\";\nimport * as Data from \"effect/Data\";\n//#region src/http.ts\n/** A non-2xx response from the Management API (or a transport failure). */\nvar PrismaApiError = class extends Data.TaggedError(\"PrismaApiError\") {};\nconst attempt = (f) => Effect.tryPromise({\n\ttry: f,\n\tcatch: (cause) => new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: String(cause)\n\t})\n});\nconst fail = (r) => Effect.fail(new PrismaApiError({\n\tstatus: r.response.status,\n\tmessage: JSON.stringify(r.error)\n}));\n/** Unwrap `data`, failing on any API error. Preserves the SDK's response type. */\nconst call = (f) => attempt(f).pipe(Effect.flatMap((r) => r.error !== void 0 || r.data === void 0 ? fail(r) : Effect.succeed(r.data)));\n/** Unwrap `data`, mapping a 404 to `undefined` (resource gone / not found). */\nconst callOptional = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 404 ? Effect.succeed(void 0) : r.error !== void 0 ? fail(r) : Effect.succeed(r.data)));\n/** Fire-and-forget a call, tolerating a 404 (already deleted). */\nconst callVoid = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 404 || r.error === void 0 ? Effect.void : fail(r)));\n//#endregion\nexport { callVoid as i, call as n, callOptional as r, PrismaApiError as t };\n\n//# sourceMappingURL=http-d1HGunF-.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, t as PrismaApiError } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Data from \"effect/Data\";\n//#region src/pagination.ts\n/** Far beyond any real collection size per listing; hitting it means the API's pagination is broken. */\nconst MAX_PAGES = 1e3;\nconst brokenPaginationError = (description, reason) => new PrismaApiError({\n\tstatus: 0,\n\tmessage: `listing ${description} ${reason} — the Management API pagination appears broken; refusing to continue with a possibly incomplete listing.`\n});\n/** {@link drivePages} in its most common shape: every page's rows, accumulated. */\nconst collectPages = (description, fetchPage) => Effect.gen(function* () {\n\tconst rows = [];\n\tyield* drivePages(description, fetchPage, (data) => {\n\t\trows.push(...data);\n\t\treturn false;\n\t});\n\treturn rows;\n});\n/**\n* Drives a cursor-paginated Management API listing with a guard against\n* broken pagination: a cursor that does not advance, more pages reported\n* without a cursor to fetch them with, or more than {@link MAX_PAGES} pages,\n* FAILS instead of hanging forever or returning a listing known to be\n* incomplete. `onPage` receives each page's rows as they arrive; returning\n* `true` stops early (the caller found what it wanted).\n*/\nconst drivePages = (description, fetchPage, onPage) => Effect.gen(function* () {\n\tlet cursor;\n\tfor (let pageCount = 0;; pageCount++) {\n\t\tif (pageCount >= MAX_PAGES) return yield* Effect.fail(brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`));\n\t\tconst page = yield* fetchPage(cursor);\n\t\tif (onPage(page.data)) return;\n\t\tif (!page.pagination.hasMore) return;\n\t\tconst next = page.pagination.nextCursor;\n\t\tif (next === null) return yield* Effect.fail(brokenPaginationError(description, \"reported more pages but returned no cursor\"));\n\t\tif (next === cursor) return yield* Effect.fail(brokenPaginationError(description, \"returned a non-advancing cursor\"));\n\t\tcursor = next;\n\t}\n});\n/**\n* {@link drivePages} for Promise-based callers (e.g. target's preflight,\n* which speaks the SDK's `{data, error}` shape directly). Same guard, same\n* errors; deliberately a sibling loop rather than a wrapper, because routing\n* a Promise fetch through Effect and back (`Effect.tryPromise` +\n* `runPromise`) would re-wrap the caller's own thrown errors. `fetchPage`\n* rejections propagate untouched.\n*/\nasync function drivePagesAsync(description, fetchPage, onPage) {\n\tlet cursor;\n\tfor (let pageCount = 0;; pageCount++) {\n\t\tif (pageCount >= MAX_PAGES) throw brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`);\n\t\tconst page = await fetchPage(cursor);\n\t\tif (onPage(page.data)) return;\n\t\tif (!page.pagination.hasMore) return;\n\t\tconst next = page.pagination.nextCursor;\n\t\tif (next === null) throw brokenPaginationError(description, \"reported more pages but returned no cursor\");\n\t\tif (next === cursor) throw brokenPaginationError(description, \"returned a non-advancing cursor\");\n\t\tcursor = next;\n\t}\n}\n//#endregion\n//#region src/container.ts\n/** Raised with `ensure: false` when the app's Project (or a named stage's Branch) doesn't exist. */\nvar ContainerNotFoundError = class extends Data.TaggedError(\"ContainerNotFoundError\") {};\nconst listAllProjects = (client) => collectPages(\"projects\", (cursor) => call(() => client.GET(\"/v1/projects\", { params: { query: cursor === void 0 ? {} : { cursor } } })));\n/**\n* Workspace ids circulate in two shapes: `wksp_`-prefixed and bare. Compare\n* bare-to-bare so a `wksp_`-prefixed API id still matches a bare configured\n* one (the same normalization `state/bootstrap.ts` applies to the same\n* `/v1/projects` listing).\n*/\nconst bareWorkspaceId = (id) => id.startsWith(\"wksp_\") ? id.slice(5) : id;\n/**\n* Finds the app's Project by logical id or name in the workspace, creating\n* one if absent. Logical id match (exact, workspace-unique) is preferred over\n* display-name match (oldest-wins fallback for projects without a logical id).\n* Creates one if none match, unless `ensure` is `false` (find-only —\n* `destroy`), in which case an absent Project fails with\n* `ContainerNotFoundError`. No ownership marker and no `--project` override\n* (both deferred — see ADR-0019).\n*/\nconst resolveProject = (client, workspaceId, appName, ensure) => Effect.gen(function* () {\n\tconst workspaceProjects = (yield* listAllProjects(client)).filter((p) => bareWorkspaceId(p.workspace.id) === bareWorkspaceId(workspaceId));\n\tconst logicalIdMatch = workspaceProjects.find((p) => p.logicalId != null && p.logicalId === appName);\n\tif (logicalIdMatch !== void 0) return logicalIdMatch.id;\n\tconst nameMatch = workspaceProjects.filter((p) => p.name === appName).sort((a, b) => a.createdAt.localeCompare(b.createdAt))[0];\n\tif (nameMatch !== void 0) return nameMatch.id;\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({ appName }));\n\treturn (yield* call(() => client.POST(\"/v1/projects\", { body: {\n\t\tname: appName,\n\t\tworkspaceId,\n\t\tcreateDatabase: false,\n\t\tlogicalId: appName\n\t} })).pipe(Effect.catch((err) => err.status === 409 ? Effect.fail(new PrismaApiError({\n\t\tstatus: 409,\n\t\tmessage: \"a project with this name already exists in the workspace; rename your Composer module or free the name.\"\n\t})) : Effect.fail(err)))).data.id;\n});\n/**\n* The project's implicit default Branch — every live Project owns exactly\n* one (a platform invariant). The list endpoint has no `isDefault` filter,\n* so this pages through the Branches (bounded — drivePages) and returns as\n* soon as a page contains it. Never creates one: its absence means the\n* platform's invariant is broken, which is not something a deploy can\n* repair.\n*/\nconst resolveDefaultBranchId = (client, projectId) => Effect.gen(function* () {\n\tlet found;\n\tyield* drivePages(`branches of project ${projectId}`, (cursor) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\t\tpath: { projectId },\n\t\tquery: cursor === void 0 ? {} : { cursor }\n\t} })), (data) => {\n\t\tfound = data.find((b) => b.isDefault)?.id;\n\t\treturn found !== void 0;\n\t});\n\tif (found !== void 0) return found;\n\treturn yield* Effect.fail(new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: `project ${projectId} has no default Branch — the platform guarantees every live Project owns one; contact support.`\n\t}));\n});\nconst findBranchId = (client, projectId, gitName) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\tpath: { projectId },\n\tquery: { gitName }\n} })).pipe(Effect.map((page) => page.data[0]?.id));\n/**\n* Finds the stage's Branch by its exact `gitName`, creating it if absent\n* unless `ensure` is `false` (find-only — `destroy`), in which case an\n* absent Branch fails with `ContainerNotFoundError`. The Management API has\n* no server-side \"create-or-return\" idempotency (`POST\n* /v1/projects/:id/branches` 409s on a duplicate `gitName`, with no request\n* field to make that a no-op), so idempotency is client-side: observe\n* first, and on a racing 409 from create, re-observe rather than fail.\n*/\nconst resolveBranch = (client, projectId, gitName, appName, ensure) => Effect.gen(function* () {\n\tconst existing = yield* findBranchId(client, projectId, gitName);\n\tif (existing !== void 0) return existing;\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({\n\t\tappName,\n\t\tstage: gitName\n\t}));\n\treturn yield* call(() => client.POST(\"/v1/projects/{projectId}/branches\", {\n\t\tparams: { path: { projectId } },\n\t\tbody: { gitName }\n\t})).pipe(Effect.map((r) => r.data.id), Effect.catch((err) => err.status === 409 ? findBranchId(client, projectId, gitName).pipe(Effect.flatMap((id) => id === void 0 ? Effect.fail(err) : Effect.succeed(id))) : Effect.fail(err)));\n});\n/**\n* Resolves the two containers a stage's deploy runs into (ADR-0019): the\n* app's **Project**, found-or-created by name, and — for a named stage\n* only — its **Branch**, found-or-created by `gitName`. The default stage\n* (no `stage`) creates no Branch; `branchId` is omitted, and the project's\n* default Branch's id is read into `defaultBranchId` instead. With `ensure:\n* false` (`destroy`), nothing is created — an absent Project or Branch\n* fails with `ContainerNotFoundError` instead.\n*/\nconst resolveContainer = (opts) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tconst ensure = opts.ensure ?? true;\n\tconst projectId = yield* resolveProject(client, opts.workspaceId, opts.appName, ensure);\n\tif (opts.stage === void 0) return {\n\t\tprojectId,\n\t\tdefaultBranchId: yield* resolveDefaultBranchId(client, projectId)\n\t};\n\treturn {\n\t\tprojectId,\n\t\tbranchId: yield* resolveBranch(client, projectId, opts.stage, opts.appName, ensure)\n\t};\n});\n/**\n* Soft-deletes a Branch. Tolerates a 404 (already gone). The API refuses if\n* the Branch still has live members or is the production/default Branch —\n* that surfaces as a `PrismaApiError`.\n*/\nconst deleteBranch = (branchId) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tyield* callVoid(() => client.DELETE(\"/v1/branches/{branchId}\", { params: { path: { branchId } } }));\n});\n/**\n* Deletes a Project. Tolerates a 404 (already gone). The API refuses with a\n* 400 if the Project still has live dependencies (e.g. another stage's\n* Branch/resources) — that surfaces as a `PrismaApiError`.\n*/\nconst deleteProject = (projectId) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tyield* callVoid(() => client.DELETE(\"/v1/projects/{id}\", { params: { path: { id: projectId } } }));\n});\n//#endregion\nexport { resolveDefaultBranchId as a, drivePagesAsync as c, resolveContainer as i, deleteBranch as n, collectPages as o, deleteProject as r, drivePages as s, ContainerNotFoundError as t };\n\n//# sourceMappingURL=container-BdSTYN8l.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, r as callOptional } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy\";\n//#region src/buckets/Bucket.ts\n/** A Prisma **Object Store bucket** inside a project. */\nconst Bucket = Resource(\"Prisma.Bucket\");\nconst BucketProvider = () => Provider.effect(Bucket, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/buckets/{bucketId}\", { params: { path: { bucketId: output.id } } })) : void 0;\n\t\t\tif (observed) return {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name\n\t\t\t};\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/buckets\", { body: {\n\t\t\t\tprojectId: news.projectId,\n\t\t\t\tname: news.name,\n\t\t\t\t...news.branchId !== void 0 ? { branchId: news.branchId } : {}\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tname: created.data.name\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/buckets/{bucketId}\", { params: { path: { bucketId: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst b = yield* callOptional(() => client.GET(\"/v1/buckets/{bucketId}\", { params: { path: { bucketId: output.id } } }));\n\t\t\treturn b ? {\n\t\t\t\tid: b.data.id,\n\t\t\t\tname: b.data.name\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/buckets/BucketKey.ts\n/** A **bucket access key** for a Prisma Object Store bucket — yields the S3 credentials. */\nconst BucketKey = Resource(\"Prisma.BucketKey\");\nconst BucketKeyProvider = () => Provider.effect(BucketKey, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\n\t\t\t\"id\",\n\t\t\t\"bucketId\",\n\t\t\t\"secretAccessKey\",\n\t\t\t\"accessKeyId\",\n\t\t\t\"endpoint\",\n\t\t\t\"bucketName\"\n\t\t],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tif (output?.id) return output;\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/buckets/{bucketId}/keys\", {\n\t\t\t\tparams: { path: { bucketId: news.bucketId } },\n\t\t\t\tbody: {\n\t\t\t\t\tname: news.name,\n\t\t\t\t\trole: news.role\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tbucketId: news.bucketId,\n\t\t\t\taccessKeyId: created.data.accessKeyId,\n\t\t\t\tsecretAccessKey: Redacted.make(created.data.secretAccessKey),\n\t\t\t\tendpoint: created.data.endpoint,\n\t\t\t\tbucketName: created.data.bucketName\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/buckets/{bucketId}/keys/{keyId}\", { params: { path: {\n\t\t\t\tbucketId: output.bucketId,\n\t\t\t\tkeyId: output.id\n\t\t\t} } }));\n\t\t})\n\t};\n}));\n//#endregion\nexport { Bucket, BucketKey, BucketKeyProvider, BucketProvider };\n\n//# sourceMappingURL=buckets.mjs.map","import fs from \"node:fs\";\nimport path from \"node:path\";\n//#region src/bundle-paths.ts\n/**\n* The path-containment predicate and bundle-link validation shared by every\n* assembly and packaging seam (node/nextjs adapters, the compute artifact\n* writer, the local extractor). This predicate is the enforcement point of\n* ADR-0047's boundary — a symlink may be preserved only while its target\n* stays inside the assembled bundle — so it exists exactly once.\n*/\n/** Lexical containment: `candidate` is `root` itself or below it. Both paths\n* must already be absolute or share a resolution base; no filesystem access. */\nfunction isWithin(root, candidate) {\n\tconst relative = path.relative(root, candidate);\n\treturn relative === \"\" || !relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative);\n}\n/** Walks the assembled bundle and rejects a dangling symlink or one whose\n* resolved target escapes the bundle root. Symlinked directories are not\n* descended: their targets are validated, and their contents belong to the\n* target's own location. */\nasync function assertBundleSymlinksStayInside(bundleDir) {\n\tconst realRoot = await fs.promises.realpath(bundleDir);\n\tconst walk = async (directory) => {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst full = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tlet realTarget;\n\t\t\t\ttry {\n\t\t\t\t\trealTarget = await fs.promises.realpath(full);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new Error(`the assembled bundle contains a dangling symlink: ${full}`);\n\t\t\t\t}\n\t\t\t\tif (!isWithin(realRoot, realTarget)) throw new Error(`the assembled bundle contains a symlink whose target escapes the bundle: ${full} -> ${await fs.promises.readlink(full)}`);\n\t\t\t} else if (entry.isDirectory()) await walk(full);\n\t\t}\n\t};\n\tawait walk(bundleDir);\n}\n//#endregion\nexport { assertBundleSymlinksStayInside, isWithin };\n\n//# sourceMappingURL=index.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, r as callOptional, t as PrismaApiError } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy\";\nimport * as Schedule from \"effect/Schedule\";\nimport * as fs from \"node:fs\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport * as crypto$1 from \"node:crypto\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport * as zlib from \"node:zlib\";\nimport { isWithin } from \"@internal/bundle-paths\";\n//#region src/compute/ComputeService.ts\n/**\n* Stopping a deployment before the app that owns it can be\n* deleted is asynchronous on the platform's side: DELETE can 409 with this\n* message while the deployment is still winding down. Retrying blindly on\n* every API error would mask real failures (bad auth, a genuinely conflicting\n* state, etc.), so this only matches the platform's specific \"not delete-safe\n* yet\" wording — everything else fails immediately, as before.\n*/\nconst isDeleteNotSafeYet = (error) => error.message.includes(\"did not reach a delete-safe state\");\n/**\n* Backs off exponentially from 2s, capped at 5 minutes total — long enough\n* for the platform to finish stopping the deployment, short enough to still\n* fail loudly (rather than hang forever) if it never does.\n*/\nconst deleteSafeRetrySchedule = Schedule.exponential(\"2 seconds\", 2).pipe(Schedule.upTo({ duration: \"5 minutes\" }));\n/** Every region Prisma Compute serves — the runtime source of truth; `ComputeRegion` is derived from it so the two can never drift. */\nconst COMPUTE_REGIONS = [\n\t\"us-east-1\",\n\t\"us-west-1\",\n\t\"eu-west-3\",\n\t\"eu-central-1\",\n\t\"ap-northeast-1\",\n\t\"ap-southeast-1\"\n];\n/** A Prisma **Compute service** — the stable app identity behind a project. */\nconst ComputeService = Resource(\"Prisma.ComputeService\");\nconst ComputeServiceProvider = () => Provider.effect(ComputeService, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/apps/{appId}\", { params: { path: { appId: output.id } } })) : void 0;\n\t\t\tif (observed) return {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name,\n\t\t\t\tendpointDomain: observed.data.appEndpointDomain\n\t\t\t};\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/apps\", { body: {\n\t\t\t\tdisplayName: news.name,\n\t\t\t\tprojectId: news.projectId,\n\t\t\t\t...news.region && { regionId: news.region },\n\t\t\t\t...news.branchId !== void 0 && { branchId: news.branchId }\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tname: created.data.name,\n\t\t\t\tendpointDomain: created.data.appEndpointDomain\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/apps/{appId}\", { params: { path: { appId: output.id } } })).pipe(Effect.retry({\n\t\t\t\tschedule: deleteSafeRetrySchedule,\n\t\t\t\twhile: isDeleteNotSafeYet\n\t\t\t}));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst s = yield* callOptional(() => client.GET(\"/v1/apps/{appId}\", { params: { path: { appId: output.id } } }));\n\t\t\treturn s ? {\n\t\t\t\tid: s.data.id,\n\t\t\t\tname: s.data.name,\n\t\t\t\tendpointDomain: s.data.appEndpointDomain\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/compute/Deployment.ts\n/**\n* A **deployment** of a Prisma app — creates a deployment, uploads\n* its artifact, starts the VM, waits for it to run, then promotes it to the\n* app's stable endpoint.\n*/\nconst Deployment = Resource(\"Prisma.Deployment\");\nconst DeploymentProvider = () => Provider.effect(Deployment, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tconst waitForRunning = (deploymentId) => call(() => client.GET(\"/v1/deployments/{deploymentId}\", { params: { path: { deploymentId } } })).pipe(Effect.flatMap((v) => v.data.status === \"running\" ? Effect.void : Effect.fail(new PrismaApiError({\n\t\tstatus: 409,\n\t\tmessage: `deployment ${deploymentId} is ${v.data.status}, not running`\n\t}))), Effect.retry(Schedule.spaced(\"2 seconds\").pipe(Schedule.upTo({ duration: \"2 minutes\" }))));\n\treturn {\n\t\tstables: [],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news }) {\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/apps/{appId}/deployments\", {\n\t\t\t\tparams: { path: { appId: news.computeServiceId } },\n\t\t\t\tbody: news.port !== void 0 ? { portMapping: { http: news.port } } : {}\n\t\t\t}));\n\t\t\tconst deploymentId = created.data.id;\n\t\t\tif (created.data.uploadUrl) {\n\t\t\t\tconst uploadUrl = created.data.uploadUrl;\n\t\t\t\tconst artifact = yield* Effect.try({\n\t\t\t\t\ttry: () => fs.readFileSync(news.artifactPath),\n\t\t\t\t\tcatch: (cause) => new PrismaApiError({\n\t\t\t\t\t\tstatus: 0,\n\t\t\t\t\t\tmessage: `failed to read artifact ${news.artifactPath}: ${String(cause)}`\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t\tyield* Effect.tryPromise({\n\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\tconst res = await fetch(uploadUrl, {\n\t\t\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\t\t\tbody: artifact\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!res.ok) throw new PrismaApiError({\n\t\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\t\tmessage: `artifact upload failed: ${res.status} ${res.statusText}`\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tcatch: (cause) => cause instanceof PrismaApiError ? cause : new PrismaApiError({\n\t\t\t\t\t\tstatus: 0,\n\t\t\t\t\t\tmessage: String(cause)\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t}\n\t\t\tyield* call(() => client.POST(\"/v1/deployments/{deploymentId}/start\", { params: { path: { deploymentId } } }));\n\t\t\tyield* waitForRunning(deploymentId);\n\t\t\tconst deployedUrl = (yield* call(() => client.POST(\"/v1/apps/{appId}/promote\", {\n\t\t\t\tparams: { path: { appId: news.computeServiceId } },\n\t\t\t\tbody: { deploymentId }\n\t\t\t}))).data.appEndpointDomain;\n\t\t\treturn {\n\t\t\t\tdeploymentId,\n\t\t\t\t...deployedUrl !== void 0 && { deployedUrl }\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* () {}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.deploymentId) return void 0;\n\t\t\tconst v = yield* callOptional(() => client.GET(\"/v1/deployments/{deploymentId}\", { params: { path: { deploymentId: output.deploymentId } } }));\n\t\t\treturn v ? {\n\t\t\t\tdeploymentId: v.data.id,\n\t\t\t\t...v.data.previewDomain && { deployedUrl: v.data.previewDomain }\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/compute/EnvironmentVariable.ts\n/**\n* A project-scoped **environment variable** that Compute injects into the\n* project's services from their attached branch (e.g. wiring one module's URL into\n* another).\n*/\nconst EnvironmentVariable = Resource(\"Prisma.EnvironmentVariable\");\nconst EnvironmentVariableProvider = () => Provider.effect(EnvironmentVariable, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst cls = news.class ?? \"production\";\n\t\t\tlet id = output?.id;\n\t\t\tif (id !== void 0) {\n\t\t\t\tconst priorId = id;\n\t\t\t\tif (!(yield* callOptional(() => client.GET(\"/v1/environment-variables/{envVarId}\", { params: { path: { envVarId: priorId } } })))) id = void 0;\n\t\t\t}\n\t\t\tif (id === void 0) {\n\t\t\t\tconst matchId = blindCast(yield* call(() => client.GET(\"/v1/environment-variables\", { params: { query: blindCast({\n\t\t\t\t\tprojectId: news.projectId,\n\t\t\t\t\tclass: cls,\n\t\t\t\t\tkey: news.key,\n\t\t\t\t\t...news.branchId !== void 0 ? { branchId: news.branchId } : {}\n\t\t\t\t}) } }))).data?.find((row) => (row.branchId ?? null) === (news.branchId ?? null))?.id;\n\t\t\t\tif (matchId !== void 0) {\n\t\t\t\t\tif (!(news.key === \"DATABASE_URL\" || news.key === \"DATABASE_URL_POOLED\")) {\n\t\t\t\t\t\tconst scope = news.branchId !== void 0 ? `class \"${cls}\", branch \"${news.branchId}\"` : `class \"${cls}\"`;\n\t\t\t\t\t\tthrow new Error(`EnvironmentVariable \"${news.key}\" (project \"${news.projectId}\", ${scope}) exists but is untracked in this deploy state — refusing to overwrite a reserved COMPOSER_ key. Restore this deploy's hosted state, or remove the variable to let this deploy recreate it.`);\n\t\t\t\t\t}\n\t\t\t\t\tid = matchId;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (id !== void 0) {\n\t\t\t\tconst targetId = id;\n\t\t\t\tyield* call(() => client.PATCH(\"/v1/environment-variables/{envVarId}\", {\n\t\t\t\t\tparams: { path: { envVarId: targetId } },\n\t\t\t\t\tbody: { value: news.value }\n\t\t\t\t}));\n\t\t\t\treturn {\n\t\t\t\t\tid,\n\t\t\t\t\tkey: news.key\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/environment-variables\", { body: {\n\t\t\t\tprojectId: news.projectId,\n\t\t\t\tclass: cls,\n\t\t\t\tkey: news.key,\n\t\t\t\tvalue: news.value,\n\t\t\t\t...news.branchId ? { branchId: news.branchId } : {}\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tkey: created.data.key\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/environment-variables/{envVarId}\", { params: { path: { envVarId: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst v = yield* callOptional(() => client.GET(\"/v1/environment-variables/{envVarId}\", { params: { path: { envVarId: output.id } } }));\n\t\t\treturn v ? {\n\t\t\t\tid: v.data.id,\n\t\t\t\tkey: v.data.key\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/compute/artifact.ts\n/**\n* Assembles a Prisma Compute artifact: the app-built bundle plus the\n* extension-printed bootstrap and manifest, tarred and gzipped deterministically\n* (fixed mtimes, sorted entry order) so an unchanged service noops on\n* redeploy — a rebuild is the only thing that changes the hash. Lives here\n* (not in @prisma/composer-prisma-cloud/control) because it needs node:fs/node:zlib,\n* which the extension's shipped src may never import (invariant 5).\n*/\nconst MANIFEST_VERSION = \"1\";\n/** Finds main.js/main.mjs in a bundle dir when no explicit entry is given. */\nfunction resolveEntry(bundleDir, entry) {\n\tif (entry !== void 0) return entry;\n\tconst found = fs.readdirSync(bundleDir).find((f) => /^main\\.m?js$/.test(f));\n\tif (found === void 0) throw new Error(`no main.js/main.mjs found in bundle dir ${bundleDir}`);\n\treturn found;\n}\nfunction compareArchivePaths(left, right) {\n\treturn Buffer.compare(Buffer.from(left.relPath, \"utf8\"), Buffer.from(right.relPath, \"utf8\"));\n}\n/** All files and safe symlinks under `dir`, as dir-relative POSIX paths, in\n* sorted order. Symlinks are preserved as links — never dereferenced — after\n* their real target is proven to remain inside the bundle root. This accepts\n* framework-produced trees such as Next standalone while retaining ADR-0005's\n* boundary against packaging arbitrary files from the deploy machine. */\nfunction walkEntries(dir) {\n\tconst out = [];\n\tconst realRoot = fs.realpathSync(dir);\n\tconst visit = (sub) => {\n\t\tfor (const entry of fs.readdirSync(path.join(dir, sub), { withFileTypes: true })) {\n\t\t\tconst rel = sub.length > 0 ? `${sub}/${entry.name}` : entry.name;\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tconst symlinkPath = path.join(dir, ...rel.split(\"/\"));\n\t\t\t\tconst target = fs.readlinkSync(symlinkPath);\n\t\t\t\tif (path.sep === \"/\" && target.includes(\"\\\\\")) throw new Error(`bundle symlink at ${rel} has an unsupported backslash target: ${target}`);\n\t\t\t\tlet realTarget;\n\t\t\t\ttry {\n\t\t\t\t\trealTarget = fs.realpathSync(path.resolve(path.dirname(symlinkPath), target));\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new Error(`bundle symlink at ${rel} is dangling: ${target}`);\n\t\t\t\t}\n\t\t\t\tif (!isWithin(realRoot, realTarget)) throw new Error(`bundle symlink at ${rel} escapes the bundle root: ${target} — deploy artifacts may only preserve links whose targets are inside the assembled bundle.`);\n\t\t\t\tconst linkname = (path.isAbsolute(target) ? path.relative(fs.realpathSync(path.dirname(symlinkPath)), realTarget) : target).split(path.sep).join(\"/\");\n\t\t\t\tif (!isWithin(dir, path.resolve(path.dirname(symlinkPath), ...linkname.split(\"/\")))) throw new Error(`bundle symlink at ${rel} has a target that leaves the bundle: ${linkname} — its resolved target is inside the bundle, but the link path itself walks outside and re-enters, which every extractor rejects. Point the link at the in-bundle path directly.`);\n\t\t\t\tout.push({\n\t\t\t\t\trelPath: rel,\n\t\t\t\t\ttype: \"symlink\",\n\t\t\t\t\tlinkname\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) visit(rel);\n\t\t\telse if (entry.isFile()) {\n\t\t\t\tconst mode = fs.statSync(path.join(dir, ...rel.split(\"/\"))).mode;\n\t\t\t\tout.push({\n\t\t\t\t\trelPath: rel,\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\texecutable: (mode & 64) !== 0\n\t\t\t\t});\n\t\t\t} else throw new Error(`bundle contains an unsupported filesystem entry: ${rel}`);\n\t\t}\n\t};\n\tvisit(\"\");\n\treturn out.sort(compareArchivePaths);\n}\nfunction octal(value, length) {\n\treturn `${value.toString(8).padStart(length - 1, \"0\")}\\0`;\n}\n/** Splits a path into ustar's name (<=100 bytes) + prefix (<=155 bytes) fields. */\nfunction splitUstarPath(relPath) {\n\tif (Buffer.byteLength(relPath, \"utf8\") <= 100) return {\n\t\tname: relPath,\n\t\tprefix: \"\"\n\t};\n\tfor (let i = relPath.length - 1; i >= 0; i--) {\n\t\tif (relPath[i] !== \"/\") continue;\n\t\tconst prefix = relPath.slice(0, i);\n\t\tconst name = relPath.slice(i + 1);\n\t\tif (Buffer.byteLength(prefix, \"utf8\") <= 155 && Buffer.byteLength(name, \"utf8\") <= 100) return {\n\t\t\tname,\n\t\t\tprefix\n\t\t};\n\t}\n\tthrow new Error(`path too long for a ustar tar entry: ${relPath}`);\n}\nfunction paxRecord(key, value) {\n\tconst payload = ` ${key}=${value}\\n`;\n\tlet length = Buffer.byteLength(payload, \"utf8\") + 1;\n\twhile (true) {\n\t\tconst record = `${length}${payload}`;\n\t\tconst actualLength = Buffer.byteLength(record, \"utf8\");\n\t\tif (actualLength === length) return record;\n\t\tlength = actualLength;\n\t}\n}\nfunction ustarPathOrPlaceholder(relPath) {\n\ttry {\n\t\tsplitUstarPath(relPath);\n\t\treturn { path: relPath };\n\t} catch {\n\t\treturn {\n\t\t\tpath: `PaxEntries/${crypto$1.createHash(\"sha256\").update(relPath).digest(\"hex\").slice(0, 32)}`,\n\t\t\tpaxPath: relPath\n\t\t};\n\t}\n}\nfunction ustarHeader(relPath, size, options) {\n\tconst { name, prefix } = splitUstarPath(relPath);\n\tconst buf = Buffer.alloc(512);\n\tbuf.write(name, 0, 100, \"utf8\");\n\tbuf.write(octal(options.mode, 8), 100, 8, \"utf8\");\n\tbuf.write(octal(0, 8), 108, 8, \"utf8\");\n\tbuf.write(octal(0, 8), 116, 8, \"utf8\");\n\tbuf.write(octal(size, 12), 124, 12, \"utf8\");\n\tbuf.write(octal(0, 12), 136, 12, \"utf8\");\n\tbuf.write(\" \", 148, 8, \"utf8\");\n\tbuf.write(options.typeflag, 156, 1, \"utf8\");\n\tif (options.linkname !== void 0) buf.write(options.linkname, 157, 100, \"utf8\");\n\tbuf.write(\"ustar\\0\", 257, 6, \"utf8\");\n\tbuf.write(\"00\", 263, 2, \"utf8\");\n\tbuf.write(prefix, 345, 155, \"utf8\");\n\tlet sum = 0;\n\tfor (const b of buf) sum += b;\n\tbuf.write(`${sum.toString(8).padStart(6, \"0\")}\\0 `, 148, 8, \"utf8\");\n\treturn buf;\n}\nfunction createDeterministicTarGz(entries) {\n\tconst sorted = [...entries].sort(compareArchivePaths);\n\tconst chunks = [];\n\tfor (const entry of sorted) {\n\t\tconst archivePath = ustarPathOrPlaceholder(entry.relPath);\n\t\tconst pax = [archivePath.paxPath === void 0 ? \"\" : paxRecord(\"path\", archivePath.paxPath)];\n\t\tif (entry.type === \"symlink\" && Buffer.byteLength(entry.linkname, \"utf8\") > 100) pax.push(paxRecord(\"linkpath\", entry.linkname));\n\t\tconst paxContent = Buffer.from(pax.join(\"\"), \"utf8\");\n\t\tif (paxContent.length > 0) {\n\t\t\tconst digest = crypto$1.createHash(\"sha256\").update(entry.relPath).digest(\"hex\").slice(0, 32);\n\t\t\tchunks.push(ustarHeader(`PaxHeaders/${digest}`, paxContent.length, {\n\t\t\t\tmode: 420,\n\t\t\t\ttypeflag: \"x\"\n\t\t\t}));\n\t\t\tchunks.push(paxContent);\n\t\t\tconst paxPad = (512 - paxContent.length % 512) % 512;\n\t\t\tif (paxPad > 0) chunks.push(Buffer.alloc(paxPad));\n\t\t}\n\t\tif (entry.type === \"symlink\") chunks.push(ustarHeader(archivePath.path, 0, {\n\t\t\tmode: 511,\n\t\t\ttypeflag: \"2\",\n\t\t\tlinkname: Buffer.byteLength(entry.linkname, \"utf8\") <= 100 ? entry.linkname : \"././@LongSymLink\"\n\t\t}));\n\t\telse {\n\t\t\tchunks.push(ustarHeader(archivePath.path, entry.content.length, {\n\t\t\t\tmode: entry.mode,\n\t\t\t\ttypeflag: \"0\"\n\t\t\t}));\n\t\t\tchunks.push(entry.content);\n\t\t\tconst pad = (512 - entry.content.length % 512) % 512;\n\t\t\tif (pad > 0) chunks.push(Buffer.alloc(pad));\n\t\t}\n\t}\n\tchunks.push(Buffer.alloc(1024));\n\treturn zlib.gzipSync(Buffer.concat(chunks));\n}\n/**\n* Prints the bootstrap + manifest and tars them with the bundle into a\n* deterministic artifact. If bundleDir doesn't exist (e.g. `alchemy destroy`\n* run before any build), returns a placeholder rather than throwing — the\n* artifact is never read on destroy.\n*/\nfunction packageComputeArtifact(opts) {\n\tif (!fs.existsSync(opts.bundleDir)) return {\n\t\tpath: \"\",\n\t\tsha256: \"absent\"\n\t};\n\tconst entryFile = resolveEntry(opts.bundleDir, opts.bundleEntry);\n\tconst bootstrapData = `${JSON.stringify({\n\t\tmoduleEntrypoint: `./${entryFile}`,\n\t\tappEntrypoint: `./${opts.appEntry}`,\n\t\taddress: opts.address\n\t}, null, 2)}\\n`;\n\tconst bootstrap = `import { readFile } from \"node:fs/promises\";\n\nconst boot = JSON.parse(\n await readFile(new URL(\"./compute.bootstrap.json\", import.meta.url), \"utf8\"),\n);\n\n// Compute currently boots JavaScript with Bun. Its URL and URLSearchParams\n// implementations accept Object.defineProperty but reject assignment to\n// Node's custom-inspect symbol. SvelteKit assigns that symbol while creating a\n// tracked request URL, so install a narrow setter that materializes the same\n// own property Node would. Remove this compatibility shim when the upstream\n// Alchemy Compute runtime owns the equivalent normalization.\nif (process.versions.bun !== undefined) {\n const inspect = Symbol.for(\"nodejs.util.inspect.custom\");\n for (const constructor of [URL, URLSearchParams]) {\n const inherited = constructor.prototype[inspect];\n Object.defineProperty(constructor.prototype, inspect, {\n configurable: true,\n get() { return inherited; },\n set(value) {\n Object.defineProperty(this, inspect, { configurable: true, value, writable: true });\n },\n });\n }\n}\n\nconst main = (await import(boot.moduleEntrypoint)).default;\nawait main.run(boot.address, () => import(boot.appEntrypoint));\n`;\n\tconst manifest = `${JSON.stringify({\n\t\tmanifestVersion: MANIFEST_VERSION,\n\t\tentrypoint: \"bootstrap.js\",\n\t\taddress: opts.address\n\t}, null, 2)}\\n`;\n\tconst files = walkEntries(opts.bundleDir).map((entry) => entry.type === \"symlink\" ? entry : {\n\t\trelPath: entry.relPath,\n\t\ttype: \"file\",\n\t\tcontent: fs.readFileSync(path.join(opts.bundleDir, ...entry.relPath.split(\"/\"))),\n\t\tmode: entry.executable ? 493 : 420\n\t});\n\tfiles.push({\n\t\trelPath: \"bootstrap.js\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(bootstrap, \"utf8\"),\n\t\tmode: 420\n\t});\n\tfiles.push({\n\t\trelPath: \"compute.bootstrap.json\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(bootstrapData, \"utf8\"),\n\t\tmode: 420\n\t});\n\tfiles.push({\n\t\trelPath: \"compute.manifest.json\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(manifest, \"utf8\"),\n\t\tmode: 420\n\t});\n\tfiles.push({\n\t\trelPath: \"bunfig.toml\",\n\t\ttype: \"file\",\n\t\tcontent: Buffer.from(\"[install]\\nauto = \\\"disable\\\"\\n\", \"utf8\"),\n\t\tmode: 420\n\t});\n\tconst gz = createDeterministicTarGz(files);\n\tconst sha256 = crypto$1.createHash(\"sha256\").update(gz).digest(\"hex\");\n\tconst outDir = path.join(os.tmpdir(), `prisma-composer-compute-${String(os.userInfo().uid)}`, sha256.slice(0, 16));\n\tfs.mkdirSync(outDir, { recursive: true });\n\tconst outPath = path.join(outDir, `${opts.id}.tar.gz`);\n\tconst tmpPath = path.join(outDir, `.${opts.id}.${crypto$1.randomUUID()}.tmp`);\n\tfs.writeFileSync(tmpPath, gz);\n\tfs.renameSync(tmpPath, outPath);\n\treturn {\n\t\tpath: outPath,\n\t\tsha256\n\t};\n}\n//#endregion\n//#region src/compute/ServiceKey.ts\n/**\n* The `ServiceKey` Alchemy resource (ADR-0030) — mints a random 256-bit key\n* ONCE at create and keeps it STABLE across deploys, so an unchanged edge\n* no-ops on redeploy. Same mint-once-stable lifecycle as `S3Credentials`\n* (`packages/1-prisma-cloud/1-extensions/target/src/s3-credentials-resource.ts`):\n* Web Crypto only (`crypto.getRandomValues` — no `node:` import), persisted in\n* Alchemy state; on every later apply the provider returns the persisted\n* attributes (`reconcile`'s `output`) unchanged. One resource per RPC edge;\n* rotation is destroy/recreate.\n*/\n/** The `ServiceKey` resource constructor — `yield* Prisma.ServiceKey(id, {})` in the lowering. */\nconst ServiceKey = Resource(\"PrismaCloud.ServiceKey\");\n/** A fresh 256-bit key as 64 lowercase hex chars (Web Crypto — no node import). */\nfunction mintServiceKey() {\n\tconst bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32));\n\treturn { value: Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\") };\n}\n/**\n* The `ServiceKey` provider service. `reconcile` runs for create and update;\n* it returns the persisted `output` when present (a redeploy reuses the\n* stored key — the no-op property) and mints a fresh key only on first\n* create. Nothing to enumerate (`list` → `[]`) or tear down (`delete` →\n* no-op; the key lives only in state).\n*/\nconst serviceKeyProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ output }) => Effect.sync(() => output ?? mintServiceKey()),\n\tdelete: () => Effect.void\n};\n/** The `ServiceKey` provider layer — merged into the Prisma Cloud extension's `providers()`. */\nconst ServiceKeyProvider = () => Provider.effect(ServiceKey, Effect.succeed(serviceKeyProviderService));\n//#endregion\nexport { COMPUTE_REGIONS, ComputeService, ComputeServiceProvider, Deployment, DeploymentProvider, EnvironmentVariable, EnvironmentVariableProvider, ServiceKey, ServiceKeyProvider, deleteSafeRetrySchedule, isDeleteNotSafeYet, mintServiceKey, packageComputeArtifact, serviceKeyProviderService };\n\n//# sourceMappingURL=compute.mjs.map","import { n as ManagementClient } from \"./client-I552wJ2o.mjs\";\nimport { i as callVoid, n as call, r as callOptional, t as PrismaApiError } from \"./http-d1HGunF-.mjs\";\nimport * as Effect from \"effect/Effect\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy\";\n//#region src/postgres/Connection.ts\n/** A **connection** to a Prisma Postgres database — yields the connection string. */\nconst Connection = Resource(\"Prisma.Connection\");\nconst ConnectionProvider = () => Provider.effect(Connection, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\", \"connectionString\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tif (output?.id) return output;\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/databases/{databaseId}/connections\", {\n\t\t\t\tparams: { path: { databaseId: news.databaseId } },\n\t\t\t\tbody: { name: news.name }\n\t\t\t}));\n\t\t\tconst endpoints = created.data.endpoints;\n\t\t\tconst dsn = endpoints?.direct?.connectionString ?? endpoints?.pooled?.connectionString;\n\t\t\tif (dsn === void 0) return yield* Effect.fail(new PrismaApiError({\n\t\t\t\tstatus: 0,\n\t\t\t\tmessage: `connection ${created.data.id} returned no direct/pooled connection string`\n\t\t\t}));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tconnectionString: Redacted.make(dsn)\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/connections/{id}\", { params: { path: { id: output.id } } }));\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/postgres/Database.ts\n/** A Prisma **Postgres database** inside a project. */\nconst Database = Resource(\"Prisma.Database\");\nconst DatabaseProvider = () => Provider.effect(Database, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/databases/{databaseId}\", { params: { path: { databaseId: output.id } } })) : void 0;\n\t\t\tif (!observed) {\n\t\t\t\tconst created = yield* call(() => client.POST(\"/v1/databases\", { body: {\n\t\t\t\t\tprojectId: news.projectId,\n\t\t\t\t\tname: news.name,\n\t\t\t\t\tregion: news.region,\n\t\t\t\t\t...news.isDefault !== void 0 && { isDefault: news.isDefault },\n\t\t\t\t\t...news.branchId !== void 0 && { branchId: news.branchId }\n\t\t\t\t} }));\n\t\t\t\treturn {\n\t\t\t\t\tid: created.data.id,\n\t\t\t\t\tname: created.data.name\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name\n\t\t\t};\n\t\t\tif (news.branchId !== void 0) {\n\t\t\t\tconst branchId = news.branchId;\n\t\t\t\tyield* call(() => client.PATCH(\"/v1/databases/{databaseId}\", {\n\t\t\t\t\tparams: { path: { databaseId: result.id } },\n\t\t\t\t\tbody: { branchId }\n\t\t\t\t}));\n\t\t\t}\n\t\t\treturn result;\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/databases/{databaseId}\", { params: { path: { databaseId: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst d = yield* callOptional(() => client.GET(\"/v1/databases/{databaseId}\", { params: { path: { databaseId: output.id } } }));\n\t\t\treturn d ? {\n\t\t\t\tid: d.data.id,\n\t\t\t\tname: d.data.name\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\n//#region src/postgres/Project.ts\n/** A Prisma Developer Platform **Project** — the container for databases and compute services. */\nconst Project = Resource(\"Prisma.Project\");\nconst ProjectProvider = () => Provider.effect(Project, Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\treturn {\n\t\tstables: [\"id\"],\n\t\tlist: () => Effect.succeed([]),\n\t\treconcile: Effect.fn(function* ({ news, output }) {\n\t\t\tconst observed = output?.id ? yield* callOptional(() => client.GET(\"/v1/projects/{id}\", { params: { path: { id: output.id } } })) : void 0;\n\t\t\tif (observed) return {\n\t\t\t\tid: observed.data.id,\n\t\t\t\tname: observed.data.name\n\t\t\t};\n\t\t\tconst created = yield* call(() => client.POST(\"/v1/projects\", { body: {\n\t\t\t\tname: news.name,\n\t\t\t\tworkspaceId: news.workspaceId\n\t\t\t} }));\n\t\t\treturn {\n\t\t\t\tid: created.data.id,\n\t\t\t\tname: created.data.name\n\t\t\t};\n\t\t}),\n\t\tdelete: Effect.fn(function* ({ output }) {\n\t\t\tyield* callVoid(() => client.DELETE(\"/v1/projects/{id}\", { params: { path: { id: output.id } } }));\n\t\t}),\n\t\tread: Effect.fn(function* ({ output }) {\n\t\t\tif (!output?.id) return void 0;\n\t\t\tconst p = yield* callOptional(() => client.GET(\"/v1/projects/{id}\", { params: { path: { id: output.id } } }));\n\t\t\treturn p ? {\n\t\t\t\tid: p.data.id,\n\t\t\t\tname: p.data.name\n\t\t\t} : void 0;\n\t\t})\n\t};\n}));\n//#endregion\nexport { Connection, ConnectionProvider, Database, DatabaseProvider, Project, ProjectProvider };\n\n//# sourceMappingURL=postgres.mjs.map","import { a as fromEnv, i as PrismaCredentials, n as ManagementClient, r as layer, t as MANAGEMENT_API_ORIGIN } from \"./client-I552wJ2o.mjs\";\nimport { a as resolveDefaultBranchId, c as drivePagesAsync, i as resolveContainer, n as deleteBranch, o as collectPages, r as deleteProject, s as drivePages, t as ContainerNotFoundError } from \"./container-BdSTYN8l.mjs\";\nimport { Bucket, BucketKey, BucketKeyProvider, BucketProvider } from \"./buckets.mjs\";\nimport { COMPUTE_REGIONS, ComputeService, ComputeServiceProvider, Deployment, DeploymentProvider, EnvironmentVariable, EnvironmentVariableProvider, ServiceKey, ServiceKeyProvider, deleteSafeRetrySchedule, isDeleteNotSafeYet, mintServiceKey, packageComputeArtifact, serviceKeyProviderService } from \"./compute.mjs\";\nimport { Connection, ConnectionProvider, Database, DatabaseProvider, Project, ProjectProvider } from \"./postgres.mjs\";\nimport * as Layer from \"effect/Layer\";\nimport * as Provider from \"alchemy/Provider\";\n//#region src/providers.ts\n/** The collection of Prisma resource providers. */\nvar Providers = class extends Provider.ProviderCollection()(\"Prisma\") {};\n/**\n* The Prisma provider bundle: every resource provider, the Management API\n* client, and env-based credentials. Plug into a stack with\n* `{ providers: Prisma.providers() }`.\n*/\nconst providers = () => Layer.effect(Providers, Provider.collection([\n\tProject,\n\tDatabase,\n\tConnection,\n\tComputeService,\n\tDeployment,\n\tEnvironmentVariable,\n\tBucket,\n\tBucketKey\n])).pipe(Layer.provide(Layer.mergeAll(ProjectProvider(), DatabaseProvider(), ConnectionProvider(), ComputeServiceProvider(), DeploymentProvider(), EnvironmentVariableProvider(), BucketProvider(), BucketKeyProvider())), Layer.provideMerge(layer()), Layer.provideMerge(fromEnv()), Layer.orDie);\n//#endregion\nexport { Bucket, BucketKey, BucketKeyProvider, BucketProvider, COMPUTE_REGIONS, ComputeService, ComputeServiceProvider, Connection, ConnectionProvider, ContainerNotFoundError, Database, DatabaseProvider, Deployment, DeploymentProvider, EnvironmentVariable, EnvironmentVariableProvider, MANAGEMENT_API_ORIGIN, ManagementClient, PrismaCredentials, Project, ProjectProvider, Providers, ServiceKey, ServiceKeyProvider, collectPages, deleteBranch, deleteProject, deleteSafeRetrySchedule, drivePages, drivePagesAsync, fromEnv, isDeleteNotSafeYet, layer as managementClientLayer, mintServiceKey, packageComputeArtifact, providers, resolveContainer, resolveDefaultBranchId, serviceKeyProviderService };\n\n//# sourceMappingURL=index.mjs.map","import { createHash, createHmac, randomUUID, timingSafeEqual } from \"node:crypto\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nconst DEFAULT_CONTENT_TYPE$1 = \"application/octet-stream\";\nconst TMP_DIR_NAME = \".tmp\";\nconst META_DIR_NAME = \".meta\";\nconst RESERVED_SEGMENTS = /* @__PURE__ */ new Set([TMP_DIR_NAME, META_DIR_NAME]);\nconst BUCKET_NAME_RE = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;\nfunction etagOf$1(bytes) {\n\treturn `\"${createHash(\"sha256\").update(bytes).digest(\"hex\")}\"`;\n}\nfunction isErrnoException(err) {\n\treturn err instanceof Error && \"code\" in err;\n}\nfunction isEnoent(err) {\n\treturn isErrnoException(err) && err.code === \"ENOENT\";\n}\n/**\n* Splits a key into its `/` segments, rejecting anything that could escape\n* the bucket dir or collide with the reserved `.tmp`/`.meta` namespaces:\n* `..` segments, an empty segment (leading/trailing/doubled `/`, which also\n* catches a leading-slash \"absolute\" key), or a segment literally `.tmp` or\n* `.meta` at any depth.\n*/\nfunction keySegments(key) {\n\tconst segments = key.split(\"/\");\n\tfor (const segment of segments) if (segment === \"\" || segment === \".\" || segment === \"..\" || RESERVED_SEGMENTS.has(segment)) throw new Error(`invalid object key: \"${key}\"`);\n\treturn segments;\n}\n/** `<bucketDir>/<key's segments>`, double-checked to still resolve inside `bucketDir`. */\nfunction objectPath(bucketDir, key) {\n\tconst target = path.join(bucketDir, ...keySegments(key));\n\tconst resolvedRoot = path.resolve(bucketDir) + path.sep;\n\tif (!(path.resolve(target) + path.sep).startsWith(resolvedRoot)) throw new Error(`invalid object key: \"${key}\"`);\n\treturn target;\n}\n/** `<bucketDir>/.meta/<key's segments>.json` — mirrors `objectPath`'s tree under `.meta`. */\nfunction sidecarPath(bucketDir, key) {\n\tconst segments = keySegments(key);\n\tconst last = segments[segments.length - 1];\n\tconst dirs = segments.slice(0, -1);\n\treturn path.join(bucketDir, META_DIR_NAME, ...dirs, `${last}.json`);\n}\n/** Write-temp-then-rename: never leaves a reader observing a partial file. */\nasync function writeAtomic(finalPath, tmpRoot, bytes) {\n\tawait fs.mkdir(tmpRoot, { recursive: true });\n\tconst tmpPath = path.join(tmpRoot, randomUUID());\n\tawait fs.writeFile(tmpPath, bytes);\n\tawait fs.mkdir(path.dirname(finalPath), { recursive: true });\n\tawait fs.rename(tmpPath, finalPath);\n}\nfunction isSidecar(value) {\n\treturn typeof value === \"object\" && value !== null && \"contentType\" in value && typeof value.contentType === \"string\" && \"etag\" in value && typeof value.etag === \"string\";\n}\nasync function readSidecar(sidecar) {\n\tlet raw;\n\ttry {\n\t\traw = await fs.readFile(sidecar, \"utf8\");\n\t} catch (err) {\n\t\tif (isEnoent(err)) return null;\n\t\tthrow err;\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (isSidecar(parsed)) return parsed;\n\t} catch {}\n\treturn null;\n}\n/** Read the object's bytes plus its metadata — adopting a sidecar-less file (dropped in by a developer) by computing and lazily persisting one. `null` when the object is missing. */\nasync function readObject(bucketDir, key) {\n\tconst target = objectPath(bucketDir, key);\n\tlet bytes;\n\ttry {\n\t\tbytes = await fs.readFile(target);\n\t} catch (err) {\n\t\tif (isEnoent(err)) return null;\n\t\tthrow err;\n\t}\n\tconst existing = await readSidecar(sidecarPath(bucketDir, key));\n\tif (existing) return {\n\t\tbytes,\n\t\tmeta: existing\n\t};\n\tconst meta = {\n\t\tcontentType: DEFAULT_CONTENT_TYPE$1,\n\t\tetag: etagOf$1(bytes)\n\t};\n\tawait writeAtomic(sidecarPath(bucketDir, key), path.join(bucketDir, TMP_DIR_NAME), Buffer.from(JSON.stringify(meta)));\n\treturn {\n\t\tbytes,\n\t\tmeta\n\t};\n}\n/** Remove now-empty directories from `startDir` up to (never including) `root`. */\nasync function pruneEmptyDirs(root, startDir) {\n\tconst resolvedRoot = path.resolve(root);\n\tlet dir = path.resolve(startDir);\n\twhile (dir !== resolvedRoot && dir.startsWith(resolvedRoot + path.sep)) {\n\t\tlet entries;\n\t\ttry {\n\t\t\tentries = await fs.readdir(dir);\n\t\t} catch (err) {\n\t\t\tif (isEnoent(err)) {\n\t\t\t\tdir = path.dirname(dir);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t\tif (entries.length > 0) break;\n\t\ttry {\n\t\t\tawait fs.rmdir(dir);\n\t\t} catch (err) {\n\t\t\tif (!isEnoent(err)) throw err;\n\t\t}\n\t\tdir = path.dirname(dir);\n\t}\n}\n/** Recursively lists every object key under `dir`, skipping `.tmp`/`.meta` at any depth. */\nasync function walkKeys(dir) {\n\tconst keys = [];\n\tasync function walk(current, prefix) {\n\t\tlet entries;\n\t\ttry {\n\t\t\tentries = await fs.readdir(current, { withFileTypes: true });\n\t\t} catch (err) {\n\t\t\tif (isEnoent(err)) return;\n\t\t\tthrow err;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (RESERVED_SEGMENTS.has(entry.name)) continue;\n\t\t\tconst rel = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`;\n\t\t\tif (entry.isDirectory()) await walk(path.join(current, entry.name), rel);\n\t\t\telse if (entry.isFile()) keys.push(rel);\n\t\t}\n\t}\n\tawait walk(dir, \"\");\n\treturn keys;\n}\n/**\n* A disk-backed `ObjectStore`: object bytes and a metadata sidecar under a\n* per-bucket directory the caller resolves. See the module doc for the\n* unknown-bucket / invalid-key failure shapes.\n*/\nfunction fsStore(resolveBucketDir) {\n\tfunction resolveDir(bucket) {\n\t\tif (!BUCKET_NAME_RE.test(bucket)) return void 0;\n\t\treturn resolveBucketDir(bucket);\n\t}\n\treturn {\n\t\tasync put(bucket, key, bytes, opts = {}) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) throw new Error(`no such bucket: \"${bucket}\"`);\n\t\t\tconst target = objectPath(dir, key);\n\t\t\tconst tmpRoot = path.join(dir, TMP_DIR_NAME);\n\t\t\tconst etag = etagOf$1(bytes);\n\t\t\tconst contentType = opts.contentType ?? DEFAULT_CONTENT_TYPE$1;\n\t\t\tawait writeAtomic(target, tmpRoot, bytes);\n\t\t\tawait writeAtomic(sidecarPath(dir, key), tmpRoot, Buffer.from(JSON.stringify({\n\t\t\t\tcontentType,\n\t\t\t\tetag\n\t\t\t})));\n\t\t\treturn { etag };\n\t\t},\n\t\tasync get(bucket, key, opts = {}) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return null;\n\t\t\tconst found = await readObject(dir, key);\n\t\t\tif (!found) return null;\n\t\t\tconst { bytes, meta } = found;\n\t\t\tconst size = bytes.byteLength;\n\t\t\tif (opts.range) {\n\t\t\t\tconst start = opts.range.start;\n\t\t\t\tconst end = opts.range.end === void 0 ? size - 1 : Math.min(opts.range.end, size - 1);\n\t\t\t\treturn {\n\t\t\t\t\tbytes: start > end ? /* @__PURE__ */ new Uint8Array(0) : bytes.subarray(start, end + 1),\n\t\t\t\t\tetag: meta.etag,\n\t\t\t\t\tcontentType: meta.contentType,\n\t\t\t\t\tsize\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tbytes: new Uint8Array(bytes),\n\t\t\t\tetag: meta.etag,\n\t\t\t\tcontentType: meta.contentType,\n\t\t\t\tsize\n\t\t\t};\n\t\t},\n\t\tasync head(bucket, key) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return null;\n\t\t\tconst found = await readObject(dir, key);\n\t\t\tif (!found) return null;\n\t\t\treturn {\n\t\t\t\tetag: found.meta.etag,\n\t\t\t\tsize: found.bytes.byteLength,\n\t\t\t\tcontentType: found.meta.contentType\n\t\t\t};\n\t\t},\n\t\tasync delete(bucket, key) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return;\n\t\t\tconst target = objectPath(dir, key);\n\t\t\tconst sidecar = sidecarPath(dir, key);\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(target);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isEnoent(err)) throw err;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(sidecar);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isEnoent(err)) throw err;\n\t\t\t}\n\t\t\tawait pruneEmptyDirs(dir, path.dirname(target));\n\t\t\tawait pruneEmptyDirs(path.join(dir, META_DIR_NAME), path.dirname(sidecar));\n\t\t},\n\t\tasync list(bucket, opts = {}) {\n\t\t\tconst dir = resolveDir(bucket);\n\t\t\tif (dir === void 0) return {\n\t\t\t\tkeys: [],\n\t\t\t\tisTruncated: false\n\t\t\t};\n\t\t\tconst prefix = opts.prefix ?? \"\";\n\t\t\tconst maxKeys = opts.maxKeys ?? 1e3;\n\t\t\tconst token = opts.continuationToken;\n\t\t\tconst matching = (await walkKeys(dir)).filter((key) => key.startsWith(prefix)).sort().filter((key) => token === void 0 ? true : key > token);\n\t\t\tconst page = matching.slice(0, maxKeys);\n\t\t\tconst isTruncated = matching.length > maxKeys;\n\t\t\tconst last = page.at(-1);\n\t\t\treturn {\n\t\t\t\tkeys: page,\n\t\t\t\tisTruncated,\n\t\t\t\t...isTruncated && last !== void 0 ? { nextContinuationToken: last } : {}\n\t\t\t};\n\t\t}\n\t};\n}\n//#endregion\n//#region src/sigv4.ts\n/**\n* AWS SigV4 verification for the S3 wire protocol (spec § 2 auth). The payload\n* hash comes from the client — `x-amz-content-sha256` (a real hash or\n* `UNSIGNED-PAYLOAD`) for header auth, `UNSIGNED-PAYLOAD` for presign — and is\n* never re-hashed; the verifier trusts what was signed, like a real S3 endpoint.\n* Runtime engine code (`node:crypto`); not re-exported from the authoring barrel.\n*\n* Also owns `mintKeyPair` (local-dev spec § 1) — the one key-pair generator\n* both the deploy-time `S3Credentials` resource and the local dev bucket\n* emulator's credential provisioning use.\n*/\nfunction randomBytes(n) {\n\treturn crypto.getRandomValues(new Uint8Array(n));\n}\nfunction toHexUpper(bytes) {\n\treturn Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\").toUpperCase();\n}\n/** A fresh SigV4 key pair: an AKIA-prefixed id and a 40-char base64 secret. */\nfunction mintKeyPair() {\n\treturn {\n\t\taccessKeyId: `AKIA${toHexUpper(randomBytes(8))}`,\n\t\tsecretAccessKey: btoa(String.fromCharCode(...randomBytes(30)))\n\t};\n}\nconst ALGORITHM = \"AWS4-HMAC-SHA256\";\nconst UNSIGNED_PAYLOAD = \"UNSIGNED-PAYLOAD\";\nfunction sha256Hex(data) {\n\treturn createHash(\"sha256\").update(data).digest(\"hex\");\n}\nfunction hmac(key, data) {\n\treturn createHmac(\"sha256\", key).update(data).digest();\n}\n/** AWS canonical URI encoding: every byte except the unreserved set is %XX. */\nfunction awsUriEncode(value) {\n\treturn encodeURIComponent(value).replace(/[!'()*]/g, (ch) => `%${ch.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%7E/g, \"~\");\n}\nfunction parseCredential(credential) {\n\tconst parts = credential.split(\"/\");\n\tif (parts.length !== 5 || parts[4] !== \"aws4_request\") return null;\n\tconst [accessKeyId, date, region, service] = parts;\n\tif (!accessKeyId || !date || !region || !service) return null;\n\treturn {\n\t\taccessKeyId,\n\t\tdate,\n\t\tregion,\n\t\tservice\n\t};\n}\nfunction signingKey(secret, scope) {\n\treturn hmac(hmac(hmac(hmac(`AWS4${secret}`, scope.date), scope.region), scope.service), \"aws4_request\");\n}\nfunction canonicalHeaders(url, req, signedHeaders) {\n\treturn signedHeaders.map((name) => {\n\t\treturn `${name}:${(name === \"host\" ? url.host : req.headers.get(name) ?? \"\").trim().replace(/\\s+/g, \" \")}\\n`;\n\t}).join(\"\");\n}\nfunction canonicalQuery(url, exclude) {\n\tconst entries = [];\n\tfor (const [key, value] of url.searchParams.entries()) {\n\t\tif (exclude !== void 0 && key === exclude) continue;\n\t\tentries.push([awsUriEncode(key), awsUriEncode(value)]);\n\t}\n\tconst cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;\n\tentries.sort(([ak, av], [bk, bv]) => cmp(ak, bk) || cmp(av, bv));\n\treturn entries.map(([k, v]) => `${k}=${v}`).join(\"&\");\n}\nfunction stringToSign(amzDate, scope, canonicalRequest) {\n\tconst scopeString = `${scope.date}/${scope.region}/${scope.service}/aws4_request`;\n\treturn [\n\t\tALGORITHM,\n\t\tamzDate,\n\t\tscopeString,\n\t\tsha256Hex(canonicalRequest)\n\t].join(\"\\n\");\n}\nfunction signatureMatches(expected, provided) {\n\tconst a = Buffer.from(expected, \"hex\");\n\tconst b = Buffer.from(provided, \"hex\");\n\treturn a.length === b.length && a.length > 0 && timingSafeEqual(a, b);\n}\n/** `YYYYMMDDTHHMMSSZ` → epoch ms, or null when malformed. */\nfunction parseAmzDate(amzDate) {\n\tconst match = /^(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})Z$/.exec(amzDate);\n\tif (!match) return null;\n\tconst [, y, mo, d, h, mi, s] = match;\n\treturn Date.UTC(Number(y), Number(mo) - 1, Number(d), Number(h), Number(mi), Number(s));\n}\nfunction parseAuthorizationHeader(header) {\n\tif (!header.startsWith(`${ALGORITHM} `)) return null;\n\tconst rest = header.slice(17);\n\tconst fields = /* @__PURE__ */ new Map();\n\tfor (const part of rest.split(\",\")) {\n\t\tconst eq = part.indexOf(\"=\");\n\t\tif (eq === -1) continue;\n\t\tfields.set(part.slice(0, eq).trim(), part.slice(eq + 1).trim());\n\t}\n\tconst credential = fields.get(\"Credential\");\n\tconst signedHeaders = fields.get(\"SignedHeaders\");\n\tconst signature = fields.get(\"Signature\");\n\tif (!credential || !signedHeaders || !signature) return null;\n\treturn {\n\t\tcredential,\n\t\tsignedHeaders: signedHeaders.split(\";\"),\n\t\tsignature\n\t};\n}\n/** The one signing core both auth forms share: check the access key, rebuild the canonical request, derive the key, compare in constant time. */\nfunction verifySignature(req, url, credentials, params) {\n\tif (params.scope.accessKeyId !== credentials.accessKeyId) return {\n\t\tok: false,\n\t\treason: \"unknown access key\"\n\t};\n\tconst canonicalRequest = [\n\t\treq.method,\n\t\turl.pathname,\n\t\tcanonicalQuery(url, params.excludeQuery),\n\t\tcanonicalHeaders(url, req, params.signedHeaders),\n\t\tparams.signedHeaders.join(\";\"),\n\t\tparams.payloadHash\n\t].join(\"\\n\");\n\treturn signatureMatches(hmac(signingKey(credentials.secretAccessKey, params.scope), stringToSign(params.amzDate, params.scope, canonicalRequest)).toString(\"hex\"), params.signature) ? { ok: true } : {\n\t\tok: false,\n\t\treason: \"signature mismatch\"\n\t};\n}\nfunction verifyHeader(req, url, credentials) {\n\tconst auth = parseAuthorizationHeader(req.headers.get(\"authorization\") ?? \"\");\n\tif (!auth) return {\n\t\tok: false,\n\t\treason: \"malformed Authorization header\"\n\t};\n\tconst scope = parseCredential(auth.credential);\n\tif (!scope) return {\n\t\tok: false,\n\t\treason: \"malformed credential scope\"\n\t};\n\tconst amzDate = req.headers.get(\"x-amz-date\");\n\tif (!amzDate) return {\n\t\tok: false,\n\t\treason: \"missing x-amz-date\"\n\t};\n\tconst payloadHash = req.headers.get(\"x-amz-content-sha256\");\n\tif (!payloadHash) return {\n\t\tok: false,\n\t\treason: \"missing x-amz-content-sha256\"\n\t};\n\treturn verifySignature(req, url, credentials, {\n\t\tscope,\n\t\tamzDate,\n\t\tsignedHeaders: auth.signedHeaders,\n\t\tpayloadHash,\n\t\tsignature: auth.signature\n\t});\n}\nfunction verifyPresigned(req, url, credentials, now) {\n\tconst q = url.searchParams;\n\tif (q.get(\"X-Amz-Algorithm\") !== ALGORITHM) return {\n\t\tok: false,\n\t\treason: \"unsupported presign algorithm\"\n\t};\n\tconst credentialRaw = q.get(\"X-Amz-Credential\");\n\tconst amzDate = q.get(\"X-Amz-Date\");\n\tconst expiresRaw = q.get(\"X-Amz-Expires\");\n\tconst signedHeadersRaw = q.get(\"X-Amz-SignedHeaders\");\n\tconst signature = q.get(\"X-Amz-Signature\");\n\tif (!credentialRaw || !amzDate || !expiresRaw || !signedHeadersRaw || !signature) return {\n\t\tok: false,\n\t\treason: \"incomplete presign parameters\"\n\t};\n\tconst scope = parseCredential(credentialRaw);\n\tif (!scope) return {\n\t\tok: false,\n\t\treason: \"malformed credential scope\"\n\t};\n\tconst signedAt = parseAmzDate(amzDate);\n\tconst expires = Number(expiresRaw);\n\tif (signedAt === null || !Number.isFinite(expires)) return {\n\t\tok: false,\n\t\treason: \"malformed presign date\"\n\t};\n\tif (now.getTime() > signedAt + expires * 1e3) return {\n\t\tok: false,\n\t\treason: \"presign expired\"\n\t};\n\treturn verifySignature(req, url, credentials, {\n\t\tscope,\n\t\tamzDate,\n\t\tsignedHeaders: signedHeadersRaw.split(\";\"),\n\t\tpayloadHash: UNSIGNED_PAYLOAD,\n\t\tsignature,\n\t\texcludeQuery: \"X-Amz-Signature\"\n\t});\n}\n/**\n* Verify a request's SigV4 signature against a single credential pair. Picks\n* the presigned form when `X-Amz-Signature` is present, otherwise the\n* `Authorization`-header form. `now` is injectable for deterministic\n* expiry tests.\n*/\nfunction verifyRequest(req, credentials, now = /* @__PURE__ */ new Date()) {\n\tconst url = new URL(req.url);\n\tif (url.searchParams.has(\"X-Amz-Signature\")) return verifyPresigned(req, url, credentials, now);\n\tif (req.headers.has(\"authorization\")) return verifyHeader(req, url, credentials);\n\treturn {\n\t\tok: false,\n\t\treason: \"unsigned request\"\n\t};\n}\n//#endregion\n//#region src/handler.ts\nconst DEFAULT_CONTENT_TYPE = \"application/octet-stream\";\n/** Path-style: `/{bucket}/{key…}`. Each segment is percent-decoded. */\nfunction parseTarget(url) {\n\tconst segments = url.pathname.split(\"/\").filter((s) => s.length > 0);\n\tif (segments.length === 0) return null;\n\tconst [bucket, ...keyParts] = segments;\n\treturn {\n\t\tbucket: decodeURIComponent(bucket ?? \"\"),\n\t\tkey: keyParts.map(decodeURIComponent).join(\"/\")\n\t};\n}\n/** `bytes=a-b` (inclusive) or `bytes=a-` (open-ended). Null when absent/malformed. */\nfunction parseRange(header) {\n\tif (!header) return null;\n\tconst match = /^bytes=(\\d+)-(\\d*)$/.exec(header.trim());\n\tif (!match) return null;\n\tconst start = Number(match[1]);\n\treturn match[2] ? {\n\t\tstart,\n\t\tend: Number(match[2])\n\t} : { start };\n}\nfunction xmlEscape(value) {\n\treturn value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\").replace(/'/g, \"'\");\n}\nfunction listXml(bucket, prefix, maxKeys, result) {\n\tconst contents = result.keys.map((k) => `<Contents><Key>${xmlEscape(k)}</Key></Contents>`).join(\"\");\n\tconst next = result.isTruncated && result.nextContinuationToken !== void 0 ? `<NextContinuationToken>${xmlEscape(result.nextContinuationToken)}</NextContinuationToken>` : \"\";\n\treturn `<?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>\";\n}\nconst DEFAULT_MAX_KEYS$1 = 1e3;\nasync function handleList(store, bucket, url) {\n\tconst prefix = url.searchParams.get(\"prefix\") ?? \"\";\n\tconst continuationToken = url.searchParams.get(\"continuation-token\");\n\tconst maxKeysRaw = url.searchParams.get(\"max-keys\");\n\tconst maxKeys = maxKeysRaw !== null && Number.isFinite(Number(maxKeysRaw)) ? Number(maxKeysRaw) : DEFAULT_MAX_KEYS$1;\n\tconst result = await store.list(bucket, {\n\t\tprefix,\n\t\tmaxKeys,\n\t\t...continuationToken !== null ? { continuationToken } : {}\n\t});\n\treturn new Response(listXml(bucket, prefix, maxKeys, result), {\n\t\tstatus: 200,\n\t\theaders: { \"content-type\": \"application/xml\" }\n\t});\n}\n/** aws-chunked / flexible-checksum PUTs frame the body as chunks + a trailer (signalled by `x-amz-content-sha256: STREAMING-…` or `content-encoding: aws-chunked`); the seed signature still verifies, so reject them (501) rather than store the raw framing as the object bytes. Decoding is out of scope. */\nfunction isStreamingPut(req) {\n\tconst contentSha = req.headers.get(\"x-amz-content-sha256\") ?? \"\";\n\tconst contentEncoding = req.headers.get(\"content-encoding\") ?? \"\";\n\treturn contentSha.startsWith(\"STREAMING-\") || contentEncoding.split(\",\").some((e) => e.trim() === \"aws-chunked\");\n}\nasync function handlePut(store, t, req) {\n\tif (isStreamingPut(req)) return new Response(\"aws-chunked / flexible checksums not supported; set requestChecksumCalculation: 'WHEN_REQUIRED'\", { status: 501 });\n\tconst body = new Uint8Array(await req.arrayBuffer());\n\tconst contentType = req.headers.get(\"content-type\") ?? DEFAULT_CONTENT_TYPE;\n\tconst { etag } = await store.put(t.bucket, t.key, body, { contentType });\n\treturn new Response(null, {\n\t\tstatus: 200,\n\t\theaders: { etag }\n\t});\n}\n/** The etag/content-type/content-length/accept-ranges headers GET and HEAD share — `contentLength` is the slice length for GET, the total object size for HEAD. */\nfunction metaHeaders(meta) {\n\treturn new Headers({\n\t\tetag: meta.etag,\n\t\t\"content-type\": meta.contentType,\n\t\t\"content-length\": String(meta.contentLength),\n\t\t\"accept-ranges\": \"bytes\"\n\t});\n}\nasync function handleGet(store, t, req) {\n\tconst range = parseRange(req.headers.get(\"range\"));\n\tconst object = await store.get(t.bucket, t.key, range ? { range } : void 0);\n\tif (!object) return new Response(null, { status: 404 });\n\tconst headers = metaHeaders({\n\t\tetag: object.etag,\n\t\tcontentType: object.contentType,\n\t\tcontentLength: object.bytes.byteLength\n\t});\n\tif (!range) return new Response(object.bytes, {\n\t\tstatus: 200,\n\t\theaders\n\t});\n\tif (range.start >= object.size && object.size > 0) return new Response(null, {\n\t\tstatus: 416,\n\t\theaders: { \"content-range\": `bytes */${object.size}` }\n\t});\n\tconst end = range.end === void 0 ? object.size - 1 : Math.min(range.end, object.size - 1);\n\theaders.set(\"content-range\", `bytes ${range.start}-${end}/${object.size}`);\n\treturn new Response(object.bytes, {\n\t\tstatus: 206,\n\t\theaders\n\t});\n}\nasync function handleHead(store, t) {\n\tconst meta = await store.head(t.bucket, t.key);\n\tif (!meta) return new Response(null, { status: 404 });\n\treturn new Response(null, {\n\t\tstatus: 200,\n\t\theaders: metaHeaders({\n\t\t\tetag: meta.etag,\n\t\t\tcontentType: meta.contentType,\n\t\t\tcontentLength: meta.size\n\t\t})\n\t});\n}\nasync function handleDelete(store, t) {\n\tawait store.delete(t.bucket, t.key);\n\treturn new Response(null, { status: 204 });\n}\nfunction createS3Handler(opts) {\n\tconst { store, credentials } = opts;\n\treturn async (req) => {\n\t\tif (!verifyRequest(req, credentials).ok) return new Response(null, { status: 403 });\n\t\tconst url = new URL(req.url);\n\t\tconst target = parseTarget(url);\n\t\tif (!target) return new Response(null, { status: 400 });\n\t\tif (req.method === \"GET\" && url.searchParams.get(\"list-type\") === \"2\" && target.key === \"\") return handleList(store, target.bucket, url);\n\t\tif (target.key === \"\") return new Response(null, { status: 400 });\n\t\tswitch (req.method) {\n\t\t\tcase \"PUT\": return handlePut(store, target, req);\n\t\t\tcase \"GET\": return handleGet(store, target, req);\n\t\t\tcase \"HEAD\": return handleHead(store, target);\n\t\t\tcase \"DELETE\": return handleDelete(store, target);\n\t\t\tdefault: return new Response(null, { status: 405 });\n\t\t}\n\t};\n}\n//#endregion\n//#region src/memory-store.ts\n/**\n* An in-memory `ObjectStore` for the protocol tests — the same contract the\n* Postgres store (D3) implements. Test-only; never wired into a deployed\n* service. Not re-exported from the authoring barrel.\n*/\nconst DEFAULT_MAX_KEYS = 1e3;\nfunction etagOf(bytes) {\n\treturn `\"${createHash(\"sha256\").update(bytes).digest(\"hex\")}\"`;\n}\nvar MemoryObjectStore = class {\n\tentries = /* @__PURE__ */ new Map();\n\tid(bucket, key) {\n\t\treturn `${bucket}\\x00${key}`;\n\t}\n\tasync put(bucket, key, bytes, opts = {}) {\n\t\tconst copy = bytes.slice();\n\t\tconst etag = etagOf(copy);\n\t\tthis.entries.set(this.id(bucket, key), {\n\t\t\tbytes: copy,\n\t\t\tetag,\n\t\t\tcontentType: opts.contentType ?? \"application/octet-stream\"\n\t\t});\n\t\treturn { etag };\n\t}\n\tasync get(bucket, key, opts = {}) {\n\t\tconst entry = this.entries.get(this.id(bucket, key));\n\t\tif (!entry) return null;\n\t\tconst size = entry.bytes.byteLength;\n\t\tif (opts.range) {\n\t\t\tconst start = opts.range.start;\n\t\t\tconst end = opts.range.end === void 0 ? size - 1 : Math.min(opts.range.end, size - 1);\n\t\t\treturn {\n\t\t\t\tbytes: start > end ? /* @__PURE__ */ new Uint8Array(0) : entry.bytes.slice(start, end + 1),\n\t\t\t\tetag: entry.etag,\n\t\t\t\tcontentType: entry.contentType,\n\t\t\t\tsize\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tbytes: entry.bytes.slice(),\n\t\t\tetag: entry.etag,\n\t\t\tcontentType: entry.contentType,\n\t\t\tsize\n\t\t};\n\t}\n\tasync head(bucket, key) {\n\t\tconst entry = this.entries.get(this.id(bucket, key));\n\t\tif (!entry) return null;\n\t\treturn {\n\t\t\tetag: entry.etag,\n\t\t\tsize: entry.bytes.byteLength,\n\t\t\tcontentType: entry.contentType\n\t\t};\n\t}\n\tasync delete(bucket, key) {\n\t\tthis.entries.delete(this.id(bucket, key));\n\t}\n\tasync list(bucket, opts = {}) {\n\t\tconst prefix = opts.prefix ?? \"\";\n\t\tconst maxKeys = opts.maxKeys ?? DEFAULT_MAX_KEYS;\n\t\tconst token = opts.continuationToken;\n\t\tconst prefixHit = `${bucket}\\x00${prefix}`;\n\t\tconst matching = [...this.entries.keys()].filter((id) => id.startsWith(prefixHit)).map((id) => id.slice(bucket.length + 1)).sort().filter((key) => token === void 0 ? true : key > token);\n\t\tconst page = matching.slice(0, maxKeys);\n\t\tconst isTruncated = matching.length > maxKeys;\n\t\tconst last = page.at(-1);\n\t\treturn {\n\t\t\tkeys: page,\n\t\t\tisTruncated,\n\t\t\t...isTruncated && last !== void 0 ? { nextContinuationToken: last } : {}\n\t\t};\n\t}\n};\n//#endregion\nexport { MemoryObjectStore, createS3Handler, fsStore, mintKeyPair, verifyRequest };\n\n//# sourceMappingURL=index.mjs.map","import { a as isEnvParamSource, c as paramName, n as secretName, o as isGeneratedParamSource } from \"./secret-Doubjztg.mjs\";\nimport { i as withConnectionRetry, n as normalizeSslMode } from \"./pg-connection-CadPZuEK.mjs\";\nimport { inputManifest, isSecretSource, paramManifest } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport { ManagementClient, deleteBranch, deleteProject, fromEnv, managementClientLayer, resolveContainer } from \"@internal/lowering\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { Resource } from \"alchemy\";\nimport * as Provider from \"alchemy/Provider\";\nimport pg from \"pg\";\nimport { loadConfig } from \"@prisma/orm-toolchain/config-loader\";\nimport { resolve } from \"pathe\";\nimport { createPostgresControlClient } from \"@prisma/orm-postgres/control\";\nimport { readRef } from \"@prisma/orm-toolchain/migration-tools/refs\";\nimport { APP_SPACE_ID, readContractSpaceHeadRef, spaceMigrationDirectory, spaceRefsDirectory } from \"@prisma/orm-toolchain/migration-tools/spaces\";\nimport { mintKeyPair } from \"@internal/s3-protocol\";\n//#region src/container.ts\nconst PRISMA_CLOUD_EXTENSION_ID = \"@prisma/composer-prisma-cloud\";\n/** Accepts exactly what Alchemy's own `--stage` validation accepts (pinned 2.0.0-beta.59, `Cli/commands/_shared.ts`), rewritten without overlapping quantifiers so it cannot backtrack catastrophically. Asserted before a Branch id is exposed as a stage. */\nconst ALCHEMY_STAGE_PATTERN = /^[a-z0-9][-_a-z0-9]*$/i;\nfunction invalidAlchemyStageError(branchId) {\n\treturn /* @__PURE__ */ new Error(`${PRISMA_CLOUD_EXTENSION_ID}: the resolved Branch id \"${branchId}\" does not match Alchemy's stage pattern ^[a-z0-9][-_a-z0-9]*\\$ (case-insensitive) — it cannot scope the deploy state. The platform should never return such an id; contact support.`);\n}\nvar PrismaCloudContainer = class {\n\tinput;\n\tprojectId;\n\tbranchId;\n\tdefaultBranchId;\n\t/** The deterministic Alchemy stage (ContainerInstance SPI): the stage Branch's id, or the default Branch's id for the default stage. Absent only for the dev container, which resolves no Branch. */\n\talchemyStage;\n\tconstructor(input, projectId, branchId, defaultBranchId) {\n\t\tthis.input = input;\n\t\tthis.projectId = projectId;\n\t\tthis.branchId = branchId;\n\t\tthis.defaultBranchId = defaultBranchId;\n\t\tconst stageBranchId = branchId ?? defaultBranchId;\n\t\tif (stageBranchId !== void 0 && !ALCHEMY_STAGE_PATTERN.test(stageBranchId)) throw invalidAlchemyStageError(stageBranchId);\n\t\tthis.alchemyStage = stageBranchId;\n\t}\n\tserialize() {\n\t\treturn JSON.stringify({\n\t\t\tinput: this.input,\n\t\t\tprojectId: this.projectId,\n\t\t\t...this.branchId !== void 0 ? { branchId: this.branchId } : {},\n\t\t\t...this.defaultBranchId !== void 0 ? { defaultBranchId: this.defaultBranchId } : {}\n\t\t});\n\t}\n};\n/** `instanceof` — parent-side instances and child-side deserialized instances are both constructed by this module. */\nfunction isPrismaCloudContainer(value) {\n\treturn value instanceof PrismaCloudContainer;\n}\n/** Narrow-or-throw for hook inputs. */\nfunction prismaCloudContainerOf(value) {\n\tif (!isPrismaCloudContainer(value)) throw new Error(\"the Prisma Cloud container was not resolved — the extension's container descriptor did not run.\");\n\treturn value;\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction invalidPayloadError(reason) {\n\treturn /* @__PURE__ */ new Error(`${PRISMA_CLOUD_EXTENSION_ID}: invalid container transport payload — ${reason}.`);\n}\n/**\n* Reconstructs a `PrismaCloudContainer` from `serialize()`'s JSON output —\n* real narrowing, no casts. Exported so `dev/container.ts`'s\n* `devContainerDescriptor` can reuse it verbatim (local-dev spec § 5) — the\n* dev and deploy container descriptors deserialize the identical wire shape.\n*/\nfunction deserialize(serialized) {\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(serialized);\n\t} catch (error) {\n\t\tthrow invalidPayloadError(`not valid JSON (${error instanceof Error ? error.message : String(error)})`);\n\t}\n\tif (!isRecord(parsed)) throw invalidPayloadError(\"not an object\");\n\tconst input = parsed[\"input\"];\n\tif (!isRecord(input)) throw invalidPayloadError(\"\\\"input\\\" is not an object\");\n\tconst appName = input[\"appName\"];\n\tif (typeof appName !== \"string\") throw invalidPayloadError(\"\\\"input.appName\\\" is not a string\");\n\tconst stage = input[\"stage\"];\n\tif (stage !== void 0 && typeof stage !== \"string\") throw invalidPayloadError(\"\\\"input.stage\\\" is not a string or absent\");\n\tconst projectId = parsed[\"projectId\"];\n\tif (typeof projectId !== \"string\") throw invalidPayloadError(\"\\\"projectId\\\" is not a string\");\n\tconst branchId = parsed[\"branchId\"];\n\tif (branchId !== void 0 && typeof branchId !== \"string\") throw invalidPayloadError(\"\\\"branchId\\\" is not a string or absent\");\n\tconst defaultBranchId = parsed[\"defaultBranchId\"];\n\tif (defaultBranchId !== void 0 && typeof defaultBranchId !== \"string\") throw invalidPayloadError(\"\\\"defaultBranchId\\\" is not a string or absent\");\n\treturn new PrismaCloudContainer({\n\t\tappName,\n\t\tstage\n\t}, projectId, branchId, defaultBranchId);\n}\nconst workspaceRequiredError = () => /* @__PURE__ */ new Error(\"environment variable PRISMA_WORKSPACE_ID is required.\");\nconst tokenRequiredError = () => /* @__PURE__ */ new Error(\"environment variable PRISMA_SERVICE_TOKEN is required.\");\n/**\n* The caller's workspace id, or — only when the caller passed no credentials\n* at all — the env protocol, which is what the alchemy child process and\n* existing programmatic hosts have set.\n*/\nfunction requireWorkspaceId(credentials) {\n\tconst workspaceId = credentials === void 0 ? process.env[\"PRISMA_WORKSPACE_ID\"] : credentials.workspaceId;\n\tif (workspaceId === void 0 || workspaceId.length === 0) throw workspaceRequiredError();\n\treturn workspaceId;\n}\nfunction requireTokenUnlessInjected(client) {\n\tif (client === void 0 && (process.env[\"PRISMA_SERVICE_TOKEN\"] ?? \"\").length === 0) throw tokenRequiredError();\n}\nfunction clientFor(credentials, deps) {\n\treturn credentials?.client ?? deps?.client;\n}\n/** Runs against the injected client when there is one, and against an env-built one otherwise. */\nfunction runWithClient(program, client) {\n\treturn Effect.runPromise(client !== void 0 ? program.pipe(Effect.provideService(ManagementClient, client)) : program.pipe(Effect.provide(managementClientLayer().pipe(Layer.provide(fromEnv())))));\n}\nasync function ensureContainer(input, credentials, deps) {\n\tconst workspaceId = requireWorkspaceId(credentials);\n\tconst client = clientFor(credentials, deps);\n\trequireTokenUnlessInjected(client);\n\tconst outcome = await runWithClient(resolveContainer({\n\t\tworkspaceId,\n\t\tappName: input.appName,\n\t\t...input.stage !== void 0 ? { stage: input.stage } : {},\n\t\tensure: true\n\t}).pipe(Effect.map((c) => ({\n\t\tok: true,\n\t\tcontainer: c\n\t})), Effect.catchTag(\"PrismaApiError\", (e) => Effect.succeed({\n\t\tok: false,\n\t\tmessage: `Prisma Management API error resolving containers: ${e.message}.`\n\t}))), client);\n\tif (!outcome.ok) throw new Error(outcome.message);\n\treturn new PrismaCloudContainer(input, outcome.container.projectId, outcome.container.branchId, outcome.container.defaultBranchId);\n}\nasync function locateContainer(input, credentials, deps) {\n\tconst workspaceId = requireWorkspaceId(credentials);\n\tconst client = clientFor(credentials, deps);\n\trequireTokenUnlessInjected(client);\n\tconst outcome = await runWithClient(resolveContainer({\n\t\tworkspaceId,\n\t\tappName: input.appName,\n\t\t...input.stage !== void 0 ? { stage: input.stage } : {},\n\t\tensure: false\n\t}).pipe(Effect.map((c) => ({\n\t\tok: true,\n\t\tcontainer: c\n\t})), Effect.catchTag(\"ContainerNotFoundError\", () => Effect.succeed({ ok: false })), Effect.catchTag(\"PrismaApiError\", (e) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error resolving containers: ${e.message}.`)))), client);\n\tif (!outcome.ok) return void 0;\n\treturn new PrismaCloudContainer(input, outcome.container.projectId, outcome.container.branchId, outcome.container.defaultBranchId);\n}\n/**\n* Soft-deletes a named stage's Branch after a successful `alchemy destroy`\n* has removed its members — the Management API refuses to delete a Branch\n* that still has live members.\n*/\nasync function removeStageBranch(branchId, credentials, deps) {\n\tconst client = clientFor(credentials, deps);\n\trequireTokenUnlessInjected(client);\n\tconst outcome = await runWithClient(deleteBranch(branchId).pipe(Effect.map(() => ({ ok: true })), Effect.catchTag(\"PrismaApiError\", (e) => Effect.succeed({\n\t\tok: false,\n\t\tmessage: `Failed to delete the stage Branch: ${e.message}.`\n\t}))), client);\n\tif (!outcome.ok) throw new Error(outcome.message);\n}\n/**\n* Best-effort cleanup after a successful `--production` destroy: removes\n* the app's Project so hand-run stacks don't accumulate as empty Projects\n* (they eventually hit the workspace's plan limit). Unlike `removeStageBranch`,\n* this never throws: the destroy itself already succeeded, and the API's own\n* 400 (\"still has dependencies\") is the only check that matters — failing\n* the command over a cleanup step would be worse than leaving a Project shell.\n*/\nasync function removeAppProject(projectId, credentials, deps) {\n\tconst client = clientFor(credentials, deps);\n\tif (client === void 0 && (process.env[\"PRISMA_SERVICE_TOKEN\"] ?? \"\").length === 0) {\n\t\tconsole.warn(`Skipped removing the Project (${projectId}): PRISMA_SERVICE_TOKEN is not set.`);\n\t\treturn;\n\t}\n\tconst outcome = await runWithClient(deleteProject(projectId).pipe(Effect.map(() => ({ ok: true })), Effect.catchTag(\"PrismaApiError\", (e) => Effect.succeed({\n\t\tok: false,\n\t\terror: e\n\t}))), client);\n\tif (outcome.ok) {\n\t\tconsole.log(`Removed the Project (${projectId}) — nothing was left in it.`);\n\t\treturn;\n\t}\n\tif (outcome.error.status === 400) {\n\t\tconsole.log(`Kept the Project (${projectId}) — it still has another stage's resources.`);\n\t\treturn;\n\t}\n\tconsole.warn(`Could not remove the Project (${projectId}) after destroy: ${outcome.error.message}.`);\n}\nfunction containerDescriptor(deps) {\n\treturn {\n\t\tensure: (input, credentials) => ensureContainer(input, credentials, deps),\n\t\tlocate: (input, credentials) => locateContainer(input, credentials, deps),\n\t\tremove: (instance, credentials) => instance.input.stage !== void 0 ? removeStageBranch(instance.branchId ?? missingBranchId(instance), credentials, deps) : removeAppProject(instance.projectId, credentials, deps),\n\t\tdeserialize\n\t};\n}\n/** Defensive: a named-stage container always resolves a Branch together with its stage — `ensure`/`locate`/`deserialize` never produce one without the other. */\nfunction missingBranchId(instance) {\n\tthrow new Error(`${PRISMA_CLOUD_EXTENSION_ID}: a named-stage (\"${instance.input.stage}\") container instance is missing its branchId — this is a bug in ensure/locate/deserialize.`);\n}\n//#endregion\n//#region src/generated-param-resource.ts\n/**\n* The `GeneratedParam` Alchemy resource — generates a random value ONCE at\n* create and keeps it STABLE across deploys, so an unchanged service no-ops on\n* redeploy. The value is `bytes` random bytes produced with the Web Crypto\n* global (`crypto.getRandomValues` — no `node:` import, matching this package's\n* runtime-coupling invariant), base64-encoded, and persisted in Alchemy state;\n* on every later apply the provider returns the persisted attributes\n* (`reconcile`'s `output`) unchanged — the same way `S3Credentials` keeps its\n* pair stable. Changing `bytes` on an existing resource KEEPS the old value\n* (reconcile short-circuits on the persisted output); rotation is\n* destroy/recreate.\n*\n* One resource per `generatedParam()`-bound input leaf, provisioned by the\n* compute descriptor's serialize step; the resource id derives from the input\n* document row key and the leaf path, so the value is stable per service+leaf.\n*\n* Deploy-time only: imports `alchemy`. Imported by `control/extension.ts` and\n* tests, never by `index.ts` / the authoring entry.\n*/\n/** The `GeneratedParam` resource constructor — `yield* GeneratedParam(id, { bytes })` in the lowering. */\nconst GeneratedParam = Resource(\"PrismaCloud.GeneratedParam\");\n/** A fresh generated value: `bytes` random bytes, base64. */\nfunction generateValue(bytes) {\n\tconst random = crypto.getRandomValues(new Uint8Array(bytes));\n\treturn { value: btoa(String.fromCharCode(...random)) };\n}\n/**\n* The `GeneratedParam` provider service. `reconcile` runs for create and\n* update; it returns the persisted `output` when present (a redeploy reuses the\n* stored value — the no-op property, and the reason a `bytes` change does not\n* re-generate) and generates a fresh value only on first create. Nothing to\n* enumerate (`list` → `[]`) or tear down (`delete` → no-op; the value lives\n* only in state). Exported so tests can drive it directly.\n*/\nconst generatedParamProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ news, output }) => Effect.sync(() => output ?? generateValue(news.bytes)),\n\tdelete: () => Effect.void\n};\n/** The `GeneratedParam` provider layer — merged into the extension descriptor's `providers()`. */\nconst GeneratedParamProvider = () => Provider.effect(GeneratedParam, Effect.succeed(generatedParamProviderService));\n//#endregion\n//#region src/pg-warm-resource.ts\n/**\n* The `PgWarm` Alchemy resource (slice 3, FT-5226) — warm a freshly-provisioned\n* Prisma Postgres database at apply-time so it is ready by deploy-end, and the\n* first real connection (a service's runtime client, or the migration) doesn't\n* eat the cold-start reject.\n*\n* The DB `url` is a lazy `Output` at lowering time, so warming must be an\n* apply-time tracked resource (same pattern as `PnMigration`): its `reconcile`\n* receives the RESOLVED url and connects with `withConnectionRetry` + `select 1`,\n* riding out the cold-start. Shared by BOTH the bare-`postgres` and the\n* `prisma-next` lowerings; keyed on the connection `url`, so an unchanged\n* redeploy is a no-op (warming is idempotent anyway).\n*\n* Deploy-time only: imports `pg` directly + `alchemy`. Imported by `control.ts`\n* and tests, never by `index.ts` / the `./prisma-next` authoring entry — the\n* isolation invariants hold.\n*/\n/** The `PgWarm` resource constructor — `yield* PgWarm(id, { url })` in a lowering. */\nconst PgWarm = Resource(\"PrismaCloud.PgWarm\");\n/**\n* Connect (retrying the cold-start) and run `select 1`, then release the\n* connection. Exported so tests can drive it directly; `retry` overrides the\n* bounded retry's defaults.\n*/\nasync function warmDatabase(url, retry = {}) {\n\tawait withConnectionRetry(async () => {\n\t\tconst client = new pg.Client({ connectionString: normalizeSslMode(url) });\n\t\tclient.on(\"error\", (error) => console.error(\"pg warm client socket error\", error));\n\t\tawait client.connect();\n\t\ttry {\n\t\t\tawait client.query(\"select 1\");\n\t\t} finally {\n\t\t\tawait client.end();\n\t\t}\n\t}, retry);\n}\n/**\n* The `PgWarm` provider service. `reconcile` warms the DB (retrying the\n* cold-start) and echoes the `url` so a downstream resource that reads\n* `warm.url` runs only after the DB is warm. Idempotent — safe on redeploy;\n* nothing to enumerate (`list` → `[]`) or tear down (`delete` → no-op; the DB's\n* own deletion handles teardown). Exported so tests can drive it directly.\n*/\nconst pgWarmProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ news }) => Effect.tryPromise({\n\t\ttry: () => warmDatabase(news.url),\n\t\tcatch: (error) => error\n\t}).pipe(Effect.map(() => ({ url: news.url }))),\n\tdelete: () => Effect.void\n};\n/** The `PgWarm` provider layer — merged into the extension descriptor's `providers()`. */\nconst PgWarmProvider = () => Provider.effect(PgWarm, Effect.succeed(pgWarmProviderService));\n//#endregion\n//#region src/pn-config.ts\n/**\n* Resolves a `pnPostgres` resource's `prisma-next.config.ts` path to the\n* project facts the deploy needs (ADR-0022, slice 2): the on-disk migrations\n* directory the control client's `migrate`/`dbInit` read, and the declared\n* extension packs. Deploy-time only: loads PN's config (via c12) and applies\n* PN's own convention — `migrations.dir`, or the default `migrations/`,\n* relative to the config file's directory (mirrors the CLI's\n* `resolveMigrationPaths`). Imported by `control.ts` + tests, never by\n* `index.ts` / the `./prisma-next` authoring entry.\n*\n* `pathe` (not `node:path`) does the path work so the shipped source carries no\n* `node:` import — the same discipline `control.ts` already follows by\n* delegating fs/tar to `@internal/lowering` (invariant 5).\n*/\n/** Loads the config at `configPath` and resolves the facts the deploy consumes. */\nasync function resolvePrismaNextConfig(configPath) {\n\tconst loaded = await loadConfig(configPath);\n\tif (!loaded.ok) throw loaded.failure;\n\tconst config = loaded.value.config;\n\treturn {\n\t\tmigrationsDir: resolve(configPath, \"..\", config.migrations?.dir ?? \"migrations\"),\n\t\textensionPacks: blindCast(config.extensions ?? [])\n\t};\n}\n/**\n* The pack-head identity entries the `PnMigration` resource folds into its\n* diff key: `\"<packId>:<headRefHash>\"` — each pack's contract-space head ref,\n* identified by its storage hash — sorted by pack id, so a pack upgrade (or a\n* pack added/removed) produces a distinct deploy step. A pack without a\n* `contractSpace` contributes `\"-\"` for its head — it declares no migratable\n* space, but its presence still belongs in the key.\n*/\nfunction packHeadRefHashes(packs) {\n\treturn packs.map((pack) => `${pack.id}:${pack.contractSpace?.headRef.hash ?? \"-\"}`).sort();\n}\n//#endregion\n//#region src/prisma-next-migrate.ts\n/**\n* The Prisma Next migration step of the deploy lowering (ADR-0022, slice 2) —\n* the safety-critical decision that brings a live database to a target REF\n* using ONLY Prisma Next's authored migrations.\n*\n* Deploy-time only: this module imports `@prisma/orm-postgres/control` (which\n* transitively pulls PN's control/migration machinery + `pg`). It is imported\n* by the deploy descriptors and this package's tests, NEVER by `index.ts` / the\n* `./prisma-next` authoring entry — so it never lands in an app runtime bundle\n* (the index-isolation invariant holds).\n*\n* The target is a ref `{ hash, invariants }` — not a bare `storageHash`. A\n* ref's `invariants` are named postconditions established by `data`-class\n* migration steps (e.g. a backfill), recorded monotonically on the live\n* marker. Keying on the hash alone would make a pure data-invariant change an\n* A→A self-edge the deploy wrongly skips. The decision, given the live marker\n* and the target ref (see {@link decideMigrationAction}):\n* - marker at ref.hash AND ref.invariants ⊆ marker.invariants → no-op\n* - no marker (fresh DB) AND no required invariants → `dbInit`\n* - otherwise → `migrate`\n*\n* `dbInit` is additive-only synthesis — it NEVER runs app-space data steps —\n* so it is only correct when the ref requires no invariants; a fresh DB whose\n* target carries invariants goes through `migrate`, which walks the AUTHORED\n* graph (including the invariant-bearing data migrations) from empty.\n*\n* Never `dbUpdate`: synthesized diff-and-apply plans are never run against a\n* deployed database. A no-authored-path (`MIGRATION_PATH_NOT_FOUND`) or a\n* runner failure fails the deploy as a typed `PnMigrationError` (not swallowed).\n* PN applies each migration in its own transaction, so a failed apply is atomic\n* and resume-safe — the marker and schema are left as the last committed step.\n*/\n/** A deploy-failing migration error — surfaced, never swallowed. */\nvar PnMigrationError = class extends Error {\n\tcode;\n\t/** PN's structured explanation, when present. */\n\twhy;\n\tconstructor(code, summary, why) {\n\t\tsuper(`prisma-next migrate (${code}): ${summary}`);\n\t\tthis.name = \"PnMigrationError\";\n\t\tthis.code = code;\n\t\tthis.why = why;\n\t}\n};\n/**\n* The target `storageHash` a contract heads to — `contractJson.storage.storageHash`.\n* Read defensively: `contractJson` crosses the boundary as `unknown`.\n*/\nfunction targetStorageHash(contractJson) {\n\tif (typeof contractJson === \"object\" && contractJson !== null && \"storage\" in contractJson) {\n\t\tconst storage = contractJson.storage;\n\t\tif (typeof storage === \"object\" && storage !== null && \"storageHash\" in storage) {\n\t\t\tconst hash = storage.storageHash;\n\t\t\tif (typeof hash === \"string\" && hash.length > 0) return hash;\n\t\t}\n\t}\n\tthrow new PnMigrationError(\"INIT_FAILED\", \"the contract has no storage.storageHash — cannot determine the target schema version\");\n}\n/**\n* Resolve the deploy's target ref from the migrations dir.\n*\n* - `targetRef` named: read `migrations/app/refs/<name>.json` — fail loudly\n* (`TARGET_REF_NOT_FOUND`) when the ref doesn't exist or can't be parsed.\n* - Default: the app space's head. PN synthesizes the app head from the\n* emitted contract — `{ hash: contract.storage.storageHash, invariants: [] }`\n* (`contract emit` writes no app-space `refs/head.json` today; extension\n* spaces have one on disk). When a future PN version does emit one, the\n* on-disk `head.json` wins — read via `readContractSpaceHeadRef`, exactly\n* the loader PN's own migrate uses.\n*/\nasync function resolveTargetRef(migrationsDir, contractJson, targetRef) {\n\tif (targetRef !== void 0) {\n\t\tconst refsDir = spaceRefsDirectory(spaceMigrationDirectory(migrationsDir, APP_SPACE_ID));\n\t\ttry {\n\t\t\tconst ref = await readRef(refsDir, targetRef);\n\t\t\treturn {\n\t\t\t\thash: ref.hash,\n\t\t\t\tinvariants: ref.invariants\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new PnMigrationError(\"TARGET_REF_NOT_FOUND\", `targetRef \"${targetRef}\" could not be read from ${refsDir}`, error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\tconst head = await readContractSpaceHeadRef(migrationsDir, APP_SPACE_ID);\n\tif (head !== null) return {\n\t\thash: head.hash,\n\t\tinvariants: head.invariants\n\t};\n\treturn {\n\t\thash: targetStorageHash(contractJson),\n\t\tinvariants: []\n\t};\n}\n/**\n* The pure migration decision, mirroring PN's own verifier: the database is\n* AT the target when the marker's hash equals the ref's hash AND every ref\n* invariant is on the marker (marker invariants are monotonic). `dbInit` is\n* additive-only synthesis, so it is chosen only for a fresh DB whose\n* effective required invariants (`ref.invariants − marker.invariants`) are\n* empty; anything else — different hash, missing invariant (the A→A\n* data-only self-edge), or a fresh DB with required invariants — walks the\n* authored graph via `migrate`.\n*/\nfunction decideMigrationAction(marker, ref) {\n\tconst markerInvariants = new Set(marker?.invariants ?? []);\n\tconst missing = ref.invariants.filter((id) => !markerInvariants.has(id));\n\tif (marker !== null && marker.storageHash === ref.hash && missing.length === 0) return \"noop\";\n\tif (marker === null && missing.length === 0) return \"init\";\n\treturn \"migrate\";\n}\n/**\n* Bring the database at `url` to the target ref via PN's authored migrations.\n* Reads the live marker, decides no-op / init / migrate\n* ({@link decideMigrationAction}), applies, and throws a typed\n* {@link PnMigrationError} on a no-path or runner failure. `migrationsDir` is\n* the on-disk migrations root and `ref` the resolved target\n* ({@link resolveTargetRef} — both resolved by the lowering, which also keys\n* the PnMigration resource on them). `refName` (the resource's `targetRef`,\n* when set) is threaded into `migrate` so PN targets the named ref's hash and\n* plans an invariant-bearing path.\n*/\nasync function applyPnMigration(opts) {\n\tconst connection = normalizeSslMode(opts.url);\n\treturn withConnectionRetry(() => runMigration(connection, opts.contractJson, opts.migrationsDir, opts.ref, opts.refName, opts.extensionPacks ?? []), { shouldRetry: (error) => !(error instanceof PnMigrationError) });\n}\nasync function runMigration(connection, contractJson, migrationsDir, ref, refName, extensionPacks) {\n\tconst client = createPostgresControlClient({\n\t\tconnection,\n\t\textensions: extensionPacks\n\t});\n\tawait client.connect();\n\ttry {\n\t\tconst marker = await client.readMarker();\n\t\tconst markerHashBefore = marker?.storageHash ?? null;\n\t\tlet action = decideMigrationAction(marker, ref);\n\t\tif (action === \"noop\") {\n\t\t\tif (extensionPacks.length === 0) return {\n\t\t\t\taction,\n\t\t\t\ttargetHash: ref.hash,\n\t\t\t\tmarkerHashBefore\n\t\t\t};\n\t\t\taction = \"migrate\";\n\t\t}\n\t\tif (action === \"init\") {\n\t\t\tconst result = await client.dbInit({\n\t\t\t\tcontract: contractJson,\n\t\t\t\tmode: \"apply\",\n\t\t\t\tmigrationsDir\n\t\t\t});\n\t\t\tif (!result.ok) throw new PnMigrationError(\"INIT_FAILED\", result.failure.summary, result.failure.why);\n\t\t\treturn {\n\t\t\t\taction,\n\t\t\t\ttargetHash: ref.hash,\n\t\t\t\tmarkerHashBefore\n\t\t\t};\n\t\t}\n\t\tconst result = await client.migrate({\n\t\t\tcontract: contractJson,\n\t\t\tmigrationsDir,\n\t\t\t...refName !== void 0 ? {\n\t\t\t\trefHash: ref.hash,\n\t\t\t\trefInvariants: ref.invariants,\n\t\t\t\trefName\n\t\t\t} : {}\n\t\t});\n\t\tif (!result.ok) throw new PnMigrationError(result.failure.code === \"MIGRATION_PATH_NOT_FOUND\" ? \"MIGRATION_PATH_NOT_FOUND\" : \"RUNNER_FAILED\", result.failure.summary, result.failure.why);\n\t\treturn {\n\t\t\taction,\n\t\t\ttargetHash: ref.hash,\n\t\t\tmarkerHashBefore\n\t\t};\n\t} finally {\n\t\tawait client.close();\n\t}\n}\n//#endregion\n//#region src/pn-migration-resource.ts\n/**\n* The `PnMigration` Alchemy resource (ADR-0022) — the migration\n* step modeled as a tracked resource so it participates in deploy state: keyed\n* on the target REF identity (`targetHash` + sorted `invariants`), an\n* unchanged redeploy is an Alchemy-level no-op (on top of the marker read),\n* and a contract change — or a DATA-ONLY change that adds a ref invariant at\n* the same hash — re-runs the migration.\n*\n* Its provider's `reconcile` receives the RESOLVED props at apply-time — in\n* particular the concrete DB `url` (a lazy `Output` until the Connection\n* provisions) — and delegates to the proven `applyPnMigration` decision. The\n* provider is a standalone `Provider<PnMigration>` layer; the extension\n* descriptor merges it into its `providers()` (`Layer.merge(Prisma.providers(),\n* PnMigrationProvider())`), and Alchemy resolves it at apply via a direct\n* provider-tag lookup (`tryFindProviderByType`) — no change to `@internal/lowering`.\n*\n* Deploy-time only: imports `@prisma/orm-postgres/control` (via the helper) +\n* `alchemy`. Imported by `control.ts` and tests, never by `index.ts` / the\n* `./prisma-next` authoring entry — index isolation holds.\n*/\n/** The `PnMigration` resource constructor — `yield* PnMigration(id, props)` in the lowering. */\nconst PnMigration = Resource(\"PrismaNext.Migration\");\n/**\n* The `PnMigration` provider service. `reconcile` runs for both create and\n* update (Alchemy's unified lifecycle); `applyPnMigration` is idempotent via\n* the live marker read, so it is safe to run for either — the marker decides\n* no-op / init / migrate. A migration has nothing to enumerate (`list` → `[]`)\n* and nothing to tear down on its own (`delete` → no-op; the DB's own deletion\n* handles teardown). Exported so tests can drive `reconcile` directly, without\n* building an Effect layer.\n*/\nconst pnMigrationProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ news }) => Effect.tryPromise({\n\t\ttry: async () => {\n\t\t\tconst extensionPacks = news.packHeadRefHashes.length > 0 ? (await resolvePrismaNextConfig(news.configPath)).extensionPacks : [];\n\t\t\treturn applyPnMigration({\n\t\t\t\turl: news.url,\n\t\t\t\tcontractJson: news.contractJson,\n\t\t\t\tmigrationsDir: news.migrationsDir,\n\t\t\t\tref: {\n\t\t\t\t\thash: news.targetHash,\n\t\t\t\t\tinvariants: news.invariants\n\t\t\t\t},\n\t\t\t\textensionPacks,\n\t\t\t\t...news.refName !== void 0 ? { refName: news.refName } : {}\n\t\t\t});\n\t\t},\n\t\tcatch: (error) => error\n\t}).pipe(Effect.map((outcome) => ({\n\t\tstorageHash: outcome.targetHash,\n\t\tinvariants: news.invariants\n\t}))),\n\tdelete: () => Effect.void\n};\n/** The `PnMigration` provider layer — merged into the extension descriptor's `providers()`. */\nconst PnMigrationProvider = () => Provider.effect(PnMigration, Effect.succeed(pnMigrationProviderService));\n//#endregion\n//#region src/preflight-names.ts\nfunction dedupedNames(entries) {\n\tconst byName = /* @__PURE__ */ new Map();\n\tfor (const entry of entries) if (!byName.has(entry.name)) byName.set(entry.name, entry);\n\treturn [...byName.values()];\n}\n/** Every `envSecret` leaf of one input binding: its platform name, found by the same dumb recursive descent the serializer uses (ADR-0042). */\nfunction collectSecretLeafNames(binding, serviceAddress, out) {\n\tif (isGeneratedParamSource(binding)) return;\n\tif (isSecretSource(binding)) {\n\t\tout.push(secretName(binding, `an input-binding secret leaf of service \"${serviceAddress}\"`));\n\t\treturn;\n\t}\n\tif (typeof binding !== \"object\" || binding === null) return;\n\tconst members = Array.isArray(binding) ? binding : Object.values(binding);\n\tfor (const member of members) collectSecretLeafNames(member, serviceAddress, out);\n}\n/** Walks each service's input binding for `envSecret` leaves, and `graph.params` for env-sourced params (ADR-0042). */\nfunction collectPreflightNames(graph) {\n\tconst secretEntries = [];\n\tfor (const { serviceAddress, binding } of inputManifest(graph)) {\n\t\tconst leafNames = [];\n\t\tcollectSecretLeafNames(binding, serviceAddress, leafNames);\n\t\tfor (const name of leafNames) secretEntries.push({\n\t\t\tname,\n\t\t\tserviceAddress\n\t\t});\n\t}\n\tconst envParams = dedupedNames(paramManifest(graph).filter((binding) => isEnvParamSource(binding.binding)).map((binding) => ({\n\t\tname: paramName(binding),\n\t\tserviceAddress: binding.serviceAddress\n\t})));\n\treturn {\n\t\tsecrets: dedupedNames(secretEntries),\n\t\tenvParams\n\t};\n}\n//#endregion\n//#region src/s3-credentials-resource.ts\n/**\n* The `S3Credentials` Alchemy resource (S5) — mints a random SigV4 key pair\n* ONCE at create and keeps it STABLE across deploys, so an unchanged module\n* no-ops on redeploy. The pair is generated by `@internal/s3-protocol`'s\n* `mintKeyPair` (moved there per the local-dev spec § 1, so deploy and local\n* dev credential minting share one implementation) and persisted in Alchemy\n* state; on every later apply the provider returns the persisted attributes\n* (`reconcile`'s `output`) unchanged — the same way the postgres resource\n* keeps a Connection stable. Rotation is destroy/recreate (a platform ask,\n* not solved here).\n*\n* Deploy-time only: imports `alchemy`. Imported by `control.ts` and tests,\n* never by `index.ts` / the authoring entry.\n*/\n/** The `S3Credentials` resource constructor — `yield* S3Credentials(id, {})` in the lowering. */\nconst S3Credentials = Resource(\"PrismaCloud.S3Credentials\");\n/**\n* The `S3Credentials` provider service. `reconcile` runs for create and update;\n* it returns the persisted `output` when present (a redeploy reuses the stored\n* pair — the no-op property) and mints a fresh pair only on first create.\n* Nothing to enumerate (`list` → `[]`) or tear down (`delete` → no-op; the pair\n* lives only in state). Exported so tests can drive it directly.\n*/\nconst s3CredentialsProviderService = {\n\tlist: () => Effect.succeed([]),\n\treconcile: ({ output }) => Effect.sync(() => output ?? mintKeyPair()),\n\tdelete: () => Effect.void\n};\n/** The `S3Credentials` provider layer — merged into the extension descriptor's `providers()`. */\nconst S3CredentialsProvider = () => Provider.effect(S3Credentials, Effect.succeed(s3CredentialsProviderService));\n//#endregion\nexport { prismaCloudContainerOf as _, PnMigrationProvider as a, resolvePrismaNextConfig as c, GeneratedParam as d, GeneratedParamProvider as f, deserialize as g, containerDescriptor as h, PnMigration as i, PgWarm as l, PrismaCloudContainer as m, S3CredentialsProvider as n, resolveTargetRef as o, PRISMA_CLOUD_EXTENSION_ID as p, collectPreflightNames as r, packHeadRefHashes as s, S3Credentials as t, PgWarmProvider as u };\n\n//# sourceMappingURL=s3-credentials-resource-vElUxfYi.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAI,oBAAoB,cAAc,QAAQ,QAAQ,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;;AAE9E,MAAM,gBAAgB,MAAM,OAAO,mBAAmB,OAAO,IAAI,aAAa;CAC7E,OAAO,EAAE,OAAO,OAAOA,SAAO,SAAS,sBAAsB,EAAE;AAChE,CAAC,CAAC;;AAIF,MAAM,wBAAwB;;;;;;AAM9B,IAAI,mBAAmB,cAAc,QAAQ,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAClF,MAAM,SAAS,YAAY,MAAM,OAAO,kBAAkB,OAAO,IAAI,aAAa;CACjF,MAAM,EAAE,UAAU,OAAO;CACzB,OAAO,0BAA0B;EAChC,OAAO,SAAS,MAAM,KAAK;EAC3B,SAAS,SAAS,aAAa;CAChC,CAAC;AACF,CAAC,CAAC;;;;AC5BF,IAAI,iBAAiB,cAAc,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC;AACvE,MAAM,WAAW,MAAM,OAAO,WAAW;CACxC,KAAK;CACL,Q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