@powerhousedao/ph-cli 6.2.3-dev.79 → 6.2.3-dev.80
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/{build-DUzhIPb7.mjs → build-t5pFQx0f.mjs} +37 -35
- package/dist/build-t5pFQx0f.mjs.map +1 -0
- package/dist/build-wvc_NiGr.mjs +4 -0
- package/dist/{check-DDy1o6Vr.mjs → check-ecwBLzrg.mjs} +5 -5
- package/dist/{check-DDy1o6Vr.mjs.map → check-ecwBLzrg.mjs.map} +1 -1
- package/dist/{cli-connect-override-By7u9IVR.mjs → cli-connect-override-DW7OYAGx.mjs} +4 -4
- package/dist/{cli-connect-override-By7u9IVR.mjs.map → cli-connect-override-DW7OYAGx.mjs.map} +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/{compound-Cfqa5Jal-B5rkCmIj.mjs → compound-C7GuPnTP-Ba4ce2Xa.mjs} +251 -17
- package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs.map +1 -0
- package/dist/{connect-build-BBAZuqpo.mjs → connect-build-7nmQw9c5.mjs} +5 -5
- package/dist/{connect-build-BBAZuqpo.mjs.map → connect-build-7nmQw9c5.mjs.map} +1 -1
- package/dist/{connect-config-ghJlOd-x.mjs → connect-config-CfQwxG8G.mjs} +4 -4
- package/dist/{connect-config-ghJlOd-x.mjs.map → connect-config-CfQwxG8G.mjs.map} +1 -1
- package/dist/{connect-plugin-configs-BoPbxD9u.mjs → connect-plugin-configs-CXN8_KL0.mjs} +4 -4
- package/dist/{connect-plugin-configs-BoPbxD9u.mjs.map → connect-plugin-configs-CXN8_KL0.mjs.map} +1 -1
- package/dist/{connect-preview-8-qLgWKt.mjs → connect-preview-l0Car-nX.mjs} +7 -5
- package/dist/connect-preview-l0Car-nX.mjs.map +1 -0
- package/dist/{connect-studio-BaVeuul3.mjs → connect-studio-Cac3eE_U.mjs} +11 -8
- package/dist/connect-studio-Cac3eE_U.mjs.map +1 -0
- package/dist/{connect-studio-CfggUldW.mjs → connect-studio-Cf6UZvOo.mjs} +3 -3
- package/dist/{dist-Bd6sSt7Y.mjs → dist-DcARVrSg.mjs} +8 -6
- package/dist/dist-DcARVrSg.mjs.map +1 -0
- package/dist/{explain-C9zER5xn.mjs → explain-Rx7JW1OU.mjs} +5 -5
- package/dist/{explain-C9zER5xn.mjs.map → explain-Rx7JW1OU.mjs.map} +1 -1
- package/dist/{export-CrIz2spe.mjs → export-ZnJeAtLS.mjs} +4 -4
- package/dist/{export-CrIz2spe.mjs.map → export-ZnJeAtLS.mjs.map} +1 -1
- package/dist/{generate-all-DgEFOXwU.mjs → generate-all-5Om0CB4N.mjs} +4 -4
- package/dist/{generate-all-DgEFOXwU.mjs.map → generate-all-5Om0CB4N.mjs.map} +1 -1
- package/dist/{generate-desktop-shell-BXcGvbms.mjs → generate-desktop-shell-DzEzNspp.mjs} +4 -4
- package/dist/{generate-desktop-shell-BXcGvbms.mjs.map → generate-desktop-shell-DzEzNspp.mjs.map} +1 -1
- package/dist/{get-version-_coBX13A.mjs → get-version-C-oL2owF.mjs} +4 -4
- package/dist/{get-version-_coBX13A.mjs.map → get-version-C-oL2owF.mjs.map} +1 -1
- package/dist/{index-DdpGYzN0.d.mts → index-CJN_BRkc.d.mts} +5 -3
- package/dist/index-CJN_BRkc.d.mts.map +1 -0
- package/dist/{mcp-CZ02pj76.mjs → mcp-DvyBEajv.mjs} +4 -4
- package/dist/{mcp-CZ02pj76.mjs.map → mcp-DvyBEajv.mjs.map} +1 -1
- package/dist/{member-config-8Vwys-4O.mjs → member-config-0tHtiVN_.mjs} +5 -5
- package/dist/{member-config-8Vwys-4O.mjs.map → member-config-0tHtiVN_.mjs.map} +1 -1
- package/dist/{ph-cli-commands-B37zr8uN.mjs → ph-cli-commands-C8eWT5mr.mjs} +19 -18
- package/dist/ph-cli-commands-C8eWT5mr.mjs.map +1 -0
- package/dist/ph-cli-commands-DviLBBKz.mjs +4 -0
- package/dist/{run-sugar-BzGnofrW.mjs → run-sugar-CRzZsmVo.mjs} +4 -4
- package/dist/{run-sugar-BzGnofrW.mjs.map → run-sugar-CRzZsmVo.mjs.map} +1 -1
- package/dist/runners/connect.d.mts +11 -3
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +36 -12
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +20 -5
- package/dist/runners/switchboard.d.mts.map +1 -1
- package/dist/runners/switchboard.mjs +49 -17
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/{schemas-Cnv5AnQT.mjs → schemas-ByfuhvAb.mjs} +4 -4
- package/dist/{schemas-Cnv5AnQT.mjs.map → schemas-ByfuhvAb.mjs.map} +1 -1
- package/dist/{start-run-BAQDM5Bu.mjs → start-run-CRVBqQ8L.mjs} +4 -4
- package/dist/{start-run-BAQDM5Bu.mjs.map → start-run-CRVBqQ8L.mjs.map} +1 -1
- package/dist/switchboard-B7mvNWcd.mjs +4 -0
- package/dist/{switchboard-BI35F5H7.mjs → switchboard-Cqs5IBNF.mjs} +19 -12
- package/dist/switchboard-Cqs5IBNF.mjs.map +1 -0
- package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
- package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
- package/dist/{vetra-C9fsChId.mjs → vetra-DZYtcHqV.mjs} +7 -7
- package/dist/{vetra-C9fsChId.mjs.map → vetra-DZYtcHqV.mjs.map} +1 -1
- package/package.json +14 -14
- package/dist/build-DUzhIPb7.mjs.map +0 -1
- package/dist/build-FoZl36TM.mjs +0 -4
- package/dist/compound-Cfqa5Jal-B5rkCmIj.mjs.map +0 -1
- package/dist/connect-preview-8-qLgWKt.mjs.map +0 -1
- package/dist/connect-studio-BaVeuul3.mjs.map +0 -1
- package/dist/dist-Bd6sSt7Y.mjs.map +0 -1
- package/dist/index-DdpGYzN0.d.mts.map +0 -1
- package/dist/ph-cli-commands-B37zr8uN.mjs.map +0 -1
- package/dist/ph-cli-commands-S3ArIR8q.mjs +0 -4
- package/dist/switchboard-BI35F5H7.mjs.map +0 -1
- package/dist/switchboard-DohZ1tbp.mjs +0 -4
|
@@ -1,14 +1,15 @@
|
|
|
1
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]="
|
|
3
|
-
import {
|
|
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]="57a0cfdd-936e-5667-92af-0b7932191a13")}catch(e){}}();
|
|
3
|
+
import { c as number, d as string, f as union, g as prettifyError, h as toJSONSchema, i as boolean, l as record, m as url, n as _enum, o as literal, p as unknown, r as array, s as looseObject, t as ZodType, u as strictObject } from "./schemas-ByfuhvAb.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import fs, { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
import { isOriginPlaceholderUrl } from "@powerhousedao/shared/connect/origin-placeholder";
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
9
|
import { pathToFileURL } from "node:url";
|
|
9
|
-
import { TOKEN_ESCAPE_KEY, envTokenable, findToken, isToken, tokenKeyOf, tokenSchema, tokenable } from "@powerhousedao/shared/host-tokens";
|
|
10
|
+
import { TOKEN_ESCAPE_KEY, envTokenable, findToken, isToken, switchboardOfDrive, tokenKeyOf, tokenSchema, tokenable } from "@powerhousedao/shared/host-tokens";
|
|
10
11
|
import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
|
|
11
|
-
//#region ../../packages/host-core/dist/compound-
|
|
12
|
+
//#region ../../packages/host-core/dist/compound-C7GuPnTP.mjs
|
|
12
13
|
/**
|
|
13
14
|
* R1 — the host plugin framework (bridge-runners-to-plugins plan,
|
|
14
15
|
* customization-references/host-core as the blueprint).
|
|
@@ -364,9 +365,20 @@ function projectDriveIdWith(sha256Hex, projectRoot, slug) {
|
|
|
364
365
|
* `config` is runner-defined.
|
|
365
366
|
*
|
|
366
367
|
* Token-able fields (typed-host-configs 3.5): `reactor.backends.*.remote.url`
|
|
367
|
-
* (required), `reactor.drives` (whole list, e.g. `$map`),
|
|
368
|
+
* (required, a switchboard drive address), `reactor.drives` (whole list, e.g. `$map`),
|
|
368
369
|
* `reactor.drives[].remote.url` and `storage.dataDir` (`$env` only). Their z.input admits tokens, their z.output is the resolved type.
|
|
369
370
|
*/
|
|
371
|
+
/** A host's `name` keys its run record, `.ph/run/<name>.json`, so it must be
|
|
372
|
+
* one safe path segment. */
|
|
373
|
+
const HOST_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
374
|
+
const HOST_NAME_MESSAGE = "A host name is used as a file name, so use only letters, digits, '.', '_' and '-', start with a letter or digit, and keep it to 128 characters.";
|
|
375
|
+
const hostNameSchema = string().min(1).max(128, HOST_NAME_MESSAGE).regex(HOST_NAME_PATTERN, HOST_NAME_MESSAGE);
|
|
376
|
+
/**
|
|
377
|
+
* A URL, or one written against the page origin (`${origin}/graphql`): the
|
|
378
|
+
* browser resolves the placeholder when it loads Connect's config, for a
|
|
379
|
+
* member whose own server proxies the switchboard's paths.
|
|
380
|
+
*/
|
|
381
|
+
const originOrUrlSchema = union([url(), string().refine(isOriginPlaceholderUrl, { message: "a URL, or ${origin}/<path> for a proxied sibling" })]);
|
|
370
382
|
const profileSchema = strictObject({
|
|
371
383
|
appId: string().min(1).optional(),
|
|
372
384
|
name: string().min(1).optional(),
|
|
@@ -449,11 +461,184 @@ const FORBID_TOKENS = {
|
|
|
449
461
|
any: (schema) => union([schema]),
|
|
450
462
|
env: (schema) => union([schema])
|
|
451
463
|
};
|
|
464
|
+
/** The replacement a non-drive `remote.url` message names. */
|
|
465
|
+
function useDriveUrl(host = "switchboard", member) {
|
|
466
|
+
return `remote: { url: ${host}.drives.<slug>.url } with ${host} from ../${host}/outputs.js, or remote: { url: { $output: { host: "${host}"${member ? `, member: "${member}"` : ""}, path: ["drives", "<slug>", "url"] } } }`;
|
|
467
|
+
}
|
|
468
|
+
/** The `$output` of a declared `remote.url` that reads `endpoints.graphql`. */
|
|
469
|
+
function endpointsGraphqlRef(url) {
|
|
470
|
+
if (typeof url !== "object" || url === null || !("$output" in url)) return;
|
|
471
|
+
const ref = url.$output;
|
|
472
|
+
if (typeof ref !== "object" || ref === null) return void 0;
|
|
473
|
+
const { host, member, path } = ref;
|
|
474
|
+
if (typeof host !== "string" || !Array.isArray(path)) return void 0;
|
|
475
|
+
if (path.join(".") !== "endpoints.graphql") return void 0;
|
|
476
|
+
return {
|
|
477
|
+
host,
|
|
478
|
+
...typeof member === "string" ? { member } : {}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
/** The slug a drive link names: a `drives.<slug>.url` token's slug or a
|
|
482
|
+
* literal address's served slug; undefined when only runtime knows it. */
|
|
483
|
+
function linkedSlug(url) {
|
|
484
|
+
if (typeof url === "string") return switchboardOfDrive(url)?.slug;
|
|
485
|
+
const ref = typeof url === "object" && url !== null && "$output" in url ? url.$output : void 0;
|
|
486
|
+
const path = Array.isArray(ref?.path) ? ref.path : [];
|
|
487
|
+
return path.length === 3 && path[0] === "drives" && typeof path[1] === "string" && path[2] === "url" ? path[1] : void 0;
|
|
488
|
+
}
|
|
489
|
+
/** The drives a declared host names (home drives, `reactor.drives`, plugin
|
|
490
|
+
* `config.drive` links), or undefined when one is known only at runtime. */
|
|
491
|
+
function knownDriveSlugs(host) {
|
|
492
|
+
const reactor = host.reactor ?? {};
|
|
493
|
+
const slugs = [];
|
|
494
|
+
for (const backend of Object.values(reactor.backends ?? {})) {
|
|
495
|
+
if (backend.kind !== "remote") continue;
|
|
496
|
+
const slug = linkedSlug(backend.remote?.url);
|
|
497
|
+
if (slug === void 0) return void 0;
|
|
498
|
+
slugs.push(slug);
|
|
499
|
+
}
|
|
500
|
+
if (reactor.drives !== void 0) {
|
|
501
|
+
if (!Array.isArray(reactor.drives)) return void 0;
|
|
502
|
+
for (const drive of reactor.drives) if (typeof drive.slug === "string") slugs.push(drive.slug);
|
|
503
|
+
}
|
|
504
|
+
const plugins = Array.isArray(host.runner?.plugins) ? host.runner.plugins : [];
|
|
505
|
+
for (const entry of plugins) {
|
|
506
|
+
const config = typeof entry === "object" && entry !== null && "config" in entry ? entry.config : void 0;
|
|
507
|
+
if (typeof config !== "object" || config === null) continue;
|
|
508
|
+
if (!("drive" in config) || config.drive === void 0) continue;
|
|
509
|
+
const slug = linkedSlug(config.drive);
|
|
510
|
+
if (slug === void 0) return void 0;
|
|
511
|
+
slugs.push(slug);
|
|
512
|
+
}
|
|
513
|
+
return slugs;
|
|
514
|
+
}
|
|
515
|
+
/** Declared form, at host level so plugin drives are seen: a placement key
|
|
516
|
+
* must name a drive the host names, when every drive is knowable. A host
|
|
517
|
+
* with no remote backend is not checked: its plugins may contribute drives
|
|
518
|
+
* (a switchboard's workflows drive) that no field names. */
|
|
519
|
+
function refineDeclaredPlacementKeys(host, ctx) {
|
|
520
|
+
const placed = Object.keys(host.reactor?.placement?.drives ?? {});
|
|
521
|
+
if (placed.length === 0) return;
|
|
522
|
+
if (!Object.values(host.reactor?.backends ?? {}).some((b) => b.kind === "remote")) return;
|
|
523
|
+
const known = knownDriveSlugs(host);
|
|
524
|
+
if (!known) return;
|
|
525
|
+
const names = (slug, served) => served === slug || served.startsWith(`${slug}-`) && /^[0-9a-f]{8}$/.test(served.slice(slug.length + 1));
|
|
526
|
+
for (const slug of placed) {
|
|
527
|
+
if (known.some((served) => names(slug, served))) continue;
|
|
528
|
+
ctx.addIssue({
|
|
529
|
+
code: "custom",
|
|
530
|
+
path: [
|
|
531
|
+
"reactor",
|
|
532
|
+
"placement",
|
|
533
|
+
"drives",
|
|
534
|
+
slug
|
|
535
|
+
],
|
|
536
|
+
message: `placement.drives.${slug} names no drive this host links to or declares (${[...new Set(known)].join(", ") || "none"}).`
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
/** Resolved-form checks across backends, drives and placement: one base is
|
|
541
|
+
* one remote backend, and a drive placed on a remote is on its switchboard. */
|
|
542
|
+
function refineResolvedReactor(reactor, ctx) {
|
|
543
|
+
const backends = reactor.backends ?? {};
|
|
544
|
+
const baseOf = /* @__PURE__ */ new Map();
|
|
545
|
+
const byBase = /* @__PURE__ */ new Map();
|
|
546
|
+
const linked = /* @__PURE__ */ new Map();
|
|
547
|
+
const link = (slug, base) => linked.set(slug, (linked.get(slug) ?? /* @__PURE__ */ new Set()).add(base));
|
|
548
|
+
for (const [name, backend] of Object.entries(backends)) {
|
|
549
|
+
const url = backend.remote?.url;
|
|
550
|
+
if (backend.kind !== "remote" || typeof url !== "string") continue;
|
|
551
|
+
const home = switchboardOfDrive(url);
|
|
552
|
+
if (!home) continue;
|
|
553
|
+
baseOf.set(name, home.base);
|
|
554
|
+
link(home.slug, home.base);
|
|
555
|
+
const first = byBase.get(home.base);
|
|
556
|
+
if (first === void 0) {
|
|
557
|
+
byBase.set(home.base, name);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
ctx.addIssue({
|
|
561
|
+
code: "custom",
|
|
562
|
+
path: [
|
|
563
|
+
"backends",
|
|
564
|
+
name,
|
|
565
|
+
"remote",
|
|
566
|
+
"url"
|
|
567
|
+
],
|
|
568
|
+
message: `backends "${first}" and "${name}" both open drives on the same switchboard (${home.base}). Keep "${first}", and list the second drive under reactor.drives with its remote.url instead.`
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
const kept = /* @__PURE__ */ new Set();
|
|
572
|
+
(Array.isArray(reactor.drives) ? reactor.drives : []).forEach((drive, index) => {
|
|
573
|
+
if (!drive.remote) {
|
|
574
|
+
kept.add(drive.slug);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const at = switchboardOfDrive(drive.remote.url);
|
|
578
|
+
if (at || drive.remote.url === "") {
|
|
579
|
+
if (at) link(drive.slug, at.base);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
ctx.addIssue({
|
|
583
|
+
code: "custom",
|
|
584
|
+
path: [
|
|
585
|
+
"drives",
|
|
586
|
+
index,
|
|
587
|
+
"remote",
|
|
588
|
+
"url"
|
|
589
|
+
],
|
|
590
|
+
message: `remote.url must be a switchboard drive address (<switchboard>/d/<slug>), not ${drive.remote.url}: sync needs the drive. Use url: switchboard.drives.<slug>.url, or url: { $output: { host: "switchboard", path: ["drives", "<slug>", "url"] } }.`
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
const nameOf = (base) => byBase.get(base) ?? base;
|
|
594
|
+
for (const [slug, name] of Object.entries(reactor.placement?.drives ?? {})) {
|
|
595
|
+
const at = [
|
|
596
|
+
"placement",
|
|
597
|
+
"drives",
|
|
598
|
+
slug
|
|
599
|
+
];
|
|
600
|
+
const on = [...linked.get(slug) ?? []];
|
|
601
|
+
if (on.length > 0 && kept.has(slug)) {
|
|
602
|
+
ctx.addIssue({
|
|
603
|
+
code: "custom",
|
|
604
|
+
path: at,
|
|
605
|
+
message: `Drive "${slug}" is both this reactor's own drive and on ${on.map(nameOf).join(" and ")}. Rename one, or link only one.`
|
|
606
|
+
});
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
if (on.length > 1) {
|
|
610
|
+
ctx.addIssue({
|
|
611
|
+
code: "custom",
|
|
612
|
+
path: at,
|
|
613
|
+
message: `Drive "${slug}" is on both ${on.map(nameOf).join(" and ")}. Rename one, or link only one.`
|
|
614
|
+
});
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
const base = baseOf.get(name);
|
|
618
|
+
if (base === void 0) continue;
|
|
619
|
+
if (on.length === 0) {
|
|
620
|
+
if (!kept.has(slug)) continue;
|
|
621
|
+
ctx.addIssue({
|
|
622
|
+
code: "custom",
|
|
623
|
+
path: at,
|
|
624
|
+
message: `placement.drives.${slug} opens drive "${slug}" on "${name}", but this reactor keeps that drive itself. Only a drive on a switchboard can open there without a copy.`
|
|
625
|
+
});
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
if (on[0] === base) continue;
|
|
629
|
+
ctx.addIssue({
|
|
630
|
+
code: "custom",
|
|
631
|
+
path: at,
|
|
632
|
+
message: `placement.drives.${slug} opens drive "${slug}" on "${name}" (${base}), but the drive is on ${on[0]}. Place it on the backend for that switchboard.`
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
452
636
|
/**
|
|
453
637
|
* Builds the host schema set. "allow" (declared form) accepts `T | Token` in
|
|
454
638
|
* every token-able field; "forbid" (resolved form) accepts `T` only.
|
|
455
639
|
*/
|
|
456
640
|
function buildHostSchemas(tokenField) {
|
|
641
|
+
const resolved = tokenField === FORBID_TOKENS;
|
|
457
642
|
const reactorBackendSchema = strictObject({
|
|
458
643
|
kind: reactorBackendKindSchema,
|
|
459
644
|
storage: strictObject({
|
|
@@ -474,12 +659,24 @@ function buildHostSchemas(tokenField) {
|
|
|
474
659
|
/** on-demand model resolution (was DYNAMIC_MODEL_LOADING). */
|
|
475
660
|
dynamic: boolean().optional()
|
|
476
661
|
}).optional(),
|
|
477
|
-
remote: strictObject({ url: tokenField.any(
|
|
662
|
+
remote: strictObject({ url: tokenField.any(originOrUrlSchema) }).optional()
|
|
478
663
|
}).superRefine((backend, ctx) => {
|
|
479
664
|
if (backend.kind === "remote" && !backend.remote) ctx.addIssue({
|
|
480
665
|
code: "custom",
|
|
481
666
|
path: ["remote", "url"],
|
|
482
|
-
message:
|
|
667
|
+
message: `a "remote" backend needs remote.url, a switchboard drive address: ${useDriveUrl()}.`
|
|
668
|
+
});
|
|
669
|
+
const url = backend.remote?.url;
|
|
670
|
+
const graphqlRef = resolved ? void 0 : endpointsGraphqlRef(url);
|
|
671
|
+
if (graphqlRef) ctx.addIssue({
|
|
672
|
+
code: "custom",
|
|
673
|
+
path: ["remote", "url"],
|
|
674
|
+
message: `remote.url reads ${graphqlRef.host}'s endpoints.graphql; it must be a switchboard drive address (<switchboard>/d/<slug>): sync needs the drive. Use ${useDriveUrl(graphqlRef.host, graphqlRef.member)}.`
|
|
675
|
+
});
|
|
676
|
+
if (resolved && typeof url === "string" && !switchboardOfDrive(url)) ctx.addIssue({
|
|
677
|
+
code: "custom",
|
|
678
|
+
path: ["remote", "url"],
|
|
679
|
+
message: `remote.url must be a switchboard drive address (<switchboard>/d/<slug>), not ${url}: sync needs the drive. Use ${useDriveUrl()}.`
|
|
483
680
|
});
|
|
484
681
|
const store = backend.storage;
|
|
485
682
|
const storeDir = store?.kind === "path" ? store.dataDir : void 0;
|
|
@@ -492,7 +689,13 @@ function buildHostSchemas(tokenField) {
|
|
|
492
689
|
});
|
|
493
690
|
const reactorSchema = strictObject({
|
|
494
691
|
backends: record(string(), reactorBackendSchema).optional(),
|
|
495
|
-
placement: strictObject({
|
|
692
|
+
placement: strictObject({
|
|
693
|
+
primary: string().optional(),
|
|
694
|
+
/** Declared drive slug → backend name. A local backend keeps a
|
|
695
|
+
* synced copy; the drive's own remote backend opens it there with
|
|
696
|
+
* no copy. An unlisted drive keeps a synced copy. */
|
|
697
|
+
drives: record(string().min(1), string().min(1)).optional()
|
|
698
|
+
}).optional(),
|
|
496
699
|
protocol: reactorProtocolSchema.optional(),
|
|
497
700
|
/** DEPRECATED (dies in R2): workflows become a listed plugin. */
|
|
498
701
|
workflows: boolean().optional(),
|
|
@@ -503,6 +706,21 @@ function buildHostSchemas(tokenField) {
|
|
|
503
706
|
}).optional(),
|
|
504
707
|
namespace: string().min(1).optional(),
|
|
505
708
|
drives: tokenField.any(array(buildDriveDeclarationSchema(tokenField.any))).optional()
|
|
709
|
+
}).superRefine((reactor, ctx) => {
|
|
710
|
+
const backends = reactor.backends ?? {};
|
|
711
|
+
for (const [slug, name] of Object.entries(reactor.placement?.drives ?? {})) {
|
|
712
|
+
if (Object.hasOwn(backends, name)) continue;
|
|
713
|
+
ctx.addIssue({
|
|
714
|
+
code: "custom",
|
|
715
|
+
path: [
|
|
716
|
+
"placement",
|
|
717
|
+
"drives",
|
|
718
|
+
slug
|
|
719
|
+
],
|
|
720
|
+
message: `placement.drives.${slug} names backend "${name}", which is not in backends (${Object.keys(backends).join(", ") || "none"}).`
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
if (resolved) refineResolvedReactor(reactor, ctx);
|
|
506
724
|
});
|
|
507
725
|
/** Common runner options; runner modules extend it with their own. */
|
|
508
726
|
const runnerBaseSchema = looseObject({
|
|
@@ -531,14 +749,14 @@ function buildHostSchemas(tokenField) {
|
|
|
531
749
|
childWrapperSchema,
|
|
532
750
|
childrenSchema,
|
|
533
751
|
reactorHostSchema: strictObject({
|
|
534
|
-
name:
|
|
752
|
+
name: hostNameSchema,
|
|
535
753
|
runner: runnerBaseSchema,
|
|
536
754
|
config: looseObject({}).optional(),
|
|
537
755
|
profile: profileSchema.optional(),
|
|
538
756
|
reactor: reactorSchema.optional()
|
|
539
757
|
}),
|
|
540
758
|
compoundHostSchema: strictObject({
|
|
541
|
-
name:
|
|
759
|
+
name: hostNameSchema,
|
|
542
760
|
runner: runnerBaseSchema,
|
|
543
761
|
children: childrenSchema,
|
|
544
762
|
config: looseObject({}).optional(),
|
|
@@ -557,6 +775,13 @@ function buildHostSchemas(tokenField) {
|
|
|
557
775
|
function makeHostSchemas(options) {
|
|
558
776
|
return buildHostSchemas(options.tokens === "allow" ? ALLOW_TOKENS : FORBID_TOKENS);
|
|
559
777
|
}
|
|
778
|
+
/** Adds the host-level placement key check to a runner's declared schema. */
|
|
779
|
+
function withPlacementKeys(schema) {
|
|
780
|
+
if (!(schema instanceof ZodType)) return schema;
|
|
781
|
+
return schema.superRefine((host, ctx) => {
|
|
782
|
+
if (typeof host === "object" && host !== null && "reactor" in host) refineDeclaredPlacementKeys(host, ctx);
|
|
783
|
+
});
|
|
784
|
+
}
|
|
560
785
|
/**
|
|
561
786
|
* One runner definition, two schemas (3.5): `build` runs over the DECLARED
|
|
562
787
|
* set (tokens allowed; its z.input types host files) and the RESOLVED set
|
|
@@ -567,7 +792,7 @@ function makeHostSchemas(options) {
|
|
|
567
792
|
*/
|
|
568
793
|
function defineHostSchemas(build) {
|
|
569
794
|
return {
|
|
570
|
-
declaredHostSchema: build(declaredSchemas),
|
|
795
|
+
declaredHostSchema: withPlacementKeys(build(declaredSchemas)),
|
|
571
796
|
hostSchema: build(resolvedSchemas)
|
|
572
797
|
};
|
|
573
798
|
}
|
|
@@ -1173,7 +1398,11 @@ function checkReactor(reactor, base, found) {
|
|
|
1173
1398
|
const producer = typeof host === "string" ? host : "switchboard";
|
|
1174
1399
|
found.push({
|
|
1175
1400
|
path: `${base}reactor.backends.${name}.remote.host`,
|
|
1176
|
-
message: `remote: { host } was removed; use remote: { url: ${producer}.
|
|
1401
|
+
message: `remote: { host } was removed; use a drive address: remote: { url: ${producer}.drives.<slug>.url } with ${producer} from ../${producer}/outputs.js, or remote: { url: ${outputToken(producer, [
|
|
1402
|
+
"drives",
|
|
1403
|
+
"<slug>",
|
|
1404
|
+
"url"
|
|
1405
|
+
])} }.`
|
|
1177
1406
|
});
|
|
1178
1407
|
}
|
|
1179
1408
|
}
|
|
@@ -1860,7 +2089,7 @@ function hostSchemaIssues(runner, schema, specifier, host, options = {}) {
|
|
|
1860
2089
|
schemaIssues: result.error.issues.map((issue) => {
|
|
1861
2090
|
const element = describeMapElements(host, issue.path);
|
|
1862
2091
|
const dotted = (issue.path.map(String).join(".") || "<root>") + (element ? ` (${element})` : "");
|
|
1863
|
-
const message = tokenKeyOf(valueAt(host, issue.path)) ? "this field does not take an output token (it is not token-able); spell the value literally." : issue.message;
|
|
2092
|
+
const message = issue.code !== "custom" && tokenKeyOf(valueAt(host, issue.path)) ? "this field does not take an output token (it is not token-able); spell the value literally." : issue.message;
|
|
1864
2093
|
return {
|
|
1865
2094
|
path: formatPath(issue.path.filter((key) => typeof key === "string" || typeof key === "number")),
|
|
1866
2095
|
message: element ? `${message} (${element})` : message,
|
|
@@ -2274,7 +2503,7 @@ const runRecordMemberSchema = strictObject({
|
|
|
2274
2503
|
});
|
|
2275
2504
|
const runRecordSchema = strictObject({
|
|
2276
2505
|
version: literal(2),
|
|
2277
|
-
host:
|
|
2506
|
+
host: hostNameSchema,
|
|
2278
2507
|
projectName: string(),
|
|
2279
2508
|
kind: runnerKindSchema,
|
|
2280
2509
|
verb: string().min(1),
|
|
@@ -2288,7 +2517,12 @@ const runRecordSchema = strictObject({
|
|
|
2288
2517
|
extra: record(string(), unknown()).optional()
|
|
2289
2518
|
});
|
|
2290
2519
|
const runDir = (projectDir, env = process.env) => path.join(resolvePhDir(projectDir, env), "run");
|
|
2291
|
-
|
|
2520
|
+
function recordPath(projectDir, hostName, env) {
|
|
2521
|
+
const dir = runDir(projectDir, env);
|
|
2522
|
+
const file = path.resolve(dir, `${hostName}.json`);
|
|
2523
|
+
if (!hostNameSchema.safeParse(hostName).success || path.dirname(file) !== path.resolve(dir)) throw new Error(`"${hostName}" can't name a run record. ${HOST_NAME_MESSAGE}`);
|
|
2524
|
+
return file;
|
|
2525
|
+
}
|
|
2292
2526
|
function readRunRecord(projectDir, hostName, env = process.env) {
|
|
2293
2527
|
let raw;
|
|
2294
2528
|
try {
|
|
@@ -2575,5 +2809,5 @@ async function prepareMember(projectRoot, key, member) {
|
|
|
2575
2809
|
//#endregion
|
|
2576
2810
|
export { takesCspRegistrySync as $, loadProducers as A, processResolveEnv as B, hostSchemaIssues as C, isToken as D, isSchemaLike as E, outputSitesOf as F, renderTokens as G, projectDriveIdWith as H, planCompound as I, resolvePluginContributions as J, resolveHostOutputs as K, prepareMember as L, memberVerbOf as M, normalizePluginEntries as N, kindShapeIssues as O, outputRefsOf as P, substituteBuiltinEnv as Q, probeHostsFolder as R, getVerb as S, isPlainObject as T, readProjectName as U, producerOutputsSchemas as V, readRunRecord as W, runRecordOutputSource as X, resolveRunnerModule as Y, runnerOutputsSchema as Z, entryActiveForVerb as _, TokenResolutionError as a, findRemovedForms as b, checkTokenSites as c, compoundOutputSource as d, toStartedHandle as et, compoundStartVerb as f, drivesSchema as g, describeToken as h, PluginError as i, writeRunRecord as it, memberForRef as j, loadHost as k, clearRunRecord as l, defineHostSchemas as m, HostLoadError as n, validateDeclaredHost as nt, applyChildWrapper as o, declaredHostSchemas as p, resolveHostPlugins as q, ONE_SHOT_VERBS as r, validateHost as rt, checkOutputPaths as s, CONNECT_RUNNER as t, unsetEnvMessage as tt, collectTokenSites as u, envSitesOf as v, isBuiltinEnvName as w, formatPath as x, findDeadConnectConfig as y, probeRun as z };
|
|
2577
2811
|
|
|
2578
|
-
//# sourceMappingURL=compound-
|
|
2579
|
-
//# debugId=
|
|
2812
|
+
//# sourceMappingURL=compound-C7GuPnTP-Ba4ce2Xa.mjs.map
|
|
2813
|
+
//# debugId=57a0cfdd-936e-5667-92af-0b7932191a13
|