@prisma/composer 0.5.0 → 0.6.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-config-bsTo57A8-BfG21wAI.d.mts → app-config-CFsSXEVj-B242oUnm.d.mts} +7 -5
- package/dist/app-config-CFsSXEVj-B242oUnm.d.mts.map +1 -0
- package/dist/bin.mjs +11 -3274
- package/dist/bin.mjs.map +1 -1
- package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs +401 -0
- package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs.map +1 -0
- package/dist/config-ku5b_2YD.d.mts +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs +75 -0
- package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs.map +1 -0
- package/dist/control.d.mts +216 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +70 -0
- package/dist/control.mjs.map +1 -0
- package/dist/deploy-ku5b_2YD.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/deploy.mjs +312 -1
- package/dist/deploy.mjs.map +1 -0
- package/dist/deployment-summary-r47O6kFr-CcMYVOn5.mjs +70 -0
- package/dist/deployment-summary-r47O6kFr-CcMYVOn5.mjs.map +1 -0
- package/dist/{dist-BdvFDCLV.mjs → dist-C5rZnr4n.mjs} +2 -2
- package/dist/{dist-BdvFDCLV.mjs.map → dist-C5rZnr4n.mjs.map} +1 -1
- package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs +24 -0
- package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs.map +1 -0
- package/dist/errors-0e8IVwzi.mjs +88 -0
- package/dist/errors-0e8IVwzi.mjs.map +1 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs +306 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs.map +1 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs +265 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs.map +1 -0
- package/dist/execute-dev-DLYyduEM-88uyvrbj.mjs +2009 -0
- package/dist/execute-dev-DLYyduEM-88uyvrbj.mjs.map +1 -0
- package/dist/execute-dev-DLYyduEM-BuUGTm0g.mjs +2006 -0
- package/dist/execute-dev-DLYyduEM-BuUGTm0g.mjs.map +1 -0
- package/dist/execute-log-VIOL4DBz-DBPH8By4.mjs +157 -0
- package/dist/execute-log-VIOL4DBz-DBPH8By4.mjs.map +1 -0
- package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs +155 -0
- package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs.map +1 -0
- package/dist/{graph-DgbALPDo-BEHF94BN.mjs → graph-BJgUfGB0-kvgFzT4q.mjs} +13 -7
- package/dist/graph-BJgUfGB0-kvgFzT4q.mjs.map +1 -0
- package/dist/{graph-DDpXh7S8-b-93BcHn.d.mts → graph-DqklX5Sf-BNS2aO1j.d.mts} +3 -3
- package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts.map +1 -0
- package/dist/{graph-types-C3FOaaXm-C6_rGzfn.d.mts → graph-types-N6brq1zY-1VMNwtkJ.d.mts} +88 -5
- package/dist/graph-types-N6brq1zY-1VMNwtkJ.d.mts.map +1 -0
- package/dist/{index-BQVrMGfe.d.mts → index-DryPyF9U.d.mts} +3 -3
- package/dist/{index-BQVrMGfe.d.mts.map → index-DryPyF9U.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/internal-error-BIc-ehme-Ck_lgxD_.mjs +18 -0
- package/dist/internal-error-BIc-ehme-Ck_lgxD_.mjs.map +1 -0
- package/dist/local-target-DnA2E8IN.mjs +47 -0
- package/dist/local-target-DnA2E8IN.mjs.map +1 -0
- package/dist/local-target-DuSyWeYc.mjs +68 -0
- package/dist/local-target-DuSyWeYc.mjs.map +1 -0
- package/dist/local-target.d.mts +1 -1
- package/dist/local-target.mjs +2 -46
- package/dist/{nextjs-DLyeRR7M-D47aMmfr.d.mts → nextjs-DLyeRR7M-DZODs9tk.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-D47aMmfr.d.mts.map → nextjs-DLyeRR7M-DZODs9tk.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/pipeline-D3QoVzAB-Ci2aJ2mE.mjs +331 -0
- package/dist/pipeline-D3QoVzAB-Ci2aJ2mE.mjs.map +1 -0
- package/dist/pipeline-D3QoVzAB-D_ufjg3N.mjs +857 -0
- package/dist/pipeline-D3QoVzAB-D_ufjg3N.mjs.map +1 -0
- package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs +30 -0
- package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs.map +1 -0
- package/dist/report.d.mts +4 -3
- package/dist/report.d.mts.map +1 -1
- package/dist/report.mjs +4 -1
- package/dist/report.mjs.map +1 -1
- package/dist/result-CFqJKiqg.mjs +106 -0
- package/dist/result-CFqJKiqg.mjs.map +1 -0
- package/dist/result-CzGChwbZ.mjs +231 -0
- package/dist/result-CzGChwbZ.mjs.map +1 -0
- package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs +48 -0
- package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs.map +1 -0
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/shared-CCaR42wo-BvegvmA_.mjs +265 -0
- package/dist/shared-CCaR42wo-BvegvmA_.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/package.json +15 -14
- package/src/exports/control.ts +1 -0
- package/dist/app-config-bsTo57A8-BfG21wAI.d.mts.map +0 -1
- package/dist/config-DUzvB5cQ.d.mts +0 -1
- package/dist/deploy-C4DxNkJ9-D73lmBqy.mjs +0 -313
- package/dist/deploy-C4DxNkJ9-D73lmBqy.mjs.map +0 -1
- package/dist/deploy-DUzvB5cQ.d.mts +0 -1
- package/dist/graph-DDpXh7S8-b-93BcHn.d.mts.map +0 -1
- package/dist/graph-DgbALPDo-BEHF94BN.mjs.map +0 -1
- package/dist/graph-types-C3FOaaXm-C6_rGzfn.d.mts.map +0 -1
- package/dist/local-target.mjs.map +0 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { dt as CliStructuredError } from "./graph-types-N6brq1zY-1VMNwtkJ.mjs";
|
|
2
|
+
import { l as DeployedEntity } from "./app-config-CFsSXEVj-B242oUnm.mjs";
|
|
3
|
+
import "./config-ku5b_2YD.mjs";
|
|
4
|
+
import "./index-DryPyF9U.mjs";
|
|
5
|
+
import "./deploy-ku5b_2YD.mjs";
|
|
6
|
+
//#region ../../0-framework/3-tooling/cli/dist/load-entry-BS8rSRif.d.mts
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/operations/shared.d.ts
|
|
9
|
+
/** A running service's dotted address plus its local URL — what `dev` reports
|
|
10
|
+
* as the front door and `log` reports as the tailable services. */
|
|
11
|
+
interface ServiceEndpoint {
|
|
12
|
+
readonly address: string;
|
|
13
|
+
readonly url: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Where a failed execution left its artifacts — details of the CURRENT
|
|
17
|
+
* execution mechanism (a spawned deploy-engine child driving a generated
|
|
18
|
+
* stack file), for hosts that want to print a reproduce hint. The mechanism
|
|
19
|
+
* is not part of the surface's contract, so these fields may change or
|
|
20
|
+
* disappear if the mechanism does; branch on `code`/`message`/`cause` for
|
|
21
|
+
* anything durable.
|
|
22
|
+
*/
|
|
23
|
+
interface ExecutionDiagnostics {
|
|
24
|
+
/** The child's exit status; undefined means the spawn itself threw. */
|
|
25
|
+
readonly exitCode: number | undefined;
|
|
26
|
+
readonly stackFilePath: string;
|
|
27
|
+
readonly reproduceCommand: string;
|
|
28
|
+
readonly cwd: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reads the execution diagnostics an engine-failure error carries in
|
|
32
|
+
* `meta.diagnostics`; undefined for every other failure.
|
|
33
|
+
*/
|
|
34
|
+
declare function executionDiagnostics(f: CliStructuredError): ExecutionDiagnostics | undefined;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../0-framework/0-foundation/foundation/dist/result.d.mts
|
|
37
|
+
//#region src/result.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* Represents a successful result containing a value.
|
|
40
|
+
*/
|
|
41
|
+
interface Ok<T> {
|
|
42
|
+
readonly ok: true;
|
|
43
|
+
readonly value: T;
|
|
44
|
+
assertOk(): T;
|
|
45
|
+
assertNotOk(): never;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents an unsuccessful result containing failure details.
|
|
49
|
+
*/
|
|
50
|
+
interface NotOk<F> {
|
|
51
|
+
readonly ok: false;
|
|
52
|
+
readonly failure: F;
|
|
53
|
+
assertOk(): never;
|
|
54
|
+
assertNotOk(): F;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A discriminated union representing either success (Ok) or failure (NotOk).
|
|
58
|
+
*
|
|
59
|
+
* @typeParam T - The success value type
|
|
60
|
+
* @typeParam F - The failure details type
|
|
61
|
+
*/
|
|
62
|
+
type Result<T, F> = Ok<T> | NotOk<F>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../../0-framework/3-tooling/cli/dist/control.d.mts
|
|
65
|
+
//#region src/deployment-summary.d.ts
|
|
66
|
+
/** The serializable projection of DeploymentResult — what CAN cross the process
|
|
67
|
+
* boundary. Writer (report hook) and reader (deploy operation) share this shape. */
|
|
68
|
+
interface DeployedNodeSummary {
|
|
69
|
+
readonly address: string;
|
|
70
|
+
readonly entities: readonly DeployedEntity[];
|
|
71
|
+
}
|
|
72
|
+
interface DeploymentSummary {
|
|
73
|
+
readonly app: string;
|
|
74
|
+
readonly nodes: readonly DeployedNodeSummary[];
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/operations/deploy.d.ts
|
|
78
|
+
interface DeployInput {
|
|
79
|
+
/** Path to the entry module, resolved against `cwd` — same contract as `prisma-composer deploy <entry>`. */
|
|
80
|
+
readonly entry: string;
|
|
81
|
+
/** Override the root node's name (the `--name` flag's slot). */
|
|
82
|
+
readonly name?: string | undefined;
|
|
83
|
+
/** Target stage. ABSENT = production — bare deploy targets production (main.ts effectiveStage). */
|
|
84
|
+
readonly stage?: string | undefined;
|
|
85
|
+
/** Defaults to process.cwd(); the directory `.prisma-composer/` and `.alchemy` state live under. */
|
|
86
|
+
readonly cwd?: string | undefined;
|
|
87
|
+
}
|
|
88
|
+
interface DeploySuccess {
|
|
89
|
+
/** Parsed from the alchemy child's result file. Undefined when the child
|
|
90
|
+
* did not write one (injected fake alchemy, or a report-less apply). */
|
|
91
|
+
readonly summary: DeploymentSummary | undefined;
|
|
92
|
+
}
|
|
93
|
+
declare function deploy(input: DeployInput): Promise<Result<DeploySuccess, CliStructuredError>>;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/operations/destroy.d.ts
|
|
96
|
+
/** Destroy must name its target explicitly — no silent default to production. Encoded, not re-derived from flags. */
|
|
97
|
+
type DestroyTarget = {
|
|
98
|
+
readonly kind: 'production';
|
|
99
|
+
} | {
|
|
100
|
+
readonly kind: 'stage';
|
|
101
|
+
readonly stage: string;
|
|
102
|
+
};
|
|
103
|
+
type DestroyEvent =
|
|
104
|
+
/** Emitted before the pipeline when `<cwd>/.alchemy` is missing/empty. */
|
|
105
|
+
{
|
|
106
|
+
readonly kind: 'no-local-deploy-state';
|
|
107
|
+
readonly cwd: string;
|
|
108
|
+
};
|
|
109
|
+
interface DestroyInput {
|
|
110
|
+
readonly entry: string;
|
|
111
|
+
readonly name?: string | undefined;
|
|
112
|
+
readonly target: DestroyTarget;
|
|
113
|
+
readonly cwd?: string | undefined;
|
|
114
|
+
/** Mid-operation notifications, in real time. Rendering is the host's. */
|
|
115
|
+
readonly onEvent?: ((event: DestroyEvent) => void) | undefined;
|
|
116
|
+
}
|
|
117
|
+
declare function destroy(input: DestroyInput): Promise<Result<void, CliStructuredError>>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/operations/dev.d.ts
|
|
120
|
+
type DevEvent =
|
|
121
|
+
/** Initial front door + after each successful re-converge. */
|
|
122
|
+
{
|
|
123
|
+
readonly kind: 'ready';
|
|
124
|
+
readonly endpoints: readonly ServiceEndpoint[];
|
|
125
|
+
} | {
|
|
126
|
+
readonly kind: 'unwatchable';
|
|
127
|
+
readonly address: string;
|
|
128
|
+
} | {
|
|
129
|
+
readonly kind: 'rebuild-failed';
|
|
130
|
+
readonly message: string;
|
|
131
|
+
} |
|
|
132
|
+
/** The file watcher itself errored (EMFILE, a vanished directory); the session keeps running. */
|
|
133
|
+
{
|
|
134
|
+
readonly kind: 'watch-error';
|
|
135
|
+
readonly message: string;
|
|
136
|
+
} |
|
|
137
|
+
/** The app keeps running, still watching. */
|
|
138
|
+
{
|
|
139
|
+
readonly kind: 'converge-failed';
|
|
140
|
+
readonly stackFilePath: string;
|
|
141
|
+
readonly reproduceCommand: string;
|
|
142
|
+
readonly cwd: string;
|
|
143
|
+
} | {
|
|
144
|
+
readonly kind: 'stopping';
|
|
145
|
+
} |
|
|
146
|
+
/** One service refused to stop during stop(); teardown continues and `stopped` still follows. */
|
|
147
|
+
{
|
|
148
|
+
readonly kind: 'stop-error';
|
|
149
|
+
readonly message: string;
|
|
150
|
+
} | {
|
|
151
|
+
readonly kind: 'stopped';
|
|
152
|
+
};
|
|
153
|
+
interface DevInput {
|
|
154
|
+
readonly entry: string;
|
|
155
|
+
readonly name?: string | undefined;
|
|
156
|
+
readonly fresh?: boolean | undefined;
|
|
157
|
+
readonly cwd?: string | undefined;
|
|
158
|
+
readonly onEvent?: ((event: DevEvent) => void) | undefined;
|
|
159
|
+
}
|
|
160
|
+
/** A running dev session. The operation NEVER touches process signal handlers —
|
|
161
|
+
* the host owns signals (and must evict alchemy's import-time SIGINT/SIGTERM
|
|
162
|
+
* listeners before installing its own; see run-dev.ts). */
|
|
163
|
+
interface DevSession {
|
|
164
|
+
/** The initial front door, already merged across attachments. */
|
|
165
|
+
readonly endpoints: readonly ServiceEndpoint[];
|
|
166
|
+
/** Stop the watch loop and the app's services (emulators and data stay up).
|
|
167
|
+
* Idempotent; emits 'stopping'/'stopped'; resolves `closed`. */
|
|
168
|
+
stop(): Promise<void>;
|
|
169
|
+
/** Settles when the session has fully stopped (via stop()). */
|
|
170
|
+
readonly closed: Promise<void>;
|
|
171
|
+
}
|
|
172
|
+
declare function dev(input: DevInput): Promise<Result<DevSession, CliStructuredError>>;
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/operations/log.d.ts
|
|
175
|
+
interface LogLine {
|
|
176
|
+
readonly service: string;
|
|
177
|
+
readonly line: string;
|
|
178
|
+
}
|
|
179
|
+
type LogEvent =
|
|
180
|
+
/** One attachment's stream died; the others continue. */
|
|
181
|
+
{
|
|
182
|
+
readonly kind: 'stream-failed';
|
|
183
|
+
readonly message: string;
|
|
184
|
+
} |
|
|
185
|
+
/** The consumer fell behind and the bounded merge queue overflowed:
|
|
186
|
+
* `count` oldest lines were dropped since the last delivered line. */
|
|
187
|
+
{
|
|
188
|
+
readonly kind: 'lines-dropped';
|
|
189
|
+
readonly count: number;
|
|
190
|
+
};
|
|
191
|
+
interface LogInput {
|
|
192
|
+
readonly entry: string;
|
|
193
|
+
readonly name?: string | undefined;
|
|
194
|
+
/** Restrict to one service's dotted address; validated against running services. */
|
|
195
|
+
readonly address?: string | undefined;
|
|
196
|
+
/** Trailing history lines before live output. Defaults to 0 (live only) —
|
|
197
|
+
* the attachment contract's default; the CLI's user-facing default of 20 stays in main.ts. */
|
|
198
|
+
readonly tail?: number | undefined;
|
|
199
|
+
readonly cwd?: string | undefined;
|
|
200
|
+
/** Ends the stream when aborted. The host owns SIGINT/SIGTERM → abort. */
|
|
201
|
+
readonly signal?: AbortSignal | undefined;
|
|
202
|
+
readonly onEvent?: ((event: LogEvent) => void) | undefined;
|
|
203
|
+
}
|
|
204
|
+
interface LogAttached {
|
|
205
|
+
/** For the adapter's empty-services notice. */
|
|
206
|
+
readonly appName: string;
|
|
207
|
+
/** Every running service. EMPTY means nothing is running — a valid, non-failure state;
|
|
208
|
+
* `lines` is then an already-finished iterable. */
|
|
209
|
+
readonly services: readonly ServiceEndpoint[];
|
|
210
|
+
/** Merged, address-filtered stream; ends on signal abort or when every source ends. */
|
|
211
|
+
readonly lines: AsyncIterable<LogLine>;
|
|
212
|
+
}
|
|
213
|
+
declare function log(input: LogInput): Promise<Result<LogAttached, CliStructuredError>>;
|
|
214
|
+
//#endregion
|
|
215
|
+
export { type CliStructuredError, type DeployInput, type DeploySuccess, type DeployedNodeSummary, type DeploymentSummary, type DestroyEvent, type DestroyInput, type DestroyTarget, type DevEvent, type DevInput, type DevSession, type ExecutionDiagnostics, type LogAttached, type LogEvent, type LogInput, type LogLine, type NotOk, type Ok, type Result, type ServiceEndpoint, deploy, destroy, dev, executionDiagnostics, log };
|
|
216
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/load-entry-BS8rSRif.d.mts","../../../0-framework/0-foundation/foundation/dist/result.d.mts","../../../0-framework/3-tooling/cli/dist/control.d.mts"],"mappings":";;;;;;;;;;UAyBU;WACC;WACA;;;;;;;;;;UAqBD;;WAEC;WACA;WACA;WACA;;;;;;iBAMM,qBAAqB,GAAG,qBAAqB;;;;;;;UCvDpD,GAAG;WACF;WACA,OAAO;EAChB,YAAY;EACZ;;;;;UAKQ,MAAM;WACL;WACA,SAAS;EAClB;EACA,eAAe;;;;;;;;KAQZ,OAAO,GAAG,KAAK,GAAG,KAAK,MAAM;;;;;;UCfxB;WACC;WACA,mBAAmB;;UAEpB;WACC;WACA,gBAAgB;;;;UAIjB;;WAEC;;WAEA;;WAEA;;WAEA;;UAED;;;WAGC,SAAS;;iBAEH,OAAO,OAAO,cAAc,QAAQ,OAAS,eAAe;;;;KAIxE;WACM;;WAEA;WACA;;KAEN;;;WAGM;WACA;;UAED;WACC;WACA;WACA,QAAQ;WACR;;WAEA,YAAY,OAAO;;iBAEb,QAAQ,OAAO,eAAe,QAAQ,aAAe;;;KAGjE;;;WAGM;WACA,oBAAoB;;WAEpB;WACA;;WAEA;WACA;;;;WAIA;WACA;;;;WAIA;WACA;WACA;WACA;;WAEA;;;;WAIA;WACA;;WAEA;;UAED;WACC;WACA;WACA;WACA;WACA,YAAY,OAAO;;;;;UAKpB;;WAEC,oBAAoB;;;EAG7B,QAAQ;;WAEC,QAAQ;;iBAEF,IAAI,OAAO,WAAW,QAAQ,OAAS,YAAY;;;UAG1D;WACC;WACA;;KAEN;;;WAGM;WACA;;;;;WAKA;WACA;;UAED;WACC;WACA;;WAEA;;;WAGA;WACA;;WAEA,SAAS;WACT,YAAY,OAAO;;UAEpB;;WAEC;;;WAGA,mBAAmB;;WAEnB,OAAO,cAAc;;iBAEf,IAAI,OAAO,WAAW,QAAQ,OAAS,aAAa"}
|
package/dist/control.mjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { a as executorLoadFailure, i as executionDiagnostics, t as notOk } from "./result-CzGChwbZ.mjs";
|
|
2
|
+
//#region ../../0-framework/3-tooling/cli/dist/destroy-DPAo6kVj.mjs
|
|
3
|
+
async function dev(input) {
|
|
4
|
+
return devWithDeps(input, {});
|
|
5
|
+
}
|
|
6
|
+
/** In-package variant threading the injection seam (the CLI's RunDeps, unit
|
|
7
|
+
* tests). Deliberately NOT re-exported through `./control` — the seam mirrors
|
|
8
|
+
* internal types and is not part of the published surface. */
|
|
9
|
+
async function devWithDeps(input, deps) {
|
|
10
|
+
const cwd = input.cwd ?? process.cwd();
|
|
11
|
+
let executor;
|
|
12
|
+
try {
|
|
13
|
+
executor = await import("./execute-dev-DLYyduEM-88uyvrbj.mjs");
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return notOk(executorLoadFailure("dev", error, cwd));
|
|
16
|
+
}
|
|
17
|
+
return executor.executeDev(input, deps, cwd);
|
|
18
|
+
}
|
|
19
|
+
async function log(input) {
|
|
20
|
+
return logWithDeps(input, {});
|
|
21
|
+
}
|
|
22
|
+
/** In-package variant threading the injection seam (the CLI's LogRunDeps,
|
|
23
|
+
* unit tests). Deliberately NOT re-exported through `./control` — the seam
|
|
24
|
+
* mirrors internal types and is not part of the published surface. */
|
|
25
|
+
async function logWithDeps(input, deps) {
|
|
26
|
+
const cwd = input.cwd ?? process.cwd();
|
|
27
|
+
let executor;
|
|
28
|
+
try {
|
|
29
|
+
executor = await import("./execute-log-VIOL4DBz-DBPH8By4.mjs");
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return notOk(executorLoadFailure("log", error, cwd));
|
|
32
|
+
}
|
|
33
|
+
return executor.executeLog(input, deps, cwd);
|
|
34
|
+
}
|
|
35
|
+
async function deploy(input) {
|
|
36
|
+
return deployWithDeps(input, {});
|
|
37
|
+
}
|
|
38
|
+
/** In-package variant threading the injection seam (the CLI's RunDeps, unit
|
|
39
|
+
* tests). Deliberately NOT re-exported through `./control` — the seam mirrors
|
|
40
|
+
* internal types and is not part of the published surface. */
|
|
41
|
+
async function deployWithDeps(input, deps) {
|
|
42
|
+
const cwd = input.cwd ?? process.cwd();
|
|
43
|
+
let executor;
|
|
44
|
+
try {
|
|
45
|
+
executor = await import("./execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs");
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return notOk(executorLoadFailure("deploy", error, cwd));
|
|
48
|
+
}
|
|
49
|
+
return executor.executeDeploy(input, deps, cwd);
|
|
50
|
+
}
|
|
51
|
+
async function destroy(input) {
|
|
52
|
+
return destroyWithDeps(input, {});
|
|
53
|
+
}
|
|
54
|
+
/** In-package variant threading the injection seam (the CLI's RunDeps, unit
|
|
55
|
+
* tests). Deliberately NOT re-exported through `./control` — the seam mirrors
|
|
56
|
+
* internal types and is not part of the published surface. */
|
|
57
|
+
async function destroyWithDeps(input, deps) {
|
|
58
|
+
const cwd = input.cwd ?? process.cwd();
|
|
59
|
+
let executor;
|
|
60
|
+
try {
|
|
61
|
+
executor = await import("./execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs");
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return notOk(executorLoadFailure("destroy", error, cwd));
|
|
64
|
+
}
|
|
65
|
+
return executor.executeDestroy(input, deps, cwd);
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { deploy, destroy, dev, executionDiagnostics, log };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/destroy-DPAo6kVj.mjs"],"sourcesContent":["import { n as executorLoadFailure } from \"./shared-CCaR42wo.mjs\";\nimport { notOk } from \"@internal/foundation/result\";\n//#region src/operations/dev.ts\nasync function dev(input) {\n\treturn devWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's RunDeps, unit\n* tests). Deliberately NOT re-exported through `./control` — the seam mirrors\n* internal types and is not part of the published surface. */\nasync function devWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-dev-DLYyduEM.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"dev\", error, cwd));\n\t}\n\treturn executor.executeDev(input, deps, cwd);\n}\n//#endregion\n//#region src/operations/log.ts\nasync function log(input) {\n\treturn logWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's LogRunDeps,\n* unit tests). Deliberately NOT re-exported through `./control` — the seam\n* mirrors internal types and is not part of the published surface. */\nasync function logWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-log-VIOL4DBz.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"log\", error, cwd));\n\t}\n\treturn executor.executeLog(input, deps, cwd);\n}\n//#endregion\n//#region src/operations/deploy.ts\nasync function deploy(input) {\n\treturn deployWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's RunDeps, unit\n* tests). Deliberately NOT re-exported through `./control` — the seam mirrors\n* internal types and is not part of the published surface. */\nasync function deployWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-deploy-destroy-IT4vGkMc.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"deploy\", error, cwd));\n\t}\n\treturn executor.executeDeploy(input, deps, cwd);\n}\n//#endregion\n//#region src/operations/destroy.ts\nasync function destroy(input) {\n\treturn destroyWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's RunDeps, unit\n* tests). Deliberately NOT re-exported through `./control` — the seam mirrors\n* internal types and is not part of the published surface. */\nasync function destroyWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-deploy-destroy-IT4vGkMc.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"destroy\", error, cwd));\n\t}\n\treturn executor.executeDestroy(input, deps, cwd);\n}\n//#endregion\nexport { log as a, devWithDeps as c, deployWithDeps as i, destroyWithDeps as n, logWithDeps as o, deploy as r, dev as s, destroy as t };\n\n//# sourceMappingURL=destroy-DPAo6kVj.mjs.map"],"mappings":";;AAGA,eAAe,IAAI,OAAO;CACzB,OAAO,YAAY,OAAO,CAAC,CAAC;AAC7B;;;;AAIA,eAAe,YAAY,OAAO,MAAM;CACvC,MAAM,MAAM,MAAM,OAAO,QAAQ,IAAI;CACrC,IAAI;CACJ,IAAI;EACH,WAAW,MAAM,OAAO;CACzB,SAAS,OAAO;EACf,OAAO,MAAM,oBAAoB,OAAO,OAAO,GAAG,CAAC;CACpD;CACA,OAAO,SAAS,WAAW,OAAO,MAAM,GAAG;AAC5C;AAGA,eAAe,IAAI,OAAO;CACzB,OAAO,YAAY,OAAO,CAAC,CAAC;AAC7B;;;;AAIA,eAAe,YAAY,OAAO,MAAM;CACvC,MAAM,MAAM,MAAM,OAAO,QAAQ,IAAI;CACrC,IAAI;CACJ,IAAI;EACH,WAAW,MAAM,OAAO;CACzB,SAAS,OAAO;EACf,OAAO,MAAM,oBAAoB,OAAO,OAAO,GAAG,CAAC;CACpD;CACA,OAAO,SAAS,WAAW,OAAO,MAAM,GAAG;AAC5C;AAGA,eAAe,OAAO,OAAO;CAC5B,OAAO,eAAe,OAAO,CAAC,CAAC;AAChC;;;;AAIA,eAAe,eAAe,OAAO,MAAM;CAC1C,MAAM,MAAM,MAAM,OAAO,QAAQ,IAAI;CACrC,IAAI;CACJ,IAAI;EACH,WAAW,MAAM,OAAO;CACzB,SAAS,OAAO;EACf,OAAO,MAAM,oBAAoB,UAAU,OAAO,GAAG,CAAC;CACvD;CACA,OAAO,SAAS,cAAc,OAAO,MAAM,GAAG;AAC/C;AAGA,eAAe,QAAQ,OAAO;CAC7B,OAAO,gBAAgB,OAAO,CAAC,CAAC;AACjC;;;;AAIA,eAAe,gBAAgB,OAAO,MAAM;CAC3C,MAAM,MAAM,MAAM,OAAO,QAAQ,IAAI;CACrC,IAAI;CACJ,IAAI;EACH,WAAW,MAAM,OAAO;CACzB,SAAS,OAAO;EACf,OAAO,MAAM,oBAAoB,WAAW,OAAO,GAAG,CAAC;CACxD;CACA,OAAO,SAAS,eAAe,OAAO,MAAM,GAAG;AAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./app-config-CFsSXEVj-B242oUnm.mjs";
|
package/dist/deploy.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as ProvisionerDescriptor, B as joinDeployment, C as Lowering, E as PackageInput, H as lowering, P as buildConfig, S as LoweredResult, T as Outputs, U as mergedProviders, V as lower, W as resolveStateLayer, a as Bundle, b as LowerError, d as DeploymentResult, i as AssembleInput, j as ServiceLowering, k as ProvisionEdge, l as DeployedEntity, n as ApplicationDescriptor, r as Artifact, t as AlchemyStateLayer, u as DeployedNode, x as LowerOptions, y as LowerContext } from "./app-config-
|
|
2
|
-
import "./deploy-
|
|
1
|
+
import { A as ProvisionerDescriptor, B as joinDeployment, C as Lowering, E as PackageInput, H as lowering, P as buildConfig, S as LoweredResult, T as Outputs, U as mergedProviders, V as lower, W as resolveStateLayer, a as Bundle, b as LowerError, d as DeploymentResult, i as AssembleInput, j as ServiceLowering, k as ProvisionEdge, l as DeployedEntity, n as ApplicationDescriptor, r as Artifact, t as AlchemyStateLayer, u as DeployedNode, x as LowerOptions, y as LowerContext } from "./app-config-CFsSXEVj-B242oUnm.mjs";
|
|
2
|
+
import "./deploy-ku5b_2YD.mjs";
|
|
3
3
|
export { AlchemyStateLayer, ApplicationDescriptor, Artifact, AssembleInput, Bundle, DeployedEntity, DeployedNode, DeploymentResult, LowerContext, LowerError, LowerOptions, LoweredResult, Lowering, Outputs, PackageInput, ProvisionEdge, ProvisionerDescriptor, ServiceLowering, buildConfig, joinDeployment, lower, lowering, mergedProviders, resolveStateLayer };
|
package/dist/deploy.mjs
CHANGED
|
@@ -1,2 +1,313 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as isParamSource, t as Load } from "./graph-BJgUfGB0-kvgFzT4q.mjs";
|
|
2
|
+
import { r as deserializeContainers } from "./container-transport-DKmKg5JQ-DKWs0ubK.mjs";
|
|
3
|
+
import * as Alchemy from "alchemy";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
//#region ../../0-framework/1-core/core/dist/deploy.mjs
|
|
7
|
+
var LowerError = class extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "LowerError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Resolves one SERVICE-OWN param to its config value. The full resolution
|
|
15
|
+
* order across both value channels:
|
|
16
|
+
*
|
|
17
|
+
* 1. A param claiming BOTH a provision-time binding and a `provision` need
|
|
18
|
+
* (ADR-0031) is a loud error — two sources for one value.
|
|
19
|
+
* 2. A provision-time binding (a schema-validated literal, or an opaque
|
|
20
|
+
* `ParamSource` the target resolves at boot per ADR-0019) beats the
|
|
21
|
+
* declared `default`.
|
|
22
|
+
* 3. A framework-minted `provision` need is resolved per dependency EDGE
|
|
23
|
+
* against the consumer extension's registry — that path fills CONNECTION
|
|
24
|
+
* params in `buildConfig`'s inputs loop, never this function. A
|
|
25
|
+
* service-own param has no edge to mint against, so an unbound need here
|
|
26
|
+
* falls through like any unbound param.
|
|
27
|
+
* 4. The `default`, else absent (only legal when `optional`), else a loud
|
|
28
|
+
* error naming the param, the service, and the fix.
|
|
29
|
+
*/
|
|
30
|
+
function resolveParam(node, serviceId, name, param, bound) {
|
|
31
|
+
if (bound !== void 0) {
|
|
32
|
+
if (param.provision !== void 0) throw new LowerError(`Param "${name}" of "${serviceId}" (service "${node.name}") has two sources claiming one value: a provision-time binding (${isParamSource(bound) ? "a param source" : "a literal value"}) AND a framework provision need ("${String(param.provision.brand)}") on its declaration — remove the binding or drop the \`provision\` facet.`);
|
|
33
|
+
if (isParamSource(bound)) return bound;
|
|
34
|
+
const result = param.schema["~standard"].validate(bound);
|
|
35
|
+
if (result instanceof Promise) throw new LowerError(`Param "${name}" of "${serviceId}" (service "${node.name}") uses an async Standard Schema — a provision-time literal value requires a synchronous validator.`);
|
|
36
|
+
if (result.issues !== void 0) {
|
|
37
|
+
const messages = result.issues.map((issue) => issue.message).join("; ");
|
|
38
|
+
throw new LowerError(`Param "${name}" of "${serviceId}" (service "${node.name}") received an invalid provision-time value: ${messages}`);
|
|
39
|
+
}
|
|
40
|
+
return result.value;
|
|
41
|
+
}
|
|
42
|
+
if (param.default !== void 0) return param.default;
|
|
43
|
+
if (param.optional === true) return void 0;
|
|
44
|
+
throw new LowerError(`Param "${name}" of "${serviceId}" (service "${node.name}") has no default, is not optional, and was not bound at provision — bind it with a literal value or a param source (e.g. envParam('NAME')) on its provision() call, or give it a default.`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Assembles a service's typed Config. Connection params come from the
|
|
48
|
+
* dependency edge's lowered outputs — or, for a param carrying a `provision`
|
|
49
|
+
* need (ADR-0031), from `provisioned` (keyed by edge id): the framework mints
|
|
50
|
+
* it, the producer hands nothing over. The service's own params resolve via
|
|
51
|
+
* `resolveParam` (provision-time binding, then default, then loud
|
|
52
|
+
* unbound-required failure).
|
|
53
|
+
*
|
|
54
|
+
* This is also where the connection contract is enforced: a producer that fails to
|
|
55
|
+
* supply a required param its consumer's connection declares fails the deploy
|
|
56
|
+
* here, naming the edge, rather than reaching the consumer as `undefined`.
|
|
57
|
+
*/
|
|
58
|
+
function buildConfig(node, id, graph, lowered, provisioned) {
|
|
59
|
+
const inputs = {};
|
|
60
|
+
for (const [inputName, inputNode] of Object.entries(node.inputs)) {
|
|
61
|
+
const edge = graph.edges.find((e) => e.to === id && e.input === inputName && e.kind === "dependency");
|
|
62
|
+
const producedOutputs = edge !== void 0 ? lowered.get(edge.from) ?? {} : {};
|
|
63
|
+
const values = {};
|
|
64
|
+
for (const [name, param] of Object.entries(inputNode.connection.params)) {
|
|
65
|
+
if (param.provision !== void 0) {
|
|
66
|
+
values[name] = provisioned.get(`${id}.${inputName}`);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const value = producedOutputs[name];
|
|
70
|
+
if (value === void 0 && param.optional !== true && edge !== void 0) throw new LowerError(`Connection input "${id}.${inputName}" declares param "${name}", but its producer "${edge.from}" did not supply it — the producer's outputs carry [${Object.keys(producedOutputs).join(", ") || "nothing"}]. Add "${name}" to the outputs the producer returns from its lowering, or declare the param optional on the connection.`);
|
|
71
|
+
values[name] = value;
|
|
72
|
+
}
|
|
73
|
+
inputs[inputName] = values;
|
|
74
|
+
}
|
|
75
|
+
const boundParams = new Map(graph.params.filter((binding) => binding.serviceAddress === id).map((b) => [b.slot, b.binding]));
|
|
76
|
+
const service = {};
|
|
77
|
+
for (const [name, param] of Object.entries(node.params)) {
|
|
78
|
+
const value = resolveParam(node, id, name, param, boundParams.get(name));
|
|
79
|
+
if (value !== void 0) service[name] = value;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
service,
|
|
83
|
+
inputs
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Joins resolved report entries back to their graph nodes — the last step of a
|
|
88
|
+
* deploy report, run inside the Action with apply's resolved values.
|
|
89
|
+
*
|
|
90
|
+
* The entries cross Alchemy's action-input boundary, so they carry addresses
|
|
91
|
+
* and plain entities only; the graph is held by closure on this side. That
|
|
92
|
+
* split is why this join exists at all, and it is what keeps functions and
|
|
93
|
+
* Standard Schemas (which a node carries, and which the plan's input hash
|
|
94
|
+
* would have to serialize) out of the input.
|
|
95
|
+
*
|
|
96
|
+
* Skips an address the graph no longer holds: entries are data, the graph is
|
|
97
|
+
* truth.
|
|
98
|
+
*/
|
|
99
|
+
function joinDeployment(graph, entries) {
|
|
100
|
+
const nodes = [];
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
const node = graph.nodes.find((n) => n.id === entry.address)?.node;
|
|
103
|
+
if (node === void 0 || node.kind !== "service" && node.kind !== "resource") continue;
|
|
104
|
+
nodes.push({
|
|
105
|
+
address: entry.address,
|
|
106
|
+
node,
|
|
107
|
+
entities: entry.entities
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return nodes;
|
|
111
|
+
}
|
|
112
|
+
function missingBundleError(id) {
|
|
113
|
+
return new LowerError(`No bundle provided for service "${id}" (opts.bundles["${id}"] is required).`);
|
|
114
|
+
}
|
|
115
|
+
function duplicateExtensionError(id) {
|
|
116
|
+
return new LowerError(`Extension "${id}" is listed more than once in \`extensions\` — each extension id must be unique.`);
|
|
117
|
+
}
|
|
118
|
+
/** Registries as extension id → descriptor. Fails on a duplicate id — the CLI validates config, but lowering() is the programmatic escape hatch that doesn't. */
|
|
119
|
+
function extensionsById(config) {
|
|
120
|
+
const map = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const extension of config.extensions) {
|
|
122
|
+
if (map.has(extension.id)) return Effect.fail(duplicateExtensionError(extension.id));
|
|
123
|
+
map.set(extension.id, extension);
|
|
124
|
+
}
|
|
125
|
+
return Effect.succeed(map);
|
|
126
|
+
}
|
|
127
|
+
function unknownExtensionError(extension, id) {
|
|
128
|
+
return new LowerError(`No extension "${extension}" is configured (needed by node "${id}") — add it to prisma-composer.config.ts's \`extensions\` (import its /control entry and list its descriptor).`);
|
|
129
|
+
}
|
|
130
|
+
function unknownNodeTypeError(extension, type) {
|
|
131
|
+
return new LowerError(`Extension "${extension.id}" has no descriptor for node type "${type}" (known: ${Object.keys(extension.nodes).join(", ")}).`);
|
|
132
|
+
}
|
|
133
|
+
/** A provisioned param's need brand isn't registered by the consumer's extension (ADR-0031). */
|
|
134
|
+
function unknownProvisionerError(extension, brand, edgeId) {
|
|
135
|
+
const known = extension.provisions !== void 0 && extension.provisions.size > 0 ? Array.from(extension.provisions.keys(), String).join(", ") : "(none registered)";
|
|
136
|
+
return new LowerError(`Extension "${extension.id}" has no provisioner for need "${String(brand)}" (needed by edge "${edgeId}") (known: ${known}).`);
|
|
137
|
+
}
|
|
138
|
+
/** A provisioned edge whose consumer and provider nodes belong to different extensions (ADR-0031). */
|
|
139
|
+
function crossExtensionProvisionError(edgeId) {
|
|
140
|
+
return new LowerError(`Provisioned edge "${edgeId}" spans two extensions — cross-extension provisioned edges aren't supported yet.`);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* More than one provisioned param on one connection (ADR-0031). One edge mints
|
|
144
|
+
* ONE value, keyed by edge id, so a second need on the same connection would
|
|
145
|
+
* silently receive the first's value under the first's brand.
|
|
146
|
+
*/
|
|
147
|
+
function multipleProvisionedParamsError(edgeId, names) {
|
|
148
|
+
return new LowerError(`Connection input "${edgeId}" declares more than one provisioned param (${names.join(", ")}) — only one provisioned param per connection is supported.`);
|
|
149
|
+
}
|
|
150
|
+
function wrongKindError(extension, type, expected, got) {
|
|
151
|
+
return new LowerError(`Extension "${extension}"'s descriptor for node type "${type}" is a "${got}" descriptor — this node needs a "${expected}" descriptor.`);
|
|
152
|
+
}
|
|
153
|
+
/** Looks up one node's descriptor: extension by `node.extension`, then descriptor by `node.type`, then the kind check. */
|
|
154
|
+
function descriptorFor(extensions, node, id) {
|
|
155
|
+
const extension = extensions.get(node.extension);
|
|
156
|
+
if (extension === void 0) return Effect.fail(unknownExtensionError(node.extension, id));
|
|
157
|
+
const descriptor = extension.nodes[node.type];
|
|
158
|
+
if (descriptor === void 0) return Effect.fail(unknownNodeTypeError(extension, node.type));
|
|
159
|
+
if (descriptor.kind !== node.kind) return Effect.fail(wrongKindError(node.extension, node.type, node.kind, descriptor.kind));
|
|
160
|
+
return Effect.succeed(descriptor);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The state-layer precedence a deploy resolves to: an explicit opts.state
|
|
164
|
+
* always wins; failing that, the config's own (required) state descriptor,
|
|
165
|
+
* created with its owning extension's resolved container (`undefined` when
|
|
166
|
+
* that extension declared none). A pure function so the precedence is
|
|
167
|
+
* testable without booting Alchemy.
|
|
168
|
+
*/
|
|
169
|
+
function resolveStateLayer(opts, config, containers) {
|
|
170
|
+
return opts.state ?? config.state.create(containers.get(config.state.extension));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* All configured extensions' providers merged, config array order — an
|
|
174
|
+
* extension without `providers` is skipped; no used-extensions-only
|
|
175
|
+
* filtering (ADR-0017's pinned providers rule).
|
|
176
|
+
*/
|
|
177
|
+
function mergedProviders(config) {
|
|
178
|
+
const [first, ...rest] = config.extensions.flatMap((extension) => extension.providers !== void 0 ? [extension.providers()] : []);
|
|
179
|
+
return first === void 0 ? Layer.empty : Layer.mergeAll(first, ...rest);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Composable form for mixed stacks: hand-wired Alchemy resources alongside Prisma App nodes in one stack effect.
|
|
183
|
+
* Fails with LowerError or whatever an extension's lowering raises — the error type is open.
|
|
184
|
+
*/
|
|
185
|
+
function lowering(root, config, opts) {
|
|
186
|
+
return Effect.gen(function* () {
|
|
187
|
+
const graph = Load(root, { id: opts.name });
|
|
188
|
+
const extensions = yield* extensionsById(config);
|
|
189
|
+
const containers = deserializeContainers(config.extensions, process.env);
|
|
190
|
+
const lowered = /* @__PURE__ */ new Map();
|
|
191
|
+
const entries = [];
|
|
192
|
+
const provisioned = /* @__PURE__ */ new Map();
|
|
193
|
+
const applications = /* @__PURE__ */ new Map();
|
|
194
|
+
for (const descriptor of config.extensions) {
|
|
195
|
+
if (descriptor.application === void 0) continue;
|
|
196
|
+
const appCtx = {
|
|
197
|
+
id: graph.root.id,
|
|
198
|
+
address: "",
|
|
199
|
+
node: graph.root.node,
|
|
200
|
+
graph,
|
|
201
|
+
opts,
|
|
202
|
+
application: void 0,
|
|
203
|
+
container: containers.get(descriptor.id),
|
|
204
|
+
lowered,
|
|
205
|
+
provisioned
|
|
206
|
+
};
|
|
207
|
+
applications.set(descriptor.id, yield* descriptor.application.provision(appCtx));
|
|
208
|
+
}
|
|
209
|
+
for (const edge of graph.edges) {
|
|
210
|
+
if (edge.kind !== "dependency") continue;
|
|
211
|
+
const consumer = graph.nodes.find((n) => n.id === edge.to)?.node;
|
|
212
|
+
if (consumer === void 0 || consumer.kind !== "service") continue;
|
|
213
|
+
const slot = consumer.inputs[edge.input];
|
|
214
|
+
if (slot === void 0) continue;
|
|
215
|
+
const provisionedParams = Object.entries(slot.connection.params).filter(([, param]) => param.provision !== void 0);
|
|
216
|
+
if (provisionedParams.length === 0) continue;
|
|
217
|
+
const edgeId = `${edge.to}.${edge.input}`;
|
|
218
|
+
if (provisionedParams.length > 1) return yield* Effect.fail(multipleProvisionedParamsError(edgeId, provisionedParams.map(([name]) => name)));
|
|
219
|
+
const need = provisionedParams[0]?.[1].provision;
|
|
220
|
+
if (need === void 0) continue;
|
|
221
|
+
const provider = graph.nodes.find((n) => n.id === edge.from)?.node;
|
|
222
|
+
if (provider === void 0 || provider.kind !== "service" && provider.kind !== "resource") continue;
|
|
223
|
+
if (consumer.extension !== provider.extension) return yield* Effect.fail(crossExtensionProvisionError(edgeId));
|
|
224
|
+
const extension = extensions.get(consumer.extension);
|
|
225
|
+
if (extension === void 0) return yield* Effect.fail(unknownExtensionError(consumer.extension, edge.to));
|
|
226
|
+
const provisioner = extension.provisions?.get(need.brand);
|
|
227
|
+
if (provisioner === void 0) return yield* Effect.fail(unknownProvisionerError(extension, need.brand, edgeId));
|
|
228
|
+
const ref = yield* provisioner.provision({
|
|
229
|
+
edgeId,
|
|
230
|
+
consumerAddress: edge.to,
|
|
231
|
+
providerAddress: edge.from,
|
|
232
|
+
input: edge.input,
|
|
233
|
+
need
|
|
234
|
+
});
|
|
235
|
+
provisioned.set(edgeId, ref);
|
|
236
|
+
}
|
|
237
|
+
for (const { id, node } of graph.nodes) {
|
|
238
|
+
if (node.kind === "module") continue;
|
|
239
|
+
if (node.kind === "dependency") continue;
|
|
240
|
+
const ctx = {
|
|
241
|
+
id,
|
|
242
|
+
address: id,
|
|
243
|
+
node,
|
|
244
|
+
graph,
|
|
245
|
+
opts,
|
|
246
|
+
application: applications.get(node.extension),
|
|
247
|
+
container: containers.get(node.extension),
|
|
248
|
+
lowered,
|
|
249
|
+
provisioned
|
|
250
|
+
};
|
|
251
|
+
const descriptor = yield* descriptorFor(extensions, node, id);
|
|
252
|
+
if (descriptor.kind === "resource") {
|
|
253
|
+
const result = yield* descriptor(ctx);
|
|
254
|
+
lowered.set(id, result.outputs);
|
|
255
|
+
entries.push({
|
|
256
|
+
address: id,
|
|
257
|
+
entities: result.entities
|
|
258
|
+
});
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (descriptor.kind !== "service") return yield* Effect.fail(wrongKindError(node.extension, node.type, node.kind, descriptor.kind));
|
|
262
|
+
const service = node;
|
|
263
|
+
const provisionedNode = yield* descriptor.provision(ctx);
|
|
264
|
+
const typedConfig = buildConfig(service, id, graph, lowered, provisioned);
|
|
265
|
+
const serialized = yield* descriptor.serialize(ctx, provisionedNode, typedConfig);
|
|
266
|
+
const bundle = opts.bundles[id];
|
|
267
|
+
if (bundle === void 0) return yield* Effect.fail(missingBundleError(id));
|
|
268
|
+
const artifact = yield* descriptor.package(ctx, {
|
|
269
|
+
assembled: {
|
|
270
|
+
dir: bundle.dir,
|
|
271
|
+
entry: bundle.entry
|
|
272
|
+
},
|
|
273
|
+
address: id
|
|
274
|
+
});
|
|
275
|
+
const result = yield* descriptor.deploy(ctx, provisionedNode, artifact, serialized);
|
|
276
|
+
lowered.set(id, result.outputs);
|
|
277
|
+
entries.push({
|
|
278
|
+
address: id,
|
|
279
|
+
entities: result.entities
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (opts.report !== void 0) {
|
|
283
|
+
const report = opts.report;
|
|
284
|
+
yield* Alchemy.Action("composer-deployment-report", (input) => Effect.sync(() => {
|
|
285
|
+
report({
|
|
286
|
+
app: opts.name,
|
|
287
|
+
nodes: joinDeployment(graph, input.entries)
|
|
288
|
+
});
|
|
289
|
+
}))({
|
|
290
|
+
nonce: Date.now(),
|
|
291
|
+
entries
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The whole-stack wrapper: Load → route each node through the config's
|
|
298
|
+
* extension registries → an Alchemy Stack (the default export the alchemy
|
|
299
|
+
* CLI consumes).
|
|
300
|
+
*/
|
|
301
|
+
function lower(root, config, opts) {
|
|
302
|
+
const stackEffect = Effect.orDie(lowering(root, config, opts));
|
|
303
|
+
const containers = deserializeContainers(config.extensions, process.env);
|
|
304
|
+
const providers = opts.providers ?? mergedProviders(config);
|
|
305
|
+
return Alchemy.Stack(opts.name, {
|
|
306
|
+
providers,
|
|
307
|
+
state: resolveStateLayer(opts, config, containers)
|
|
308
|
+
}, stackEffect);
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
2
311
|
export { LowerError, buildConfig, joinDeployment, lower, lowering, mergedProviders, resolveStateLayer };
|
|
312
|
+
|
|
313
|
+
//# sourceMappingURL=deploy.mjs.map
|