@prisma/composer-cli 0.34.0 → 0.35.0-dev.2
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/{dev-current-vAfxVcnD-Drp6NbCc.mjs → dev-current-8HfFCN7C-C9CEq_7T.mjs} +9 -7
- package/dist/dev-current-8HfFCN7C-C9CEq_7T.mjs.map +1 -0
- package/dist/{dist-j4X7U5yA.mjs → dist-B9-nLeho.mjs} +10 -4
- package/dist/{dist-j4X7U5yA.mjs.map → dist-B9-nLeho.mjs.map} +1 -1
- package/dist/{execute-deploy-destroy-CdjqjHzw-BgnsJ75H.mjs → execute-deploy-destroy-DerNHILD-Bz6XZitd.mjs} +49 -35
- package/dist/execute-deploy-destroy-DerNHILD-Bz6XZitd.mjs.map +1 -0
- package/dist/{execute-dev-C75Y_wIa-lffN9oPi.mjs → execute-dev-D_JvTKjS-Bfdv-HU4.mjs} +166 -39
- package/dist/{execute-dev-C75Y_wIa-lffN9oPi.mjs.map → execute-dev-D_JvTKjS-Bfdv-HU4.mjs.map} +1 -1
- package/dist/{execute-dev-current-C0y1X-EE-DB7Q506a.mjs → execute-dev-current-BRJkR4Y1-DV2_N-Do.mjs} +10 -8
- package/dist/execute-dev-current-BRJkR4Y1-DV2_N-Do.mjs.map +1 -0
- package/dist/{family-BYcJFXg--DbwOABZy.d.mts → family-DBTO11ZA-CADtFQ_B.d.mts} +136 -50
- package/dist/family-DBTO11ZA-CADtFQ_B.d.mts.map +1 -0
- package/dist/family.d.mts +35 -4
- package/dist/family.d.mts.map +1 -1
- package/dist/family.mjs +191 -60
- package/dist/family.mjs.map +1 -1
- package/dist/{generate-dev-stack-DSBhURJV-Gv1jakWP.mjs → generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs} +5 -3
- package/dist/generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs.map +1 -0
- package/dist/list-deployed-Dba4D_0R.mjs +381 -0
- package/dist/list-deployed-Dba4D_0R.mjs.map +1 -0
- package/dist/{local-target-DZ6bu7Aj.mjs → local-target-CK8gvYV4.mjs} +2 -2
- package/dist/{local-target-DZ6bu7Aj.mjs.map → local-target-CK8gvYV4.mjs.map} +1 -1
- package/dist/{pipeline-Dpesfd2j-DKL3f1bj.mjs → pipeline-BmWt-Nhb-Bos4TFXR.mjs} +107 -24
- package/dist/pipeline-BmWt-Nhb-Bos4TFXR.mjs.map +1 -0
- package/dist/{composer-config-CY9fET8H-CgnpfWc2.mjs → run-alchemy-Dl_MWw4g-DaWV9tkH.mjs} +333 -310
- package/dist/run-alchemy-Dl_MWw4g-DaWV9tkH.mjs.map +1 -0
- package/dist/testing.d.mts +3 -1
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +5 -4
- package/dist/testing.mjs.map +1 -1
- package/dist/validate-environment-Y3kuF-NC-DvIK2JUY.mjs +16 -0
- package/dist/validate-environment-Y3kuF-NC-DvIK2JUY.mjs.map +1 -0
- package/package.json +9 -7
- package/src/exports/family.ts +8 -1
- package/src/family/deploy-list.ts +103 -0
- package/src/family/deployed-nodes.ts +55 -0
- package/src/family/list-deployed.ts +64 -0
- package/dist/composer-config-CY9fET8H-CgnpfWc2.mjs.map +0 -1
- package/dist/dev-current-vAfxVcnD-Drp6NbCc.mjs.map +0 -1
- package/dist/execute-deploy-destroy-CdjqjHzw-BgnsJ75H.mjs.map +0 -1
- package/dist/execute-dev-current-C0y1X-EE-DB7Q506a.mjs.map +0 -1
- package/dist/family-BYcJFXg--DbwOABZy.d.mts.map +0 -1
- package/dist/generate-dev-stack-DSBhURJV-Gv1jakWP.mjs.map +0 -1
- package/dist/pipeline-Dpesfd2j-DKL3f1bj.mjs.map +0 -1
package/dist/{generate-dev-stack-DSBhURJV-Gv1jakWP.mjs → generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as noComposerExportMessage } from "./run-alchemy-Dl_MWw4g-DaWV9tkH.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
//#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-
|
|
4
|
+
//#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-CfneNj97.mjs
|
|
5
5
|
/**
|
|
6
6
|
* Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but at
|
|
7
7
|
* `.prisma-composer/dev/alchemy.run.ts`, always Alchemy stage `dev`, using
|
|
@@ -33,6 +33,8 @@ function renderOptions(input) {
|
|
|
33
33
|
lines.push(" bundles: {");
|
|
34
34
|
for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
|
|
35
35
|
lines.push(" },");
|
|
36
|
+
const unassembled = Object.keys(input.assembled.devServers);
|
|
37
|
+
if (unassembled.length > 0) lines.push(` unassembled: [${unassembled.map(quote).join(", ")}],`);
|
|
36
38
|
lines.push(" providers: localTargetProviders(resolved, containers, devDir),");
|
|
37
39
|
lines.push(" state: devState(),");
|
|
38
40
|
return lines.join("\n");
|
|
@@ -84,4 +86,4 @@ const DEV_STACK_RELATIVE_PATH = path.join(DEV_GENERATED_DIR, DEV_GENERATED_FILE)
|
|
|
84
86
|
//#endregion
|
|
85
87
|
export { renderDevStackFile as n, writeDevStackFile as r, DEV_STACK_RELATIVE_PATH as t };
|
|
86
88
|
|
|
87
|
-
//# sourceMappingURL=generate-dev-stack-
|
|
89
|
+
//# sourceMappingURL=generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/generate-dev-stack-CfneNj97.mjs"],"sourcesContent":["import { i as noComposerExportMessage } from \"./composer-config-ehUUVHtU.mjs\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n//#region src/dev/generate-dev-stack.ts\n/**\n* Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but at\n* `.prisma-composer/dev/alchemy.run.ts`, always Alchemy stage `dev`, using\n* Composer's `devState()` (Alchemy's file store) and no `report` — dev prints its own front\n* door (run-dev.ts), so core's presentation-free lower() gets nothing to\n* call back into. The generated module IS the one orchestration point where\n* dev provenance is resolved (spec § 3 REVISED): it deserializes the\n* containers, top-level-awaits `resolveLocalTargets(config)` (the lazy\n* `localTarget` thunks, ADR-0041), and passes\n* `providers: localTargetProviders(...)` + `state: devState()` explicitly\n* — `lower()` learns nothing about dev.\n*/\nconst DEV_GENERATED_DIR = \".prisma-composer/dev\";\nconst DEV_GENERATED_FILE = \"alchemy.run.ts\";\n/** A relative import specifier from `.prisma-composer/dev/alchemy.run.ts` to `target` (posix separators). */\nfunction relativeImportSpecifier(generatedDir, target) {\n\tconst rel = path.relative(generatedDir, target).split(path.sep).join(\"/\");\n\treturn rel.startsWith(\".\") ? rel : `./${rel}`;\n}\nfunction quote(value) {\n\treturn JSON.stringify(value);\n}\nfunction renderBundle(bundle) {\n\treturn `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;\n}\nfunction renderOptions(input) {\n\tconst lines = [];\n\tlines.push(` name: ${quote(input.name)},`);\n\tlines.push(\" bundles: {\");\n\tfor (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);\n\tlines.push(\" },\");\n\tconst unassembled = Object.keys(input.assembled.devServers);\n\tif (unassembled.length > 0) lines.push(` unassembled: [${unassembled.map(quote).join(\", \")}],`);\n\tlines.push(\" providers: localTargetProviders(resolved, containers, devDir),\");\n\tlines.push(\" state: devState(),\");\n\treturn lines.join(\"\\n\");\n}\n/** Renders the dev stack module's source (tests assert on it without touching disk). */\nfunction renderDevStackFile(input) {\n\tconst generatedDir = path.join(input.cwd, DEV_GENERATED_DIR);\n\tconst appImport = relativeImportSpecifier(generatedDir, input.entryPath);\n\tconst imports = [\n\t\t\"import * as path from 'node:path';\",\n\t\t\"import { deserializeContainers } from '@prisma/composer/config';\",\n\t\t\"import { lower } from '@prisma/composer/deploy';\",\n\t\t\"import { DEV_DIR, devState, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';\",\n\t\t`import prismaConfig from ${quote(relativeImportSpecifier(generatedDir, input.configFile))};`,\n\t\t`import app from ${quote(appImport)};`\n\t].join(\"\\n\");\n\treturn `// Generated by \\`prisma dev\\` — overwritten on every run; do not\n// edit by hand. Independently runnable from ${quote(input.cwd)} by the\n// command Composer starts, which a failed run prints:\n//\n// <node> <bin of the alchemy @prisma/composer depends on> deploy ${DEV_GENERATED_DIR}/${DEV_GENERATED_FILE} --yes --stage dev\n//\n// bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).\n${imports}\n\nconst config = prismaConfig.composer;\nif (config === undefined) {\n throw new Error(${quote(noComposerExportMessage(input.configFile))});\n}\n\nconst containers = deserializeContainers(config.extensions, process.env);\nconst resolved = await resolveLocalTargets(config);\nconst devDir = path.join(process.cwd(), DEV_DIR);\n\nexport default lower(app, config, {\n${renderOptions(input)}\n});\n`;\n}\n/** Writes the dev stack file, returning its absolute path. */\nfunction writeDevStackFile(input) {\n\tconst generatedDir = path.join(input.cwd, DEV_GENERATED_DIR);\n\tfs.mkdirSync(generatedDir, { recursive: true });\n\tconst filePath = path.join(generatedDir, DEV_GENERATED_FILE);\n\tfs.writeFileSync(filePath, renderDevStackFile(input));\n\treturn filePath;\n}\nconst DEV_STACK_RELATIVE_PATH = path.join(DEV_GENERATED_DIR, DEV_GENERATED_FILE);\n//#endregion\nexport { renderDevStackFile as n, writeDevStackFile as r, DEV_STACK_RELATIVE_PATH as t };\n\n//# sourceMappingURL=generate-dev-stack-CfneNj97.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;;AAE3B,SAAS,wBAAwB,cAAc,QAAQ;CAC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U,MAAM,wBAAwB,MAAM,UAAU,CAAC,EAAE;;;;;;;;EAQnE,cAAc,KAAK,EAAE;;;AAGvB;;AAEA,SAAS,kBAAkB,OAAO;CACjC,MAAM,eAAe,KAAK,KAAK,MAAM,KAAK,iBAAiB;CAC3D,GAAG,UAAU,cAAc,EAAE,WAAW,KAAK,CAAC;CAC9C,MAAM,WAAW,KAAK,KAAK,cAAc,kBAAkB;CAC3D,GAAG,cAAc,UAAU,mBAAmB,KAAK,CAAC;CACpD,OAAO;AACR;AACA,MAAM,0BAA0B,KAAK,KAAK,mBAAmB,kBAAkB"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { a as notOk, c as CliStructuredError, o as ok } from "./run-alchemy-Dl_MWw4g-DaWV9tkH.mjs";
|
|
2
|
+
import { n as resolveAppIdentity } from "./pipeline-BmWt-Nhb-Bos4TFXR.mjs";
|
|
3
|
+
import { t as validateEnvironmentName } from "./validate-environment-Y3kuF-NC-DvIK2JUY.mjs";
|
|
4
|
+
import "effect/Layer";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import "effect/Config";
|
|
8
|
+
import "@prisma/management-api-sdk";
|
|
9
|
+
import "effect/Redacted";
|
|
10
|
+
import * as Data from "effect/Data";
|
|
11
|
+
Context.Service()("PrismaComposerCredentials");
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/container-DkYGcPVk.mjs
|
|
14
|
+
/**
|
|
15
|
+
* The typed Prisma Management API client, built once from the resolved
|
|
16
|
+
* credentials. Providers yield this in their outer Effect and call it inside
|
|
17
|
+
* `reconcile` / `delete`.
|
|
18
|
+
*/
|
|
19
|
+
var ManagementClient = class extends Context.Service()("PrismaManagementClient") {};
|
|
20
|
+
/** A non-2xx response from the Management API (or a transport failure). */
|
|
21
|
+
var PrismaApiError = class extends Data.TaggedError("PrismaApiError") {};
|
|
22
|
+
const attempt = (f) => Effect.tryPromise({
|
|
23
|
+
try: f,
|
|
24
|
+
catch: (cause) => new PrismaApiError({
|
|
25
|
+
status: 0,
|
|
26
|
+
message: String(cause)
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
const fail = (r) => Effect.fail(new PrismaApiError({
|
|
30
|
+
status: r.response.status,
|
|
31
|
+
message: JSON.stringify(r.error)
|
|
32
|
+
}));
|
|
33
|
+
/** Unwrap `data`, failing on any API error. Preserves the SDK's response type. */
|
|
34
|
+
const call = (f) => attempt(f).pipe(Effect.flatMap((r) => r.error !== void 0 || r.data === void 0 ? fail(r) : Effect.succeed(r.data)));
|
|
35
|
+
/** Unwrap `data`, mapping a 404 to `undefined` (resource gone / not found). */
|
|
36
|
+
const 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)));
|
|
37
|
+
/** Far beyond any real collection size per listing; hitting it means the API's pagination is broken. */
|
|
38
|
+
const MAX_PAGES = 1e3;
|
|
39
|
+
const brokenPaginationError = (description, reason) => new PrismaApiError({
|
|
40
|
+
status: 0,
|
|
41
|
+
message: `listing ${description} ${reason} — the Management API pagination appears broken; refusing to continue with a possibly incomplete listing.`
|
|
42
|
+
});
|
|
43
|
+
/** {@link drivePages} in its most common shape: every page's rows, accumulated. */
|
|
44
|
+
const collectPages = (description, fetchPage) => Effect.gen(function* () {
|
|
45
|
+
const rows = [];
|
|
46
|
+
yield* drivePages(description, fetchPage, (data) => {
|
|
47
|
+
rows.push(...data);
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
return rows;
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Drives a cursor-paginated Management API listing with a guard against
|
|
54
|
+
* broken pagination: a cursor that does not advance, more pages reported
|
|
55
|
+
* without a cursor to fetch them with, or more than {@link MAX_PAGES} pages,
|
|
56
|
+
* FAILS instead of hanging forever or returning a listing known to be
|
|
57
|
+
* incomplete. `onPage` receives each page's rows as they arrive; returning
|
|
58
|
+
* `true` stops early (the caller found what it wanted).
|
|
59
|
+
*/
|
|
60
|
+
const drivePages = (description, fetchPage, onPage) => Effect.gen(function* () {
|
|
61
|
+
let cursor;
|
|
62
|
+
for (let pageCount = 0;; pageCount++) {
|
|
63
|
+
if (pageCount >= MAX_PAGES) return yield* Effect.fail(brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`));
|
|
64
|
+
const page = yield* fetchPage(cursor);
|
|
65
|
+
if (onPage(page.data)) return;
|
|
66
|
+
if (!page.pagination.hasMore) return;
|
|
67
|
+
const next = page.pagination.nextCursor;
|
|
68
|
+
if (next === null) return yield* Effect.fail(brokenPaginationError(description, "reported more pages but returned no cursor"));
|
|
69
|
+
if (next === cursor) return yield* Effect.fail(brokenPaginationError(description, "returned a non-advancing cursor"));
|
|
70
|
+
cursor = next;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
/** Raised with `ensure: false` when the app's Project (or a named environment's Branch) doesn't exist. */
|
|
74
|
+
var ContainerNotFoundError = class extends Data.TaggedError("ContainerNotFoundError") {};
|
|
75
|
+
/** The environment that maps to the Project's default Branch. */
|
|
76
|
+
const PRODUCTION_ENVIRONMENT = "production";
|
|
77
|
+
/** Whether `environment` maps to the Project's default Branch rather than a Branch of its own. */
|
|
78
|
+
function isProductionEnvironment(environment) {
|
|
79
|
+
return environment === PRODUCTION_ENVIRONMENT;
|
|
80
|
+
}
|
|
81
|
+
/** Raised when a name other than `production` resolves to the Project's default Branch, which would make it production under a second name. */
|
|
82
|
+
var DefaultBranchUnderAnotherNameError = class extends Data.TaggedError("DefaultBranchUnderAnotherNameError") {
|
|
83
|
+
get message() {
|
|
84
|
+
return `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.`;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const listAllProjects = (client) => collectPages("projects", (cursor) => call(() => client.GET("/v1/projects", { params: { query: cursor === void 0 ? {} : { cursor } } })));
|
|
88
|
+
/**
|
|
89
|
+
* Workspace ids circulate in two shapes: `wksp_`-prefixed and bare. Compare
|
|
90
|
+
* bare-to-bare so a `wksp_`-prefixed API id still matches a bare configured
|
|
91
|
+
* one (the same normalization `state/bootstrap.ts` applies to the same
|
|
92
|
+
* `/v1/projects` listing).
|
|
93
|
+
*/
|
|
94
|
+
const bareWorkspaceId = (id) => id.startsWith("wksp_") ? id.slice(5) : id;
|
|
95
|
+
/**
|
|
96
|
+
* Finds the app's Project by logical id or name in the workspace, creating
|
|
97
|
+
* one if absent. Logical id match (exact, workspace-unique) is preferred over
|
|
98
|
+
* display-name match (oldest-wins fallback for projects without a logical id).
|
|
99
|
+
* Creates one if none match, unless `ensure` is `false` (find-only —
|
|
100
|
+
* `destroy`), in which case an absent Project fails with
|
|
101
|
+
* `ContainerNotFoundError`. No ownership marker and no `--project` override
|
|
102
|
+
* (both deferred — see ADR-0019).
|
|
103
|
+
*/
|
|
104
|
+
const resolveProject = (client, workspaceId, appName, ensure, region) => Effect.gen(function* () {
|
|
105
|
+
const workspaceProjects = (yield* listAllProjects(client)).filter((p) => bareWorkspaceId(p.workspace.id) === bareWorkspaceId(workspaceId));
|
|
106
|
+
const logicalIdMatch = workspaceProjects.find((p) => p.logicalId != null && p.logicalId === appName);
|
|
107
|
+
if (logicalIdMatch !== void 0) return logicalIdMatch.id;
|
|
108
|
+
const nameMatch = workspaceProjects.filter((p) => p.name === appName).sort((a, b) => a.createdAt.localeCompare(b.createdAt))[0];
|
|
109
|
+
if (nameMatch !== void 0) return nameMatch.id;
|
|
110
|
+
if (!ensure) return yield* Effect.fail(new ContainerNotFoundError({ appName }));
|
|
111
|
+
if (region === void 0) return yield* Effect.fail(new PrismaApiError({
|
|
112
|
+
status: 0,
|
|
113
|
+
message: `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`
|
|
114
|
+
}));
|
|
115
|
+
return (yield* call(() => client.POST("/v1/projects", { body: {
|
|
116
|
+
name: appName,
|
|
117
|
+
workspaceId,
|
|
118
|
+
createDatabase: false,
|
|
119
|
+
logicalId: appName,
|
|
120
|
+
region
|
|
121
|
+
} })).pipe(Effect.catch((err) => err.status === 409 ? Effect.fail(new PrismaApiError({
|
|
122
|
+
status: 409,
|
|
123
|
+
message: "a project with this name already exists in the workspace; rename your Composer module or free the name."
|
|
124
|
+
})) : Effect.fail(err)))).data.id;
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* The project's implicit default Branch — every live Project owns exactly
|
|
128
|
+
* one (a platform invariant). The list endpoint has no `isDefault` filter,
|
|
129
|
+
* so this pages through the Branches (bounded — drivePages) and returns as
|
|
130
|
+
* soon as a page contains it. Never creates one: its absence means the
|
|
131
|
+
* platform's invariant is broken, which is not something a deploy can
|
|
132
|
+
* repair.
|
|
133
|
+
*/
|
|
134
|
+
const resolveDefaultBranchId = (client, projectId) => Effect.gen(function* () {
|
|
135
|
+
let found;
|
|
136
|
+
yield* drivePages(`branches of project ${projectId}`, (cursor) => call(() => client.GET("/v1/projects/{projectId}/branches", { params: {
|
|
137
|
+
path: { projectId },
|
|
138
|
+
query: cursor === void 0 ? {} : { cursor }
|
|
139
|
+
} })), (data) => {
|
|
140
|
+
found = data.find((b) => b.isDefault)?.id;
|
|
141
|
+
return found !== void 0;
|
|
142
|
+
});
|
|
143
|
+
if (found !== void 0) return found;
|
|
144
|
+
return yield* Effect.fail(new PrismaApiError({
|
|
145
|
+
status: 0,
|
|
146
|
+
message: `project ${projectId} has no default Branch — the platform guarantees every live Project owns one; contact support.`
|
|
147
|
+
}));
|
|
148
|
+
});
|
|
149
|
+
const findBranch = (client, projectId, gitName) => call(() => client.GET("/v1/projects/{projectId}/branches", { params: {
|
|
150
|
+
path: { projectId },
|
|
151
|
+
query: { gitName }
|
|
152
|
+
} })).pipe(Effect.map((page) => {
|
|
153
|
+
const branch = page.data[0];
|
|
154
|
+
return branch === void 0 ? void 0 : {
|
|
155
|
+
id: branch.id,
|
|
156
|
+
isDefault: branch.isDefault
|
|
157
|
+
};
|
|
158
|
+
}));
|
|
159
|
+
/**
|
|
160
|
+
* Finds the environment's Branch by its exact `gitName`, creating it if absent
|
|
161
|
+
* unless `ensure` is `false` (find-only — `destroy`), in which case an
|
|
162
|
+
* absent Branch fails with `ContainerNotFoundError`. A `gitName` that finds
|
|
163
|
+
* the default Branch fails with `DefaultBranchUnderAnotherNameError`. The Management API has
|
|
164
|
+
* no server-side "create-or-return" idempotency (`POST
|
|
165
|
+
* /v1/projects/:id/branches` 409s on a duplicate `gitName`, with no request
|
|
166
|
+
* field to make that a no-op), so idempotency is client-side: observe
|
|
167
|
+
* first, and on a racing 409 from create, re-observe rather than fail.
|
|
168
|
+
*/
|
|
169
|
+
const resolveBranch = (client, projectId, gitName, appName, ensure) => Effect.gen(function* () {
|
|
170
|
+
const existing = yield* findBranch(client, projectId, gitName);
|
|
171
|
+
if (existing !== void 0) return yield* refuseDefaultBranch(existing, gitName);
|
|
172
|
+
if (!ensure) return yield* Effect.fail(new ContainerNotFoundError({
|
|
173
|
+
appName,
|
|
174
|
+
environment: gitName
|
|
175
|
+
}));
|
|
176
|
+
return yield* call(() => client.POST("/v1/projects/{projectId}/branches", {
|
|
177
|
+
params: { path: { projectId } },
|
|
178
|
+
body: { gitName }
|
|
179
|
+
})).pipe(Effect.map((r) => r.data.id), Effect.catch((err) => err.status === 409 ? Effect.gen(function* () {
|
|
180
|
+
const found = yield* findBranch(client, projectId, gitName);
|
|
181
|
+
if (found === void 0) return yield* Effect.fail(err);
|
|
182
|
+
return yield* refuseDefaultBranch(found, gitName);
|
|
183
|
+
}) : Effect.fail(err)));
|
|
184
|
+
});
|
|
185
|
+
const refuseDefaultBranch = (branch, gitName) => branch.isDefault === true ? Effect.fail(new DefaultBranchUnderAnotherNameError({
|
|
186
|
+
environment: gitName,
|
|
187
|
+
branchId: branch.id
|
|
188
|
+
})) : Effect.succeed(branch.id);
|
|
189
|
+
/**
|
|
190
|
+
* Resolves the two containers an environment's deploy runs into (ADR-0019):
|
|
191
|
+
* the app's **Project**, found-or-created by name, and its **Branch**. The
|
|
192
|
+
* environment `production` is the Project's default Branch, read into
|
|
193
|
+
* `defaultBranchId` and never created; `branchId` is omitted. Any other name
|
|
194
|
+
* is the Branch with that `gitName`, found-or-created into `branchId`. With
|
|
195
|
+
* `ensure: false` (`destroy`), nothing is created — an absent Project or
|
|
196
|
+
* Branch fails with `ContainerNotFoundError` instead.
|
|
197
|
+
*/
|
|
198
|
+
const resolveContainer = (opts) => Effect.gen(function* () {
|
|
199
|
+
const client = yield* ManagementClient;
|
|
200
|
+
const ensure = opts.ensure ?? true;
|
|
201
|
+
const projectId = yield* resolveProject(client, opts.workspaceId, opts.appName, ensure, opts.region);
|
|
202
|
+
if (isProductionEnvironment(opts.environment)) return {
|
|
203
|
+
projectId,
|
|
204
|
+
defaultBranchId: yield* resolveDefaultBranchId(client, projectId)
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
projectId,
|
|
208
|
+
branchId: yield* resolveBranch(client, projectId, opts.environment, opts.appName, ensure)
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/deployed.mjs
|
|
213
|
+
const program = (input) => Effect.gen(function* () {
|
|
214
|
+
const container = yield* resolveContainer({
|
|
215
|
+
workspaceId: input.workspaceId,
|
|
216
|
+
appName: input.appName,
|
|
217
|
+
ensure: false,
|
|
218
|
+
environment: input.environment
|
|
219
|
+
});
|
|
220
|
+
const { projectId } = container;
|
|
221
|
+
const branchId = container.branchId ?? container.defaultBranchId;
|
|
222
|
+
if (branchId === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`project ${projectId} resolved no Branch`));
|
|
223
|
+
const client = yield* ManagementClient;
|
|
224
|
+
const topology = yield* callOptional(() => client.GET("/v1/projects/{projectId}/branches/{branchId}/application-topology", { params: { path: {
|
|
225
|
+
projectId,
|
|
226
|
+
branchId
|
|
227
|
+
} } }));
|
|
228
|
+
if (topology === void 0 || topology.data.nodes.length === 0) return {
|
|
229
|
+
projectId,
|
|
230
|
+
branchId,
|
|
231
|
+
nodes: [],
|
|
232
|
+
services: [],
|
|
233
|
+
databases: [],
|
|
234
|
+
buckets: []
|
|
235
|
+
};
|
|
236
|
+
const query = (cursor) => cursor === void 0 ? {
|
|
237
|
+
projectId,
|
|
238
|
+
branchId
|
|
239
|
+
} : {
|
|
240
|
+
projectId,
|
|
241
|
+
branchId,
|
|
242
|
+
cursor
|
|
243
|
+
};
|
|
244
|
+
const services = yield* collectPages(`services of branch ${branchId}`, (cursor) => call(() => client.GET("/v1/services", { params: { query: query(cursor) } })));
|
|
245
|
+
const databases = yield* collectPages(`databases of branch ${branchId}`, (cursor) => call(() => client.GET("/v1/databases", { params: { query: query(cursor) } })));
|
|
246
|
+
const buckets = yield* collectPages(`buckets of branch ${branchId}`, (cursor) => call(() => client.GET("/v1/buckets", { params: { query: query(cursor) } })));
|
|
247
|
+
return {
|
|
248
|
+
projectId,
|
|
249
|
+
branchId,
|
|
250
|
+
nodes: topology.data.nodes.map(({ logicalId, parentLogicalId, kind, type }) => ({
|
|
251
|
+
logicalId,
|
|
252
|
+
parentLogicalId,
|
|
253
|
+
kind,
|
|
254
|
+
...type === void 0 ? {} : { type }
|
|
255
|
+
})),
|
|
256
|
+
services: services.map(({ id, logicalId, appEndpointDomain }) => ({
|
|
257
|
+
id,
|
|
258
|
+
logicalId,
|
|
259
|
+
appEndpointDomain
|
|
260
|
+
})),
|
|
261
|
+
databases: databases.map(({ id, logicalId }) => ({
|
|
262
|
+
id,
|
|
263
|
+
logicalId
|
|
264
|
+
})),
|
|
265
|
+
buckets: buckets.map(({ id, logicalId }) => ({
|
|
266
|
+
id,
|
|
267
|
+
logicalId
|
|
268
|
+
}))
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
/**
|
|
272
|
+
* Reads what an environment has deployed: its Project and Branch by the same
|
|
273
|
+
* find-only lookup `destroy` uses, the application topology the last deploy
|
|
274
|
+
* wrote, and the Branch's services, databases and buckets. `undefined` when
|
|
275
|
+
* there is no Project or no Branch. Rejects on any other Management API
|
|
276
|
+
* failure.
|
|
277
|
+
*/
|
|
278
|
+
async function readDeployedEnvironment(client, input) {
|
|
279
|
+
return 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)));
|
|
280
|
+
}
|
|
281
|
+
/** The platform row each Prisma Cloud resource type deploys to. A type missing here, such as an S3 credentials resource, has no row. */
|
|
282
|
+
const RESOURCE_ROW_KINDS = /* @__PURE__ */ new Map([
|
|
283
|
+
["postgres", "database"],
|
|
284
|
+
["raw-postgres", "database"],
|
|
285
|
+
["s3", "bucket"]
|
|
286
|
+
]);
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/family/deployed-nodes.ts
|
|
289
|
+
function kindOf(node) {
|
|
290
|
+
if (node.parentLogicalId === null) return "project";
|
|
291
|
+
if (node.kind === "resource") {
|
|
292
|
+
if (node.type === void 0) return "resource";
|
|
293
|
+
const rowKind = RESOURCE_ROW_KINDS.get(node.type);
|
|
294
|
+
if (rowKind === "database") return "postgres";
|
|
295
|
+
return rowKind ?? node.type;
|
|
296
|
+
}
|
|
297
|
+
return node.kind;
|
|
298
|
+
}
|
|
299
|
+
function rowId(rows, logicalId) {
|
|
300
|
+
return rows.find((row) => row.logicalId === logicalId)?.id ?? null;
|
|
301
|
+
}
|
|
302
|
+
function deployedNode(deployed, node) {
|
|
303
|
+
const kind = kindOf(node);
|
|
304
|
+
const address = node.logicalId;
|
|
305
|
+
switch (kind) {
|
|
306
|
+
case "project": return {
|
|
307
|
+
address,
|
|
308
|
+
kind,
|
|
309
|
+
platformId: deployed.projectId,
|
|
310
|
+
url: null
|
|
311
|
+
};
|
|
312
|
+
case "service": {
|
|
313
|
+
const row = deployed.services.find((service) => service.logicalId === address);
|
|
314
|
+
return {
|
|
315
|
+
address,
|
|
316
|
+
kind,
|
|
317
|
+
platformId: row?.id ?? null,
|
|
318
|
+
url: row?.appEndpointDomain ?? null
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
case "postgres": return {
|
|
322
|
+
address,
|
|
323
|
+
kind,
|
|
324
|
+
platformId: rowId(deployed.databases, address),
|
|
325
|
+
url: null
|
|
326
|
+
};
|
|
327
|
+
case "bucket": return {
|
|
328
|
+
address,
|
|
329
|
+
kind,
|
|
330
|
+
platformId: rowId(deployed.buckets, address),
|
|
331
|
+
url: null
|
|
332
|
+
};
|
|
333
|
+
default: return {
|
|
334
|
+
address,
|
|
335
|
+
kind,
|
|
336
|
+
platformId: null,
|
|
337
|
+
url: null
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/** 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. */
|
|
342
|
+
function deployedNodes(deployed) {
|
|
343
|
+
return deployed.nodes.map((node) => deployedNode(deployed, node));
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/family/list-deployed.ts
|
|
347
|
+
function notFound(app, environment) {
|
|
348
|
+
return new CliStructuredError("DEPLOY.TARGET_NOT_FOUND", `Nothing deployed for ${app} in the environment ${environment}.`, { fix: "Deploy it first." });
|
|
349
|
+
}
|
|
350
|
+
function lookupFailed(error) {
|
|
351
|
+
return new CliStructuredError("DEPLOY.CONTAINER_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
|
|
352
|
+
}
|
|
353
|
+
/** Every node the app has deployed in the environment, or `DEPLOY.TARGET_NOT_FOUND` when the environment has no Project, Branch or topology. */
|
|
354
|
+
async function listDeployed(input) {
|
|
355
|
+
let app;
|
|
356
|
+
try {
|
|
357
|
+
validateEnvironmentName(input.environment);
|
|
358
|
+
app = (await resolveAppIdentity(input.entry, input.name, input.cwd, input.config)).name;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
361
|
+
throw error;
|
|
362
|
+
}
|
|
363
|
+
if (input.workspaceId === void 0) return notOk(lookupFailed(/* @__PURE__ */ new Error("environment variable PRISMA_WORKSPACE_ID is required.")));
|
|
364
|
+
let deployed;
|
|
365
|
+
try {
|
|
366
|
+
deployed = await readDeployedEnvironment(input.client, {
|
|
367
|
+
workspaceId: input.workspaceId,
|
|
368
|
+
appName: app,
|
|
369
|
+
environment: input.environment
|
|
370
|
+
});
|
|
371
|
+
} catch (error) {
|
|
372
|
+
return notOk(lookupFailed(error));
|
|
373
|
+
}
|
|
374
|
+
const nodes = deployed === void 0 ? [] : deployedNodes(deployed);
|
|
375
|
+
if (nodes.length === 0) return notOk(notFound(app, input.environment));
|
|
376
|
+
return ok(nodes);
|
|
377
|
+
}
|
|
378
|
+
//#endregion
|
|
379
|
+
export { listDeployed };
|
|
380
|
+
|
|
381
|
+
//# sourceMappingURL=list-deployed-Dba4D_0R.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-deployed-Dba4D_0R.mjs","names":[],"sources":["../../../1-prisma-cloud/0-lowering/lowering/dist/credentials-px7h4mUR.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/container-DkYGcPVk.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 * as Config from \"effect/Config\";\n//#region package.json\nvar version = \"0.35.0-dev.2\";\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 normalizeBaseUrl = (value) => Effect.try({\n\ttry: () => {\n\t\tconst url = new URL(value);\n\t\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") throw new Error(\"Prisma Management API URL must use HTTP or HTTPS.\");\n\t\tif (url.username.length > 0 || url.password.length > 0) throw new Error(\"Prisma Management API URL must not contain credentials.\");\n\t\tif (url.protocol === \"http:\" && !isLoopbackHost(url.hostname)) throw new Error(\"Prisma Management API URL must use HTTPS unless it targets a loopback host.\");\n\t\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\t\treturn url.origin;\n\t},\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 Management API origin every Prisma-Cloud client in this package uses —\n* Composer's own SDK client AND upstream alchemy's postgres providers resolve\n* it through this one function, so `PRISMA_API_URL` can never point them at\n* different hosts. Mirrors upstream alchemy's `PrismaEnvironment` resolution:\n* `PRISMA_API_URL`, then `PRISMA_MANAGEMENT_API_URL`, then the public origin,\n* normalized and validated identically.\n*/\nconst managementApiBaseUrl = (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//#endregion\nexport { managementApiBaseUrl as i, deploySourceHeaders as n, fromEnv as r, PrismaCredentials as t };\n\n//# sourceMappingURL=credentials-px7h4mUR.mjs.map","import { i as managementApiBaseUrl, n as deploySourceHeaders, t as PrismaCredentials } from \"./credentials-px7h4mUR.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* By default the base URL comes from `managementApiBaseUrl()` — the SAME\n* resolver upstream's providers use (see providers.ts), so `PRISMA_API_URL`\n* can never split the postgres family and the compute/bucket/state clients\n* across hosts. `apiOrigin` overrides it (tests point it at a fake).\n*/\nconst layer = (options) => Layer.effect(ManagementClient, Effect.gen(function* () {\n\tconst { token } = yield* PrismaCredentials;\n\tconst baseUrl = options?.apiOrigin ?? (yield* managementApiBaseUrl());\n\treturn createManagementApiClient({\n\t\ttoken: Redacted.value(token),\n\t\tbaseUrl,\n\t\theaders: deploySourceHeaders()\n\t});\n}));\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 };\n\n//# sourceMappingURL=container-DkYGcPVk.mjs.map","import { g as ManagementClient, h as callOptional, l as collectPages, p as call, s as resolveContainer } from \"./container-DkYGcPVk.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":";;;;;;;;;;AAYsC,QAAQ,QAAQ,CAAC,CAAC,2BAA2B;;;;;;;;ACCnF,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,IAA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 -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as CliStructuredError } from "./run-alchemy-Dl_MWw4g-DaWV9tkH.mjs";
|
|
2
2
|
import "effect/Layer";
|
|
3
3
|
import "alchemy/State/LocalState";
|
|
4
4
|
//#region ../../0-framework/1-core/core/dist/app-config-CGJHcFb-.mjs
|
|
@@ -45,4 +45,4 @@ async function resolveLocalTargets(config) {
|
|
|
45
45
|
//#endregion
|
|
46
46
|
export { DEV_DIR as n, resolveLocalTargets as t };
|
|
47
47
|
|
|
48
|
-
//# sourceMappingURL=local-target-
|
|
48
|
+
//# sourceMappingURL=local-target-CK8gvYV4.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-target-
|
|
1
|
+
{"version":3,"file":"local-target-CK8gvYV4.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/app-config-CGJHcFb-.mjs","../../../0-framework/1-core/core/dist/local-target.mjs"],"sourcesContent":["//#region src/control/app-config.ts\n/** `<cwd>/.prisma-composer/dev` — the dev instance's app-scoped state directory (ADR-0041, ADR-0004's tool-state rule). \"dev\" names the user-facing feature/dir (naming, operator 2026-07-23) — this constant's name and value are unchanged by the localTarget rename. */\nconst DEV_DIR = \".prisma-composer/dev\";\n/**\n* True when an extension only participates in assembly (every `nodes` entry\n* is `kind: 'build'`, and it declares none of `providers`/`application`/\n* `provisions`/`container`) — it owns no resources or services, so it has\n* nothing to emulate and is exempt from local-target-capability requirements\n* (ADR-0041). Shared by `localTargetProviders` and every local-target hook\n* iteration.\n*/\nfunction isBuildOnlyExtension(extension) {\n\treturn Object.values(extension.nodes).every((node) => node.kind === \"build\") && extension.providers === void 0 && extension.application === void 0 && extension.provisions === void 0 && extension.container === void 0;\n}\n/** Typed identity — exists so the `composer` section of `prisma.config.ts` gets checked against PrismaAppConfig where it is written. */\nfunction defineConfig(config) {\n\treturn config;\n}\n//#endregion\nexport { defineConfig as n, isBuildOnlyExtension as r, DEV_DIR as t };\n\n//# sourceMappingURL=app-config-CGJHcFb-.mjs.map","import { r as isBuildOnlyExtension, t as DEV_DIR } from \"./app-config-CGJHcFb-.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. The generated dev stack\n* module calls this once and threads the resolved map through every\n* subsequent hook, including `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). The generated dev stack module is this\n* aggregator's one caller, passing the result as `LowerOptions.providers`.\n*/\nfunction localTargetProviders(resolved, containers, devDir) {\n\tconst [first, ...rest] = [...resolved.entries()].map(([id, descriptor]) => descriptor.providers({\n\t\tcontainer: containers.get(id),\n\t\tdevDir\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, devState, localTargetProviders, resolveLocalTargets };\n\n//# sourceMappingURL=local-target.mjs.map"],"mappings":";;;;;AAEA,MAAM,UAAU;;;;;;;;;AAShB,SAAS,qBAAqB,WAAW;CACxC,OAAO,OAAO,OAAO,UAAU,KAAK,CAAC,CAAC,OAAO,SAAS,KAAK,SAAS,OAAO,KAAK,UAAU,cAAc,KAAK,KAAK,UAAU,gBAAgB,KAAK,KAAK,UAAU,eAAe,KAAK,KAAK,UAAU,cAAc,KAAK;AACvN;;;;ACPA,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"}
|