@powerhousedao/switchboard 6.2.3-staging.0 → 6.3.0-dev.1
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/.tsbuild/test/ai-gateway.test.d.ts +2 -0
- package/.tsbuild/test/ai-gateway.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-helpers.d.ts +5 -0
- package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
- package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts +2 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-undo-v3-flag.test.d.ts +2 -0
- package/.tsbuild/test/boot-undo-v3-flag.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
- package/.tsbuild/test/config-from-env.test.d.ts +2 -0
- package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
- package/.tsbuild/test/config-merge.test.d.ts +2 -0
- package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
- package/.tsbuild/test/config-schema.test.d.ts +2 -0
- package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
- package/.tsbuild/test/default-composition.test.d.ts +2 -0
- package/.tsbuild/test/default-composition.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
- package/.tsbuild/test/delegated-publish.test.d.ts +2 -0
- package/.tsbuild/test/delegated-publish.test.d.ts.map +1 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.d.ts +13 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/index.d.ts +3 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/index.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/tally/index.d.ts +7 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/tally/index.d.ts.map +1 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts +2 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts.map +1 -0
- package/.tsbuild/test/observability-signals.test.d.ts +2 -0
- package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-store.test.d.ts +2 -0
- package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
- package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
- package/.tsbuild/test/port-probe.test.d.ts +2 -0
- package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts +2 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts.map +1 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas-mixed-package.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas-mixed-package.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/shutdown.test.d.ts +2 -0
- package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
- package/.tsbuild/test/snapshot-writer.d.ts +18 -0
- package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
- package/.tsbuild/test/store-lock.test.d.ts +2 -0
- package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
- package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
- package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts +2 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/Auth.md +108 -2
- package/CHANGELOG.md +1065 -1
- package/README.md +69 -24
- package/dist/boot.d.mts +46 -0
- package/dist/boot.d.mts.map +1 -0
- package/dist/boot.mjs +67 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/config/from-env.d.mts +15 -0
- package/dist/config/from-env.d.mts.map +1 -0
- package/dist/config/from-env.mjs +4 -0
- package/dist/config/schema.d.mts +3 -0
- package/dist/config/schema.mjs +4 -0
- package/dist/from-env-DKK_wPrO.mjs +497 -0
- package/dist/from-env-DKK_wPrO.mjs.map +1 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +40 -219
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-VW52B8KD.mjs +32 -0
- package/dist/mcp-VW52B8KD.mjs.map +1 -0
- package/dist/migrate.mjs +5 -4
- package/dist/migrate.mjs.map +1 -1
- package/dist/observability-CldagyT_.mjs +224 -0
- package/dist/observability-CldagyT_.mjs.map +1 -0
- package/dist/observability.d.mts +30 -0
- package/dist/observability.d.mts.map +1 -0
- package/dist/observability.mjs +4 -0
- package/dist/plugin-host-tTjDTNz0.d.mts +46 -0
- package/dist/plugin-host-tTjDTNz0.d.mts.map +1 -0
- package/dist/plugins/ai.d.mts +37 -0
- package/dist/plugins/ai.d.mts.map +1 -0
- package/dist/plugins/ai.mjs +400 -0
- package/dist/plugins/ai.mjs.map +1 -0
- package/dist/plugins/attachments.d.mts +33 -0
- package/dist/plugins/attachments.d.mts.map +1 -0
- package/dist/plugins/attachments.mjs +4 -0
- package/dist/plugins/mcp.d.mts +31 -0
- package/dist/plugins/mcp.d.mts.map +1 -0
- package/dist/plugins/mcp.mjs +4 -0
- package/dist/plugins/privacy.d.mts +22 -0
- package/dist/plugins/privacy.d.mts.map +1 -0
- package/dist/plugins/privacy.mjs +4 -0
- package/dist/plugins/workflows.d.mts +80 -0
- package/dist/plugins/workflows.d.mts.map +1 -0
- package/dist/plugins/workflows.mjs +4 -0
- package/dist/postgres-url-DTDhBjXX.mjs +11 -0
- package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
- package/dist/privacy-HQnhqf2H.mjs +91 -0
- package/dist/privacy-HQnhqf2H.mjs.map +1 -0
- package/dist/privacy-UodgY0i_.mjs +44 -0
- package/dist/privacy-UodgY0i_.mjs.map +1 -0
- package/dist/renown-layers-DmbWLt46.mjs +42 -0
- package/dist/renown-layers-DmbWLt46.mjs.map +1 -0
- package/dist/schema-BJ-OFAox.mjs +359 -0
- package/dist/schema-BJ-OFAox.mjs.map +1 -0
- package/dist/schema-w1lShimw.d.mts +258 -0
- package/dist/schema-w1lShimw.d.mts.map +1 -0
- package/dist/server-BS-PFzoK.mjs +2752 -0
- package/dist/server-BS-PFzoK.mjs.map +1 -0
- package/dist/server.d.mts +94 -228
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +5 -4
- package/dist/types-Bk4T4D9F.d.mts +318 -0
- package/dist/types-Bk4T4D9F.d.mts.map +1 -0
- package/dist/utils-Cm0TE6dP.mjs +148 -0
- package/dist/utils-Cm0TE6dP.mjs.map +1 -0
- package/dist/utils.d.mts +29 -3
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +5 -4
- package/dist/worker-pool-gyxJnCxA.mjs +304 -0
- package/dist/worker-pool-gyxJnCxA.mjs.map +1 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts +33 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts.map +1 -0
- package/dist/workflows-mdYUh3Us.mjs +1947 -0
- package/dist/workflows-mdYUh3Us.mjs.map +1 -0
- package/package.json +86 -24
- package/scripts/install-packages.sh +0 -0
- package/test/ai-gateway.test.ts +612 -0
- package/test/attachment-reference-read-model.test.ts +28 -20
- package/test/attachments/byte-grants.test.ts +4 -1
- package/test/attachments/download-target.test.ts +36 -20
- package/test/attachments/index.test.ts +13 -1
- package/test/attachments/reserve-metadata-parity.test.ts +96 -0
- package/test/attachments/routes-integration.test.ts +1 -0
- package/test/attachments/routes.test.ts +132 -12
- package/test/attachments/service-config.test.ts +28 -16
- package/test/boot-auth-config.test.ts +146 -0
- package/test/boot-create-signature-policy.test.ts +15 -13
- package/test/boot-desktop-auth.test.ts +278 -0
- package/test/boot-env-isolation.test.ts +26 -0
- package/test/boot-helpers.ts +19 -0
- package/test/boot-inspection-enabled.test.ts +140 -0
- package/test/boot-mcp-auth.test.ts +449 -0
- package/test/boot-mcp-enabled.test.ts +27 -27
- package/test/boot-port-zero.test.ts +101 -0
- package/test/boot-preconditions.test.ts +213 -0
- package/test/boot-privacy.test.ts +232 -0
- package/test/boot-ready-drives.test.ts +141 -0
- package/test/boot-undo-v3-flag.test.ts +120 -0
- package/test/boot-unsupported-stored-documents.test.ts +23 -19
- package/test/boot-without-renown.test.ts +11 -9
- package/test/boot-without-require-signatures.test.ts +12 -10
- package/test/boot-worker-trust-policy.test.ts +11 -10
- package/test/boot-workflow-singleton-conflict.test.ts +109 -0
- package/test/boot-workflow-singleton-retry.test.ts +122 -0
- package/test/config-from-env.test.ts +968 -0
- package/test/config-merge.test.ts +351 -0
- package/test/config-schema.test.ts +183 -0
- package/test/default-composition.test.ts +290 -0
- package/test/default-drive-protocol-versions.test.ts +79 -0
- package/test/default-drive-slug.test.ts +265 -0
- package/test/delegated-publish.test.ts +435 -0
- package/test/durable-node-fs-pg16.test.ts +80 -0
- package/test/fatal-shutdown.test.ts +104 -1
- package/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.ts +16 -0
- package/test/fixtures/mixed-subgraphs/subgraphs/index.ts +3 -0
- package/test/fixtures/mixed-subgraphs/subgraphs/tally/index.ts +73 -0
- package/test/goldens/packages.graphql +797 -0
- package/test/goldens/privacy.graphql +853 -0
- package/test/goldens/reactor-drive-nodes.graphql +827 -0
- package/test/goldens/resolvers.json +327 -0
- package/test/goldens/supergraph.graphql +5918 -0
- package/test/goldens/workflow-runtime.graphql +1548 -0
- package/test/inspection-throttle.test.ts +23 -0
- package/test/keyframe-reclaim-store.test.ts +156 -0
- package/test/observability-signals.test.ts +131 -0
- package/test/permissions-backfill.test.ts +486 -0
- package/test/pglite-dialect.test.ts +237 -2
- package/test/pglite-preflight.test.ts +313 -0
- package/test/pglite-storage-dirs.test.ts +113 -0
- package/test/pglite-store.test.ts +441 -0
- package/test/pglite-version.test.ts +9 -1
- package/test/plugin-config-schemas.test.ts +83 -0
- package/test/plugin-presence.test.ts +262 -0
- package/test/port-probe.test.ts +45 -0
- package/test/processor-timing-log.test.ts +109 -0
- package/test/reactor-feature-flags.test.ts +20 -0
- package/test/redact-webhook-path.test.ts +9 -0
- package/test/renown-storage-path.test.ts +40 -0
- package/test/renown-trust-policy.test.ts +7 -9
- package/test/served-schemas-mixed-package.test.ts +251 -0
- package/test/served-schemas.test.ts +134 -0
- package/test/shutdown.test.ts +278 -0
- package/test/snapshot-writer.ts +94 -0
- package/test/store-lock.test.ts +65 -0
- package/test/two-switchboards.test.ts +146 -0
- package/test/worker-pool.test.ts +27 -1
- package/test/workflow/oauth-apps-config.test.ts +66 -0
- package/test/workflow/oauth.test.ts +82 -10
- package/test/workflow/resolvers.test.ts +230 -38
- package/test/workflow/runtime-host.test.ts +19 -0
- package/test/workflow/waitpoint-routes.test.ts +306 -0
- package/test/workflow/waitpoint-runtime.test.ts +204 -0
- package/test/workflow/webhook-trigger-test.test.ts +8 -0
- package/test/workflow-reactor-access.test.ts +384 -0
- package/test/workflow-reactor-enforcement.test.ts +808 -0
- package/test/workflow-read-gate.test.ts +128 -60
- package/test/workflow-runtime.test.ts +1005 -237
- package/test/workflows-plugin-config.test.ts +77 -0
- package/tsconfig.json +5 -2
- package/tsdown.config.ts +12 -0
- package/vitest.config.ts +66 -1
- package/.tsbuild/test/mcp-flag.test.d.ts +0 -2
- package/.tsbuild/test/mcp-flag.test.d.ts.map +0 -1
- package/dist/server-sQoWp21G.mjs +0 -2939
- package/dist/server-sQoWp21G.mjs.map +0 -1
- package/dist/utils-uaBlzyjS.mjs +0 -86
- package/dist/utils-uaBlzyjS.mjs.map +0 -1
- package/test/mcp-flag.test.ts +0 -56
package/dist/server.d.mts
CHANGED
|
@@ -1,221 +1,24 @@
|
|
|
1
|
+
import { a as SwitchboardConfigInput, i as SwitchboardConfig } from "./schema-w1lShimw.mjs";
|
|
2
|
+
import { n as WorkflowTriggersCapability } from "./workflow-runtime-CF5pc8mt.mjs";
|
|
3
|
+
import { a as SwitchboardDriveDocumentType, i as SwitchboardDeps, n as StartServerOptions, o as SwitchboardDriveInput, r as StorageOptions, s as SwitchboardReactor, t as IdentityOptions } from "./types-Bk4T4D9F.mjs";
|
|
1
4
|
import { ILogger } from "document-model";
|
|
2
|
-
import { ChannelScheme,
|
|
3
|
-
import {
|
|
4
|
-
import { IAttachmentService } from "@powerhousedao/reactor-attachments";
|
|
5
|
-
import { IRenown } from "@renown/sdk/node";
|
|
6
|
-
import { DriveInput } from "@powerhousedao/shared/document-drive";
|
|
5
|
+
import { ChannelScheme, Database, IDocumentModelLoader, IStoreMaintenance, JwtHandler, KeyframeSettings, PoolInstrumentation, ReactorBuilder, ReactorClientBuilder, ReactorFeatureFlags, ReactorStorageFacts, SignerConfig, StoredProtocolRefusal, UnsupportedStoredDocuments, UnsupportedStoredProtocolError } from "@powerhousedao/reactor";
|
|
6
|
+
import { PGliteLike, PgliteMaintenanceSettings, resolvePgliteMaintenance } from "@powerhousedao/reactor-api/pglite-node";
|
|
7
7
|
import { DocumentModelModule, SignaturePolicy, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
8
|
-
import "@
|
|
9
|
-
import "
|
|
10
|
-
import
|
|
11
|
-
//#region src/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type WorkflowTriggersCapability = {
|
|
15
|
-
status: "available";
|
|
16
|
-
} | {
|
|
17
|
-
status: "unavailable";
|
|
18
|
-
reason: "in-process-reactor-module-unavailable" | "live-read-model-registration-unsupported";
|
|
19
|
-
};
|
|
8
|
+
import { IRenown } from "@renown/sdk/node";
|
|
9
|
+
import { Kysely } from "kysely";
|
|
10
|
+
import "@electric-sql/pglite";
|
|
11
|
+
//#region src/pglite-version.d.ts
|
|
12
|
+
declare const SUPPORTED_PG_MAJORS: readonly [16, 17];
|
|
13
|
+
type SupportedPgMajor = (typeof SUPPORTED_PG_MAJORS)[number];
|
|
20
14
|
//#endregion
|
|
21
|
-
//#region src/
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export type SwitchboardDriveDocumentType = "powerhouse/document-drive" | "powerhouse/reactor-drive";
|
|
29
|
-
/** A {@link DriveInput} extended with the optional drive-container type. */
|
|
30
|
-
export type SwitchboardDriveInput = DriveInput & {
|
|
31
|
-
documentType?: SwitchboardDriveDocumentType;
|
|
32
|
-
};
|
|
33
|
-
export type StorageOptions = {
|
|
34
|
-
type: "filesystem" | "memory" | "postgres" | "browser";
|
|
35
|
-
filesystemPath?: string;
|
|
36
|
-
postgresUrl?: string;
|
|
37
|
-
};
|
|
38
|
-
export type IdentityOptions = {
|
|
39
|
-
/** Path to the keypair file. Defaults to ~/.ph/keypair.json */
|
|
40
|
-
keypairPath?: string;
|
|
41
|
-
/**
|
|
42
|
-
* If true, won't start without an existing keypair.
|
|
43
|
-
* Use this to ensure the switchboard only runs with an authenticated identity.
|
|
44
|
-
*/
|
|
45
|
-
requireExisting?: boolean;
|
|
46
|
-
/** Base url of the Renown instance to use */
|
|
47
|
-
baseUrl?: string;
|
|
48
|
-
};
|
|
49
|
-
export type StartServerOptions = {
|
|
50
|
-
/**
|
|
51
|
-
* Pre-built ReactorClientModule (typically from
|
|
52
|
-
* `@powerhousedao/reactor#ReactorClientBuilder.buildModule`). When set, the
|
|
53
|
-
* switchboard reuses the caller's reactor instead of building its own,
|
|
54
|
-
* and the caller owns the reactor's lifecycle. The API, GraphQL manager,
|
|
55
|
-
* MCP, attachments, package management subgraph, and registry HTTP loader
|
|
56
|
-
* are still configured around it.
|
|
57
|
-
*
|
|
58
|
-
* Lifecycle contract: switchboard does NOT wire itself into the caller's
|
|
59
|
-
* reactor shutdown. Callers must invoke `shutdown()` on the returned
|
|
60
|
-
* `SwitchboardReactor` from their own teardown (and SIGINT handlers) to
|
|
61
|
-
* drain `/graphql`, MCP, attachments, etc. Killing the caller's reactor
|
|
62
|
-
* alone will not release these resources.
|
|
63
|
-
*
|
|
64
|
-
* Setup contract: the reactor must have switchboard's expected wiring
|
|
65
|
-
* already applied — channel scheme, document models, signal handlers,
|
|
66
|
-
* etc. Use `applySwitchboardReactorDefaults` from this module to apply
|
|
67
|
-
* the same defaults switchboard uses internally; opt out of individual
|
|
68
|
-
* pieces as needed.
|
|
69
|
-
*/
|
|
70
|
-
reactor?: InProcessReactorClientModule;
|
|
71
|
-
/**
|
|
72
|
-
* Route uncaught exceptions, and unhandled rejections nothing else listens
|
|
73
|
-
* for, through the reactor's SIGTERM shutdown, so PGlite stores are flushed
|
|
74
|
-
* before the process exits with code 1. Installed once the switchboard's own reactor is built;
|
|
75
|
-
* ignored when `reactor` is passed. For process entry points only, since
|
|
76
|
-
* it adds process-wide listeners.
|
|
77
|
-
*/
|
|
78
|
-
fatalErrorShutdown?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Registry URL for the HttpPackageLoader. Enables `PackagesSubgraph`
|
|
81
|
-
* (install/uninstall mutations) plus dynamic package resolution.
|
|
82
|
-
* Falls back to PH_REGISTRY_URL env, then `packageRegistryUrl` in the
|
|
83
|
-
* powerhouse config file.
|
|
84
|
-
*/
|
|
85
|
-
registryUrl?: string;
|
|
86
|
-
configFile?: string;
|
|
87
|
-
port?: number;
|
|
88
|
-
/**
|
|
89
|
-
* If true, fail immediately when the requested port is in use instead of
|
|
90
|
-
* falling back to the next free port. Matches the semantics of Vite's
|
|
91
|
-
* `--strictPort` flag that flows through the `ph vetra` command.
|
|
92
|
-
*/
|
|
93
|
-
strictPort?: boolean;
|
|
94
|
-
dev?: boolean;
|
|
95
|
-
dbPath?: string;
|
|
96
|
-
drive?: SwitchboardDriveInput;
|
|
97
|
-
packages?: string[];
|
|
98
|
-
remoteDrives?: string[];
|
|
99
|
-
https?: {
|
|
100
|
-
keyPath: string;
|
|
101
|
-
certPath: string;
|
|
102
|
-
} | boolean | undefined;
|
|
103
|
-
/**
|
|
104
|
-
* Identity options for Renown.
|
|
105
|
-
* When configured, the switchboard will load the keypair from `ph login`
|
|
106
|
-
* and can authenticate with remote services on behalf of the user.
|
|
107
|
-
*/
|
|
108
|
-
identity?: IdentityOptions;
|
|
109
|
-
/** Base URL for the attachment service; defaults to `PH_SWITCHBOARD_PUBLIC_URL` then `http(s)://localhost:${port}`. */
|
|
110
|
-
attachmentServiceUrl?: string;
|
|
111
|
-
/** Mount the MCP server at `/mcp`. On by default; `false` wins over
|
|
112
|
-
* MCP_ENABLED, which can turn it off but never on. */
|
|
113
|
-
mcp?: boolean;
|
|
114
|
-
/** Powerhouse workflows: the runtime, its subgraph, its webhooks and its
|
|
115
|
-
* document models. Wins over PH_WORKFLOWS_ENABLED and the config file. */
|
|
116
|
-
workflows?: {
|
|
117
|
-
enabled?: boolean;
|
|
118
|
-
};
|
|
119
|
-
processorConfig?: Map<string, unknown>;
|
|
120
|
-
disableLocalPackages?: boolean;
|
|
121
|
-
enableDocumentModelSubgraphs?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* When true, enables dynamic loading of document models from the registry
|
|
124
|
-
* when an unknown document type is encountered during sync.
|
|
125
|
-
* Disabled by default — enable with DYNAMIC_MODEL_LOADING=true env var.
|
|
126
|
-
*/
|
|
127
|
-
dynamicModelLoading?: boolean;
|
|
128
|
-
logger?: ILogger;
|
|
129
|
-
/**
|
|
130
|
-
* When true, on startup any local PGLite data dirs whose `PG_VERSION` is
|
|
131
|
-
* older than the bundled PGLite are migrated to the current version
|
|
132
|
-
* (backup → dump → restore) before the server boots. When false, the
|
|
133
|
-
* server logs a warning and runs against the legacy data using the
|
|
134
|
-
* matching legacy PGLite module.
|
|
135
|
-
*
|
|
136
|
-
* Triggered by the `--migrate-pglite` CLI flag or `PH_MIGRATE_PGLITE=true`.
|
|
137
|
-
*/
|
|
138
|
-
migratePglite?: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Force a specific PGLite-embedded PG major (16 or 17) on startup.
|
|
141
|
-
*
|
|
142
|
-
* **Destructive**: any existing local PGLite data dirs are wiped before
|
|
143
|
-
* the chosen PGLite re-`initdb`'s them at the requested version. Postgres
|
|
144
|
-
* URLs are unaffected. Takes precedence over `migratePglite`.
|
|
145
|
-
*
|
|
146
|
-
* Triggered by `PH_FORCE_PG_VERSION=16|17`.
|
|
147
|
-
*/
|
|
148
|
-
forcePgVersion?: 16 | 17;
|
|
149
|
-
/**
|
|
150
|
-
* Executor worker pool: `numWorkers > 0` runs jobs in N worker threads;
|
|
151
|
-
* `"auto"` sizes the pool from the machine's available cores; 0 or unset
|
|
152
|
-
* keeps the in-process executor (the default). Unset fields fall back to
|
|
153
|
-
* the REACTOR_WORKERS / REACTOR_DB_* env vars. Requires a Postgres reactor
|
|
154
|
-
* database; incompatible with `dev` mode (Vite-loaded models cannot cross
|
|
155
|
-
* a thread boundary).
|
|
156
|
-
*/
|
|
157
|
-
workerPool?: {
|
|
158
|
-
numWorkers?: number | "auto";
|
|
159
|
-
dbPoolSizePerWorker?: number;
|
|
160
|
-
acquireTimeoutMs?: number;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Projection worker: `enabled` runs the built-in document-view /
|
|
164
|
-
* document-indexer read models in one worker thread, off the host event
|
|
165
|
-
* loop; unset keeps them in-process (the default). Unset fields fall back
|
|
166
|
-
* to the REACTOR_PROJECTION_WORKER / REACTOR_DB_POOL_SIZE_PROJECTION env
|
|
167
|
-
* vars. Requires a Postgres reactor database and worker-importable
|
|
168
|
-
* document-model sources (switchboard resolves them itself); incompatible
|
|
169
|
-
* with `dev` mode (Vite-loaded models cannot cross a thread boundary).
|
|
170
|
-
*/
|
|
171
|
-
projectionWorker?: {
|
|
172
|
-
enabled?: boolean;
|
|
173
|
-
dbPoolSize?: number;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Stored documents at protocol versions this build does not run: "refuse"
|
|
177
|
-
* (the default) fails the boot with a StoredDocumentsRefusedError;
|
|
178
|
-
* "read-only" starts with a warning and keeps those documents read-only.
|
|
179
|
-
* Unset falls back to the REACTOR_UNSUPPORTED_STORED_DOCUMENTS env var.
|
|
180
|
-
* Ignored when `reactor` is passed.
|
|
181
|
-
*/
|
|
182
|
-
unsupportedStoredDocuments?: UnsupportedStoredDocuments;
|
|
183
|
-
};
|
|
184
|
-
export type SwitchboardReactor = {
|
|
185
|
-
defaultDriveUrl: string | undefined;
|
|
186
|
-
reactor: IReactorClient;
|
|
187
|
-
/** Switchboard-backed remote attachment service over its own `/attachments/*` API, for downstream consumers. */
|
|
188
|
-
attachmentService: IAttachmentService;
|
|
189
|
-
/** Whether the authoritative attachment-reference projection is active. */
|
|
190
|
-
attachmentReferenceProjection: AttachmentReferenceProjectionCapability;
|
|
191
|
-
/** Whether the workflow runtime's operation intake is indexing. Undefined
|
|
192
|
-
* when workflows are off; unavailable means no document trigger fires. */
|
|
193
|
-
workflowTriggers?: WorkflowTriggersCapability;
|
|
194
|
-
/** Whether workflows are on, after the option, PH_WORKFLOWS_ENABLED and the config file. */
|
|
195
|
-
workflowsEnabled: boolean;
|
|
196
|
-
/** Whether `/mcp` is mounted, after the option and MCP_ENABLED. */
|
|
197
|
-
mcpEnabled: boolean;
|
|
198
|
-
/** The Renown instance if identity was initialized */
|
|
199
|
-
renown: IRenown$1 | null;
|
|
200
|
-
/**
|
|
201
|
-
* Port the HTTP server actually bound to. May differ from the requested
|
|
202
|
-
* port when the requested port was in use and fallback kicked in.
|
|
203
|
-
*/
|
|
204
|
-
port: number;
|
|
205
|
-
/**
|
|
206
|
-
* Drain switchboard-owned resources: HTTP server, GraphQL manager,
|
|
207
|
-
* attachments, MCP, packages subgraph, and the read-model DB. This does
|
|
208
|
-
* NOT kill the reactor — in owned-reactor mode the reactor lifecycle is
|
|
209
|
-
* handled by its own SIGINT signal handlers, which then drain the api via
|
|
210
|
-
* the shutdown hook switchboard registered on the builder. In
|
|
211
|
-
* caller-provided mode the caller owns the reactor lifecycle separately.
|
|
212
|
-
*
|
|
213
|
-
* Callers using a caller-provided reactor must invoke this from their own
|
|
214
|
-
* teardown / SIGINT path so api resources are released; killing the
|
|
215
|
-
* reactor alone won't release them.
|
|
216
|
-
*/
|
|
217
|
-
shutdown: () => Promise<void>;
|
|
218
|
-
};
|
|
15
|
+
//#region src/pglite-store.d.mts
|
|
16
|
+
/** How each PGlite store runs; unset fields take the defaults. */
|
|
17
|
+
interface PgliteStoreSettings {
|
|
18
|
+
fsync?: boolean;
|
|
19
|
+
maintenance?: PgliteMaintenanceSettings;
|
|
20
|
+
workerMemoryMb?: number;
|
|
21
|
+
}
|
|
219
22
|
//#endregion
|
|
220
23
|
//#region src/builder-defaults.d.mts
|
|
221
24
|
type SwitchboardReactorDefaultsOptions = {
|
|
@@ -227,7 +30,8 @@ type SwitchboardReactorDefaultsOptions = {
|
|
|
227
30
|
/**
|
|
228
31
|
* Channel scheme. Defaults to `ChannelScheme.SWITCHBOARD`, which populates
|
|
229
32
|
* `reactorModule.syncModule.syncManager` — required by reactor-api. Set
|
|
230
|
-
* to `false`
|
|
33
|
+
* to `false` if the caller configures sync itself (`withChannelScheme` or
|
|
34
|
+
* `withSync`); the builder refuses both together.
|
|
231
35
|
*/
|
|
232
36
|
channelScheme?: ChannelScheme | false;
|
|
233
37
|
/** Defaults to true. Set false when the caller owns SIGINT handling. */
|
|
@@ -261,23 +65,84 @@ export declare function applySwitchboardReactorDefaults(reactorBuilder: ReactorB
|
|
|
261
65
|
export declare function resolveUnsupportedStoredDocuments(input: UnsupportedStoredDocuments | undefined, env: NodeJS.ProcessEnv): UnsupportedStoredDocuments;
|
|
262
66
|
/** The reactor refused to start over documents this build does not run. */
|
|
263
67
|
export declare class StoredDocumentsRefusedError extends Error {
|
|
264
|
-
readonly versions: readonly
|
|
265
|
-
protocol: string;
|
|
266
|
-
version: number;
|
|
267
|
-
}[];
|
|
68
|
+
readonly versions: readonly StoredProtocolRefusal[];
|
|
268
69
|
readonly documents: number;
|
|
269
70
|
constructor(cause: UnsupportedStoredProtocolError);
|
|
270
71
|
static isError(error: unknown): error is StoredDocumentsRefusedError;
|
|
271
72
|
}
|
|
272
73
|
//#endregion
|
|
273
74
|
//#region src/server.d.mts
|
|
75
|
+
/** Process-wide settings an edge applies once, before its first `startSwitchboard`. */
|
|
76
|
+
export declare function initSwitchboardProcess(options?: Pick<SwitchboardConfigInput, "logLevel">): void;
|
|
274
77
|
/**
|
|
275
78
|
* Attempt to bind a throwaway TCP server to the given port. Resolves true if
|
|
276
79
|
* the port is free, false if the OS reports it in use. Any other error is
|
|
277
80
|
* surfaced so we don't silently mask real issues (permissions, bad host, …).
|
|
278
81
|
*/
|
|
279
82
|
export declare function isPortAvailable(port: number): Promise<boolean>;
|
|
280
|
-
/**
|
|
83
|
+
/** `PH_KEYFRAMES` (or a caller's layer) wins whole over the project config. */
|
|
84
|
+
export declare function resolveKeyframes(configured: SwitchboardConfig["storage"]["keyframes"], fromFile: unknown, configPath: string): KeyframeSettings | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The reactor's storage handle, plus the pool instrumentation when that
|
|
87
|
+
* storage is Postgres. The PGlite branch has no `pg.Pool` at all, so the
|
|
88
|
+
* instrumentation is absent rather than optional-by-convention.
|
|
89
|
+
*/
|
|
90
|
+
type ReactorStorage = {
|
|
91
|
+
kysely: Kysely<Database>;
|
|
92
|
+
poolInstrumentation: PoolInstrumentation | undefined;
|
|
93
|
+
storageFacts: ReactorStorageFacts;
|
|
94
|
+
/** Absent on Postgres, where the host does not own the connection. */
|
|
95
|
+
storeMaintenance?: IStoreMaintenance;
|
|
96
|
+
};
|
|
97
|
+
export declare function createReactorKysely(opts: {
|
|
98
|
+
reactorDbUrl: string | undefined;
|
|
99
|
+
reactorPgliteDir: string | null;
|
|
100
|
+
reactorPgliteMajor: SupportedPgMajor | null;
|
|
101
|
+
inMemory: boolean;
|
|
102
|
+
/** Called only on the Postgres branch, the one with a host pool. */
|
|
103
|
+
hostPoolSize: () => number;
|
|
104
|
+
/** Open the PGlite store in its own worker thread. */
|
|
105
|
+
pgliteWorkers: boolean;
|
|
106
|
+
pgliteSettings?: PgliteStoreSettings;
|
|
107
|
+
/** The store, when it's already opening. */
|
|
108
|
+
openingStore?: PGliteLike;
|
|
109
|
+
logger: ILogger;
|
|
110
|
+
}): Promise<ReactorStorage>;
|
|
111
|
+
export interface PgliteStorageDirs {
|
|
112
|
+
/** Read-model store: a Postgres URL or a PGlite dir. */
|
|
113
|
+
readModelPath: string;
|
|
114
|
+
/** Reactor store: a Postgres URL or a PGlite dir. */
|
|
115
|
+
reactorPath: string;
|
|
116
|
+
/** PGlite dir for the reactor, null for Postgres or a caller-owned reactor. */
|
|
117
|
+
reactorPgliteDir: string | null;
|
|
118
|
+
/** PGlite dir for the read model, null for Postgres. */
|
|
119
|
+
readModelPgliteDir: string | null;
|
|
120
|
+
/** The PGlite dirs for the pre-flight, as before (not deduplicated). */
|
|
121
|
+
pgliteDirs: string[];
|
|
122
|
+
/** Set when BOTH stores are PGlite on one dir (see resolvePgliteStorageDirs). */
|
|
123
|
+
sharedPgliteDir: string | null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Where the two stores live — the classic resolution, relocated verbatim.
|
|
127
|
+
* Classic layout: `./.ph/reactor-storage` for the reactor and
|
|
128
|
+
* `.ph/read-storage` for the read model (the same names inside
|
|
129
|
+
* `${userData}/.ph` under a shell's PH_USER_DATA_DIR). `dbPath` also names
|
|
130
|
+
* the reactor store unless PH_REACTOR_DATABASE_URL does: with `dbPath` alone
|
|
131
|
+
* both stores share one location. That is the long-standing contract of
|
|
132
|
+
* `--db-path` and fine for one Postgres database, but for PGlite it is two
|
|
133
|
+
* postmasters on one data dir — reported via `sharedPgliteDir` so the caller
|
|
134
|
+
* warns. Not refused: changing that contract is a separate decision.
|
|
135
|
+
*/
|
|
136
|
+
export declare function resolvePgliteStorageDirs(opts: {
|
|
137
|
+
dbPath: string | undefined;
|
|
138
|
+
reactorDbUrl: string | undefined;
|
|
139
|
+
/** The caller passed its own reactor — the reactor-side dir is unused. */
|
|
140
|
+
callerReactor: boolean;
|
|
141
|
+
/** The relocated `.ph` root (PH_USER_DATA_DIR at the edge). */
|
|
142
|
+
userDataDir?: string;
|
|
143
|
+
phDir?: string;
|
|
144
|
+
}): PgliteStorageDirs;
|
|
145
|
+
/** The remote attachment service config for switchboard's own `/attachments/*` API; `attachments.serviceUrl` carries PH_SWITCHBOARD_PUBLIC_URL. */
|
|
281
146
|
export declare function deriveAttachmentServiceConfig(options: Pick<StartServerOptions, "attachmentServiceUrl" | "https">, serverPort: number, renown: IRenown | null): {
|
|
282
147
|
remoteUrl: string;
|
|
283
148
|
jwtHandler: JwtHandler | undefined;
|
|
@@ -293,14 +158,15 @@ export declare function deriveAttachmentServiceConfig(options: Pick<StartServerO
|
|
|
293
158
|
* dangling until the process exits.
|
|
294
159
|
*
|
|
295
160
|
* When `options.reactor` is omitted, the switchboard builds and owns the
|
|
296
|
-
* reactor. `shutdown()` on the returned handle
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
161
|
+
* reactor. `shutdown()` on the returned handle then runs the reactor
|
|
162
|
+
* module's `shutdown()`: `kill()`, the `withShutdownHook` chain that drains
|
|
163
|
+
* the api (HTTP server, GraphQL, MCP, attachments, read-model db), then the
|
|
164
|
+
* reactor database. It does not exit the process. It is the same memoized
|
|
165
|
+
* teardown the SIGINT/SIGTERM handlers (`withSignalHandlers`) run, so calling
|
|
166
|
+
* it twice, or receiving a signal around it, tears down once.
|
|
301
167
|
*/
|
|
302
|
-
export declare const startSwitchboard: (
|
|
168
|
+
export declare const startSwitchboard: (input?: SwitchboardConfigInput, deps?: SwitchboardDeps) => Promise<SwitchboardReactor>;
|
|
303
169
|
//#endregion
|
|
304
|
-
export type
|
|
170
|
+
export { IdentityOptions, StartServerOptions, StorageOptions, SwitchboardDeps, SwitchboardDriveDocumentType, SwitchboardDriveInput, SwitchboardReactor, type SwitchboardReactorDefaultsOptions, type WorkflowTriggersCapability };
|
|
305
171
|
export {};
|
|
306
172
|
//# sourceMappingURL=server.d.mts.map
|
package/dist/server.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../src/pglite-version.ts","../src/pglite-store.mts","../src/builder-defaults.mts","../src/unsupported-stored-documents.mts","../src/server.mts"],"mappings":";;;;;;;;;;;cAYa;KACD,2BAA2B;;;;UCuHtB;EACf;EACA,cAAc;EACd;;;;KClHU;EAIV,iBAAiB;;EAEjB,mBAAmB;;EAEnB;;;;;;;EAOA,gBAAgB;;EAEhB;;EAEA;IACE;IACA,eAAe,QAAQ;;;EAGzB,sBAAsB;EACtB,SAAS;;;;;;EAMT,SAAS;;;;;EAKT,cAAc,KAAK;;EAEnB,wBAAwB;;wBAiBV,gCACd,gBAAgB,gBAChB,eAAe,sBACf,UAAS;;;;wBCrEK,kCACd,OAAO,wCACP,KAAK,OAAO,aACX;;qBAaU,oCAAoC;WACtC,mBAAmB;WACnB;EAET,YAAY,OAAO;SAYH,QACd,iBACC,SAAS;;;;;wBCiKE,uBACd,UAAS,KAAK;;;;;;wBAgCM,gBAAgB,eAAe;;wBA6ErC,iBACd,YAAY,2CACZ,mBACA,qBACC;;;;;;KA2CE;EACH,QAAQ,OAAO;EACf,qBAAqB;EACrB,cAAc;;EAEd,mBAAmB;;wBAGC,oBAAoB;EACxC;EACA;EACA,oBAAoB;EACpB;;EAEA;;EAEA;EACA,iBAAiB;;EAEjB,eAAe;EACf,QAAQ;IACN,QAAQ;iBAkEK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;wBAcc,yBAAyB;EACvC;EACA;;EAEA;;EAEA;EACA;IACE;;wBAmCY,8BACd,SAAS,KAAK,uDACd,oBACA,QAAQ;EACL;EAAmB,YAAY;;;;;;;;;;;;;;;;;;;;qBAs3CvB,mBAAgB,QACpB,wBAAsB,OACvB,oBACL,QAAQ"}
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { n as StoredDocumentsRefusedError, r as resolveUnsupportedStoredDocuments } from "./from-env-DKK_wPrO.mjs";
|
|
3
|
+
import { a as resolveKeyframes, i as isPortAvailable, n as deriveAttachmentServiceConfig, o as resolvePgliteStorageDirs, r as initSwitchboardProcess, s as startSwitchboard, t as createReactorKysely, u as applySwitchboardReactorDefaults } from "./server-BS-PFzoK.mjs";
|
|
4
|
+
export { StoredDocumentsRefusedError, applySwitchboardReactorDefaults, createReactorKysely, deriveAttachmentServiceConfig, initSwitchboardProcess, isPortAvailable, resolveKeyframes, resolvePgliteStorageDirs, resolveUnsupportedStoredDocuments, startSwitchboard };
|
|
5
|
+
!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]="eb798b23-f32c-5ff0-ae0c-21c9fe293a6d")}catch(e){}}();
|
|
6
|
+
//# debugId=eb798b23-f32c-5ff0-ae0c-21c9fe293a6d
|