@powerhousedao/ph-cli 6.2.3-dev.8 → 6.2.3-dev.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
- package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
- package/dist/auth-CNhbN5UM.mjs +4 -0
- package/dist/build-t5pFQx0f.mjs +304 -0
- package/dist/build-t5pFQx0f.mjs.map +1 -0
- package/dist/build-wvc_NiGr.mjs +4 -0
- package/dist/check-ecwBLzrg.mjs +56 -0
- package/dist/check-ecwBLzrg.mjs.map +1 -0
- package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-DW7OYAGx.mjs} +39 -27
- package/dist/cli-connect-override-DW7OYAGx.mjs.map +1 -0
- package/dist/cli.d.mts +2 -1
- package/dist/cli.mjs +35 -1179
- package/dist/cli.mjs.map +1 -1
- package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs +2813 -0
- package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs.map +1 -0
- package/dist/connect-build-7nmQw9c5.mjs +253 -0
- package/dist/connect-build-7nmQw9c5.mjs.map +1 -0
- package/dist/{connect-config-BWGiW3IB.mjs → connect-config-CfQwxG8G.mjs} +19 -12
- package/dist/connect-config-CfQwxG8G.mjs.map +1 -0
- package/dist/connect-plugin-configs-CXN8_KL0.mjs +50 -0
- package/dist/connect-plugin-configs-CXN8_KL0.mjs.map +1 -0
- package/dist/connect-preview-Ckoqw_XU.mjs +231 -0
- package/dist/connect-preview-Ckoqw_XU.mjs.map +1 -0
- package/dist/connect-studio-Cac3eE_U.mjs +81 -0
- package/dist/connect-studio-Cac3eE_U.mjs.map +1 -0
- package/dist/connect-studio-Cf6UZvOo.mjs +4 -0
- package/dist/dist-DcARVrSg.mjs +643 -0
- package/dist/dist-DcARVrSg.mjs.map +1 -0
- package/dist/explain-Rx7JW1OU.mjs +230 -0
- package/dist/explain-Rx7JW1OU.mjs.map +1 -0
- package/dist/export-ZnJeAtLS.mjs +42 -0
- package/dist/export-ZnJeAtLS.mjs.map +1 -0
- package/dist/feature-flags-xwqcHEWC.mjs +4 -0
- package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-5Om0CB4N.mjs} +9 -3
- package/dist/generate-all-5Om0CB4N.mjs.map +1 -0
- package/dist/generate-app-hm6CJ_4O.mjs +72 -0
- package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
- package/dist/generate-desktop-shell-DzEzNspp.mjs +318 -0
- package/dist/generate-desktop-shell-DzEzNspp.mjs.map +1 -0
- package/dist/generate-document-model-CiW13Vf7.mjs +60 -0
- package/dist/generate-document-model-CiW13Vf7.mjs.map +1 -0
- package/dist/generate-editor-kTiUOmDW.mjs +64 -0
- package/dist/generate-editor-kTiUOmDW.mjs.map +1 -0
- package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
- package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
- package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
- package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
- package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
- package/dist/generate-piece-C6ymlErL.mjs +73 -0
- package/dist/generate-piece-C6ymlErL.mjs.map +1 -0
- package/dist/generate-piece-action-DqR8BcoO.mjs +31 -0
- package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
- package/dist/generate-piece-trigger-CZaDD-cc.mjs +30 -0
- package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
- package/dist/generate-processor-BVjOsfjJ.mjs +58 -0
- package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
- package/dist/generate-subgraph-CrHbYK91.mjs +64 -0
- package/dist/generate-subgraph-CrHbYK91.mjs.map +1 -0
- package/dist/get-version-CJulKHJ0.mjs +11 -0
- package/dist/get-version-CJulKHJ0.mjs.map +1 -0
- package/dist/index-CJN_BRkc.d.mts +4459 -0
- package/dist/index-CJN_BRkc.d.mts.map +1 -0
- package/dist/{init-BZP6gvYd.mjs → init-Ch1rCksS.mjs} +16 -12
- package/dist/init-Ch1rCksS.mjs.map +1 -0
- package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
- package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
- package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
- package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
- package/dist/mcp-Cz9CubZa.mjs +262 -0
- package/dist/mcp-Cz9CubZa.mjs.map +1 -0
- package/dist/member-config-0tHtiVN_.mjs +154 -0
- package/dist/member-config-0tHtiVN_.mjs.map +1 -0
- package/dist/migrate-CIJaE3iZ.mjs +177 -0
- package/dist/migrate-CIJaE3iZ.mjs.map +1 -0
- package/dist/module-dir-1avCXsBi.mjs +17 -0
- package/dist/module-dir-1avCXsBi.mjs.map +1 -0
- package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
- package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
- package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
- package/dist/ph-cli-commands-C4gwBRyw.mjs +4 -0
- package/dist/ph-cli-commands-DFmTGL-H.mjs +1610 -0
- package/dist/ph-cli-commands-DFmTGL-H.mjs.map +1 -0
- package/dist/precompress-P6cJDPVC.mjs +77 -0
- package/dist/precompress-P6cJDPVC.mjs.map +1 -0
- package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
- package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
- package/dist/run-sugar-CRzZsmVo.mjs +39 -0
- package/dist/run-sugar-CRzZsmVo.mjs.map +1 -0
- package/dist/runners/connect.d.mts +1153 -0
- package/dist/runners/connect.d.mts.map +1 -0
- package/dist/runners/connect.mjs +300 -0
- package/dist/runners/connect.mjs.map +1 -0
- package/dist/runners/switchboard.d.mts +1481 -0
- package/dist/runners/switchboard.d.mts.map +1 -0
- package/dist/runners/switchboard.mjs +550 -0
- package/dist/runners/switchboard.mjs.map +1 -0
- package/dist/schemas-ByfuhvAb.mjs +5752 -0
- package/dist/schemas-ByfuhvAb.mjs.map +1 -0
- package/dist/scripts/emit-runner-schemas.ts +24 -0
- package/dist/scripts/generate-commands-docs.ts +12 -0
- package/dist/scripts/manage-environment +0 -0
- package/dist/scripts/setup.sh +0 -0
- package/dist/start-run-CRVBqQ8L.mjs +124 -0
- package/dist/start-run-CRVBqQ8L.mjs.map +1 -0
- package/dist/superseded-config-CbSTFun2.mjs +53 -0
- package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
- package/dist/switchboard-B7mvNWcd.mjs +4 -0
- package/dist/switchboard-Cqs5IBNF.mjs +168 -0
- package/dist/switchboard-Cqs5IBNF.mjs.map +1 -0
- package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-Docb8Cjv.mjs} +6 -5
- package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-Docb8Cjv.mjs.map} +1 -1
- package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
- package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
- package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
- package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
- package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
- package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
- package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
- package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
- package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
- package/dist/utils-DAux4Ga7.mjs +4 -0
- package/dist/{vetra-DkF6EJMY.mjs → vetra-DZYtcHqV.mjs} +130 -147
- package/dist/vetra-DZYtcHqV.mjs.map +1 -0
- package/dist/vetra-launch-DQDZxGTV.mjs +343 -0
- package/dist/vetra-launch-DQDZxGTV.mjs.map +1 -0
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
- package/package.json +42 -18
- package/dist/auth-BNkN6kS9.mjs +0 -4
- package/dist/build-C-A5-ipO.mjs +0 -4
- package/dist/build-uQXq6_HU.mjs +0 -71
- package/dist/build-uQXq6_HU.mjs.map +0 -1
- package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
- package/dist/connect-build-WL4axo4z.mjs +0 -43
- package/dist/connect-build-WL4axo4z.mjs.map +0 -1
- package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
- package/dist/connect-preview-D7ypzFDc.mjs +0 -28
- package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
- package/dist/connect-studio-BIQzyq5B.mjs +0 -5
- package/dist/connect-studio-D6rfWCNB.mjs +0 -31
- package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
- package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
- package/dist/generate-app-DNNqA-H3.mjs +0 -48
- package/dist/generate-app-DNNqA-H3.mjs.map +0 -1
- package/dist/generate-document-model-BJXyODfm.mjs +0 -34
- package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
- package/dist/generate-editor-BejvaVVT.mjs +0 -48
- package/dist/generate-editor-BejvaVVT.mjs.map +0 -1
- package/dist/generate-processor-_WOx-mMe.mjs +0 -40
- package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
- package/dist/generate-subgraph-BsHUstpl.mjs +0 -38
- package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
- package/dist/init-BZP6gvYd.mjs.map +0 -1
- package/dist/inspect-DXjbQEV_.mjs.map +0 -1
- package/dist/migrate-jGKfE02L.mjs +0 -83
- package/dist/migrate-jGKfE02L.mjs.map +0 -1
- package/dist/switchboard-CJMoMzWx.mjs +0 -75
- package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
- package/dist/switchboard-iRFugh8I.mjs +0 -4
- package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
- package/dist/utils-BzwczAW-.mjs +0 -4
- package/dist/vetra-DkF6EJMY.mjs.map +0 -1
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f0f9b514-77e1-57dc-a426-f978cf2eeaba")}catch(e){}}();
|
|
3
|
+
import { a as custom, d as string, g as prettifyError, l as record, o as literal, u as strictObject } from "./schemas-ByfuhvAb.mjs";
|
|
4
|
+
import { $ as takesCspRegistrySync, A as loadProducers, B as processResolveEnv, C as hostSchemaIssues, F as outputSitesOf, H as projectDriveIdWith, I as planCompound, K as resolveHostOutputs, L as prepareMember, M as memberVerbOf, O as kindShapeIssues, P as outputRefsOf, Q as substituteBuiltinEnv, S as getVerb, T as isPlainObject, U as readProjectName, V as producerOutputsSchemas, Y as resolveRunnerModule, Z as runnerOutputsSchema, a as TokenResolutionError, b as findRemovedForms, c as checkTokenSites, f as compoundStartVerb, j as memberForRef, k as loadHost, n as HostLoadError, p as declaredHostSchemas, r as ONE_SHOT_VERBS, s as checkOutputPaths, tt as unsetEnvMessage, v as envSitesOf, w as isBuiltinEnvName } from "./compound-C7GuPnTP-Ba4ce2Xa.mjs";
|
|
5
|
+
import "node:module";
|
|
6
|
+
import "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import "node:child_process";
|
|
9
|
+
import { DRIVE_ICON_MAX_BYTES, resolveImageRef } from "@powerhousedao/shared/connect/image-ref";
|
|
10
|
+
import "@powerhousedao/shared/connect/origin-placeholder";
|
|
11
|
+
import crypto from "node:crypto";
|
|
12
|
+
import "node:url";
|
|
13
|
+
import "@powerhousedao/shared/host-tokens";
|
|
14
|
+
//#region ../../packages/host-core/dist/index.mjs
|
|
15
|
+
/** The `ph run` pipeline up to the verb, collecting every issue; starts nothing. */
|
|
16
|
+
async function checkHost(name, options) {
|
|
17
|
+
const result = {
|
|
18
|
+
issues: [],
|
|
19
|
+
deferred: []
|
|
20
|
+
};
|
|
21
|
+
const file = `hosts/${name}/host.js`;
|
|
22
|
+
const issue = issuer(result, file);
|
|
23
|
+
const verb = options.verb ?? "run";
|
|
24
|
+
let host;
|
|
25
|
+
let runner;
|
|
26
|
+
try {
|
|
27
|
+
host = (await loadHost(options.projectRoot, name)).host;
|
|
28
|
+
runner = await resolveRunnerModule(options.projectRoot, host.runner.module);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
issue("load", "", error);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
const specifier = host.runner.module;
|
|
34
|
+
if (runner.kind === "compound") {
|
|
35
|
+
await checkCompound(result, options, {
|
|
36
|
+
file,
|
|
37
|
+
host,
|
|
38
|
+
runner,
|
|
39
|
+
specifier,
|
|
40
|
+
verb
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
const refs = outputRefsOf(host);
|
|
45
|
+
const producers = await loadProducers(options.projectRoot, refs);
|
|
46
|
+
await checkSubject(result, options, {
|
|
47
|
+
file,
|
|
48
|
+
host,
|
|
49
|
+
runner,
|
|
50
|
+
specifier,
|
|
51
|
+
verb,
|
|
52
|
+
outputsSchemaOf: producerOutputsSchemas(producers),
|
|
53
|
+
self: "outputs"
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
/** Declared validation; returns whether its tokens and its shape passed. */
|
|
58
|
+
function checkDeclared(result, subject, outputsSchemaOf) {
|
|
59
|
+
const issue = issuer(result, subject.file);
|
|
60
|
+
const { host, runner, specifier } = subject;
|
|
61
|
+
try {
|
|
62
|
+
getVerb(runner, specifier, subject.verb);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
issue("declared", "", error);
|
|
65
|
+
}
|
|
66
|
+
const tokenIssues = [
|
|
67
|
+
...findRemovedForms(host),
|
|
68
|
+
...checkTokenSites(host),
|
|
69
|
+
...outputsSchemaOf ? checkOutputPaths(host, outputsSchemaOf) : []
|
|
70
|
+
];
|
|
71
|
+
for (const i of tokenIssues) issue("declared", i);
|
|
72
|
+
const shapeIssues = runner.declaredHostSchema ? schemaIssuesOf(runner, runner.declaredHostSchema, specifier, host, true) : kindShapeIssues(runner.kind, specifier, host);
|
|
73
|
+
for (const i of shapeIssues) issue("declared", i);
|
|
74
|
+
return {
|
|
75
|
+
tokens: tokenIssues.length === 0,
|
|
76
|
+
shape: shapeIssues.length === 0
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function schemaIssuesOf(runner, schema, specifier, host, allowTokens) {
|
|
80
|
+
const checked = hostSchemaIssues(runner, schema, specifier, host, { tokens: allowTokens ? "allow" : "forbid" });
|
|
81
|
+
return [...checked.issues, ...checked.schemaIssues ?? []];
|
|
82
|
+
}
|
|
83
|
+
async function checkSubject(result, options, subject) {
|
|
84
|
+
const issue = issuer(result, subject.file);
|
|
85
|
+
const { runner, specifier, file } = subject;
|
|
86
|
+
const declared = checkDeclared(result, subject, subject.outputsSchemaOf);
|
|
87
|
+
const resolveEnv = processResolveEnv(options.projectRoot, options.env);
|
|
88
|
+
const patch = subject.patch ?? ((host) => host);
|
|
89
|
+
if (ONE_SHOT_VERBS.has(subject.verb)) {
|
|
90
|
+
if (!declared.tokens || !declared.shape) return;
|
|
91
|
+
const host = patch(substituteBuiltinEnv(subject.host, resolveEnv.builtins ?? {}));
|
|
92
|
+
const schema = runner.declaredHostSchema ?? runner.hostSchema;
|
|
93
|
+
for (const i of schemaIssuesOf(runner, schema, specifier, host, true)) issue("resolved", i);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const unset = envSitesOf(subject.host).filter((site) => !site.optional && !isBuiltinEnvName(site.name) && options.env[site.name] === void 0);
|
|
97
|
+
for (const site of unset) issue("resolve", {
|
|
98
|
+
path: site.path,
|
|
99
|
+
message: unsetEnvMessage(site.name)
|
|
100
|
+
});
|
|
101
|
+
if (!declared.tokens || unset.length > 0) return;
|
|
102
|
+
let resolved;
|
|
103
|
+
let deferred = [];
|
|
104
|
+
try {
|
|
105
|
+
if (options.outputs) resolved = resolveHostOutputs(subject.host, {
|
|
106
|
+
outputs: options.outputs,
|
|
107
|
+
...resolveEnv
|
|
108
|
+
});
|
|
109
|
+
else {
|
|
110
|
+
const partial = resolveHostOutputs(subject.host, resolveEnv, { deferSelf: subject.self });
|
|
111
|
+
resolved = partial.host;
|
|
112
|
+
deferred = partial.deferred;
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (error instanceof TokenResolutionError && error.detail) issue("resolve", {
|
|
116
|
+
path: error.detail.path,
|
|
117
|
+
message: error.detail.reason
|
|
118
|
+
});
|
|
119
|
+
else issue("resolve", "", error);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
result.deferred.push(...deferred.map((d) => ({
|
|
123
|
+
...d,
|
|
124
|
+
file
|
|
125
|
+
})));
|
|
126
|
+
if (!declared.shape) return;
|
|
127
|
+
const allow = deferred.length > 0;
|
|
128
|
+
const schema = allow ? runner.declaredHostSchema ?? runner.hostSchema : runner.hostSchema;
|
|
129
|
+
const checked = hostSchemaIssues(runner, schema, specifier, patch(resolved), { tokens: allow ? "allow" : "forbid" });
|
|
130
|
+
const resolvedIssues = [...checked.issues, ...checked.schemaIssues ?? []];
|
|
131
|
+
for (const i of resolvedIssues) issue("resolved", i);
|
|
132
|
+
if (resolvedIssues.length > 0 || !runner.checkBoot) return;
|
|
133
|
+
try {
|
|
134
|
+
const boot = await runner.checkBoot(checked.data, {
|
|
135
|
+
projectRoot: options.projectRoot,
|
|
136
|
+
verb: subject.verb,
|
|
137
|
+
env: options.env,
|
|
138
|
+
file
|
|
139
|
+
});
|
|
140
|
+
for (const i of boot) issue("boot", {
|
|
141
|
+
...i,
|
|
142
|
+
path: i.path ?? ""
|
|
143
|
+
});
|
|
144
|
+
} catch (error) {
|
|
145
|
+
issue("boot", "", error);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function checkCompound(result, options, subject) {
|
|
149
|
+
const issue = issuer(result, subject.file);
|
|
150
|
+
const { host, runner, specifier } = subject;
|
|
151
|
+
const declared = checkDeclared(result, subject);
|
|
152
|
+
if (!declared.tokens || !declared.shape) return;
|
|
153
|
+
if (!runner.declaredHostSchema) {
|
|
154
|
+
const own = schemaIssuesOf(runner, runner.hostSchema, specifier, host, true);
|
|
155
|
+
for (const i of own) issue("resolved", i);
|
|
156
|
+
if (own.length > 0) return;
|
|
157
|
+
}
|
|
158
|
+
const children = isPlainObject(host.children) ? host.children : {};
|
|
159
|
+
const wiring = isPlainObject(host.config) ? host.config : {};
|
|
160
|
+
const verb = compoundStartVerb(subject.verb, host.runner);
|
|
161
|
+
const prepared = [];
|
|
162
|
+
for (const [key, member] of Object.entries(children)) try {
|
|
163
|
+
prepared.push(await prepareMember(options.projectRoot, key, member));
|
|
164
|
+
} catch (error) {
|
|
165
|
+
issuer(result, `hosts/${member.host}/host.js`)("load", "", error);
|
|
166
|
+
}
|
|
167
|
+
const members = Object.entries(children).map(([key, m]) => ({
|
|
168
|
+
key,
|
|
169
|
+
host: m.host
|
|
170
|
+
}));
|
|
171
|
+
if (prepared.length === members.length) try {
|
|
172
|
+
planCompound(prepared.map((m) => ({
|
|
173
|
+
key: m.key,
|
|
174
|
+
host: m.member.host,
|
|
175
|
+
refs: outputSitesOf(m.draft).map(({ ref, path }) => ({
|
|
176
|
+
ref,
|
|
177
|
+
path
|
|
178
|
+
}))
|
|
179
|
+
})), wiring.startOrder);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
issue("declared", "", error);
|
|
182
|
+
}
|
|
183
|
+
const byKey = new Map(prepared.map((m) => [m.key, m]));
|
|
184
|
+
const outputsSchemaOf = (ref) => {
|
|
185
|
+
const target = memberForRef(ref, members);
|
|
186
|
+
if ("error" in target) return { error: target.error };
|
|
187
|
+
const producer = byKey.get(target.key);
|
|
188
|
+
return producer ? runnerOutputsSchema(producer.runner, producer.specifier, `member "${target.key}"`) : { error: `names member "${target.key}", which was not prepared.` };
|
|
189
|
+
};
|
|
190
|
+
for (const m of prepared) {
|
|
191
|
+
const csp = wiring.cspRegistrySync === true && takesCspRegistrySync(m);
|
|
192
|
+
await checkSubject(result, options, {
|
|
193
|
+
file: m.file,
|
|
194
|
+
host: m.draft,
|
|
195
|
+
runner: m.runner,
|
|
196
|
+
specifier: m.specifier,
|
|
197
|
+
verb: memberVerbOf(verb, m.draft.runner),
|
|
198
|
+
outputsSchemaOf,
|
|
199
|
+
self: { members },
|
|
200
|
+
...csp ? { patch: (resolved) => ({
|
|
201
|
+
...resolved,
|
|
202
|
+
runner: {
|
|
203
|
+
...resolved.runner,
|
|
204
|
+
cspRegistrySync: true
|
|
205
|
+
}
|
|
206
|
+
}) } : {}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function issuer(result, file) {
|
|
211
|
+
return (stage, found, error) => {
|
|
212
|
+
if (typeof found !== "string") {
|
|
213
|
+
const { path, message, hint } = found;
|
|
214
|
+
result.issues.push({
|
|
215
|
+
stage,
|
|
216
|
+
file,
|
|
217
|
+
path,
|
|
218
|
+
message,
|
|
219
|
+
...hint ? { hint } : {}
|
|
220
|
+
});
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const [message, hint] = (error instanceof Error ? error.message : String(error)).split("\n Hint: ");
|
|
224
|
+
result.issues.push({
|
|
225
|
+
stage,
|
|
226
|
+
file,
|
|
227
|
+
path: found,
|
|
228
|
+
message,
|
|
229
|
+
...hint ? { hint } : {}
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function isRecord$1(value) {
|
|
234
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
235
|
+
}
|
|
236
|
+
function childFolders$1(host) {
|
|
237
|
+
if (!isRecord$1(host) || !isRecord$1(host.children)) return [];
|
|
238
|
+
return Object.entries(host.children).flatMap(([key, child]) => isRecord$1(child) && typeof child.host === "string" ? [[key, child.host]] : []);
|
|
239
|
+
}
|
|
240
|
+
const declaredHostSchema = custom().superRefine((host, ctx) => {
|
|
241
|
+
const result = (isRecord$1(host) && "children" in host ? declaredHostSchemas.compoundHostSchema : declaredHostSchemas.reactorHostSchema).safeParse(host);
|
|
242
|
+
if (result.success) return;
|
|
243
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
244
|
+
code: "custom",
|
|
245
|
+
message: issue.message,
|
|
246
|
+
path: issue.path
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
/** `ph host export`: a declared host plus its members, keyed by folder. */
|
|
250
|
+
const hostExportSchema = strictObject({
|
|
251
|
+
format: literal("ph-host-export"),
|
|
252
|
+
version: literal(1),
|
|
253
|
+
project: strictObject({
|
|
254
|
+
name: string().min(1),
|
|
255
|
+
root: string().min(1)
|
|
256
|
+
}),
|
|
257
|
+
name: string().min(1),
|
|
258
|
+
host: declaredHostSchema,
|
|
259
|
+
members: record(string(), declaredHostSchema)
|
|
260
|
+
}).superRefine((value, ctx) => {
|
|
261
|
+
const reached = /* @__PURE__ */ new Set();
|
|
262
|
+
const pending = [[["host"], value.host]];
|
|
263
|
+
for (let next = pending.shift(); next; next = pending.shift()) {
|
|
264
|
+
const [at, host] = next;
|
|
265
|
+
for (const [key, folder] of childFolders$1(host)) {
|
|
266
|
+
if (!(folder in value.members)) {
|
|
267
|
+
ctx.addIssue({
|
|
268
|
+
code: "custom",
|
|
269
|
+
path: [
|
|
270
|
+
...at,
|
|
271
|
+
"children",
|
|
272
|
+
key,
|
|
273
|
+
"host"
|
|
274
|
+
],
|
|
275
|
+
message: `Member folder "${folder}" is missing from members.`
|
|
276
|
+
});
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (reached.has(folder)) continue;
|
|
280
|
+
reached.add(folder);
|
|
281
|
+
pending.push([["members", folder], value.members[folder]]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (const folder of Object.keys(value.members)) {
|
|
285
|
+
if (reached.has(folder)) continue;
|
|
286
|
+
ctx.addIssue({
|
|
287
|
+
code: "custom",
|
|
288
|
+
path: ["members", folder],
|
|
289
|
+
message: `Member "${folder}" is not reached from the host's children.`
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
function checkHint(name) {
|
|
294
|
+
return `Run \`ph host check ${name}\`.`;
|
|
295
|
+
}
|
|
296
|
+
function childFolders(host, name) {
|
|
297
|
+
if (!("children" in host)) return [];
|
|
298
|
+
const parsed = declaredHostSchemas.childrenSchema.safeParse(host.children);
|
|
299
|
+
if (!parsed.success) throw new HostLoadError(`hosts/${name}/host.js: invalid \`children\`:\n${prettifyError(parsed.error)}`, checkHint(name));
|
|
300
|
+
return Object.values(parsed.data).map((child) => child.host);
|
|
301
|
+
}
|
|
302
|
+
/** A host as declared and every member it reaches, raw `loadHost` bodies. */
|
|
303
|
+
async function exportHost(projectRoot, name) {
|
|
304
|
+
const root = path.resolve(projectRoot);
|
|
305
|
+
const { host } = await loadHost(root, name);
|
|
306
|
+
const members = {};
|
|
307
|
+
const visit = async (folders) => {
|
|
308
|
+
for (const folder of folders) {
|
|
309
|
+
if (folder in members) continue;
|
|
310
|
+
const member = (await loadHost(root, folder)).host;
|
|
311
|
+
members[folder] = member;
|
|
312
|
+
await visit(childFolders(member, folder));
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
await visit(childFolders(host, name));
|
|
316
|
+
const envelope = {
|
|
317
|
+
format: "ph-host-export",
|
|
318
|
+
version: 1,
|
|
319
|
+
project: {
|
|
320
|
+
name: readProjectName(root),
|
|
321
|
+
root
|
|
322
|
+
},
|
|
323
|
+
name,
|
|
324
|
+
host,
|
|
325
|
+
members
|
|
326
|
+
};
|
|
327
|
+
const parsed = hostExportSchema.safeParse(JSON.parse(JSON.stringify(envelope)));
|
|
328
|
+
if (!parsed.success) throw new HostLoadError(`hosts/${name}/host.js: the export is not a valid host export:\n${prettifyError(parsed.error)}`, checkHint(name));
|
|
329
|
+
return envelope;
|
|
330
|
+
}
|
|
331
|
+
const sha256Hex = (input) => crypto.createHash("sha256").update(input).digest("hex");
|
|
332
|
+
function projectDriveId(projectRoot, slug) {
|
|
333
|
+
return projectDriveIdWith(sha256Hex, projectRoot, slug);
|
|
334
|
+
}
|
|
335
|
+
function resolveDriveDeclaration(projectRoot, decl) {
|
|
336
|
+
const id = decl.projectHash ? projectDriveId(projectRoot, decl.slug) : decl.id ?? decl.slug;
|
|
337
|
+
const slug = decl.projectHash === true ? id : decl.slug;
|
|
338
|
+
if (decl.remote) return {
|
|
339
|
+
kind: "remote",
|
|
340
|
+
id,
|
|
341
|
+
slug,
|
|
342
|
+
name: decl.name ?? decl.slug,
|
|
343
|
+
remoteUrl: decl.remote.url,
|
|
344
|
+
sharingType: decl.sharingType ?? "public",
|
|
345
|
+
availableOffline: decl.availableOffline ?? true
|
|
346
|
+
};
|
|
347
|
+
return {
|
|
348
|
+
kind: "local",
|
|
349
|
+
id,
|
|
350
|
+
slug,
|
|
351
|
+
name: decl.name ?? decl.slug,
|
|
352
|
+
icon: resolveImageRef(projectRoot, decl.icon, {
|
|
353
|
+
maxBytes: DRIVE_ICON_MAX_BYTES,
|
|
354
|
+
warn: (m) => console.warn(m)
|
|
355
|
+
}),
|
|
356
|
+
preferredEditor: decl.preferredEditor,
|
|
357
|
+
sharingType: decl.sharingType ?? "public",
|
|
358
|
+
availableOffline: decl.availableOffline ?? true
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/** Idempotent, slug-keyed: an existing slug is left untouched (never
|
|
362
|
+
* recreated, never mutated — preserveStrategy refinements live here later). */
|
|
363
|
+
async function seedDrives(client, drives) {
|
|
364
|
+
const result = {
|
|
365
|
+
created: [],
|
|
366
|
+
existing: [],
|
|
367
|
+
attached: []
|
|
368
|
+
};
|
|
369
|
+
for (const drive of drives) {
|
|
370
|
+
if (drive.kind === "remote") {
|
|
371
|
+
await client.attachRemoteDrive(drive.remoteUrl);
|
|
372
|
+
result.attached.push(drive.slug);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (await client.findDriveBySlug(drive.slug) !== void 0) {
|
|
376
|
+
result.existing.push(drive.slug);
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
await client.createDrive(drive);
|
|
380
|
+
result.created.push(drive.slug);
|
|
381
|
+
}
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
/** Merge host-declared drives with plugin contributions, slug-keyed — the
|
|
385
|
+
* host file wins on conflicts (it is the most explicit source). */
|
|
386
|
+
function mergeDrivePlan(projectRoot, hostDeclared, contributed) {
|
|
387
|
+
const plan = /* @__PURE__ */ new Map();
|
|
388
|
+
for (const { declaration, source } of contributed) {
|
|
389
|
+
const drive = resolveDriveDeclaration(projectRoot, declaration);
|
|
390
|
+
plan.set(drive.slug, {
|
|
391
|
+
drive,
|
|
392
|
+
source
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
for (const declaration of hostDeclared) {
|
|
396
|
+
const drive = resolveDriveDeclaration(projectRoot, declaration);
|
|
397
|
+
plan.set(drive.slug, {
|
|
398
|
+
drive,
|
|
399
|
+
source: "host"
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return [...plan.values()];
|
|
403
|
+
}
|
|
404
|
+
function explainDrivePlan(plan) {
|
|
405
|
+
if (plan.length === 0) return "(no drives declared)";
|
|
406
|
+
return ["drives:", ...plan.map(({ drive, source }) => {
|
|
407
|
+
const kind = drive.kind === "remote" ? `remote ${drive.remoteUrl}` : "local";
|
|
408
|
+
const editor = drive.preferredEditor ? ` editor=${drive.preferredEditor}` : "";
|
|
409
|
+
return ` ${drive.slug} (${kind}, id=${drive.id}${editor}) [${source}]`;
|
|
410
|
+
})].join("\n");
|
|
411
|
+
}
|
|
412
|
+
/** The single primary backend for phase-2 projection (multi-backend routing is
|
|
413
|
+
* track R). Prefers placement.primary, else "main"/"local", else the first. */
|
|
414
|
+
function primaryBackend(reactor) {
|
|
415
|
+
const backends = reactor?.backends;
|
|
416
|
+
if (!backends) return void 0;
|
|
417
|
+
const names = Object.keys(backends);
|
|
418
|
+
if (names.length === 0) return void 0;
|
|
419
|
+
return backends[reactor.placement?.primary ?? (names.includes("main") ? "main" : names.includes("local") ? "local" : names[0])];
|
|
420
|
+
}
|
|
421
|
+
const FLAG_ENV = {
|
|
422
|
+
documentDecisions: "REACTOR_DOCUMENT_DECISIONS",
|
|
423
|
+
authEnforcement: "REACTOR_AUTH_ENFORCEMENT",
|
|
424
|
+
authGroups: "REACTOR_AUTH_GROUPS",
|
|
425
|
+
authConditions: "REACTOR_AUTH_CONDITIONS"
|
|
426
|
+
};
|
|
427
|
+
/** The env vars a protocol block maps onto, with their string values. Only
|
|
428
|
+
* keys the block actually sets appear. */
|
|
429
|
+
function protocolEnv(protocol) {
|
|
430
|
+
const env = {};
|
|
431
|
+
if (!protocol) return env;
|
|
432
|
+
for (const [key, varName] of Object.entries(FLAG_ENV)) {
|
|
433
|
+
const value = protocol.featureFlags?.[key];
|
|
434
|
+
if (value !== void 0) env[varName] = value ? "true" : "false";
|
|
435
|
+
}
|
|
436
|
+
if (protocol.createSignaturePolicy !== void 0) env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;
|
|
437
|
+
if (protocol.unsupportedStoredDocuments !== void 0) env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS = protocol.unsupportedStoredDocuments;
|
|
438
|
+
return env;
|
|
439
|
+
}
|
|
440
|
+
/** The reactor block as a switchboard config layer. The reactor store and the
|
|
441
|
+
* read model are separate fields: `readModel.url` never moves the reactor. */
|
|
442
|
+
function reactorBlockToSwitchboardConfig(reactor) {
|
|
443
|
+
const layer = {};
|
|
444
|
+
const backend = primaryBackend(reactor);
|
|
445
|
+
const storage = backend?.storage;
|
|
446
|
+
const reactorUrl = storage?.kind === "postgres" ? storage.url : storage?.dataDir;
|
|
447
|
+
const readModelUrl = backend?.readModel?.url;
|
|
448
|
+
if (reactorUrl || readModelUrl) layer.storage = {
|
|
449
|
+
...reactorUrl ? { reactor: { url: reactorUrl } } : {},
|
|
450
|
+
...readModelUrl ? { readModel: { url: readModelUrl } } : {}
|
|
451
|
+
};
|
|
452
|
+
if (reactor?.protocol) layer.protocol = reactor.protocol;
|
|
453
|
+
if (backend?.packages?.dynamic) layer.packages = { dynamic: true };
|
|
454
|
+
if (reactor?.workflows !== void 0) layer.features = { workflows: reactor.workflows };
|
|
455
|
+
return layer;
|
|
456
|
+
}
|
|
457
|
+
const LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set(["in-process", "worker"]);
|
|
458
|
+
/**
|
|
459
|
+
* Which reactor client the backend topology asks for:
|
|
460
|
+
* - local (in-process/worker) AND remote backends -> `router`
|
|
461
|
+
* - remote backend(s) only -> `remote`
|
|
462
|
+
* - a worker backend -> `worker`
|
|
463
|
+
* - anything else local -> `in-process`
|
|
464
|
+
* `undefined` when no backends are declared — the caller then keeps the
|
|
465
|
+
* legacy reactorWorker/multiReactor behaviour untouched.
|
|
466
|
+
*/
|
|
467
|
+
function reactorClientMode(reactor) {
|
|
468
|
+
const backends = reactor?.backends;
|
|
469
|
+
if (!backends) return void 0;
|
|
470
|
+
const kinds = Object.values(backends).map((b) => b.kind);
|
|
471
|
+
if (kinds.length === 0) return void 0;
|
|
472
|
+
const hasLocal = kinds.some((k) => LOCAL_BACKEND_KINDS.has(k));
|
|
473
|
+
const hasRemote = kinds.some((k) => k === "remote");
|
|
474
|
+
if (hasLocal && hasRemote) return "router";
|
|
475
|
+
if (hasRemote) return "remote";
|
|
476
|
+
return primaryBackend(reactor)?.kind === "worker" ? "worker" : "in-process";
|
|
477
|
+
}
|
|
478
|
+
/** Project the reactor block onto the Connect runtime config: protocol →
|
|
479
|
+
* connect.reactor (same shape), backend topology → instance.reactorWorker
|
|
480
|
+
* (legacy) + instance.reactorClient (the explicit 4-way selector),
|
|
481
|
+
* workflows → app.workflowsEnabled. */
|
|
482
|
+
function projectReactorToConnect(reactor) {
|
|
483
|
+
const connect = {};
|
|
484
|
+
if (reactor?.protocol) connect.reactor = reactor.protocol;
|
|
485
|
+
const backend = primaryBackend(reactor);
|
|
486
|
+
const mode = reactorClientMode(reactor);
|
|
487
|
+
if (backend?.kind !== void 0 || mode !== void 0) connect.instance = {
|
|
488
|
+
...backend?.kind !== void 0 ? { reactorWorker: backend.kind === "worker" } : {},
|
|
489
|
+
...mode !== void 0 ? { reactorClient: mode } : {}
|
|
490
|
+
};
|
|
491
|
+
if (reactor?.workflows !== void 0) connect.app = { workflowsEnabled: reactor.workflows };
|
|
492
|
+
return { connect };
|
|
493
|
+
}
|
|
494
|
+
/** Each pre-set env var that CONTRADICTS the host's protocol block, as a
|
|
495
|
+
* message naming the var, the host value and the env value. An env var that
|
|
496
|
+
* merely matches, or is unset, is fine. */
|
|
497
|
+
function protocolConflicts(protocol, env, hostFile = "the host file") {
|
|
498
|
+
if (!protocol) return [];
|
|
499
|
+
return Object.entries(protocolEnv(protocol)).flatMap(([varName, hostValue]) => {
|
|
500
|
+
const envValue = env[varName];
|
|
501
|
+
if (envValue === void 0 || envValue === hostValue) return [];
|
|
502
|
+
return [`reactor.protocol conflict: ${varName} is "${envValue}" in the environment but "${hostValue}" in ${hostFile}. These are fleet-consensus settings — a mismatch would diverge replay. Remove the env override or align the host.`];
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS
|
|
507
|
+
* the host's protocol block, fail loudly naming the var, the host value, and
|
|
508
|
+
* the env value (phase-2 transition keeps an operator's explicit env as an
|
|
509
|
+
* escape hatch unless it disagrees with the protocol — see the WBS
|
|
510
|
+
* precedence note).
|
|
511
|
+
*/
|
|
512
|
+
function assertProtocolConsistency(protocol, env, hostFile = "the host file") {
|
|
513
|
+
const conflict = protocolConflicts(protocol, env, hostFile).at(0);
|
|
514
|
+
if (conflict) throw new Error(conflict);
|
|
515
|
+
}
|
|
516
|
+
function projectStorage(name, storage) {
|
|
517
|
+
switch (storage.kind) {
|
|
518
|
+
case "idb": return { kind: "idb" };
|
|
519
|
+
case "memory": return { kind: "memory" };
|
|
520
|
+
case "path":
|
|
521
|
+
if (!storage.dataDir) throw new Error(`Backend "${name}": storage kind "path" requires dataDir.`);
|
|
522
|
+
return {
|
|
523
|
+
kind: "path",
|
|
524
|
+
dataDir: storage.dataDir
|
|
525
|
+
};
|
|
526
|
+
case "postgres": throw new Error(`Backend "${name}": storage kind "postgres" is server-side only — a provisioned (in-process/worker) reactor cannot use it. Point a "remote" backend at the switchboard that owns that database instead.`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
/** One backend → one descriptor. The protocol's featureFlags ride every
|
|
530
|
+
* descriptor (they are fleet consensus, not per-backend). A remote backend
|
|
531
|
+
* must carry remote.url — provision() requires it. */
|
|
532
|
+
function backendToDescriptor(name, backend, protocol) {
|
|
533
|
+
const descriptor = {
|
|
534
|
+
kind: backend.kind,
|
|
535
|
+
name
|
|
536
|
+
};
|
|
537
|
+
if (descriptor.kind === "remote") {
|
|
538
|
+
const url = backend.remote?.url;
|
|
539
|
+
if (!url) throw new Error(`Backend "${name}" is kind "remote" but has no remote.url — a remote descriptor attaches to an already-running reactor by URL.`);
|
|
540
|
+
descriptor.remote = { url };
|
|
541
|
+
return descriptor;
|
|
542
|
+
}
|
|
543
|
+
if (backend.storage) descriptor.storage = projectStorage(name, backend.storage);
|
|
544
|
+
if (backend.packages) descriptor.packages = backend.packages;
|
|
545
|
+
if (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;
|
|
546
|
+
return descriptor;
|
|
547
|
+
}
|
|
548
|
+
/** All named backends, in placement-primary-first order (the order a
|
|
549
|
+
* createReactorClients step would provision them). */
|
|
550
|
+
function backendsToDescriptors(reactor) {
|
|
551
|
+
const backends = reactor?.backends;
|
|
552
|
+
if (!backends) return [];
|
|
553
|
+
const names = Object.keys(backends);
|
|
554
|
+
const primary = reactor.placement?.primary;
|
|
555
|
+
return (primary && names.includes(primary) ? [primary, ...names.filter((n) => n !== primary)] : names).map((name) => backendToDescriptor(name, backends[name], reactor.protocol));
|
|
556
|
+
}
|
|
557
|
+
const LOCAL_KINDS = /* @__PURE__ */ new Set(["in-process", "worker"]);
|
|
558
|
+
/**
|
|
559
|
+
* Structural multi-reactor (phase 4): true when the block names BOTH a local
|
|
560
|
+
* backend (in-process/worker — the tab's own reactor) and a remote one. This
|
|
561
|
+
* is the shape Connect's routing client serves; a lone remote backend is an
|
|
562
|
+
* attach-only host (assistant/agent shape), not a routed tab.
|
|
563
|
+
*/
|
|
564
|
+
function isStructuralMultiReactor(reactor) {
|
|
565
|
+
const backends = reactor?.backends;
|
|
566
|
+
if (!backends) return false;
|
|
567
|
+
const kinds = Object.values(backends).map((b) => b.kind);
|
|
568
|
+
return kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === "remote");
|
|
569
|
+
}
|
|
570
|
+
/** The remote backends' drive addresses, placement order. */
|
|
571
|
+
function remoteBackendUrls(reactor) {
|
|
572
|
+
return backendsToDescriptors(reactor).filter((d) => d.kind === "remote").map((d) => d.remote?.url).filter((u) => typeof u === "string");
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Instance-fact projection for compound hosts: the drives a compound's
|
|
576
|
+
* reactor member created, projected into the Connect member's runtime-config
|
|
577
|
+
* override. Pure functions, moved from ph-cli's vetra service so the generic
|
|
578
|
+
* compound and the classic path share one implementation.
|
|
579
|
+
*/
|
|
580
|
+
function isLocalDrive(drive) {
|
|
581
|
+
return "local" in drive;
|
|
582
|
+
}
|
|
583
|
+
const driveKey = (drive) => isLocalDrive(drive) ? `local:${drive.id}` : drive.url;
|
|
584
|
+
/**
|
|
585
|
+
* Concatenate groups of `connect.drives.defaultDrives` in the order given,
|
|
586
|
+
* de-duplicating by drive identity (URL for remote entries, id for local
|
|
587
|
+
* ones). The first occurrence of a drive wins, so earlier groups keep their
|
|
588
|
+
* position and metadata — e.g. the Vetra drive `ph vetra` starts stays first
|
|
589
|
+
* even when the project's `powerhouse.config.json` lists the same drive.
|
|
590
|
+
*/
|
|
591
|
+
function mergeDefaultDrives(...groups) {
|
|
592
|
+
const seen = /* @__PURE__ */ new Set();
|
|
593
|
+
const out = [];
|
|
594
|
+
for (const group of groups) for (const drive of group) {
|
|
595
|
+
const key = driveKey(drive);
|
|
596
|
+
if (seen.has(key)) continue;
|
|
597
|
+
seen.add(key);
|
|
598
|
+
out.push(drive);
|
|
599
|
+
}
|
|
600
|
+
return out;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Rebase a local drive URL onto a public base: keeps the /d/<slug> path,
|
|
604
|
+
* swaps the loopback origin for the public base. Browser clients behind a
|
|
605
|
+
* reverse proxy can't reach http://localhost:<port>. Non-loopback URLs
|
|
606
|
+
* (e.g. a remote drive) are already public and pass through unchanged, as do
|
|
607
|
+
* unparseable ones.
|
|
608
|
+
*/
|
|
609
|
+
function rebaseDriveUrl(driveUrl, publicBase) {
|
|
610
|
+
let url;
|
|
611
|
+
try {
|
|
612
|
+
url = new URL(driveUrl);
|
|
613
|
+
} catch {
|
|
614
|
+
return driveUrl;
|
|
615
|
+
}
|
|
616
|
+
if (![
|
|
617
|
+
"localhost",
|
|
618
|
+
"127.0.0.1",
|
|
619
|
+
"[::1]"
|
|
620
|
+
].includes(url.hostname)) return driveUrl;
|
|
621
|
+
return `${publicBase.replace(/\/+$/, "")}${url.pathname}`;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* The compound's drives projection: created drives first (rebased onto the
|
|
625
|
+
* public base when given), then the project's configured drives, de-duplicated
|
|
626
|
+
* — and `preserve-all`, because compound-injected drive lists change per
|
|
627
|
+
* launch context and must never detach drives the user added by hand.
|
|
628
|
+
*/
|
|
629
|
+
function projectDrivesIntoConnect(input) {
|
|
630
|
+
return { drives: {
|
|
631
|
+
defaultDrives: mergeDefaultDrives(input.createdDriveUrls.filter((url) => typeof url === "string" && url.length > 0).map((url) => ({
|
|
632
|
+
url: input.publicBase ? rebaseDriveUrl(url, input.publicBase) : url,
|
|
633
|
+
name: null,
|
|
634
|
+
icon: null
|
|
635
|
+
})), input.configuredDefaultDrives ?? []),
|
|
636
|
+
preserveStrategy: "preserve-all"
|
|
637
|
+
} };
|
|
638
|
+
}
|
|
639
|
+
//#endregion
|
|
640
|
+
export { seedDrives as _, isStructuralMultiReactor as a, primaryBackend as c, protocolConflicts as d, protocolEnv as f, resolveDriveDeclaration as g, remoteBackendUrls as h, exportHost as i, projectDrivesIntoConnect as l, rebaseDriveUrl as m, checkHost as n, mergeDefaultDrives as o, reactorBlockToSwitchboardConfig as p, explainDrivePlan as r, mergeDrivePlan as s, assertProtocolConsistency as t, projectReactorToConnect as u };
|
|
641
|
+
|
|
642
|
+
//# sourceMappingURL=dist-DcARVrSg.mjs.map
|
|
643
|
+
//# debugId=f0f9b514-77e1-57dc-a426-f978cf2eeaba
|