@prisma/composer-cli 0.39.0-dev.7 → 0.39.0-dev.9
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/app-converge-C6Zrg2xM-DX-tW6C3.mjs +88 -0
- package/dist/app-converge-C6Zrg2xM-DX-tW6C3.mjs.map +1 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
- package/dist/{validate-environment-XwVDifWN-BdYUHyVF.mjs → deploy-Br1yvLe3.mjs} +204 -1010
- package/dist/deploy-Br1yvLe3.mjs.map +1 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +143 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-gQnmjB4V-DrQ4Zzbl.mjs → dev-current-EqQbrtj5-DieSnSVx.mjs} +12 -18
- package/dist/dev-current-EqQbrtj5-DieSnSVx.mjs.map +1 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
- package/dist/{dist-CRSv_9L8.mjs → dist-C0OGaDnj.mjs} +4 -3
- package/dist/{dist-CRSv_9L8.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
- package/dist/errors-CVYwN2km.mjs +93 -0
- package/dist/errors-CVYwN2km.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-DKbsBkqK-D8pniqZg.mjs → execute-deploy-destroy-DKEmb8WI-DcgNdw4b.mjs} +245 -244
- package/dist/execute-deploy-destroy-DKEmb8WI-DcgNdw4b.mjs.map +1 -0
- package/dist/{execute-dev-DVCWURmI-D91UZq1o.mjs → execute-dev-C42niIFY-Dh_7dJ5W.mjs} +422 -166
- package/dist/execute-dev-C42niIFY-Dh_7dJ5W.mjs.map +1 -0
- package/dist/{execute-dev-current-Dt_9srY2-D8mAcSv4.mjs → execute-dev-current-AVT4zQ8F--qMLJobM.mjs} +9 -6
- package/dist/{execute-dev-current-Dt_9srY2-D8mAcSv4.mjs.map → execute-dev-current-AVT4zQ8F--qMLJobM.mjs.map} +1 -1
- package/dist/{family-D52hWFMF-FfSJ5SN2.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +171 -69
- package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
- package/dist/family.d.mts +1 -1
- package/dist/family.mjs +87 -137
- package/dist/family.mjs.map +1 -1
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
- package/dist/{list-deployed-CIaiiV_l.mjs → list-deployed-C1cwFHrb.mjs} +5 -4
- package/dist/{list-deployed-CIaiiV_l.mjs.map → list-deployed-C1cwFHrb.mjs.map} +1 -1
- package/dist/local-target-CZzICh5R.mjs +34 -0
- package/dist/local-target-CZzICh5R.mjs.map +1 -0
- package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs +56 -0
- package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
- package/dist/{redaction-CjMYXtGp-CYefSG9A.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +17 -256
- package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
- package/dist/result-CttmabB6.mjs +91 -0
- package/dist/result-CttmabB6.mjs.map +1 -0
- package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
- package/dist/testing.d.mts +2 -42
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +2 -5
- package/dist/testing.mjs.map +1 -1
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
- package/package.json +7 -7
- package/src/exports/dev-converge-worker.ts +2 -0
- package/src/exports/testing.ts +1 -4
- package/dist/app-configuration-file-Bbfq5PR3-CYdGtitc.mjs +0 -137
- package/dist/app-configuration-file-Bbfq5PR3-CYdGtitc.mjs.map +0 -1
- package/dist/dev-current-gQnmjB4V-DrQ4Zzbl.mjs.map +0 -1
- package/dist/dev-environment-name-6eEr5PW8-kDiScOL8.mjs +0 -71
- package/dist/dev-environment-name-6eEr5PW8-kDiScOL8.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DKbsBkqK-D8pniqZg.mjs.map +0 -1
- package/dist/execute-dev-DVCWURmI-D91UZq1o.mjs.map +0 -1
- package/dist/family-D52hWFMF-FfSJ5SN2.d.mts.map +0 -1
- package/dist/generate-dev-stack-BEpqJ3AH-B7o7JyER.mjs +0 -100
- package/dist/generate-dev-stack-BEpqJ3AH-B7o7JyER.mjs.map +0 -1
- package/dist/redaction-CjMYXtGp-CYefSG9A.mjs.map +0 -1
- package/dist/result-DlBttLS8.mjs +0 -234
- package/dist/result-DlBttLS8.mjs.map +0 -1
- package/dist/run-alchemy-BlYyc4Oh-BnFv0AaY.mjs +0 -302
- package/dist/run-alchemy-BlYyc4Oh-BnFv0AaY.mjs.map +0 -1
- package/dist/validate-environment-XwVDifWN-BdYUHyVF.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-deployed-CIaiiV_l.mjs","names":[],"sources":["../../../1-prisma-cloud/0-lowering/lowering/dist/credentials-B2pml7IQ.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/container-DWciLGTN.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/deployed.mjs","../src/family/deployed-nodes.ts","../src/family/list-deployed.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as Config from \"effect/Config\";\n//#region package.json\nvar version = \"0.39.0-dev.7\";\n//#endregion\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()(\"PrismaComposerCredentials\") {};\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}));\nconst DEFAULT_BASE_URL = \"https://api.prisma.io\";\nconst isLoopbackHost = (hostname) => hostname === \"localhost\" || hostname.endsWith(\".localhost\") || hostname === \"127.0.0.1\" || hostname === \"[::1]\";\n/** Same validation as upstream alchemy's `PrismaEnvironment`: an HTTP(S) origin, HTTPS unless loopback, no credentials, no path/query/fragment. */\nconst normalizedOrigin = (value) => {\n\tconst url = new URL(value);\n\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") throw new Error(\"Prisma Management API URL must use HTTP or HTTPS.\");\n\tif (url.username.length > 0 || url.password.length > 0) throw new Error(\"Prisma Management API URL must not contain credentials.\");\n\tif (url.protocol === \"http:\" && !isLoopbackHost(url.hostname)) throw new Error(\"Prisma Management API URL must use HTTPS unless it targets a loopback host.\");\n\tif (url.pathname !== \"/\" && url.pathname !== \"\" || url.search.length > 0 || url.hash.length > 0) throw new Error(\"Prisma Management API URL must be an origin without a path, query, or fragment.\");\n\treturn url.origin;\n};\nconst normalizeBaseUrl = (value) => Effect.try({\n\ttry: () => normalizedOrigin(value),\n\tcatch: (cause) => cause instanceof Error ? cause : /* @__PURE__ */ new Error(`Invalid Prisma Management API URL: ${String(cause)}`)\n});\n/**\n* Headers the Management API records in its deploy analytics: which tool sent\n* the request, and whether it ran in GitHub Actions. The API behaves the same\n* without them.\n*/\nconst deploySourceHeaders = () => ({\n\t\"x-prisma-deploy-source\": process.env[\"GITHUB_ACTIONS\"] === \"true\" ? \"github-action\" : \"composer\",\n\t\"x-prisma-client-name\": \"composer\",\n\t\"x-prisma-client-version\": version\n});\n/**\n* The origin of a client built from `PRISMA_SERVICE_TOKEN`: `PRISMA_API_URL`, then\n* `PRISMA_MANAGEMENT_API_URL`, then the public origin, normalized and validated\n* as upstream alchemy's `PrismaEnvironment` does, so Composer's client and\n* upstream's providers always address the same host.\n*/\nconst tokenClientOrigin = (env) => env !== void 0 ? normalizeBaseUrl(env[\"PRISMA_API_URL\"] || env[\"PRISMA_MANAGEMENT_API_URL\"] || DEFAULT_BASE_URL) : Config.String(\"PRISMA_API_URL\").pipe(Config.orElse(() => Config.String(\"PRISMA_MANAGEMENT_API_URL\")), Config.withDefault(DEFAULT_BASE_URL), Effect.flatMap(normalizeBaseUrl));\n/**\n* The origin a supplied client sends to. The `prisma` CLI builds `ctx.api` on\n* `PRISMA_MANAGEMENT_API_URL` alone, trimmed, or the public origin (prisma-cli\n* `getApiBaseUrl`), so Management API requests are recognised by that origin.\n* `PRISMA_API_URL` cannot move a supplied client, so when it names another\n* origin this throws `DEPLOY.MANAGEMENT_API_URL_CONFLICT` instead of ignoring it.\n*/\nconst suppliedClientOrigin = (env) => {\n\tconst engineValue = env[\"PRISMA_MANAGEMENT_API_URL\"]?.trim() || DEFAULT_BASE_URL;\n\tconst origin = normalizedOrigin(engineValue);\n\tconst composerValue = env[\"PRISMA_API_URL\"];\n\tif (composerValue && normalizedOrigin(composerValue) !== origin) throw new CliStructuredError(\"DEPLOY.MANAGEMENT_API_URL_CONFLICT\", `PRISMA_API_URL is ${composerValue}, but the deploy's Management API client sends to ${engineValue}.`, {\n\t\twhy: \"The deploy sends every Management API request through the client it was given. For `prisma deploy` that is the `prisma` CLI's client, which reads PRISMA_MANAGEMENT_API_URL (default https://api.prisma.io) and ignores PRISMA_API_URL.\",\n\t\tfix: \"Set PRISMA_MANAGEMENT_API_URL to the host you want, and unset PRISMA_API_URL.\"\n\t});\n\treturn origin;\n};\n//#endregion\nexport { tokenClientOrigin as a, suppliedClientOrigin as i, deploySourceHeaders as n, fromEnv as r, PrismaCredentials as t };\n\n//# sourceMappingURL=credentials-B2pml7IQ.mjs.map","import { a as tokenClientOrigin, n as deploySourceHeaders, r as fromEnv, t as PrismaCredentials } from \"./credentials-B2pml7IQ.mjs\";\nimport { 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 Data from \"effect/Data\";\n//#region src/client.ts\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\") {};\n/**\n* A client built from the resolved token, on `apiOrigin`, or on\n* `tokenClientOrigin()` when none is given.\n*/\nconst layer = (options) => Layer.effect(ManagementClient, Effect.gen(function* () {\n\tconst { token } = yield* PrismaCredentials;\n\tconst baseUrl = options?.apiOrigin ?? (yield* tokenClientOrigin());\n\treturn createManagementApiClient({\n\t\ttoken: Redacted.value(token),\n\t\tbaseUrl,\n\t\theaders: deploySourceHeaders()\n\t});\n}));\n/** The caller's already-authenticated client, or one built from `PRISMA_SERVICE_TOKEN` on `apiOrigin` when the caller supplies none. */\nconst suppliedOrFromEnv = (supplied, apiOrigin) => supplied === void 0 ? layer({ apiOrigin }).pipe(Layer.provide(fromEnv())) : Layer.succeed(ManagementClient, supplied);\n//#endregion\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/**\n* Fire a CREATE call, tolerating a 409 (it already exists). Gives the caller\n* create-only semantics: the thing is created when absent, and an existing one\n* — whoever created it — is left exactly as it is.\n*/\nconst callCreateOnly = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 409 || r.error === void 0 ? Effect.void : fail(r)));\n//#endregion\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 environment's Branch) doesn't exist. */\nvar ContainerNotFoundError = class extends Data.TaggedError(\"ContainerNotFoundError\") {};\n/** The environment that maps to the Project's default Branch. */\nconst PRODUCTION_ENVIRONMENT = \"production\";\n/** Whether `environment` maps to the Project's default Branch rather than a Branch of its own. */\nfunction isProductionEnvironment(environment) {\n\treturn environment === PRODUCTION_ENVIRONMENT;\n}\n/** Raised when a name other than `production` resolves to the Project's default Branch, which would make it production under a second name. */\nvar DefaultBranchUnderAnotherNameError = class extends Data.TaggedError(\"DefaultBranchUnderAnotherNameError\") {\n\tget message() {\n\t\treturn `The environment \"${this.environment}\" names the Branch ${this.branchId}, which is this Project's default Branch, so that Branch is production. Use the environment ${PRODUCTION_ENVIRONMENT} for it, and another name for a separate environment.`;\n\t}\n};\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, region) => 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\tif (region === void 0) return yield* Effect.fail(new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: `project \"${appName}\" does not exist yet and no deploy region is configured. Set the region via prismaCloud({ region: '<id>' }) in your config, or set the PRISMA_REGION environment variable`\n\t}));\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\tregion\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 findBranch = (client, projectId, gitName) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\tpath: { projectId },\n\tquery: { gitName }\n} })).pipe(Effect.map((page) => {\n\tconst branch = page.data[0];\n\treturn branch === void 0 ? void 0 : {\n\t\tid: branch.id,\n\t\tisDefault: branch.isDefault\n\t};\n}));\n/**\n* Finds the environment'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`. A `gitName` that finds\n* the default Branch fails with `DefaultBranchUnderAnotherNameError`. 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* findBranch(client, projectId, gitName);\n\tif (existing !== void 0) return yield* refuseDefaultBranch(existing, gitName);\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({\n\t\tappName,\n\t\tenvironment: 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 ? Effect.gen(function* () {\n\t\tconst found = yield* findBranch(client, projectId, gitName);\n\t\tif (found === void 0) return yield* Effect.fail(err);\n\t\treturn yield* refuseDefaultBranch(found, gitName);\n\t}) : Effect.fail(err)));\n});\nconst refuseDefaultBranch = (branch, gitName) => branch.isDefault === true ? Effect.fail(new DefaultBranchUnderAnotherNameError({\n\tenvironment: gitName,\n\tbranchId: branch.id\n})) : Effect.succeed(branch.id);\n/**\n* Resolves the two containers an environment's deploy runs into (ADR-0019):\n* the app's **Project**, found-or-created by name, and its **Branch**. The\n* environment `production` is the Project's default Branch, read into\n* `defaultBranchId` and never created; `branchId` is omitted. Any other name\n* is the Branch with that `gitName`, found-or-created into `branchId`. With\n* `ensure: false` (`destroy`), nothing is created — an absent Project or\n* Branch 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, opts.region);\n\tif (isProductionEnvironment(opts.environment)) 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.environment, 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 environment'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 { layer as _, deleteProject as a, resolveDefaultBranchId as c, drivePagesAsync as d, PrismaApiError as f, ManagementClient as g, callOptional as h, deleteBranch as i, collectPages as l, callCreateOnly as m, DefaultBranchUnderAnotherNameError as n, isProductionEnvironment as o, call as p, PRODUCTION_ENVIRONMENT as r, resolveContainer as s, ContainerNotFoundError as t, drivePages as u, suppliedOrFromEnv as v };\n\n//# sourceMappingURL=container-DWciLGTN.mjs.map","import { g as ManagementClient, h as callOptional, l as collectPages, p as call, s as resolveContainer } from \"./container-DWciLGTN.mjs\";\nimport * as Effect from \"effect/Effect\";\n//#region src/deployed.ts\nconst program = (input) => Effect.gen(function* () {\n\tconst container = yield* resolveContainer({\n\t\tworkspaceId: input.workspaceId,\n\t\tappName: input.appName,\n\t\tensure: false,\n\t\tenvironment: input.environment\n\t});\n\tconst { projectId } = container;\n\tconst branchId = container.branchId ?? container.defaultBranchId;\n\tif (branchId === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`project ${projectId} resolved no Branch`));\n\tconst client = yield* ManagementClient;\n\tconst topology = yield* callOptional(() => client.GET(\"/v1/projects/{projectId}/branches/{branchId}/application-topology\", { params: { path: {\n\t\tprojectId,\n\t\tbranchId\n\t} } }));\n\tif (topology === void 0 || topology.data.nodes.length === 0) return {\n\t\tprojectId,\n\t\tbranchId,\n\t\tnodes: [],\n\t\tservices: [],\n\t\tdatabases: [],\n\t\tbuckets: []\n\t};\n\tconst query = (cursor) => cursor === void 0 ? {\n\t\tprojectId,\n\t\tbranchId\n\t} : {\n\t\tprojectId,\n\t\tbranchId,\n\t\tcursor\n\t};\n\tconst services = yield* collectPages(`services of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/services\", { params: { query: query(cursor) } })));\n\tconst databases = yield* collectPages(`databases of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/databases\", { params: { query: query(cursor) } })));\n\tconst buckets = yield* collectPages(`buckets of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/buckets\", { params: { query: query(cursor) } })));\n\treturn {\n\t\tprojectId,\n\t\tbranchId,\n\t\tnodes: topology.data.nodes.map(({ logicalId, parentLogicalId, kind, type }) => ({\n\t\t\tlogicalId,\n\t\t\tparentLogicalId,\n\t\t\tkind,\n\t\t\t...type === void 0 ? {} : { type }\n\t\t})),\n\t\tservices: services.map(({ id, logicalId, appEndpointDomain }) => ({\n\t\t\tid,\n\t\t\tlogicalId,\n\t\t\tappEndpointDomain\n\t\t})),\n\t\tdatabases: databases.map(({ id, logicalId }) => ({\n\t\t\tid,\n\t\t\tlogicalId\n\t\t})),\n\t\tbuckets: buckets.map(({ id, logicalId }) => ({\n\t\t\tid,\n\t\t\tlogicalId\n\t\t}))\n\t};\n});\n/**\n* Reads what an environment has deployed: its Project and Branch by the same\n* find-only lookup `destroy` uses, the application topology the last deploy\n* wrote, and the Branch's services, databases and buckets. `undefined` when\n* there is no Project or no Branch. Rejects on any other Management API\n* failure.\n*/\nasync function readDeployedEnvironment(client, input) {\n\treturn Effect.runPromise(program(input).pipe(Effect.catchTag(\"ContainerNotFoundError\", () => Effect.succeed(void 0)), Effect.catchTag(\"DefaultBranchUnderAnotherNameError\", (error) => Effect.fail(new Error(error.message))), Effect.catchTag(\"PrismaApiError\", (error) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error: ${error.message}.`))), Effect.provideService(ManagementClient, client)));\n}\n//#endregion\n//#region src/resource-rows.ts\n/** The platform row each Prisma Cloud resource type deploys to. A type missing here, such as an S3 credentials resource, has no row. */\nconst RESOURCE_ROW_KINDS = /* @__PURE__ */ new Map([\n\t[\"postgres\", \"database\"],\n\t[\"raw-postgres\", \"database\"],\n\t[\"s3\", \"bucket\"]\n]);\n//#endregion\nexport { RESOURCE_ROW_KINDS, readDeployedEnvironment };\n\n//# sourceMappingURL=deployed.mjs.map","import { type DeployedEnvironment, RESOURCE_ROW_KINDS } from '@internal/lowering/deployed';\n\n/** One row of `deploy list`: a topology node and the platform row it deployed to. */\nexport interface DeployedNode {\n readonly address: string;\n readonly kind: string;\n readonly platformId: string | null;\n readonly url: string | null;\n}\n\ntype TopologyNode = DeployedEnvironment['nodes'][number];\n\nfunction kindOf(node: TopologyNode): string {\n if (node.parentLogicalId === null) return 'project';\n if (node.kind === 'resource') {\n if (node.type === undefined) return 'resource';\n const rowKind = RESOURCE_ROW_KINDS.get(node.type);\n if (rowKind === 'database') return 'postgres';\n return rowKind ?? node.type;\n }\n return node.kind;\n}\n\nfunction rowId(rows: readonly { id: string; logicalId: string | null }[], logicalId: string) {\n return rows.find((row) => row.logicalId === logicalId)?.id ?? null;\n}\n\nfunction deployedNode(deployed: DeployedEnvironment, node: TopologyNode): DeployedNode {\n const kind = kindOf(node);\n const address = node.logicalId;\n switch (kind) {\n case 'project':\n return { address, kind, platformId: deployed.projectId, url: null };\n case 'service': {\n const row = deployed.services.find((service) => service.logicalId === address);\n return {\n address,\n kind,\n platformId: row?.id ?? null,\n url: row?.appEndpointDomain ?? null,\n };\n }\n case 'postgres':\n return { address, kind, platformId: rowId(deployed.databases, address), url: null };\n case 'bucket':\n return { address, kind, platformId: rowId(deployed.buckets, address), url: null };\n default:\n return { address, kind, platformId: null, url: null };\n }\n}\n\n/** Every node of the environment's topology, in topology order, joined by `logicalId` to the platform row it deployed to. The root's row is the Project. */\nexport function deployedNodes(deployed: DeployedEnvironment): DeployedNode[] {\n return deployed.nodes.map((node) => deployedNode(deployed, node));\n}\n","import { resolveAppIdentity, validateEnvironmentName } from '@internal/cli/app-identity';\nimport type { ComposerConfigSource } from '@internal/cli/control';\nimport { CliStructuredError } from '@internal/foundation/errors';\nimport { notOk, ok, type Result } from '@internal/foundation/result';\nimport { readDeployedEnvironment } from '@internal/lowering/deployed';\nimport type { ManagementApiClient } from '@prisma/cli-engine';\nimport { type DeployedNode, deployedNodes } from './deployed-nodes.ts';\n\nexport interface ListDeployedInput {\n readonly config: ComposerConfigSource;\n readonly entry: string | undefined;\n readonly name: string | undefined;\n readonly environment: string;\n readonly cwd: string;\n readonly workspaceId: string | undefined;\n readonly client: ManagementApiClient;\n}\n\nfunction notFound(app: string, environment: string): CliStructuredError {\n return new CliStructuredError(\n 'DEPLOY.TARGET_NOT_FOUND',\n `Nothing deployed for ${app} in the environment ${environment}.`,\n { fix: 'Deploy it first.' },\n );\n}\n\nfunction lookupFailed(error: unknown): CliStructuredError {\n return new CliStructuredError(\n 'DEPLOY.CONTAINER_FAILED',\n error instanceof Error ? error.message : String(error),\n { cause: error },\n );\n}\n\n/** Every node the app has deployed in the environment, or `DEPLOY.TARGET_NOT_FOUND` when the environment has no Project, Branch or topology. */\nexport async function listDeployed(\n input: ListDeployedInput,\n): Promise<Result<readonly DeployedNode[], CliStructuredError>> {\n let app: string;\n try {\n validateEnvironmentName(input.environment);\n app = (await resolveAppIdentity(input.entry, input.name, input.cwd, input.config)).name;\n } catch (error) {\n if (CliStructuredError.is(error)) return notOk(error);\n throw error;\n }\n if (input.workspaceId === undefined) {\n return notOk(lookupFailed(new Error('environment variable PRISMA_WORKSPACE_ID is required.')));\n }\n\n let deployed: Awaited<ReturnType<typeof readDeployedEnvironment>>;\n try {\n deployed = await readDeployedEnvironment(input.client, {\n workspaceId: input.workspaceId,\n appName: app,\n environment: input.environment,\n });\n } catch (error) {\n return notOk(lookupFailed(error));\n }\n const nodes = deployed === undefined ? [] : deployedNodes(deployed);\n if (nodes.length === 0) return notOk(notFound(app, input.environment));\n return ok(nodes);\n}\n"],"mappings":";;;;;;;;;AAasC,QAAQ,QAAQ,CAAC,CAAC,2BAA2B;;;;;;;;ACAnF,IAAI,mBAAmB,cAAc,QAAQ,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;;AAmBlF,IAAI,iBAAiB,cAAc,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC;AACvE,MAAM,WAAW,MAAM,OAAO,WAAW;CACxC,KAAK;CACL,QAAQ,UAAU,IAAI,eAAe;EACpC,QAAQ;EACR,SAAS,OAAO,KAAK;CACtB,CAAC;AACF,CAAC;AACD,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,eAAe;CAClD,QAAQ,EAAE,SAAS;CACnB,SAAS,KAAK,UAAU,EAAE,KAAK;AAChC,CAAC,CAAC;;AAEF,MAAM,QAAQ,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,EAAE,UAAU,KAAK,KAAK,EAAE,SAAS,KAAK,IAAI,KAAK,CAAC,IAAI,OAAO,QAAQ,EAAE,IAAI,CAAC,CAAC;;AAErI,MAAM,gBAAgB,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,EAAE,SAAS,WAAW,MAAM,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,KAAK,CAAC,IAAI,OAAO,QAAQ,EAAE,IAAI,CAAC,CAAC;;AAY7K,MAAM,YAAY;AAClB,MAAM,yBAAyB,aAAa,WAAW,IAAI,eAAe;CACzE,QAAQ;CACR,SAAS,WAAW,YAAY,GAAG,OAAO;AAC3C,CAAC;;AA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;AACF;;AAGA,SAAgB,cAAc,UAA+C;CAC3E,OAAO,SAAS,MAAM,KAAK,SAAS,aAAa,UAAU,IAAI,CAAC;AAClE;;;ACpCA,SAAS,SAAS,KAAa,aAAyC;CACtE,OAAO,IAAI,mBACT,2BACA,wBAAwB,IAAI,sBAAsB,YAAY,IAC9D,EAAE,KAAK,mBAAmB,CAC5B;AACF;AAEA,SAAS,aAAa,OAAoC;CACxD,OAAO,IAAI,mBACT,2BACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACrD,EAAE,OAAO,MAAM,CACjB;AACF;;AAGA,eAAsB,aACpB,OAC8D;CAC9D,IAAI;CACJ,IAAI;EACF,wBAAwB,MAAM,WAAW;EACzC,OAAO,MAAM,mBAAmB,MAAM,OAAO,MAAM,MAAM,MAAM,KAAK,MAAM,MAAM,EAAA,CAAG;CACrF,SAAS,OAAO;EACd,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACR;CACA,IAAI,MAAM,gBAAgB,KAAA,GACxB,OAAO,MAAM,6BAAa,IAAI,MAAM,uDAAuD,CAAC,CAAC;CAG/F,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,wBAAwB,MAAM,QAAQ;GACrD,aAAa,MAAM;GACnB,SAAS;GACT,aAAa,MAAM;EACrB,CAAC;CACH,SAAS,OAAO;EACd,OAAO,MAAM,aAAa,KAAK,CAAC;CAClC;CACA,MAAM,QAAQ,aAAa,KAAA,IAAY,CAAC,IAAI,cAAc,QAAQ;CAClE,IAAI,MAAM,WAAW,GAAG,OAAO,MAAM,SAAS,KAAK,MAAM,WAAW,CAAC;CACrE,OAAO,GAAG,KAAK;AACjB"}
|
|
1
|
+
{"version":3,"file":"list-deployed-C1cwFHrb.mjs","names":[],"sources":["../../../1-prisma-cloud/0-lowering/lowering/dist/credentials-DeHa0vM0.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/container-jSDTfwAi.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/deployed.mjs","../src/family/deployed-nodes.ts","../src/family/list-deployed.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as Config from \"effect/Config\";\n//#region package.json\nvar version = \"0.39.0-dev.9\";\n//#endregion\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()(\"PrismaComposerCredentials\") {};\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}));\nconst DEFAULT_BASE_URL = \"https://api.prisma.io\";\nconst isLoopbackHost = (hostname) => hostname === \"localhost\" || hostname.endsWith(\".localhost\") || hostname === \"127.0.0.1\" || hostname === \"[::1]\";\n/** Same validation as upstream alchemy's `PrismaEnvironment`: an HTTP(S) origin, HTTPS unless loopback, no credentials, no path/query/fragment. */\nconst normalizedOrigin = (value) => {\n\tconst url = new URL(value);\n\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") throw new Error(\"Prisma Management API URL must use HTTP or HTTPS.\");\n\tif (url.username.length > 0 || url.password.length > 0) throw new Error(\"Prisma Management API URL must not contain credentials.\");\n\tif (url.protocol === \"http:\" && !isLoopbackHost(url.hostname)) throw new Error(\"Prisma Management API URL must use HTTPS unless it targets a loopback host.\");\n\tif (url.pathname !== \"/\" && url.pathname !== \"\" || url.search.length > 0 || url.hash.length > 0) throw new Error(\"Prisma Management API URL must be an origin without a path, query, or fragment.\");\n\treturn url.origin;\n};\nconst normalizeBaseUrl = (value) => Effect.try({\n\ttry: () => normalizedOrigin(value),\n\tcatch: (cause) => cause instanceof Error ? cause : /* @__PURE__ */ new Error(`Invalid Prisma Management API URL: ${String(cause)}`)\n});\n/**\n* Headers the Management API records in its deploy analytics: which tool sent\n* the request, and whether it ran in GitHub Actions. The API behaves the same\n* without them.\n*/\nconst deploySourceHeaders = () => ({\n\t\"x-prisma-deploy-source\": process.env[\"GITHUB_ACTIONS\"] === \"true\" ? \"github-action\" : \"composer\",\n\t\"x-prisma-client-name\": \"composer\",\n\t\"x-prisma-client-version\": version\n});\n/**\n* The origin of a client built from `PRISMA_SERVICE_TOKEN`: `PRISMA_API_URL`, then\n* `PRISMA_MANAGEMENT_API_URL`, then the public origin, normalized and validated\n* as upstream alchemy's `PrismaEnvironment` does, so Composer's client and\n* upstream's providers always address the same host.\n*/\nconst tokenClientOrigin = (env) => env !== void 0 ? normalizeBaseUrl(env[\"PRISMA_API_URL\"] || env[\"PRISMA_MANAGEMENT_API_URL\"] || DEFAULT_BASE_URL) : Config.String(\"PRISMA_API_URL\").pipe(Config.orElse(() => Config.String(\"PRISMA_MANAGEMENT_API_URL\")), Config.withDefault(DEFAULT_BASE_URL), Effect.flatMap(normalizeBaseUrl));\n/**\n* The origin a supplied client sends to. The `prisma` CLI builds `ctx.api` on\n* `PRISMA_MANAGEMENT_API_URL` alone, trimmed, or the public origin (prisma-cli\n* `getApiBaseUrl`), so Management API requests are recognised by that origin.\n* `PRISMA_API_URL` cannot move a supplied client, so when it names another\n* origin this throws `DEPLOY.MANAGEMENT_API_URL_CONFLICT` instead of ignoring it.\n*/\nconst suppliedClientOrigin = (env) => {\n\tconst engineValue = env[\"PRISMA_MANAGEMENT_API_URL\"]?.trim() || DEFAULT_BASE_URL;\n\tconst origin = normalizedOrigin(engineValue);\n\tconst composerValue = env[\"PRISMA_API_URL\"];\n\tif (composerValue && normalizedOrigin(composerValue) !== origin) throw new CliStructuredError(\"DEPLOY.MANAGEMENT_API_URL_CONFLICT\", `PRISMA_API_URL is ${composerValue}, but the deploy's Management API client sends to ${engineValue}.`, {\n\t\twhy: \"The deploy sends every Management API request through the client it was given. For `prisma deploy` that is the `prisma` CLI's client, which reads PRISMA_MANAGEMENT_API_URL (default https://api.prisma.io) and ignores PRISMA_API_URL.\",\n\t\tfix: \"Set PRISMA_MANAGEMENT_API_URL to the host you want, and unset PRISMA_API_URL.\"\n\t});\n\treturn origin;\n};\n//#endregion\nexport { tokenClientOrigin as a, suppliedClientOrigin as i, deploySourceHeaders as n, fromEnv as r, PrismaCredentials as t };\n\n//# sourceMappingURL=credentials-DeHa0vM0.mjs.map","import { a as tokenClientOrigin, n as deploySourceHeaders, r as fromEnv, t as PrismaCredentials } from \"./credentials-DeHa0vM0.mjs\";\nimport { 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 Data from \"effect/Data\";\n//#region src/client.ts\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\") {};\n/**\n* A client built from the resolved token, on `apiOrigin`, or on\n* `tokenClientOrigin()` when none is given.\n*/\nconst layer = (options) => Layer.effect(ManagementClient, Effect.gen(function* () {\n\tconst { token } = yield* PrismaCredentials;\n\tconst baseUrl = options?.apiOrigin ?? (yield* tokenClientOrigin());\n\treturn createManagementApiClient({\n\t\ttoken: Redacted.value(token),\n\t\tbaseUrl,\n\t\theaders: deploySourceHeaders()\n\t});\n}));\n/** The caller's already-authenticated client, or one built from `PRISMA_SERVICE_TOKEN` on `apiOrigin` when the caller supplies none. */\nconst suppliedOrFromEnv = (supplied, apiOrigin) => supplied === void 0 ? layer({ apiOrigin }).pipe(Layer.provide(fromEnv())) : Layer.succeed(ManagementClient, supplied);\n//#endregion\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/**\n* Fire a CREATE call, tolerating a 409 (it already exists). Gives the caller\n* create-only semantics: the thing is created when absent, and an existing one\n* — whoever created it — is left exactly as it is.\n*/\nconst callCreateOnly = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 409 || r.error === void 0 ? Effect.void : fail(r)));\n//#endregion\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 environment's Branch) doesn't exist. */\nvar ContainerNotFoundError = class extends Data.TaggedError(\"ContainerNotFoundError\") {};\n/** The environment that maps to the Project's default Branch. */\nconst PRODUCTION_ENVIRONMENT = \"production\";\n/** Whether `environment` maps to the Project's default Branch rather than a Branch of its own. */\nfunction isProductionEnvironment(environment) {\n\treturn environment === PRODUCTION_ENVIRONMENT;\n}\n/** Raised when a name other than `production` resolves to the Project's default Branch, which would make it production under a second name. */\nvar DefaultBranchUnderAnotherNameError = class extends Data.TaggedError(\"DefaultBranchUnderAnotherNameError\") {\n\tget message() {\n\t\treturn `The environment \"${this.environment}\" names the Branch ${this.branchId}, which is this Project's default Branch, so that Branch is production. Use the environment ${PRODUCTION_ENVIRONMENT} for it, and another name for a separate environment.`;\n\t}\n};\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, region) => 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\tif (region === void 0) return yield* Effect.fail(new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: `project \"${appName}\" does not exist yet and no deploy region is configured. Set the region via prismaCloud({ region: '<id>' }) in your config, or set the PRISMA_REGION environment variable`\n\t}));\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\tregion\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 findBranch = (client, projectId, gitName) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\tpath: { projectId },\n\tquery: { gitName }\n} })).pipe(Effect.map((page) => {\n\tconst branch = page.data[0];\n\treturn branch === void 0 ? void 0 : {\n\t\tid: branch.id,\n\t\tisDefault: branch.isDefault\n\t};\n}));\n/**\n* Finds the environment'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`. A `gitName` that finds\n* the default Branch fails with `DefaultBranchUnderAnotherNameError`. 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* findBranch(client, projectId, gitName);\n\tif (existing !== void 0) return yield* refuseDefaultBranch(existing, gitName);\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({\n\t\tappName,\n\t\tenvironment: 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 ? Effect.gen(function* () {\n\t\tconst found = yield* findBranch(client, projectId, gitName);\n\t\tif (found === void 0) return yield* Effect.fail(err);\n\t\treturn yield* refuseDefaultBranch(found, gitName);\n\t}) : Effect.fail(err)));\n});\nconst refuseDefaultBranch = (branch, gitName) => branch.isDefault === true ? Effect.fail(new DefaultBranchUnderAnotherNameError({\n\tenvironment: gitName,\n\tbranchId: branch.id\n})) : Effect.succeed(branch.id);\n/**\n* Resolves the two containers an environment's deploy runs into (ADR-0019):\n* the app's **Project**, found-or-created by name, and its **Branch**. The\n* environment `production` is the Project's default Branch, read into\n* `defaultBranchId` and never created; `branchId` is omitted. Any other name\n* is the Branch with that `gitName`, found-or-created into `branchId`. With\n* `ensure: false` (`destroy`), nothing is created — an absent Project or\n* Branch 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, opts.region);\n\tif (isProductionEnvironment(opts.environment)) 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.environment, 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 environment'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 { layer as _, deleteProject as a, resolveDefaultBranchId as c, drivePagesAsync as d, PrismaApiError as f, ManagementClient as g, callOptional as h, deleteBranch as i, collectPages as l, callCreateOnly as m, DefaultBranchUnderAnotherNameError as n, isProductionEnvironment as o, call as p, PRODUCTION_ENVIRONMENT as r, resolveContainer as s, ContainerNotFoundError as t, drivePages as u, suppliedOrFromEnv as v };\n\n//# sourceMappingURL=container-jSDTfwAi.mjs.map","import { g as ManagementClient, h as callOptional, l as collectPages, p as call, s as resolveContainer } from \"./container-jSDTfwAi.mjs\";\nimport * as Effect from \"effect/Effect\";\n//#region src/deployed.ts\nconst program = (input) => Effect.gen(function* () {\n\tconst container = yield* resolveContainer({\n\t\tworkspaceId: input.workspaceId,\n\t\tappName: input.appName,\n\t\tensure: false,\n\t\tenvironment: input.environment\n\t});\n\tconst { projectId } = container;\n\tconst branchId = container.branchId ?? container.defaultBranchId;\n\tif (branchId === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`project ${projectId} resolved no Branch`));\n\tconst client = yield* ManagementClient;\n\tconst topology = yield* callOptional(() => client.GET(\"/v1/projects/{projectId}/branches/{branchId}/application-topology\", { params: { path: {\n\t\tprojectId,\n\t\tbranchId\n\t} } }));\n\tif (topology === void 0 || topology.data.nodes.length === 0) return {\n\t\tprojectId,\n\t\tbranchId,\n\t\tnodes: [],\n\t\tservices: [],\n\t\tdatabases: [],\n\t\tbuckets: []\n\t};\n\tconst query = (cursor) => cursor === void 0 ? {\n\t\tprojectId,\n\t\tbranchId\n\t} : {\n\t\tprojectId,\n\t\tbranchId,\n\t\tcursor\n\t};\n\tconst services = yield* collectPages(`services of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/services\", { params: { query: query(cursor) } })));\n\tconst databases = yield* collectPages(`databases of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/databases\", { params: { query: query(cursor) } })));\n\tconst buckets = yield* collectPages(`buckets of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/buckets\", { params: { query: query(cursor) } })));\n\treturn {\n\t\tprojectId,\n\t\tbranchId,\n\t\tnodes: topology.data.nodes.map(({ logicalId, parentLogicalId, kind, type }) => ({\n\t\t\tlogicalId,\n\t\t\tparentLogicalId,\n\t\t\tkind,\n\t\t\t...type === void 0 ? {} : { type }\n\t\t})),\n\t\tservices: services.map(({ id, logicalId, appEndpointDomain }) => ({\n\t\t\tid,\n\t\t\tlogicalId,\n\t\t\tappEndpointDomain\n\t\t})),\n\t\tdatabases: databases.map(({ id, logicalId }) => ({\n\t\t\tid,\n\t\t\tlogicalId\n\t\t})),\n\t\tbuckets: buckets.map(({ id, logicalId }) => ({\n\t\t\tid,\n\t\t\tlogicalId\n\t\t}))\n\t};\n});\n/**\n* Reads what an environment has deployed: its Project and Branch by the same\n* find-only lookup `destroy` uses, the application topology the last deploy\n* wrote, and the Branch's services, databases and buckets. `undefined` when\n* there is no Project or no Branch. Rejects on any other Management API\n* failure.\n*/\nasync function readDeployedEnvironment(client, input) {\n\treturn Effect.runPromise(program(input).pipe(Effect.catchTag(\"ContainerNotFoundError\", () => Effect.succeed(void 0)), Effect.catchTag(\"DefaultBranchUnderAnotherNameError\", (error) => Effect.fail(new Error(error.message))), Effect.catchTag(\"PrismaApiError\", (error) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error: ${error.message}.`))), Effect.provideService(ManagementClient, client)));\n}\n//#endregion\n//#region src/resource-rows.ts\n/** The platform row each Prisma Cloud resource type deploys to. A type missing here, such as an S3 credentials resource, has no row. */\nconst RESOURCE_ROW_KINDS = /* @__PURE__ */ new Map([\n\t[\"postgres\", \"database\"],\n\t[\"raw-postgres\", \"database\"],\n\t[\"s3\", \"bucket\"]\n]);\n//#endregion\nexport { RESOURCE_ROW_KINDS, readDeployedEnvironment };\n\n//# sourceMappingURL=deployed.mjs.map","import { type DeployedEnvironment, RESOURCE_ROW_KINDS } from '@internal/lowering/deployed';\n\n/** One row of `deploy list`: a topology node and the platform row it deployed to. */\nexport interface DeployedNode {\n readonly address: string;\n readonly kind: string;\n readonly platformId: string | null;\n readonly url: string | null;\n}\n\ntype TopologyNode = DeployedEnvironment['nodes'][number];\n\nfunction kindOf(node: TopologyNode): string {\n if (node.parentLogicalId === null) return 'project';\n if (node.kind === 'resource') {\n if (node.type === undefined) return 'resource';\n const rowKind = RESOURCE_ROW_KINDS.get(node.type);\n if (rowKind === 'database') return 'postgres';\n return rowKind ?? node.type;\n }\n return node.kind;\n}\n\nfunction rowId(rows: readonly { id: string; logicalId: string | null }[], logicalId: string) {\n return rows.find((row) => row.logicalId === logicalId)?.id ?? null;\n}\n\nfunction deployedNode(deployed: DeployedEnvironment, node: TopologyNode): DeployedNode {\n const kind = kindOf(node);\n const address = node.logicalId;\n switch (kind) {\n case 'project':\n return { address, kind, platformId: deployed.projectId, url: null };\n case 'service': {\n const row = deployed.services.find((service) => service.logicalId === address);\n return {\n address,\n kind,\n platformId: row?.id ?? null,\n url: row?.appEndpointDomain ?? null,\n };\n }\n case 'postgres':\n return { address, kind, platformId: rowId(deployed.databases, address), url: null };\n case 'bucket':\n return { address, kind, platformId: rowId(deployed.buckets, address), url: null };\n default:\n return { address, kind, platformId: null, url: null };\n }\n}\n\n/** Every node of the environment's topology, in topology order, joined by `logicalId` to the platform row it deployed to. The root's row is the Project. */\nexport function deployedNodes(deployed: DeployedEnvironment): DeployedNode[] {\n return deployed.nodes.map((node) => deployedNode(deployed, node));\n}\n","import { resolveAppIdentity, validateEnvironmentName } from '@internal/cli/app-identity';\nimport type { ComposerConfigSource } from '@internal/cli/control';\nimport { CliStructuredError } from '@internal/foundation/errors';\nimport { notOk, ok, type Result } from '@internal/foundation/result';\nimport { readDeployedEnvironment } from '@internal/lowering/deployed';\nimport type { ManagementApiClient } from '@prisma/cli-engine';\nimport { type DeployedNode, deployedNodes } from './deployed-nodes.ts';\n\nexport interface ListDeployedInput {\n readonly config: ComposerConfigSource;\n readonly entry: string | undefined;\n readonly name: string | undefined;\n readonly environment: string;\n readonly cwd: string;\n readonly workspaceId: string | undefined;\n readonly client: ManagementApiClient;\n}\n\nfunction notFound(app: string, environment: string): CliStructuredError {\n return new CliStructuredError(\n 'DEPLOY.TARGET_NOT_FOUND',\n `Nothing deployed for ${app} in the environment ${environment}.`,\n { fix: 'Deploy it first.' },\n );\n}\n\nfunction lookupFailed(error: unknown): CliStructuredError {\n return new CliStructuredError(\n 'DEPLOY.CONTAINER_FAILED',\n error instanceof Error ? error.message : String(error),\n { cause: error },\n );\n}\n\n/** Every node the app has deployed in the environment, or `DEPLOY.TARGET_NOT_FOUND` when the environment has no Project, Branch or topology. */\nexport async function listDeployed(\n input: ListDeployedInput,\n): Promise<Result<readonly DeployedNode[], CliStructuredError>> {\n let app: string;\n try {\n validateEnvironmentName(input.environment);\n app = (await resolveAppIdentity(input.entry, input.name, input.cwd, input.config)).name;\n } catch (error) {\n if (CliStructuredError.is(error)) return notOk(error);\n throw error;\n }\n if (input.workspaceId === undefined) {\n return notOk(lookupFailed(new Error('environment variable PRISMA_WORKSPACE_ID is required.')));\n }\n\n let deployed: Awaited<ReturnType<typeof readDeployedEnvironment>>;\n try {\n deployed = await readDeployedEnvironment(input.client, {\n workspaceId: input.workspaceId,\n appName: app,\n environment: input.environment,\n });\n } catch (error) {\n return notOk(lookupFailed(error));\n }\n const nodes = deployed === undefined ? [] : deployedNodes(deployed);\n if (nodes.length === 0) return notOk(notFound(app, input.environment));\n return ok(nodes);\n}\n"],"mappings":";;;;;;;;;;AAasC,QAAQ,QAAQ,CAAC,CAAC,2BAA2B;;;;;;;;ACAnF,IAAI,mBAAmB,cAAc,QAAQ,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;;AAmBlF,IAAI,iBAAiB,cAAc,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC;AACvE,MAAM,WAAW,MAAM,OAAO,WAAW;CACxC,KAAK;CACL,QAAQ,UAAU,IAAI,eAAe;EACpC,QAAQ;EACR,SAAS,OAAO,KAAK;CACtB,CAAC;AACF,CAAC;AACD,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,eAAe;CAClD,QAAQ,EAAE,SAAS;CACnB,SAAS,KAAK,UAAU,EAAE,KAAK;AAChC,CAAC,CAAC;;AAEF,MAAM,QAAQ,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,EAAE,UAAU,KAAK,KAAK,EAAE,SAAS,KAAK,IAAI,KAAK,CAAC,IAAI,OAAO,QAAQ,EAAE,IAAI,CAAC,CAAC;;AAErI,MAAM,gBAAgB,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,EAAE,SAAS,WAAW,MAAM,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,KAAK,CAAC,IAAI,OAAO,QAAQ,EAAE,IAAI,CAAC,CAAC;;AAY7K,MAAM,YAAY;AAClB,MAAM,yBAAyB,aAAa,WAAW,IAAI,eAAe;CACzE,QAAQ;CACR,SAAS,WAAW,YAAY,GA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|
+
import "effect/Layer";
|
|
4
|
+
import "alchemy/State/LocalState";
|
|
5
|
+
//#region ../../0-framework/1-core/core/dist/local-target.mjs
|
|
6
|
+
/** The local-target stack's own provider aggregation (ADR-0041; naming, operator 2026-07-23 — the seam is `localTarget`, "dev" names the user-facing feature only) — the local-target counterpart of `deploy.ts`'s `mergedProviders`, kept in its own module so `lower()` learns nothing about it (deploy.ts's REVISED — operator review of #162). */
|
|
7
|
+
function noLocalTargetSupportError(id) {
|
|
8
|
+
return new CliStructuredError("DEV.TARGET_UNSUPPORTED", `extension "${id}" has no dev support — it declares no \`localTarget\` descriptor (ADR-0041).`);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves every non-build-only configured extension's lazy `localTarget`
|
|
12
|
+
* thunk, once (ADR-0041's lazy local-target reference — operator directive:
|
|
13
|
+
* the production control entry carries only the thunk, never the
|
|
14
|
+
* descriptor, so resolving it is this module's job, not something a deploy
|
|
15
|
+
* path ever does). A build-only extension (`isBuildOnlyExtension`) owns no
|
|
16
|
+
* resources or services and is skipped entirely — never even checked for a
|
|
17
|
+
* `localTarget` thunk. Every other configured extension must be
|
|
18
|
+
* local-target-capable, or the dev command cannot bring the app up at all,
|
|
19
|
+
* so a missing thunk throws naming the extension. `prisma dev` calls this
|
|
20
|
+
* once on its main thread for the session's hooks, and once in each converge
|
|
21
|
+
* worker thread for `localTargetProviders`.
|
|
22
|
+
*/
|
|
23
|
+
async function resolveLocalTargets(config) {
|
|
24
|
+
const entries = await Promise.all(config.extensions.flatMap((extension) => {
|
|
25
|
+
if (isBuildOnlyExtension(extension)) return [];
|
|
26
|
+
if (extension.localTarget === void 0) throw noLocalTargetSupportError(extension.id);
|
|
27
|
+
return [extension.localTarget().then((descriptor) => [extension.id, descriptor])];
|
|
28
|
+
}));
|
|
29
|
+
return new Map(entries);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { resolveLocalTargets as t };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=local-target-CZzICh5R.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-target-CZzICh5R.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/local-target.mjs"],"sourcesContent":["import { a as isBuildOnlyExtension, i as devEnvironmentDir, n as DEV_ENVIRONMENT_NAME_FILE, t as DEV_DIR } from \"./app-config-CErnR6NK.mjs\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as Layer from \"effect/Layer\";\nimport { localState } from \"alchemy/State/LocalState\";\n//#region src/control/local-target.ts\n/** The local-target stack's own provider aggregation (ADR-0041; naming, operator 2026-07-23 — the seam is `localTarget`, \"dev\" names the user-facing feature only) — the local-target counterpart of `deploy.ts`'s `mergedProviders`, kept in its own module so `lower()` learns nothing about it (deploy.ts's REVISED — operator review of #162). */\nfunction noLocalTargetSupportError(id) {\n\treturn new CliStructuredError(\"DEV.TARGET_UNSUPPORTED\", `extension \"${id}\" has no dev support — it declares no \\`localTarget\\` descriptor (ADR-0041).`);\n}\n/**\n* Resolves every non-build-only configured extension's lazy `localTarget`\n* thunk, once (ADR-0041's lazy local-target reference — operator directive:\n* the production control entry carries only the thunk, never the\n* descriptor, so resolving it is this module's job, not something a deploy\n* path ever does). A build-only extension (`isBuildOnlyExtension`) owns no\n* resources or services and is skipped entirely — never even checked for a\n* `localTarget` thunk. Every other configured extension must be\n* local-target-capable, or the dev command cannot bring the app up at all,\n* so a missing thunk throws naming the extension. `prisma dev` calls this\n* once on its main thread for the session's hooks, and once in each converge\n* worker thread for `localTargetProviders`.\n*/\nasync function resolveLocalTargets(config) {\n\tconst entries = await Promise.all(config.extensions.flatMap((extension) => {\n\t\tif (isBuildOnlyExtension(extension)) return [];\n\t\tif (extension.localTarget === void 0) throw noLocalTargetSupportError(extension.id);\n\t\treturn [extension.localTarget().then((descriptor) => [extension.id, descriptor])];\n\t}));\n\treturn new Map(entries);\n}\n/**\n* All configured extensions' local-target providers merged, config array\n* order (ADR-0041), from the ALREADY-RESOLVED descriptor map\n* (`resolveLocalTargets`'s product — this function itself never touches a\n* `localTarget` thunk). `prisma dev`'s converge worker thread is this\n* aggregator's one caller, passing the result as `LowerOptions.providers`.\n*/\nfunction localTargetProviders(resolved, containers, devDir, plainVariableText, namedSecrets) {\n\tconst [first, ...rest] = [...resolved.entries()].map(([id, descriptor]) => descriptor.providers({\n\t\tcontainer: containers.get(id),\n\t\tdevDir,\n\t\tplainVariableText,\n\t\tnamedSecrets\n\t}));\n\treturn first === void 0 ? Layer.empty : Layer.mergeAll(first, ...rest);\n}\n/** The state store `prisma dev` converges against: Alchemy's file store in the app's working directory. */\nfunction devState() {\n\treturn localState();\n}\n//#endregion\nexport { DEV_DIR, DEV_ENVIRONMENT_NAME_FILE, devEnvironmentDir, devState, localTargetProviders, resolveLocalTargets };\n\n//# sourceMappingURL=local-target.mjs.map"],"mappings":";;;;;;AAMA,SAAS,0BAA0B,IAAI;CACtC,OAAO,IAAI,mBAAmB,0BAA0B,cAAc,GAAG,6EAA6E;AACvJ;;;;;;;;;;;;;;AAcA,eAAe,oBAAoB,QAAQ;CAC1C,MAAM,UAAU,MAAM,QAAQ,IAAI,OAAO,WAAW,SAAS,cAAc;EAC1E,IAAI,qBAAqB,SAAS,GAAG,OAAO,CAAC;EAC7C,IAAI,UAAU,gBAAgB,KAAK,GAAG,MAAM,0BAA0B,UAAU,EAAE;EAClF,OAAO,CAAC,UAAU,YAAY,CAAC,CAAC,MAAM,eAAe,CAAC,UAAU,IAAI,UAAU,CAAC,CAAC;CACjF,CAAC,CAAC;CACF,OAAO,IAAI,IAAI,OAAO;AACvB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region ../../0-framework/1-core/core/dist/preflight-transport-2d6iIchu.mjs
|
|
2
|
+
/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PRISMA_CLOUD': uppercased, every non-alphanumeric run replaced by one underscore. */
|
|
3
|
+
function envVarSafeExtensionId(extensionId) {
|
|
4
|
+
return extensionId.toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
5
|
+
}
|
|
6
|
+
/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_CONTAINER_PRISMA_COMPOSER_PRISMA_CLOUD' */
|
|
7
|
+
function containerEnvVarName(extensionId) {
|
|
8
|
+
return `PRISMA_COMPOSER_CONTAINER_${envVarSafeExtensionId(extensionId)}`;
|
|
9
|
+
}
|
|
10
|
+
function collisionError(a, b, varName) {
|
|
11
|
+
return /* @__PURE__ */ new Error(`Extension ids "${a}" and "${b}" both map to the container transport variable "${varName}" — rename one of the extensions.`);
|
|
12
|
+
}
|
|
13
|
+
function emptySerializeError(extensionId) {
|
|
14
|
+
return /* @__PURE__ */ new Error(`Extension "${extensionId}"'s container instance serialized to an empty string — ContainerInstance.serialize() must return a non-empty string.`);
|
|
15
|
+
}
|
|
16
|
+
/** The env entries the CLI sets on the alchemy process: `{ [containerEnvVarName(id)]: instance.serialize() }` for every resolved instance. */
|
|
17
|
+
function containerEnv(instances) {
|
|
18
|
+
const env = {};
|
|
19
|
+
const ownerByVarName = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const [extensionId, instance] of instances) {
|
|
21
|
+
const varName = containerEnvVarName(extensionId);
|
|
22
|
+
const owner = ownerByVarName.get(varName);
|
|
23
|
+
if (owner !== void 0) throw collisionError(owner, extensionId, varName);
|
|
24
|
+
ownerByVarName.set(varName, extensionId);
|
|
25
|
+
const serialized = instance.serialize();
|
|
26
|
+
if (serialized.length === 0) throw emptySerializeError(extensionId);
|
|
27
|
+
env[varName] = serialized;
|
|
28
|
+
}
|
|
29
|
+
return env;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Carries an extension's preflight payload from the CLI process to
|
|
33
|
+
* `destroy`'s alchemy child (which re-imports the config from scratch); `deploy`
|
|
34
|
+
* and `prisma dev` pass it to `lower()` as a value — one env var per
|
|
35
|
+
* extension, same channel as containers (container-transport.ts), filled by
|
|
36
|
+
* whichever preflight the run executed: the deploy preflight or the local
|
|
37
|
+
* target's dev preflight. The framework never reads the contents, so an
|
|
38
|
+
* extension that implements both must tell its own payload kinds apart.
|
|
39
|
+
* Payloads carry metadata only, never secret values: the child's environment
|
|
40
|
+
* is not a secret store.
|
|
41
|
+
*/
|
|
42
|
+
/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PREFLIGHT_PRISMA_COMPOSER_PRISMA_CLOUD' */
|
|
43
|
+
function preflightEnvVarName(extensionId) {
|
|
44
|
+
return `PRISMA_COMPOSER_PREFLIGHT_${envVarSafeExtensionId(extensionId)}`;
|
|
45
|
+
}
|
|
46
|
+
/** One reader as the deploy prints it, for example `read by service "shop.email", field "apiKey"`. */
|
|
47
|
+
function platformVariableReaderText(reader) {
|
|
48
|
+
switch (reader.kind) {
|
|
49
|
+
case "field": return `read by service "${reader.service}", field "${reader.path === "" ? "(root)" : reader.path}"`;
|
|
50
|
+
case "unread": return `named by resource "${reader.node}", read by no service`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { platformVariableReaderText as n, preflightEnvVarName as r, containerEnv as t };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=preflight-transport-2d6iIchu-ArIJUY1L.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight-transport-2d6iIchu-ArIJUY1L.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/preflight-transport-2d6iIchu.mjs"],"sourcesContent":["//#region src/container-transport.ts\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PRISMA_CLOUD': uppercased, every non-alphanumeric run replaced by one underscore. */\nfunction envVarSafeExtensionId(extensionId) {\n\treturn extensionId.toUpperCase().replace(/[^A-Z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\");\n}\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_CONTAINER_PRISMA_COMPOSER_PRISMA_CLOUD' */\nfunction containerEnvVarName(extensionId) {\n\treturn `PRISMA_COMPOSER_CONTAINER_${envVarSafeExtensionId(extensionId)}`;\n}\nfunction collisionError(a, b, varName) {\n\treturn /* @__PURE__ */ new Error(`Extension ids \"${a}\" and \"${b}\" both map to the container transport variable \"${varName}\" — rename one of the extensions.`);\n}\nfunction emptySerializeError(extensionId) {\n\treturn /* @__PURE__ */ new Error(`Extension \"${extensionId}\"'s container instance serialized to an empty string — ContainerInstance.serialize() must return a non-empty string.`);\n}\n/** The env entries the CLI sets on the alchemy process: `{ [containerEnvVarName(id)]: instance.serialize() }` for every resolved instance. */\nfunction containerEnv(instances) {\n\tconst env = {};\n\tconst ownerByVarName = /* @__PURE__ */ new Map();\n\tfor (const [extensionId, instance] of instances) {\n\t\tconst varName = containerEnvVarName(extensionId);\n\t\tconst owner = ownerByVarName.get(varName);\n\t\tif (owner !== void 0) throw collisionError(owner, extensionId, varName);\n\t\townerByVarName.set(varName, extensionId);\n\t\tconst serialized = instance.serialize();\n\t\tif (serialized.length === 0) throw emptySerializeError(extensionId);\n\t\tenv[varName] = serialized;\n\t}\n\treturn env;\n}\n/**\n* The alchemy-process side: for each extension with a container descriptor\n* whose var is present in `env`, call its deserialize. Absent var → no entry.\n*/\nfunction deserializeContainers(extensions, env) {\n\tconst instances = /* @__PURE__ */ new Map();\n\tfor (const extension of extensions) {\n\t\tconst descriptor = extension.container;\n\t\tif (descriptor === void 0) continue;\n\t\tconst serialized = env[containerEnvVarName(extension.id)];\n\t\tif (serialized === void 0) continue;\n\t\tinstances.set(extension.id, descriptor.deserialize(serialized));\n\t}\n\treturn instances;\n}\n//#endregion\n//#region src/preflight-transport.ts\n/**\n* Carries an extension's preflight payload from the CLI process to\n* `destroy`'s alchemy child (which re-imports the config from scratch); `deploy`\n* and `prisma dev` pass it to `lower()` as a value — one env var per\n* extension, same channel as containers (container-transport.ts), filled by\n* whichever preflight the run executed: the deploy preflight or the local\n* target's dev preflight. The framework never reads the contents, so an\n* extension that implements both must tell its own payload kinds apart.\n* Payloads carry metadata only, never secret values: the child's environment\n* is not a secret store.\n*/\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PREFLIGHT_PRISMA_COMPOSER_PRISMA_CLOUD' */\nfunction preflightEnvVarName(extensionId) {\n\treturn `PRISMA_COMPOSER_PREFLIGHT_${envVarSafeExtensionId(extensionId)}`;\n}\n/** The env entries the CLI sets on the alchemy process: `{ [preflightEnvVarName(id)]: payload }` for every extension whose preflight returned one. */\nfunction preflightEnv(payloads) {\n\tconst env = {};\n\tconst ownerByVarName = /* @__PURE__ */ new Map();\n\tfor (const [extensionId, payload] of payloads) {\n\t\tif (payload.length === 0) continue;\n\t\tconst varName = preflightEnvVarName(extensionId);\n\t\tconst owner = ownerByVarName.get(varName);\n\t\tif (owner !== void 0) throw new Error(`Extension ids \"${owner}\" and \"${extensionId}\" both use the environment variable \"${varName}\". Rename one of the extensions.`);\n\t\townerByVarName.set(varName, extensionId);\n\t\tenv[varName] = payload;\n\t}\n\treturn env;\n}\n/** The alchemy-process side: the payload this extension's own preflight wrote, or `undefined` when it wrote none (or when nothing ran a preflight at all). */\nfunction readPreflightPayload(extensionId, env) {\n\tconst payload = env[preflightEnvVarName(extensionId)];\n\treturn payload === void 0 || payload.length === 0 ? void 0 : payload;\n}\n/** One reader as the deploy prints it, for example `read by service \"shop.email\", field \"apiKey\"`. */\nfunction platformVariableReaderText(reader) {\n\tswitch (reader.kind) {\n\t\tcase \"field\": return `read by service \"${reader.service}\", field \"${reader.path === \"\" ? \"(root)\" : reader.path}\"`;\n\t\tcase \"unread\": return `named by resource \"${reader.node}\", read by no service`;\n\t}\n}\n//#endregion\nexport { containerEnv as a, readPreflightPayload as i, preflightEnv as n, containerEnvVarName as o, preflightEnvVarName as r, deserializeContainers as s, platformVariableReaderText as t };\n\n//# sourceMappingURL=preflight-transport-2d6iIchu.mjs.map"],"mappings":";;AAEA,SAAS,sBAAsB,aAAa;CAC3C,OAAO,YAAY,YAAY,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,YAAY,EAAE;AACpF;;AAEA,SAAS,oBAAoB,aAAa;CACzC,OAAO,6BAA6B,sBAAsB,WAAW;AACtE;AACA,SAAS,eAAe,GAAG,GAAG,SAAS;CACtC,uBAAuB,IAAI,MAAM,kBAAkB,EAAE,SAAS,EAAE,kDAAkD,QAAQ,kCAAkC;AAC7J;AACA,SAAS,oBAAoB,aAAa;CACzC,uBAAuB,IAAI,MAAM,cAAc,YAAY,qHAAqH;AACjL;;AAEA,SAAS,aAAa,WAAW;CAChC,MAAM,MAAM,CAAC;CACb,MAAM,iCAAiC,IAAI,IAAI;CAC/C,KAAK,MAAM,CAAC,aAAa,aAAa,WAAW;EAChD,MAAM,UAAU,oBAAoB,WAAW;EAC/C,MAAM,QAAQ,eAAe,IAAI,OAAO;EACxC,IAAI,UAAU,KAAK,GAAG,MAAM,eAAe,OAAO,aAAa,OAAO;EACtE,eAAe,IAAI,SAAS,WAAW;EACvC,MAAM,aAAa,SAAS,UAAU;EACtC,IAAI,WAAW,WAAW,GAAG,MAAM,oBAAoB,WAAW;EAClE,IAAI,WAAW;CAChB;CACA,OAAO;AACR;;;;;;;;;;;;;AA8BA,SAAS,oBAAoB,aAAa;CACzC,OAAO,6BAA6B,sBAAsB,WAAW;AACtE;;AAqBA,SAAS,2BAA2B,QAAQ;CAC3C,QAAQ,OAAO,MAAf;EACC,KAAK,SAAS,OAAO,oBAAoB,OAAO,QAAQ,YAAY,OAAO,SAAS,KAAK,WAAW,OAAO,KAAK;EAChH,KAAK,UAAU,OAAO,sBAAsB,OAAO,KAAK;CACzD;AACD"}
|
|
@@ -1,257 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as path from "node:path";
|
|
1
|
+
import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
|
|
4
2
|
import { inspect } from "node:util";
|
|
5
|
-
//#region ../../0-framework/3-tooling/cli/dist/
|
|
6
|
-
/**
|
|
7
|
-
* What makes a `composer` section valid, shared by the CLI's section validator and the programmatic operations.
|
|
8
|
-
* It imports nothing from the CLI engine, because `@prisma/composer` must not depend on it.
|
|
9
|
-
*/
|
|
10
|
-
const SECTION_FIX = "Write `composer: composer({ entry: './module.ts', extensions: [...], state: ... })` in prisma.config.ts, with `import { defineConfig as composer } from '@prisma/composer/config'`.";
|
|
11
|
-
const MOVE_TO_SECTION_FIX = `${SECTION_FIX} If the project has a prisma-composer.config.ts, move its extensions and state into that section and delete the file.`;
|
|
12
|
-
const SECTION_IS_THE_ONLY_SOURCE = "Composer reads its configuration only from the `composer` section of prisma.config.ts.";
|
|
13
|
-
const DESCRIPTOR_FIX = "Use the descriptor the extension factory returns, unchanged, instead of building one by hand.";
|
|
14
|
-
const RETIRED_FILE_NAMES = [
|
|
15
|
-
"ts",
|
|
16
|
-
"mts",
|
|
17
|
-
"mjs",
|
|
18
|
-
"js"
|
|
19
|
-
].map((extension) => `prisma-composer.config.${extension}`);
|
|
20
|
-
const sectionMissing = {
|
|
21
|
-
code: "CONFIG.SECTION_MISSING",
|
|
22
|
-
summary: "No loaded prisma.config.ts declares a `composer` section.",
|
|
23
|
-
why: `${SECTION_IS_THE_ONLY_SOURCE} A prisma-composer.config.ts file is no longer read.`,
|
|
24
|
-
fix: MOVE_TO_SECTION_FIX
|
|
25
|
-
};
|
|
26
|
-
/** What the generated stack file throws when the file it imports has no `composer` export. */
|
|
27
|
-
function noComposerExportMessage(configFile) {
|
|
28
|
-
return `${configFile} declares no \`composer\` section. Pass the prisma.config.ts that declares it.`;
|
|
29
|
-
}
|
|
30
|
-
function configFileMissing(file) {
|
|
31
|
-
return {
|
|
32
|
-
code: "CONFIG.FILE_MISSING",
|
|
33
|
-
summary: `${file} does not exist.`,
|
|
34
|
-
fix: "Pass the path of the prisma.config.ts that declares the `composer` section.",
|
|
35
|
-
where: file
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/** A prisma-composer.config.* beside the declaring file would otherwise be silently ignored. */
|
|
39
|
-
/** The path with symlinks resolved; the path itself when it cannot be resolved, so the check never throws. */
|
|
40
|
-
function realPath(file) {
|
|
41
|
-
try {
|
|
42
|
-
return fs.realpathSync(file);
|
|
43
|
-
} catch {
|
|
44
|
-
return file;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function retiredFileFinding(configFile) {
|
|
48
|
-
const directory = path.dirname(realPath(configFile));
|
|
49
|
-
const found = RETIRED_FILE_NAMES.map((name) => path.join(directory, name)).find((file) => fs.existsSync(file));
|
|
50
|
-
if (found === void 0) return void 0;
|
|
51
|
-
return {
|
|
52
|
-
code: "CONFIG.FILE_RETIRED",
|
|
53
|
-
summary: `${found} is no longer read.`,
|
|
54
|
-
why: SECTION_IS_THE_ONLY_SOURCE,
|
|
55
|
-
fix: MOVE_TO_SECTION_FIX,
|
|
56
|
-
where: found
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function isObject(value) {
|
|
60
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61
|
-
}
|
|
62
|
-
function isExtensionDescriptor(value) {
|
|
63
|
-
return isObject(value) && typeof value["id"] === "string" && value["id"].length > 0 && isObject(value["nodes"]);
|
|
64
|
-
}
|
|
65
|
-
function isStateDescriptor(value) {
|
|
66
|
-
return isObject(value) && typeof value["extension"] === "string" && typeof value["create"] === "function";
|
|
67
|
-
}
|
|
68
|
-
const stateInvalid = {
|
|
69
|
-
code: "CONFIG.FIELD_INVALID",
|
|
70
|
-
summary: "`composer.state` must be a state descriptor with a string `extension` and a `create` function.",
|
|
71
|
-
fix: "Set `state` to the state descriptor an extension provides, e.g. `state: prismaState()`.",
|
|
72
|
-
field: "state"
|
|
73
|
-
};
|
|
74
|
-
const SECTION_FIELDS = /* @__PURE__ */ new Set([
|
|
75
|
-
"entry",
|
|
76
|
-
"extensions",
|
|
77
|
-
"state",
|
|
78
|
-
"config",
|
|
79
|
-
"secrets"
|
|
80
|
-
]);
|
|
81
|
-
const entryInvalid = {
|
|
82
|
-
code: "CONFIG.FIELD_INVALID",
|
|
83
|
-
summary: "`composer.entry` must be a non-empty string: the path to the module whose default export is the app.",
|
|
84
|
-
fix: "Set `entry` to that module's path, relative to prisma.config.ts, e.g. `entry: './module.ts'`.",
|
|
85
|
-
field: "entry"
|
|
86
|
-
};
|
|
87
|
-
/** Neither the section's `entry` nor an override names the module whose default export is the app. */
|
|
88
|
-
const entryMissing = {
|
|
89
|
-
code: "CONFIG.ENTRY_MISSING",
|
|
90
|
-
summary: "No entry module is set, so there is no app to load.",
|
|
91
|
-
why: "The entry is the module whose default export is the app root, built with appRoot(...).",
|
|
92
|
-
fix: "Set `entry: './module.ts'` in the `composer` section of prisma.config.ts, or pass `--entry <path>` (the `entry` input when calling @prisma/composer/control).",
|
|
93
|
-
field: "entry"
|
|
94
|
-
};
|
|
95
|
-
function unknownField(key) {
|
|
96
|
-
return {
|
|
97
|
-
code: "CONFIG.FIELD_UNKNOWN",
|
|
98
|
-
summary: `The \`composer\` section has no field \`${key}\`.`,
|
|
99
|
-
fix: key === "composer" ? "Pass the `composer` property of the prisma.config.ts export, not the whole export. The section takes only `entry`, `extensions`, `state`, `config` and `secrets`." : `Remove \`${key}\`. The section takes only \`entry\`, \`extensions\`, \`state\`, \`config\` and \`secrets\`.`,
|
|
100
|
-
field: key
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function checkExtensions(value) {
|
|
104
|
-
if (!Array.isArray(value)) return {
|
|
105
|
-
extensions: [],
|
|
106
|
-
findings: [{
|
|
107
|
-
code: "CONFIG.FIELD_INVALID",
|
|
108
|
-
summary: "`composer.extensions` must be an array of extension descriptors.",
|
|
109
|
-
fix: "Set `extensions` to the descriptors your extensions provide, e.g. `extensions: [nodeBuild()]`.",
|
|
110
|
-
field: "extensions"
|
|
111
|
-
}]
|
|
112
|
-
};
|
|
113
|
-
const findings = [];
|
|
114
|
-
const extensions = [];
|
|
115
|
-
const seen = /* @__PURE__ */ new Set();
|
|
116
|
-
for (const [index, entry] of value.entries()) {
|
|
117
|
-
const field = `extensions[${index}]`;
|
|
118
|
-
if (!isObject(entry)) {
|
|
119
|
-
findings.push({
|
|
120
|
-
code: "CONFIG.FIELD_INVALID",
|
|
121
|
-
summary: `\`composer.${field}\` must be an extension descriptor object.`,
|
|
122
|
-
fix: "Put the descriptor an extension factory returns here, e.g. `nodeBuild()`, not the factory itself.",
|
|
123
|
-
field
|
|
124
|
-
});
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const id = entry["id"];
|
|
128
|
-
if (typeof id !== "string" || id.length === 0) findings.push({
|
|
129
|
-
code: "CONFIG.FIELD_INVALID",
|
|
130
|
-
summary: `\`composer.${field}.id\` must be a non-empty string (the extension package name).`,
|
|
131
|
-
fix: DESCRIPTOR_FIX,
|
|
132
|
-
field: `${field}.id`
|
|
133
|
-
});
|
|
134
|
-
else if (seen.has(id)) findings.push({
|
|
135
|
-
code: "CONFIG.EXTENSION_DUPLICATE",
|
|
136
|
-
summary: `Extension "${id}" is listed more than once in \`composer.extensions\`.`,
|
|
137
|
-
fix: `Remove the repeated "${id}" entry from \`extensions\`.`,
|
|
138
|
-
field: `${field}.id`
|
|
139
|
-
});
|
|
140
|
-
else seen.add(id);
|
|
141
|
-
if (!isObject(entry["nodes"])) findings.push({
|
|
142
|
-
code: "CONFIG.FIELD_INVALID",
|
|
143
|
-
summary: `\`composer.${field}.nodes\` must be an object (the node-ID → control registry).`,
|
|
144
|
-
fix: DESCRIPTOR_FIX,
|
|
145
|
-
field: `${field}.nodes`
|
|
146
|
-
});
|
|
147
|
-
if (isExtensionDescriptor(entry)) extensions.push(entry);
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
findings,
|
|
151
|
-
extensions
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function isAdapterList(value) {
|
|
155
|
-
return Array.isArray(value) && value.every((entry) => typeof entry === "function");
|
|
156
|
-
}
|
|
157
|
-
function checkAdapters(list, value) {
|
|
158
|
-
if (value === void 0) return [];
|
|
159
|
-
if (!Array.isArray(value)) return [{
|
|
160
|
-
code: "CONFIG.FIELD_INVALID",
|
|
161
|
-
summary: `\`composer.${list}\` must be an array of adapters.`,
|
|
162
|
-
fix: `Set \`${list}\` to a list of adapters, e.g. \`${list}: [dotenv(), environmentVariables()]\`, imported from '@prisma/composer/config'.`,
|
|
163
|
-
field: list
|
|
164
|
-
}];
|
|
165
|
-
return value.flatMap((entry, index) => typeof entry === "function" ? [] : [{
|
|
166
|
-
code: "CONFIG.FIELD_INVALID",
|
|
167
|
-
summary: `\`composer.${list}[${index}]\` must be an adapter: a function that receives the environment and returns its values.`,
|
|
168
|
-
fix: "Put an adapter here, e.g. `dotenv()`.",
|
|
169
|
-
field: `${list}[${index}]`
|
|
170
|
-
}]);
|
|
171
|
-
}
|
|
172
|
-
function checkFields(section) {
|
|
173
|
-
if (Object.hasOwn(section, "configPath")) return {
|
|
174
|
-
ok: false,
|
|
175
|
-
findings: [{
|
|
176
|
-
code: "CONFIG.FIELD_RETIRED",
|
|
177
|
-
summary: "`composer.configPath` is no longer supported: prisma-composer.config.ts is no longer read.",
|
|
178
|
-
why: SECTION_IS_THE_ONLY_SOURCE,
|
|
179
|
-
fix: `Replace \`configPath\` with the section itself. ${MOVE_TO_SECTION_FIX}`,
|
|
180
|
-
field: "configPath"
|
|
181
|
-
}]
|
|
182
|
-
};
|
|
183
|
-
if (Object.hasOwn(section, "composer")) return {
|
|
184
|
-
ok: false,
|
|
185
|
-
findings: [unknownField("composer")]
|
|
186
|
-
};
|
|
187
|
-
const findings = Object.keys(section).filter((key) => !SECTION_FIELDS.has(key)).map(unknownField);
|
|
188
|
-
const checked = checkExtensions(section["extensions"]);
|
|
189
|
-
findings.push(...checked.findings);
|
|
190
|
-
const state = section["state"];
|
|
191
|
-
if (!isStateDescriptor(state)) findings.push(stateInvalid);
|
|
192
|
-
const entry = section["entry"];
|
|
193
|
-
const entryValid = entry === void 0 || typeof entry === "string" && entry.length > 0;
|
|
194
|
-
if (!entryValid) findings.push(entryInvalid);
|
|
195
|
-
const config = section["config"];
|
|
196
|
-
const secrets = section["secrets"];
|
|
197
|
-
findings.push(...checkAdapters("config", config), ...checkAdapters("secrets", secrets));
|
|
198
|
-
const [first, ...rest] = findings;
|
|
199
|
-
if (first === void 0 && isStateDescriptor(state) && entryValid && (config === void 0 || isAdapterList(config)) && (secrets === void 0 || isAdapterList(secrets))) return {
|
|
200
|
-
ok: true,
|
|
201
|
-
value: {
|
|
202
|
-
extensions: checked.extensions,
|
|
203
|
-
state,
|
|
204
|
-
...entry === void 0 ? {} : { entry },
|
|
205
|
-
...config === void 0 ? {} : { config },
|
|
206
|
-
...secrets === void 0 ? {} : { secrets }
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
return {
|
|
210
|
-
ok: false,
|
|
211
|
-
findings: [first ?? stateInvalid, ...rest]
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Checks the fields that identify each descriptor and returns the descriptors as the config file's own objects.
|
|
216
|
-
* Never throws: a section's values are user code, and a throwing getter or Proxy trap becomes a finding.
|
|
217
|
-
*/
|
|
218
|
-
function checkComposerSection(raw) {
|
|
219
|
-
if (!isObject(raw)) return {
|
|
220
|
-
ok: false,
|
|
221
|
-
findings: [{
|
|
222
|
-
code: "CONFIG.FIELD_INVALID",
|
|
223
|
-
summary: "The `composer` section of prisma.config.ts must be an object.",
|
|
224
|
-
fix: SECTION_FIX
|
|
225
|
-
}]
|
|
226
|
-
};
|
|
227
|
-
try {
|
|
228
|
-
return checkFields({ ...raw });
|
|
229
|
-
} catch (cause) {
|
|
230
|
-
return {
|
|
231
|
-
ok: false,
|
|
232
|
-
findings: [{
|
|
233
|
-
code: "CONFIG.FIELD_INVALID",
|
|
234
|
-
summary: "The `composer` section of prisma.config.ts could not be read.",
|
|
235
|
-
why: `Reading it threw: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
236
|
-
fix: SECTION_FIX
|
|
237
|
-
}]
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* The whole check, shared by the section validator and the programmatic operations so both report the same findings in the same order: the retired file beside the declaring `configFile` (resolved through symlinks), then every field finding.
|
|
243
|
-
*/
|
|
244
|
-
function checkComposerConfig(raw, configFile) {
|
|
245
|
-
const retired = retiredFileFinding(configFile);
|
|
246
|
-
const checked = checkComposerSection(raw);
|
|
247
|
-
if (retired === void 0) return checked;
|
|
248
|
-
return {
|
|
249
|
-
ok: false,
|
|
250
|
-
findings: checked.ok ? [retired] : [retired, ...checked.findings]
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region ../../0-framework/3-tooling/cli/dist/redaction-CjMYXtGp.mjs
|
|
3
|
+
//#region ../../0-framework/3-tooling/cli/dist/redaction-DY6eDC12.mjs
|
|
255
4
|
const REDACTED = "[redacted]";
|
|
256
5
|
/** Env var names whose values are credentials: the service token, preflight payloads, and the usual secret spellings. */
|
|
257
6
|
const SECRET_ENV_NAME = /TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|AUTH|API_?KEY|ACCESS_?KEY|_KEY$|DATABASE_URL|_DSN$|^PRISMA_COMPOSER_PREFLIGHT_/i;
|
|
@@ -485,7 +234,7 @@ function redactErrorChain(error, redaction, seen) {
|
|
|
485
234
|
return copy;
|
|
486
235
|
}
|
|
487
236
|
}
|
|
488
|
-
/** `event` with every value `redaction` hides removed from the text it carries: a message, or a dev server's output line. */
|
|
237
|
+
/** `event` with every value `redaction` hides removed from the text it carries: a message, an Alchemy log line, a converge failure's reasons, or a dev server's output line. */
|
|
489
238
|
function redactDevEvent(event, redaction) {
|
|
490
239
|
switch (event.kind) {
|
|
491
240
|
case "target-warning":
|
|
@@ -495,6 +244,18 @@ function redactDevEvent(event, redaction) {
|
|
|
495
244
|
...event,
|
|
496
245
|
message: redaction.redact(event.message)
|
|
497
246
|
};
|
|
247
|
+
case "message": return {
|
|
248
|
+
...event,
|
|
249
|
+
text: redaction.redact(event.text)
|
|
250
|
+
};
|
|
251
|
+
case "converge-failed": return {
|
|
252
|
+
...event,
|
|
253
|
+
message: redaction.redact(event.message),
|
|
254
|
+
reasons: event.reasons.map(({ tag, message }) => ({
|
|
255
|
+
tag,
|
|
256
|
+
message: redaction.redact(message)
|
|
257
|
+
}))
|
|
258
|
+
};
|
|
498
259
|
case "dev-server-output": return {
|
|
499
260
|
...event,
|
|
500
261
|
line: redaction.redact(event.line)
|
|
@@ -561,6 +322,6 @@ var StreamRedactor = class {
|
|
|
561
322
|
}
|
|
562
323
|
};
|
|
563
324
|
//#endregion
|
|
564
|
-
export {
|
|
325
|
+
export { redactError as a, redactUnsetPlatformVariable as c, redactDevEvent as i, valuesUnderSecretsKeys as l, StreamRedactor as n, redactSummary as o, credentialLookingValues as r, redactThrown as s, SecretRedaction as t };
|
|
565
326
|
|
|
566
|
-
//# sourceMappingURL=redaction-
|
|
327
|
+
//# sourceMappingURL=redaction-DY6eDC12-BrK1aSN5.mjs.map
|