@powerhousedao/switchboard 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.
Files changed (272) hide show
  1. package/.tsbuild/test/attachments/byte-grants.test.d.ts +2 -0
  2. package/.tsbuild/test/attachments/byte-grants.test.d.ts.map +1 -0
  3. package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts +2 -0
  4. package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts.map +1 -0
  5. package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
  6. package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
  7. package/.tsbuild/test/attachments/url-signer.test.d.ts +2 -0
  8. package/.tsbuild/test/attachments/url-signer.test.d.ts.map +1 -0
  9. package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
  10. package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
  11. package/.tsbuild/test/boot-create-signature-policy.test.d.ts +2 -0
  12. package/.tsbuild/test/boot-create-signature-policy.test.d.ts.map +1 -0
  13. package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
  14. package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
  15. package/.tsbuild/test/boot-helpers.d.ts +5 -0
  16. package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
  17. package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
  18. package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
  19. package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
  20. package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
  21. package/.tsbuild/test/boot-mcp-enabled.test.d.ts +2 -0
  22. package/.tsbuild/test/boot-mcp-enabled.test.d.ts.map +1 -0
  23. package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
  24. package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
  25. package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
  26. package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
  27. package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
  28. package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
  29. package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts +2 -0
  30. package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts.map +1 -0
  31. package/.tsbuild/test/boot-without-renown.test.d.ts +2 -0
  32. package/.tsbuild/test/boot-without-renown.test.d.ts.map +1 -0
  33. package/.tsbuild/test/boot-without-require-signatures.test.d.ts +2 -0
  34. package/.tsbuild/test/boot-without-require-signatures.test.d.ts.map +1 -0
  35. package/.tsbuild/test/boot-worker-trust-policy.test.d.ts +2 -0
  36. package/.tsbuild/test/boot-worker-trust-policy.test.d.ts.map +1 -0
  37. package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
  38. package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
  39. package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
  40. package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
  41. package/.tsbuild/test/builder-defaults.test.d.ts +2 -0
  42. package/.tsbuild/test/builder-defaults.test.d.ts.map +1 -0
  43. package/.tsbuild/test/config-from-env.test.d.ts +2 -0
  44. package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
  45. package/.tsbuild/test/config-merge.test.d.ts +2 -0
  46. package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
  47. package/.tsbuild/test/config-schema.test.d.ts +2 -0
  48. package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
  49. package/.tsbuild/test/create-signature-policy.test.d.ts +2 -0
  50. package/.tsbuild/test/create-signature-policy.test.d.ts.map +1 -0
  51. package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
  52. package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
  53. package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
  54. package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
  55. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
  56. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
  57. package/.tsbuild/test/fatal-shutdown.test.d.ts +2 -0
  58. package/.tsbuild/test/fatal-shutdown.test.d.ts.map +1 -0
  59. package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
  60. package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
  61. package/.tsbuild/test/observability-signals.test.d.ts +2 -0
  62. package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
  63. package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
  64. package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
  65. package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
  66. package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
  67. package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
  68. package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
  69. package/.tsbuild/test/pglite-store.test.d.ts +2 -0
  70. package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
  71. package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
  72. package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
  73. package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
  74. package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
  75. package/.tsbuild/test/port-probe.test.d.ts +2 -0
  76. package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
  77. package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
  78. package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
  79. package/.tsbuild/test/renown-trust-policy.test.d.ts +2 -0
  80. package/.tsbuild/test/renown-trust-policy.test.d.ts.map +1 -0
  81. package/.tsbuild/test/served-schemas.test.d.ts +2 -0
  82. package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
  83. package/.tsbuild/test/shutdown.test.d.ts +2 -0
  84. package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
  85. package/.tsbuild/test/snapshot-writer.d.ts +18 -0
  86. package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
  87. package/.tsbuild/test/store-lock.test.d.ts +2 -0
  88. package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
  89. package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
  90. package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
  91. package/.tsbuild/test/unsupported-stored-documents.test.d.ts +2 -0
  92. package/.tsbuild/test/unsupported-stored-documents.test.d.ts.map +1 -0
  93. package/.tsbuild/test/workflow/harness.d.ts +56 -0
  94. package/.tsbuild/test/workflow/harness.d.ts.map +1 -0
  95. package/.tsbuild/test/workflow/oauth.test.d.ts +2 -0
  96. package/.tsbuild/test/workflow/oauth.test.d.ts.map +1 -0
  97. package/.tsbuild/test/workflow/resolvers.test.d.ts +2 -0
  98. package/.tsbuild/test/workflow/resolvers.test.d.ts.map +1 -0
  99. package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
  100. package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
  101. package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts +2 -0
  102. package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts.map +1 -0
  103. package/.tsbuild/test/workflow/webhook-signed.test.d.ts +2 -0
  104. package/.tsbuild/test/workflow/webhook-signed.test.d.ts.map +1 -0
  105. package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts +2 -0
  106. package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts.map +1 -0
  107. package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts +2 -0
  108. package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts.map +1 -0
  109. package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
  110. package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
  111. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
  112. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
  113. package/.tsbuild/test/workflow-read-gate.test.d.ts +2 -0
  114. package/.tsbuild/test/workflow-read-gate.test.d.ts.map +1 -0
  115. package/.tsbuild/test/workflow-runtime.test.d.ts +2 -0
  116. package/.tsbuild/test/workflow-runtime.test.d.ts.map +1 -0
  117. package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
  118. package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
  119. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  120. package/.tsbuild/tsdown.config.d.ts.map +1 -1
  121. package/.tsbuild/vitest.config.d.ts.map +1 -1
  122. package/Auth.md +144 -2
  123. package/CHANGELOG.md +1074 -0
  124. package/README.md +55 -14
  125. package/dist/boot.d.mts +46 -0
  126. package/dist/boot.d.mts.map +1 -0
  127. package/dist/boot.mjs +67 -0
  128. package/dist/boot.mjs.map +1 -0
  129. package/dist/config/from-env.d.mts +15 -0
  130. package/dist/config/from-env.d.mts.map +1 -0
  131. package/dist/config/from-env.mjs +4 -0
  132. package/dist/config/schema.d.mts +3 -0
  133. package/dist/config/schema.mjs +4 -0
  134. package/dist/from-env-BO0n9R02.mjs +401 -0
  135. package/dist/from-env-BO0n9R02.mjs.map +1 -0
  136. package/dist/index.d.mts +2 -1
  137. package/dist/index.mjs +76 -79
  138. package/dist/index.mjs.map +1 -1
  139. package/dist/install-packages.d.mts +2 -1
  140. package/dist/install-packages.mjs +2 -2
  141. package/dist/install-packages.mjs.map +1 -1
  142. package/dist/mcp-SsBK14Jm.mjs +32 -0
  143. package/dist/mcp-SsBK14Jm.mjs.map +1 -0
  144. package/dist/migrate.d.mts +2 -1
  145. package/dist/migrate.mjs +7 -5
  146. package/dist/migrate.mjs.map +1 -1
  147. package/dist/plugin-host-C1sYEm8g.d.mts +46 -0
  148. package/dist/plugin-host-C1sYEm8g.d.mts.map +1 -0
  149. package/dist/plugins/attachments.d.mts +33 -0
  150. package/dist/plugins/attachments.d.mts.map +1 -0
  151. package/dist/plugins/attachments.mjs +4 -0
  152. package/dist/plugins/mcp.d.mts +31 -0
  153. package/dist/plugins/mcp.d.mts.map +1 -0
  154. package/dist/plugins/mcp.mjs +4 -0
  155. package/dist/plugins/privacy.d.mts +22 -0
  156. package/dist/plugins/privacy.d.mts.map +1 -0
  157. package/dist/plugins/privacy.mjs +4 -0
  158. package/dist/plugins/workflows.d.mts +79 -0
  159. package/dist/plugins/workflows.d.mts.map +1 -0
  160. package/dist/plugins/workflows.mjs +4 -0
  161. package/dist/postgres-url-DTDhBjXX.mjs +11 -0
  162. package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
  163. package/dist/privacy-BO8Q25xI.mjs +44 -0
  164. package/dist/privacy-BO8Q25xI.mjs.map +1 -0
  165. package/dist/privacy-DxIJGH4P.mjs +91 -0
  166. package/dist/privacy-DxIJGH4P.mjs.map +1 -0
  167. package/dist/renown-layers-COZsrGQT.mjs +40 -0
  168. package/dist/renown-layers-COZsrGQT.mjs.map +1 -0
  169. package/dist/schema-0g_QdOWn.mjs +267 -0
  170. package/dist/schema-0g_QdOWn.mjs.map +1 -0
  171. package/dist/schema-ivUWPQOn.d.mts +202 -0
  172. package/dist/schema-ivUWPQOn.d.mts.map +1 -0
  173. package/dist/server-cE1BWLQu.mjs +2518 -0
  174. package/dist/server-cE1BWLQu.mjs.map +1 -0
  175. package/dist/server.d.mts +270 -48
  176. package/dist/server.d.mts.map +1 -1
  177. package/dist/server.mjs +5 -5
  178. package/dist/utils-C6AIF38Z.mjs +133 -0
  179. package/dist/utils-C6AIF38Z.mjs.map +1 -0
  180. package/dist/utils.d.mts +12 -5
  181. package/dist/utils.d.mts.map +1 -1
  182. package/dist/utils.mjs +4 -3
  183. package/dist/worker-pool-BWHBLBJd.mjs +304 -0
  184. package/dist/worker-pool-BWHBLBJd.mjs.map +1 -0
  185. package/dist/workflow-runtime-7GaJ13c9.d.mts +30 -0
  186. package/dist/workflow-runtime-7GaJ13c9.d.mts.map +1 -0
  187. package/dist/workflows-COM3MKfD.mjs +1437 -0
  188. package/dist/workflows-COM3MKfD.mjs.map +1 -0
  189. package/package.json +68 -23
  190. package/scripts/install-packages.sh +0 -0
  191. package/test/attachment-reference-read-model.test.ts +28 -20
  192. package/test/attachments/auth.test.ts +85 -0
  193. package/test/attachments/byte-grants.test.ts +290 -0
  194. package/test/attachments/byte-routes-read-gate.integration.test.ts +314 -0
  195. package/test/attachments/download-target.test.ts +211 -32
  196. package/test/attachments/index.test.ts +47 -4
  197. package/test/attachments/reserve-metadata-parity.test.ts +96 -0
  198. package/test/attachments/routes-integration.test.ts +60 -4
  199. package/test/attachments/routes.test.ts +297 -35
  200. package/test/attachments/service-config.test.ts +41 -19
  201. package/test/attachments/url-signer.test.ts +105 -0
  202. package/test/boot-auth-config.test.ts +109 -0
  203. package/test/boot-create-signature-policy.test.ts +110 -0
  204. package/test/boot-env-isolation.test.ts +26 -0
  205. package/test/boot-helpers.ts +19 -0
  206. package/test/boot-inspection-enabled.test.ts +140 -0
  207. package/test/boot-mcp-auth.test.ts +449 -0
  208. package/test/boot-mcp-enabled.test.ts +119 -0
  209. package/test/boot-port-zero.test.ts +101 -0
  210. package/test/boot-preconditions.test.ts +200 -0
  211. package/test/boot-privacy.test.ts +232 -0
  212. package/test/boot-unsupported-stored-documents.test.ts +214 -0
  213. package/test/boot-without-renown.test.ts +83 -0
  214. package/test/boot-without-require-signatures.test.ts +76 -0
  215. package/test/boot-worker-trust-policy.test.ts +91 -0
  216. package/test/boot-workflow-singleton-conflict.test.ts +109 -0
  217. package/test/boot-workflow-singleton-retry.test.ts +122 -0
  218. package/test/builder-defaults.test.ts +80 -0
  219. package/test/config-from-env.test.ts +758 -0
  220. package/test/config-merge.test.ts +215 -0
  221. package/test/config-schema.test.ts +128 -0
  222. package/test/create-signature-policy.test.ts +69 -0
  223. package/test/default-drive-protocol-versions.test.ts +102 -0
  224. package/test/default-drive-slug.test.ts +97 -0
  225. package/test/durable-node-fs-pg16.test.ts +80 -0
  226. package/test/fatal-shutdown.test.ts +165 -0
  227. package/test/goldens/packages.graphql +797 -0
  228. package/test/goldens/privacy.graphql +853 -0
  229. package/test/goldens/reactor-drive-nodes.graphql +827 -0
  230. package/test/goldens/resolvers.json +322 -0
  231. package/test/goldens/supergraph.graphql +5652 -0
  232. package/test/goldens/workflow-runtime.graphql +1419 -0
  233. package/test/inspection-throttle.test.ts +23 -0
  234. package/test/observability-signals.test.ts +131 -0
  235. package/test/permissions-backfill.test.ts +486 -0
  236. package/test/pglite-dialect.test.ts +237 -2
  237. package/test/pglite-preflight.test.ts +313 -0
  238. package/test/pglite-storage-dirs.test.ts +113 -0
  239. package/test/pglite-store.test.ts +264 -0
  240. package/test/pglite-version.test.ts +9 -1
  241. package/test/plugin-config-schemas.test.ts +83 -0
  242. package/test/plugin-presence.test.ts +262 -0
  243. package/test/port-probe.test.ts +45 -0
  244. package/test/renown-storage-path.test.ts +40 -0
  245. package/test/renown-trust-policy.test.ts +313 -0
  246. package/test/served-schemas.test.ts +134 -0
  247. package/test/shutdown.test.ts +278 -0
  248. package/test/snapshot-writer.ts +94 -0
  249. package/test/store-lock.test.ts +65 -0
  250. package/test/two-switchboards.test.ts +146 -0
  251. package/test/unsupported-stored-documents.test.ts +72 -0
  252. package/test/worker-pool.test.ts +27 -1
  253. package/test/workflow/harness.ts +289 -0
  254. package/test/workflow/oauth.test.ts +205 -0
  255. package/test/workflow/resolvers.test.ts +369 -0
  256. package/test/workflow/runtime-host.test.ts +19 -0
  257. package/test/workflow/webhook-dedupe.test.ts +295 -0
  258. package/test/workflow/webhook-signed.test.ts +509 -0
  259. package/test/workflow/webhook-trigger-test.test.ts +82 -0
  260. package/test/workflow/webhook-unsigned.test.ts +345 -0
  261. package/test/workflow-reactor-access.test.ts +384 -0
  262. package/test/workflow-reactor-enforcement.test.ts +808 -0
  263. package/test/workflow-read-gate.test.ts +213 -0
  264. package/test/workflow-runtime.test.ts +1135 -0
  265. package/test/workflows-plugin-config.test.ts +77 -0
  266. package/tsconfig.json +11 -2
  267. package/tsdown.config.ts +12 -1
  268. package/vitest.config.ts +65 -0
  269. package/dist/server-CiKkVE6g.mjs +0 -1555
  270. package/dist/server-CiKkVE6g.mjs.map +0 -1
  271. package/dist/utils-Baw7rThP.mjs +0 -80
  272. package/dist/utils-Baw7rThP.mjs.map +0 -1
package/dist/server.d.mts CHANGED
@@ -1,12 +1,45 @@
1
+ import { a as SwitchboardConfigInput } from "./schema-ivUWPQOn.mjs";
2
+ import { n as WorkflowTriggersCapability } from "./workflow-runtime-7GaJ13c9.mjs";
1
3
  import { ILogger } from "document-model";
2
- import { ChannelScheme, IDocumentModelLoader, IReactorClient, InProcessReactorClientModule, JwtHandler, ReactorBuilder, ReactorClientBuilder, ReactorFeatureFlags, SignerConfig } from "@powerhousedao/reactor";
4
+ import { ChannelScheme, Database, IDocumentModelLoader, IInspector, IReactorClient, InProcessReactorClientModule, JwtHandler, ModelManifestEntry, PoolInstrumentation, ReactorBuilder, ReactorClientBuilder, ReactorFeatureFlags, ReactorStorageFacts, SignerConfig, UnsupportedStoredDocuments, UnsupportedStoredProtocolError } from "@powerhousedao/reactor";
3
5
  import { AttachmentReferenceProjectionCapability } from "@powerhousedao/reactor-api";
6
+ import { PgliteMaintenanceSettings, resolvePgliteMaintenance } from "@powerhousedao/reactor-api/pglite-node";
7
+ import { DocumentModelModule, ISigner, SignaturePolicy, UpgradeManifest } from "@powerhousedao/shared/document-model";
8
+ import { IErasureService } from "@powerhousedao/reactor-privacy";
4
9
  import { IAttachmentService } from "@powerhousedao/reactor-attachments";
5
10
  import { IRenown } from "@renown/sdk/node";
11
+ import { Kysely } from "kysely";
12
+ import { ResolvedPlugin } from "@powerhousedao/host-core";
6
13
  import { DriveInput } from "@powerhousedao/shared/document-drive";
14
+ import "@electric-sql/pglite";
7
15
  import { IRenown as IRenown$1 } from "@renown/sdk";
8
- import { DocumentModelModule, UpgradeManifest } from "@powerhousedao/shared/document-model";
9
-
16
+ //#region src/pglite-version.d.ts
17
+ declare const SUPPORTED_PG_MAJORS: readonly [16, 17];
18
+ type SupportedPgMajor = (typeof SUPPORTED_PG_MAJORS)[number];
19
+ //#endregion
20
+ //#region src/pglite-store.d.mts
21
+ /** How each PGlite store runs; unset fields take the defaults. */
22
+ interface PgliteStoreSettings {
23
+ fsync?: boolean;
24
+ maintenance?: PgliteMaintenanceSettings;
25
+ workerMemoryMb?: number;
26
+ }
27
+ //#endregion
28
+ //#region src/privacy.d.mts
29
+ type PrivacyOptions = {
30
+ /** Wins over PH_PRIVACY_ENABLED. */
31
+ enabled?: boolean;
32
+ /** Wins over PH_PRIVACY_DEPLOYMENT_SECRET. */
33
+ deploymentSecret?: string;
34
+ /** The reactor's signer, for a caller-provided reactor. */
35
+ signer?: ISigner;
36
+ /** Each wins over its PH_PRIVACY_* env var. */
37
+ intervalMs?: number;
38
+ deadlineMs?: number;
39
+ markerGraceMs?: number;
40
+ purgeTimeoutMs?: number;
41
+ };
42
+ //#endregion
10
43
  //#region src/types.d.ts
11
44
  /**
12
45
  * Drive container document type chosen for the boot-time default drive. The
@@ -14,27 +47,33 @@ import { DocumentModelModule, UpgradeManifest } from "@powerhousedao/shared/docu
14
47
  * `powerhouse/reactor-drive` is wired through `addDefaultReactorDrive` and
15
48
  * uses the relationship-based child graph.
16
49
  */
17
- type SwitchboardDriveDocumentType = "powerhouse/document-drive" | "powerhouse/reactor-drive";
50
+ export type SwitchboardDriveDocumentType = "powerhouse/document-drive" | "powerhouse/reactor-drive";
18
51
  /** A {@link DriveInput} extended with the optional drive-container type. */
19
- type SwitchboardDriveInput = DriveInput & {
52
+ export type SwitchboardDriveInput = DriveInput & {
20
53
  documentType?: SwitchboardDriveDocumentType;
21
54
  };
22
- type StorageOptions = {
55
+ export type StorageOptions = {
23
56
  type: "filesystem" | "memory" | "postgres" | "browser";
24
57
  filesystemPath?: string;
25
58
  postgresUrl?: string;
26
59
  };
27
- type IdentityOptions = {
28
- /** Path to the keypair file. Defaults to ~/.ph/keypair.json */keypairPath?: string;
60
+ export type IdentityOptions = {
61
+ /** Path to the keypair file. Defaults to ~/.ph/keypair.json */
62
+ keypairPath?: string;
29
63
  /**
30
64
  * If true, won't start without an existing keypair.
31
65
  * Use this to ensure the switchboard only runs with an authenticated identity.
32
66
  */
33
- requireExisting?: boolean; /** Base url of the Renown instance to use */
34
- baseUrl?: string; /** If true, unsigned actions will be rejected */
35
- requireSignatures?: boolean;
67
+ requireExisting?: boolean;
68
+ /** Base url of the Renown instance to use */
69
+ baseUrl?: string;
36
70
  };
37
- type StartServerOptions = {
71
+ /**
72
+ * The options view of a switchboard's config and deps: what plugins'
73
+ * `transformServerOptions` hook receives. `startSwitchboard` takes the
74
+ * config (`@powerhousedao/switchboard/config`) and {@link SwitchboardDeps}.
75
+ */
76
+ export type StartServerOptions = {
38
77
  /**
39
78
  * Pre-built ReactorClientModule (typically from
40
79
  * `@powerhousedao/reactor#ReactorClientBuilder.buildModule`). When set, the
@@ -56,6 +95,21 @@ type StartServerOptions = {
56
95
  * pieces as needed.
57
96
  */
58
97
  reactor?: InProcessReactorClientModule;
98
+ /**
99
+ * Route uncaught exceptions, and unhandled rejections nothing else listens
100
+ * for, through the reactor's SIGTERM shutdown, so PGlite stores are flushed
101
+ * before the process exits with code 1. Installed once the switchboard's own reactor is built;
102
+ * ignored when `reactor` is passed. For process entry points only, since
103
+ * it adds process-wide listeners.
104
+ */
105
+ fatalErrorShutdown?: boolean;
106
+ /**
107
+ * Install the owned reactor's SIGINT/SIGTERM handlers (default true).
108
+ * False when a supervisor owns the process exit (a `ph run` compound
109
+ * member): the reactor then stops only through `shutdown()`. Ignored with
110
+ * a caller-provided `reactor`.
111
+ */
112
+ signalHandlers?: boolean;
59
113
  /**
60
114
  * Registry URL for the HttpPackageLoader. Enables `PackagesSubgraph`
61
115
  * (install/uninstall mutations) plus dynamic package resolution.
@@ -64,6 +118,12 @@ type StartServerOptions = {
64
118
  */
65
119
  registryUrl?: string;
66
120
  configFile?: string;
121
+ /**
122
+ * 0 binds a port the OS picks, reported on the result's `port`: the only
123
+ * race-free choice when several instances start at once. A taken non-zero
124
+ * port falls back to the next free one, which another process can still
125
+ * claim between the probe and the bind.
126
+ */
67
127
  port?: number;
68
128
  /**
69
129
  * If true, fail immediately when the requested port is in use instead of
@@ -85,9 +145,42 @@ type StartServerOptions = {
85
145
  * When configured, the switchboard will load the keypair from `ph login`
86
146
  * and can authenticate with remote services on behalf of the user.
87
147
  */
88
- identity?: IdentityOptions; /** Base URL for the attachment service; defaults to `PH_SWITCHBOARD_PUBLIC_URL` then `http(s)://localhost:${port}`. */
148
+ identity?: IdentityOptions;
149
+ /** Base URL for the attachment service; defaults to `PH_SWITCHBOARD_PUBLIC_URL` then `http(s)://localhost:${port}`. */
89
150
  attachmentServiceUrl?: string;
151
+ /** Mount the MCP server at `/mcp`. On by default; `false` wins over
152
+ * MCP_ENABLED, which can turn it off but never on. */
90
153
  mcp?: boolean;
154
+ /** The plugin composition to boot with (FEATURE_PLUGIN_HOST_ENABLED): the
155
+ * resolved host.js runner.plugins entries, supplied by the uniform-runners
156
+ * switchboard runner (R2 step 2) or a test. Omitted = the built-in default
157
+ * composition. Resolved plugins, not specifiers — resolution happens at the
158
+ * runner against the PROJECT dependency tree. */
159
+ pluginComposition?: ResolvedPlugin[];
160
+ /** Mount the read-only inspection subgraph at `/graphql/inspection`. On by
161
+ * default; `false` wins over INSPECTION_ENABLED, which can turn it off. */
162
+ inspection?: boolean;
163
+ /** Open each PGlite store (reactor-storage, read-storage) in its own worker
164
+ * thread. Wins either way over PH_PGLITE_WORKERS; unset, the env var
165
+ * decides, then PGLITE_WORKERS_DEFAULT. */
166
+ pgliteWorkers?: boolean;
167
+ /** Powerhouse workflows: the runtime, its subgraph, its webhooks and its
168
+ * document models. Wins over PH_WORKFLOWS_ENABLED and the config file. */
169
+ workflows?: {
170
+ enabled?: boolean;
171
+ /** OAuth2 apps the publisher owns (`oauth_app` on a connection): per app,
172
+ * the provider's client files by kind. Wins over the config file's
173
+ * `workflows.oauthApps`; relative paths there are from the config file. */
174
+ oauthApps?: {
175
+ id: string;
176
+ clients: {
177
+ desktop?: string;
178
+ web?: string;
179
+ };
180
+ }[];
181
+ };
182
+ /** The GDPR add-on; off unless this or PH_PRIVACY_ENABLED turns it on. */
183
+ privacy?: PrivacyOptions;
91
184
  processorConfig?: Map<string, unknown>;
92
185
  disableLocalPackages?: boolean;
93
186
  enableDocumentModelSubgraphs?: boolean;
@@ -144,68 +237,195 @@ type StartServerOptions = {
144
237
  enabled?: boolean;
145
238
  dbPoolSize?: number;
146
239
  };
240
+ /**
241
+ * Stored documents at protocol versions this build does not run: "refuse"
242
+ * (the default) fails the boot with a StoredDocumentsRefusedError;
243
+ * "read-only" starts with a warning and keeps those documents read-only.
244
+ * Unset falls back to the REACTOR_UNSUPPORTED_STORED_DOCUMENTS env var.
245
+ * Ignored when `reactor` is passed.
246
+ */
247
+ unsupportedStoredDocuments?: UnsupportedStoredDocuments;
248
+ };
249
+ /** What a switchboard is started with that is not a setting. */
250
+ export type SwitchboardDeps = {
251
+ logger?: ILogger;
252
+ /** See {@link StartServerOptions.reactor}. */
253
+ reactor?: InProcessReactorClientModule;
254
+ /** See {@link StartServerOptions.pluginComposition}. */
255
+ pluginComposition?: ResolvedPlugin[];
256
+ /** Receives failures in background work; Sentry by default. */
257
+ reportError?: (error: unknown) => void;
258
+ /** See {@link StartServerOptions.fatalErrorShutdown}. */
259
+ fatalErrorShutdown?: boolean;
260
+ /** See {@link StartServerOptions.signalHandlers}. */
261
+ signalHandlers?: boolean;
262
+ /** The privacy add-on's signer, for a caller-provided reactor. */
263
+ privacySigner?: ISigner;
147
264
  };
148
- type SwitchboardReactor = {
265
+ export type SwitchboardReactor = {
149
266
  defaultDriveUrl: string | undefined;
150
- reactor: IReactorClient; /** Switchboard-backed remote attachment service over its own `/attachments/*` API, for downstream consumers. */
151
- attachmentService: IAttachmentService; /** Whether the authoritative attachment-reference projection is active. */
152
- attachmentReferenceProjection: AttachmentReferenceProjectionCapability; /** The Renown instance if identity was initialized */
267
+ reactor: IReactorClient;
268
+ /** Switchboard-backed remote attachment service over its own `/attachments/*` API, for downstream consumers.
269
+ * Undefined when the attachments plugin is absent from the composition
270
+ * (FEATURE_PLUGIN_HOST_ENABLED — presence is activation, rewire R2.3). */
271
+ attachmentService: IAttachmentService | undefined;
272
+ /** Whether the authoritative attachment-reference projection is active. */
273
+ attachmentReferenceProjection: AttachmentReferenceProjectionCapability;
274
+ /** Whether the workflow runtime's operation intake is indexing. Undefined
275
+ * when workflows are off; unavailable means no document trigger fires. */
276
+ workflowTriggers?: WorkflowTriggersCapability;
277
+ /** Whether workflows are on, after the option, PH_WORKFLOWS_ENABLED and the config file. */
278
+ workflowsEnabled: boolean;
279
+ /** The boot list of importable models workers and workflow pieces load; empty when none are resolved. */
280
+ modelManifest(): ModelManifestEntry[];
281
+ /** Present when the privacy add-on runs: its erasure service. */
282
+ privacy?: {
283
+ erasure: IErasureService;
284
+ };
285
+ /** Whether `/mcp` is mounted, after the option and MCP_ENABLED. */
286
+ mcpEnabled: boolean;
287
+ /** Whether `/graphql/inspection` is mounted, after the option and INSPECTION_ENABLED. */
288
+ inspectionEnabled: boolean;
289
+ /** The reactor's inspector, as the host reads it (processors, catch-up); undefined without inspection. */
290
+ inspector: IInspector | undefined;
291
+ /** The Renown instance if identity was initialized */
153
292
  renown: IRenown$1 | null;
154
293
  /**
155
- * Port the HTTP server actually bound to. May differ from the requested
156
- * port when the requested port was in use and fallback kicked in.
294
+ * Port the HTTP server actually bound to: the OS-picked one when 0 was
295
+ * requested, the next free one when the requested port was in use.
157
296
  */
158
297
  port: number;
159
298
  /**
160
- * Drain switchboard-owned resources: HTTP server, GraphQL manager,
161
- * attachments, MCP, packages subgraph, and the read-model DB. This does
162
- * NOT kill the reactor — in owned-reactor mode the reactor lifecycle is
163
- * handled by its own SIGINT signal handlers, which then drain the api via
164
- * the shutdown hook switchboard registered on the builder. In
165
- * caller-provided mode the caller owns the reactor lifecycle separately.
166
- *
167
- * Callers using a caller-provided reactor must invoke this from their own
168
- * teardown / SIGINT path so api resources are released; killing the
169
- * reactor alone won't release them.
299
+ * Idempotent. Owned reactor: runs the reactor module's memoized
300
+ * `shutdown()` (kill, shutdown hooks incl. the api drain, database).
301
+ * Caller-provided reactor: drains the api only (HTTP server, GraphQL
302
+ * manager, attachments, MCP, read-model DB); the caller owns the reactor
303
+ * and must call this from its own teardown.
170
304
  */
171
305
  shutdown: () => Promise<void>;
172
306
  };
173
307
  //#endregion
174
308
  //#region src/builder-defaults.d.mts
175
309
  type SwitchboardReactorDefaultsOptions = {
176
- documentModels?: DocumentModelModule[]; /** Upgrade manifests for versioned models, one per document type. */
177
- upgradeManifests?: UpgradeManifest<readonly number[]>[]; /** Default true. */
310
+ documentModels?: DocumentModelModule[];
311
+ /** Upgrade manifests for versioned models, one per document type. */
312
+ upgradeManifests?: UpgradeManifest<readonly number[]>[];
313
+ /** Default true. */
178
314
  includeBaseModels?: boolean;
179
315
  /**
180
316
  * Channel scheme. Defaults to `ChannelScheme.SWITCHBOARD`, which populates
181
317
  * `reactorModule.syncModule.syncManager` — required by reactor-api. Set
182
- * to `false` only if the caller will configure a scheme themselves.
318
+ * to `false` if the caller configures sync itself (`withChannelScheme` or
319
+ * `withSync`); the builder refuses both together.
183
320
  */
184
- channelScheme?: ChannelScheme | false; /** Defaults to true. Set false when the caller owns SIGINT handling. */
185
- signalHandlers?: boolean; /** Executor tuning. Omit to use the reactor's own defaults. */
321
+ channelScheme?: ChannelScheme | false;
322
+ /** Defaults to true. Set false when the caller owns SIGINT handling. */
323
+ signalHandlers?: boolean;
324
+ /** Executor tuning. Omit to use the reactor's own defaults. */
186
325
  executorConfig?: {
187
326
  maxSkipThreshold?: number;
188
327
  featureFlags?: Partial<ReactorFeatureFlags>;
189
- }; /** Wire dynamic document-model loading via HTTP. */
328
+ };
329
+ /** Wire dynamic document-model loading via HTTP. */
190
330
  documentModelLoader?: IDocumentModelLoader;
191
331
  logger?: ILogger;
192
332
  /**
193
- * Identity signer (typically from `getRenownSignerConfig`). Applied to the
194
- * `ReactorClientBuilder`; omit for unsigned operation.
333
+ * Identity signer (typically from `getRenownSignerConfig`). Signs client
334
+ * writes and the operations the executor synthesizes, in pooled workers
335
+ * through `workerSigner`; omit for unsigned operation.
195
336
  */
196
337
  signer?: SignerConfig;
338
+ /**
339
+ * Which keys may sign as which users (typically from
340
+ * `getRenownTrustPolicyConfig`); wins over one carried by `signer`.
341
+ */
342
+ trustPolicy?: Pick<SignerConfig, "trustPolicy" | "workerTrustPolicy">;
343
+ /** What the client creates new documents as; see `resolveCreateSignaturePolicy`. */
344
+ createSignaturePolicy?: SignaturePolicy;
197
345
  };
198
- declare function applySwitchboardReactorDefaults(reactorBuilder: ReactorBuilder, clientBuilder: ReactorClientBuilder, options?: SwitchboardReactorDefaultsOptions): void;
346
+ export declare function applySwitchboardReactorDefaults(reactorBuilder: ReactorBuilder, clientBuilder: ReactorClientBuilder, options?: SwitchboardReactorDefaultsOptions): void;
347
+ //#endregion
348
+ //#region src/unsupported-stored-documents.d.mts
349
+ /** From REACTOR_UNSUPPORTED_STORED_DOCUMENTS; `input` wins when defined. */
350
+ export declare function resolveUnsupportedStoredDocuments(input: UnsupportedStoredDocuments | undefined, env: NodeJS.ProcessEnv): UnsupportedStoredDocuments;
351
+ /** The reactor refused to start over documents this build does not run. */
352
+ export declare class StoredDocumentsRefusedError extends Error {
353
+ readonly versions: readonly {
354
+ protocol: string;
355
+ version: number;
356
+ }[];
357
+ readonly documents: number;
358
+ constructor(cause: UnsupportedStoredProtocolError);
359
+ static isError(error: unknown): error is StoredDocumentsRefusedError;
360
+ }
199
361
  //#endregion
200
362
  //#region src/server.d.mts
363
+ /** Process-wide settings an edge applies once, before its first `startSwitchboard`. */
364
+ export declare function initSwitchboardProcess(options?: Pick<SwitchboardConfigInput, "logLevel">): void;
201
365
  /**
202
366
  * Attempt to bind a throwaway TCP server to the given port. Resolves true if
203
367
  * the port is free, false if the OS reports it in use. Any other error is
204
368
  * surfaced so we don't silently mask real issues (permissions, bad host, …).
205
369
  */
206
- declare function isPortAvailable(port: number): Promise<boolean>;
207
- /** Derive the remote attachment service config for switchboard's own `/attachments/*` API. */
208
- declare function deriveAttachmentServiceConfig(options: Pick<StartServerOptions, "attachmentServiceUrl" | "https">, serverPort: number, renown: IRenown | null): {
370
+ export declare function isPortAvailable(port: number): Promise<boolean>;
371
+ /**
372
+ * The reactor's storage handle, plus the pool instrumentation when that
373
+ * storage is Postgres. The PGlite branch has no `pg.Pool` at all, so the
374
+ * instrumentation is absent rather than optional-by-convention.
375
+ */
376
+ type ReactorStorage = {
377
+ kysely: Kysely<Database>;
378
+ poolInstrumentation: PoolInstrumentation | undefined;
379
+ storageFacts: ReactorStorageFacts;
380
+ };
381
+ export declare function createReactorKysely(opts: {
382
+ reactorDbUrl: string | undefined;
383
+ reactorPgliteDir: string | null;
384
+ reactorPgliteMajor: SupportedPgMajor | null;
385
+ inMemory: boolean;
386
+ /** Called only on the Postgres branch, the one with a host pool. */
387
+ hostPoolSize: () => number;
388
+ /** Open the PGlite store in its own worker thread. */
389
+ pgliteWorkers: boolean;
390
+ pgliteSettings?: PgliteStoreSettings;
391
+ logger: ILogger;
392
+ }): Promise<ReactorStorage>;
393
+ export interface PgliteStorageDirs {
394
+ /** Read-model store: a Postgres URL or a PGlite dir. */
395
+ readModelPath: string;
396
+ /** Reactor store: a Postgres URL or a PGlite dir. */
397
+ reactorPath: string;
398
+ /** PGlite dir for the reactor, null for Postgres or a caller-owned reactor. */
399
+ reactorPgliteDir: string | null;
400
+ /** PGlite dir for the read model, null for Postgres. */
401
+ readModelPgliteDir: string | null;
402
+ /** The PGlite dirs for the pre-flight, as before (not deduplicated). */
403
+ pgliteDirs: string[];
404
+ /** Set when BOTH stores are PGlite on one dir (see resolvePgliteStorageDirs). */
405
+ sharedPgliteDir: string | null;
406
+ }
407
+ /**
408
+ * Where the two stores live — the classic resolution, relocated verbatim.
409
+ * Classic layout: `./.ph/reactor-storage` for the reactor and
410
+ * `.ph/read-storage` for the read model (the same names inside
411
+ * `${userData}/.ph` under a shell's PH_USER_DATA_DIR). `dbPath` also names
412
+ * the reactor store unless PH_REACTOR_DATABASE_URL does: with `dbPath` alone
413
+ * both stores share one location. That is the long-standing contract of
414
+ * `--db-path` and fine for one Postgres database, but for PGlite it is two
415
+ * postmasters on one data dir — reported via `sharedPgliteDir` so the caller
416
+ * warns. Not refused: changing that contract is a separate decision.
417
+ */
418
+ export declare function resolvePgliteStorageDirs(opts: {
419
+ dbPath: string | undefined;
420
+ reactorDbUrl: string | undefined;
421
+ /** The caller passed its own reactor — the reactor-side dir is unused. */
422
+ callerReactor: boolean;
423
+ /** The relocated `.ph` root (PH_USER_DATA_DIR at the edge). */
424
+ userDataDir?: string;
425
+ phDir?: string;
426
+ }): PgliteStorageDirs;
427
+ /** The remote attachment service config for switchboard's own `/attachments/*` API; `attachments.serviceUrl` carries PH_SWITCHBOARD_PUBLIC_URL. */
428
+ export declare function deriveAttachmentServiceConfig(options: Pick<StartServerOptions, "attachmentServiceUrl" | "https">, serverPort: number, renown: IRenown | null): {
209
429
  remoteUrl: string;
210
430
  jwtHandler: JwtHandler | undefined;
211
431
  };
@@ -220,13 +440,15 @@ declare function deriveAttachmentServiceConfig(options: Pick<StartServerOptions,
220
440
  * dangling until the process exits.
221
441
  *
222
442
  * When `options.reactor` is omitted, the switchboard builds and owns the
223
- * reactor. `shutdown()` on the returned handle only drains the api (HTTP
224
- * server, GraphQL, MCP, attachments); the reactor itself is torn down by
225
- * its own signal handlers (`withSignalHandlers`), which call `kill()` and
226
- * trigger the `withShutdownHook` chain that disposes the api. Programmatic
227
- * full teardown isn't currently exposed — wire it via SIGINT/SIGTERM.
443
+ * reactor. `shutdown()` on the returned handle then runs the reactor
444
+ * module's `shutdown()`: `kill()`, the `withShutdownHook` chain that drains
445
+ * the api (HTTP server, GraphQL, MCP, attachments, read-model db), then the
446
+ * reactor database. It does not exit the process. It is the same memoized
447
+ * teardown the SIGINT/SIGTERM handlers (`withSignalHandlers`) run, so calling
448
+ * it twice, or receiving a signal around it, tears down once.
228
449
  */
229
- declare const startSwitchboard: (options?: StartServerOptions) => Promise<SwitchboardReactor>;
450
+ export declare const startSwitchboard: (input?: SwitchboardConfigInput, deps?: SwitchboardDeps) => Promise<SwitchboardReactor>;
230
451
  //#endregion
231
- export { IdentityOptions, StartServerOptions, StorageOptions, SwitchboardDriveDocumentType, SwitchboardDriveInput, SwitchboardReactor, type SwitchboardReactorDefaultsOptions, applySwitchboardReactorDefaults, deriveAttachmentServiceConfig, isPortAvailable, startSwitchboard };
452
+ export type { SwitchboardReactorDefaultsOptions, WorkflowTriggersCapability };
453
+ export {};
232
454
  //# sourceMappingURL=server.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.mts","names":[],"sources":["../src/types.ts","../src/builder-defaults.mts","../src/server.mts"],"mappings":";;;;;;;;;;;;;;;AAgBA;KAAY,4BAAA;;KAKA,qBAAA,GAAwB,UAAA;EAClC,YAAA,GAAe,4BAAA;AAAA;AAAA,KAGL,cAAA;EACV,IAAA;EACA,cAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA;EATiC,+DAW3C,WAAA;EARU;;;;EAaV,eAAA,YAXA;EAcA,OAAA,WAbW;EAgBX,iBAAA;AAAA;AAAA,KAGU,kBAAA;;;;;;;;;AAAZ;;;;;;;;;;;;EAqBE,OAAA,GAAU,4BAAA;EAQV;;;;;;EADA,WAAA;EACA,UAAA;EACA,IAAA;EAYA;;;;;EANA,UAAA;EACA,GAAA;EACA,MAAA;EACA,KAAA,GAAQ,qBAAA;EACR,QAAA;EACA,YAAA;EACA,KAAA;IAEM,OAAA;IACA,QAAA;EAAA;EA0CN;;;;;EAjCA,QAAA,GAAW,eAAA,EAyDT;EAvDF,oBAAA;EACA,GAAA;EACA,eAAA,GAAkB,GAAA;EAClB,oBAAA;EACA,4BAAA;;;;;;EAMA,mBAAA;EACA,MAAA,GAAS,OAAA;EA2Ec;;;;;;;;;EAjEvB,aAAA;EAoDA;;;;;;;;AC5JF;EDkHE,cAAA;;;;;;;;;EASA,UAAA;IACE,UAAA;IACA,mBAAA;IACA,gBAAA;EAAA;ECxHF;;;;;;;;;EDmIA,gBAAA;IACE,OAAA;IACA,UAAA;EAAA;AAAA;AAAA,KAIQ,kBAAA;EACV,eAAA;EACA,OAAA,EAAS,cAAA,ECpHY;EDsHrB,iBAAA,EAAmB,kBAAA,EChGL;EDkGd,6BAAA,EAA+B,uCAAA;EAE/B,MAAA,EAAQ,SAAA;EClGO;;;;EDuGf,IAAA;ECxGA;;;;;;;;;;ACyDF;;EF4DE,QAAA,QAAgB,OAAA;AAAA;;;KCzKN,iCAAA;EAIV,cAAA,GAAiB,mBAAA;EAEjB,gBAAA,GAAmB,eAAA;EAEnB,iBAAA;;ADZF;;;;ECkBE,aAAA,GAAgB,aAAA,UDbN;ECeV,cAAA;EAEA,cAAA;IACE,gBAAA;IACA,YAAA,GAAe,OAAA,CAAQ,mBAAA;EAAA,GDlBkB;ECqB3C,mBAAA,GAAsB,oBAAA;EACtB,MAAA,GAAS,OAAA;EDnBe;;;;ECwBxB,MAAA,GAAS,YAAA;AAAA;AAAA,iBAsBK,+BAAA,CACd,cAAA,EAAgB,cAAA,EAChB,aAAA,EAAe,oBAAA,EACf,OAAA,GAAS,iCAAA;;;;;;;;iBCuDK,eAAA,CAAgB,IAAA,WAAe,OAAA;;iBA0H/B,6BAAA,CACd,OAAA,EAAS,IAAA,CAAK,kBAAA,qCACd,UAAA,UACA,MAAA,EAAQ,OAAA;EACL,SAAA;EAAmB,UAAA,EAAY,UAAA;AAAA;;AF1OpC;;;;;;;;;AAIA;;;;;;;cEogCa,gBAAA,GACX,OAAA,GAAS,kBAAA,KACR,OAAA,CAAQ,kBAAA"}
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../src/pglite-version.ts","../src/pglite-store.mts","../src/privacy.mts","../src/types.ts","../src/builder-defaults.mts","../src/unsupported-stored-documents.mts","../src/server.mts"],"mappings":";;;;;;;;;;;;;;;;cAYa;KACD,2BAA2B;;;;UCuHtB;EACf;EACA,cAAc;EACd;;;;KC9GU;;EAEV;;EAEA;;EAEA,SAAS;;EAET;EACA;EACA;EACA;;;;;;;;;;YCXU;;YAKA,wBAAwB;EAClC,eAAe;;YAGL;EACV;EACA;EACA;;YAGU;;EAEV;;;;;EAKA;;EAGA;;;;;;;YAQU;;;;;;;;;;;;;;;;;;;;;EAqBV,UAAU;;;;;;;;EAQV;;;;;;;EAOA;;;;;;;EAOA;EACA;;;;;;;EAOA;;;;;;EAMA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;IAEM;IACA;;;;;;;EASN,WAAW;;EAEX;;;EAGA;;;;;;EAMA,oBAAoB;;;EAGpB;;;;EAIA;;;EAGA;IACE;;;;IAIA;MAAc;MAAY;QAAW;QAAkB;;;;;EAGzD,UAAU;EACV,kBAAkB;EAClB;EACA;;;;;;EAMA;EACA,SAAS;;;;;;;;;;EAUT;;;;;;;;;;EAUA;;;;;;;;;EASA;IACE;IACA;IACA;;;;;;;;;;;EAWF;IACE;IACA;;;;;;;;;EASF,6BAA6B;;;YAInB;EACV,SAAS;;EAET,UAAU;;EAEV,oBAAoB;;EAEpB,eAAe;;EAEf;;EAEA;;EAEA,gBAAgB;;YAGN;EACV;EACA,SAAS;;;;EAIT,mBAAmB;;EAEnB,+BAA+B;;;EAG/B,mBAAmB;;EAEnB;;EAEA,iBAAiB;;EAEjB;IAAY,SAAS;;;EAErB;;EAEA;;EAEA,WAAW;;EAEX,QAAQ;;;;;EAKR;;;;;;;;EAQA,gBAAgB;;;;KCvQN;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;;;;wBCvEK,kCACd,OAAO,wCACP,KAAK,OAAO,aACX;;qBAaU,oCAAoC;WACtC;IAAqB;IAAkB;;WACvC;EAET,YAAY,OAAO;SAcH,QACd,iBACC,SAAS;;;;;wBC4IE,uBACd,UAAS,KAAK;;;;;;wBAgCM,gBAAgB,eAAe;;;;;;KA0HhD;EACH,QAAQ,OAAO;EACf,qBAAqB;EACrB,cAAc;;wBAGM,oBAAoB;EACxC;EACA;EACA,oBAAoB;EACpB;;EAEA;;EAEA;EACA,iBAAiB;EACjB,QAAQ;IACN,QAAQ;iBA2DK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;wBAcc,yBAAyB;EACvC;EACA;;EAEA;;EAEA;EACA;IACE;;wBAmCY,8BACd,SAAS,KAAK,uDACd,oBACA,QAAQ;EACL;EAAmB,YAAY;;;;;;;;;;;;;;;;;;;;qBAwuCvB,mBAAgB,QACpB,wBAAsB,OACvB,oBACL,QAAQ"}
package/dist/server.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { i as applySwitchboardReactorDefaults, n as isPortAvailable, r as startSwitchboard, t as deriveAttachmentServiceConfig } from "./server-CiKkVE6g.mjs";
3
- import "./utils-Baw7rThP.mjs";
4
- export { applySwitchboardReactorDefaults, deriveAttachmentServiceConfig, isPortAvailable, 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]="43d97572-0a08-5683-83a3-d8477151600e")}catch(e){}}();
6
- //# debugId=43d97572-0a08-5683-83a3-d8477151600e
2
+ import { n as StoredDocumentsRefusedError, r as resolveUnsupportedStoredDocuments } from "./from-env-BO0n9R02.mjs";
3
+ import { a as resolvePgliteStorageDirs, i as isPortAvailable, l as applySwitchboardReactorDefaults, n as deriveAttachmentServiceConfig, o as startSwitchboard, r as initSwitchboardProcess, t as createReactorKysely } from "./server-cE1BWLQu.mjs";
4
+ export { StoredDocumentsRefusedError, applySwitchboardReactorDefaults, createReactorKysely, deriveAttachmentServiceConfig, initSwitchboardProcess, isPortAvailable, 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]="6e8b93b6-7e85-5223-a742-73dd23add9fa")}catch(e){}}();
6
+ //# debugId=6e8b93b6-7e85-5223-a742-73dd23add9fa
@@ -0,0 +1,133 @@
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]="a35c7e14-f12d-55d7-af9e-1d823fe909af")}catch(e){}}();
3
+ import { isDerivedDocumentId } from "@powerhousedao/shared/document-model";
4
+ import { REACTOR_DRIVE_DOCUMENT_TYPE, reactorDriveCreateState } from "@powerhousedao/reactor-drive";
5
+ import { driveCreateState, driveDocumentType } from "@powerhousedao/shared/document-drive";
6
+ //#region src/utils.mts
7
+ /**
8
+ * A configured id pins the drive, and only a legacy drive can take a chosen
9
+ * id; otherwise the client's creation default applies.
10
+ */
11
+ function newDrive(client, documentType, initialState, id) {
12
+ return client.newDocument(documentType, {
13
+ initialState,
14
+ ...id ? {
15
+ signaturePolicy: "legacy",
16
+ id
17
+ } : {}
18
+ });
19
+ }
20
+ /**
21
+ * The id to create a missing drive under: its configured id, unless that id
22
+ * has the content-addressed form only a v2 create derives (a drive pinned from
23
+ * another store). A legacy create may not take such an id, and a v2 one cannot
24
+ * choose it, so the drive is created anew and found by its slug from then on.
25
+ */
26
+ function creatableId(drive, logger) {
27
+ const id = drive.id || void 0;
28
+ if (!id || !isDerivedDocumentId(id)) return id;
29
+ logger.error(`The default drive "${drive.slug ?? id}" pins ${id}, which this store does not hold and only a v2 create derives: created a new drive for "${drive.slug ?? id}" instead.`);
30
+ }
31
+ /** The document that already holds `slug`; null when two do (an id and a slug). */
32
+ async function slugHolder(client, slug) {
33
+ let id;
34
+ try {
35
+ id = await client.resolveIdOrSlug(slug);
36
+ } catch (error) {
37
+ return error instanceof Error && error.name === "DocumentNotFoundError" ? void 0 : null;
38
+ }
39
+ return client.get(id);
40
+ }
41
+ /**
42
+ * A default drive whose slug another document holds: a drive of the same type
43
+ * stands in for it (its URL); anything else keeps it uncreated (null), with an
44
+ * error logged so the server still starts. Undefined when the slug is free.
45
+ */
46
+ async function slugTakenBy(client, drive, documentType, serverPort, logger) {
47
+ if (!drive.slug) return void 0;
48
+ const holder = await slugHolder(client, drive.slug);
49
+ if (holder === void 0) return void 0;
50
+ if (holder?.header.documentType === documentType) return `http://localhost:${serverPort}/d/${holder.header.id}`;
51
+ const owner = holder ? `${holder.header.documentType} document ${holder.header.id}` : "two documents";
52
+ logger.error(`The default drive "${drive.slug}" was not created: the slug belongs to ${owner}.`);
53
+ return null;
54
+ }
55
+ /** Creates a configured drive unless one with its id or slug exists; the
56
+ * URL it is served at, or undefined when another document holds the slug. */
57
+ async function addDefaultDrive(client, drive, serverPort, logger = console) {
58
+ let driveId = drive.id;
59
+ if (!driveId || driveId.length === 0) driveId = drive.slug;
60
+ if (!driveId || driveId.length === 0) throw new Error("Invalid Drive Id");
61
+ let existingDrive;
62
+ try {
63
+ existingDrive = await client.get(driveId);
64
+ } catch {}
65
+ if (existingDrive) return `http://localhost:${serverPort}/d/${driveId}`;
66
+ const { global } = driveCreateState();
67
+ const taken = await slugTakenBy(client, drive, driveDocumentType, serverPort, logger);
68
+ if (taken !== void 0) return taken ?? void 0;
69
+ const pinned = creatableId(drive, logger);
70
+ const document = await newDrive(client, driveDocumentType, {
71
+ global: {
72
+ ...global,
73
+ name: drive.global.name,
74
+ icon: drive.global.icon ?? global.icon
75
+ },
76
+ local: {
77
+ availableOffline: drive.local?.availableOffline ?? false,
78
+ sharingType: drive.local?.sharingType ?? "public",
79
+ listeners: drive.local?.listeners ?? [],
80
+ triggers: drive.local?.triggers ?? []
81
+ }
82
+ }, pinned);
83
+ if (drive.slug && drive.slug.length > 0) document.header.slug = drive.slug;
84
+ if (drive.global.name) document.header.name = drive.global.name;
85
+ if (drive.preferredEditor) document.header.meta = { preferredEditor: drive.preferredEditor };
86
+ try {
87
+ await (await client.write.create(document)).readable;
88
+ } catch (e) {
89
+ if (!(e instanceof Error ? e.message : String(e)).includes("already exists")) throw e;
90
+ }
91
+ return `http://localhost:${serverPort}/d/${pinned === drive.id ? driveId : drive.slug || document.header.id}`;
92
+ }
93
+ /** addDefaultDrive for a reactor drive. */
94
+ async function addDefaultReactorDrive(client, drive, serverPort, logger = console) {
95
+ let driveId = drive.id;
96
+ if (!driveId || driveId.length === 0) driveId = drive.slug;
97
+ if (!driveId || driveId.length === 0) throw new Error("Invalid Drive Id");
98
+ let existingDrive;
99
+ try {
100
+ existingDrive = await client.get(driveId);
101
+ } catch {}
102
+ if (existingDrive) return `http://localhost:${serverPort}/d/${driveId}`;
103
+ const { global, local } = reactorDriveCreateState();
104
+ const taken = await slugTakenBy(client, drive, REACTOR_DRIVE_DOCUMENT_TYPE, serverPort, logger);
105
+ if (taken !== void 0) return taken ?? void 0;
106
+ const pinned = creatableId(drive, logger);
107
+ const document = await newDrive(client, REACTOR_DRIVE_DOCUMENT_TYPE, {
108
+ global: {
109
+ ...global,
110
+ name: drive.global.name,
111
+ icon: drive.global.icon ?? global.icon
112
+ },
113
+ local: {
114
+ ...local,
115
+ availableOffline: drive.local?.availableOffline ?? local.availableOffline,
116
+ sharingType: drive.local?.sharingType ?? local.sharingType
117
+ }
118
+ }, pinned);
119
+ if (drive.slug && drive.slug.length > 0) document.header.slug = drive.slug;
120
+ if (drive.global.name) document.header.name = drive.global.name;
121
+ if (drive.preferredEditor) document.header.meta = { preferredEditor: drive.preferredEditor };
122
+ try {
123
+ await (await client.write.create(document)).readable;
124
+ } catch (e) {
125
+ if (!(e instanceof Error ? e.message : String(e)).includes("already exists")) throw e;
126
+ }
127
+ return `http://localhost:${serverPort}/d/${pinned === drive.id ? driveId : drive.slug || document.header.id}`;
128
+ }
129
+ //#endregion
130
+ export { addDefaultReactorDrive as n, addDefaultDrive as t };
131
+
132
+ //# sourceMappingURL=utils-C6AIF38Z.mjs.map
133
+ //# debugId=a35c7e14-f12d-55d7-af9e-1d823fe909af
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-C6AIF38Z.mjs","sources":["../src/utils.mts"],"sourcesContent":["import type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n REACTOR_DRIVE_DOCUMENT_TYPE,\n reactorDriveCreateState,\n} from \"@powerhousedao/reactor-drive\";\nimport {\n driveCreateState,\n driveDocumentType,\n} from \"@powerhousedao/shared/document-drive\";\nimport type { DriveInput } from \"@powerhousedao/shared/document-drive\";\nimport {\n isDerivedDocumentId,\n type PHBaseState,\n type PHDocument,\n} from \"@powerhousedao/shared/document-model\";\n\n/**\n * A configured id pins the drive, and only a legacy drive can take a chosen\n * id; otherwise the client's creation default applies.\n */\nfunction newDrive<TDocument extends PHDocument>(\n client: IReactorClient,\n documentType: string,\n initialState: Partial<PHBaseState>,\n id: string | undefined,\n): Promise<TDocument> {\n return client.newDocument<TDocument>(documentType, {\n initialState,\n ...(id ? { signaturePolicy: \"legacy\" as const, id } : {}),\n });\n}\n\ntype DefaultDriveLogger = { error: (message: string) => void };\n\n/**\n * The id to create a missing drive under: its configured id, unless that id\n * has the content-addressed form only a v2 create derives (a drive pinned from\n * another store). A legacy create may not take such an id, and a v2 one cannot\n * choose it, so the drive is created anew and found by its slug from then on.\n */\nfunction creatableId(\n drive: DriveInput,\n logger: DefaultDriveLogger,\n): string | undefined {\n const id = drive.id || undefined;\n if (!id || !isDerivedDocumentId(id)) return id;\n logger.error(\n `The default drive \"${drive.slug ?? id}\" pins ${id}, which this store does not hold and only a v2 create derives: created a new drive for \"${drive.slug ?? id}\" instead.`,\n );\n return undefined;\n}\n\n/** The document that already holds `slug`; null when two do (an id and a slug). */\nasync function slugHolder(\n client: IReactorClient,\n slug: string,\n): Promise<PHDocument | null | undefined> {\n let id: string;\n try {\n id = await client.resolveIdOrSlug(slug);\n } catch (error) {\n const notFound =\n error instanceof Error && error.name === \"DocumentNotFoundError\";\n return notFound ? undefined : null;\n }\n return client.get(id);\n}\n\n/**\n * A default drive whose slug another document holds: a drive of the same type\n * stands in for it (its URL); anything else keeps it uncreated (null), with an\n * error logged so the server still starts. Undefined when the slug is free.\n */\nasync function slugTakenBy(\n client: IReactorClient,\n drive: DriveInput,\n documentType: string,\n serverPort: number,\n logger: DefaultDriveLogger,\n): Promise<string | null | undefined> {\n if (!drive.slug) return undefined;\n const holder = await slugHolder(client, drive.slug);\n if (holder === undefined) return undefined;\n if (holder?.header.documentType === documentType) {\n return `http://localhost:${serverPort}/d/${holder.header.id}`;\n }\n const owner = holder\n ? `${holder.header.documentType} document ${holder.header.id}`\n : \"two documents\";\n logger.error(\n `The default drive \"${drive.slug}\" was not created: the slug belongs to ${owner}.`,\n );\n return null;\n}\n\n/** Creates a configured drive unless one with its id or slug exists; the\n * URL it is served at, or undefined when another document holds the slug. */\nexport async function addDefaultDrive(\n client: IReactorClient,\n drive: DriveInput,\n serverPort: number,\n logger: DefaultDriveLogger = console,\n): Promise<string | undefined> {\n let driveId = drive.id;\n if (!driveId || driveId.length === 0) {\n driveId = drive.slug;\n }\n\n if (!driveId || driveId.length === 0) {\n throw new Error(\"Invalid Drive Id\");\n }\n\n // check if the drive already exists\n let existingDrive;\n try {\n existingDrive = await client.get(driveId);\n } catch {\n //\n }\n\n // already exists, return the existing drive url\n if (existingDrive) {\n return `http://localhost:${serverPort}/d/${driveId}`;\n }\n\n const { global } = driveCreateState();\n const taken = await slugTakenBy(\n client,\n drive,\n driveDocumentType,\n serverPort,\n logger,\n );\n if (taken !== undefined) return taken ?? undefined;\n const pinned = creatableId(drive, logger);\n\n const document = await newDrive(\n client,\n driveDocumentType,\n {\n global: {\n ...global,\n name: drive.global.name,\n icon: drive.global.icon ?? global.icon,\n },\n local: {\n availableOffline: drive.local?.availableOffline ?? false,\n sharingType: drive.local?.sharingType ?? \"public\",\n listeners: drive.local?.listeners ?? [],\n triggers: drive.local?.triggers ?? [],\n },\n } as Partial<PHBaseState>,\n pinned,\n );\n if (drive.slug && drive.slug.length > 0) {\n document.header.slug = drive.slug;\n }\n if (drive.global.name) {\n document.header.name = drive.global.name;\n }\n if (drive.preferredEditor) {\n document.header.meta = { preferredEditor: drive.preferredEditor };\n }\n\n try {\n await (\n await client.write.create(document)\n ).readable;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n if (!errorMessage.includes(\"already exists\")) {\n throw e;\n }\n }\n\n // A pin this store could not take: the drive is served where it was made\n const servedAs =\n pinned === drive.id ? driveId : drive.slug || document.header.id;\n return `http://localhost:${serverPort}/d/${servedAs}`;\n}\n\n/** addDefaultDrive for a reactor drive. */\nexport async function addDefaultReactorDrive(\n client: IReactorClient,\n drive: DriveInput,\n serverPort: number,\n logger: DefaultDriveLogger = console,\n): Promise<string | undefined> {\n let driveId = drive.id;\n if (!driveId || driveId.length === 0) {\n driveId = drive.slug;\n }\n\n if (!driveId || driveId.length === 0) {\n throw new Error(\"Invalid Drive Id\");\n }\n\n let existingDrive;\n try {\n existingDrive = await client.get(driveId);\n } catch {\n //\n }\n\n if (existingDrive) {\n return `http://localhost:${serverPort}/d/${driveId}`;\n }\n\n const { global, local } = reactorDriveCreateState();\n const taken = await slugTakenBy(\n client,\n drive,\n REACTOR_DRIVE_DOCUMENT_TYPE,\n serverPort,\n logger,\n );\n if (taken !== undefined) return taken ?? undefined;\n const pinned = creatableId(drive, logger);\n\n const document = await newDrive(\n client,\n REACTOR_DRIVE_DOCUMENT_TYPE,\n {\n global: {\n ...global,\n name: drive.global.name,\n icon: drive.global.icon ?? global.icon,\n },\n local: {\n ...local,\n availableOffline:\n drive.local?.availableOffline ?? local.availableOffline,\n sharingType: drive.local?.sharingType ?? local.sharingType,\n },\n } as Partial<PHBaseState>,\n pinned,\n );\n if (drive.slug && drive.slug.length > 0) {\n document.header.slug = drive.slug;\n }\n if (drive.global.name) {\n document.header.name = drive.global.name;\n }\n if (drive.preferredEditor) {\n document.header.meta = { preferredEditor: drive.preferredEditor };\n }\n\n try {\n await (\n await client.write.create(document)\n ).readable;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n if (!errorMessage.includes(\"already exists\")) {\n throw e;\n }\n }\n\n // A pin this store could not take: the drive is served where it was made\n const servedAs =\n pinned === drive.id ? driveId : drive.slug || document.header.id;\n return `http://localhost:${serverPort}/d/${servedAs}`;\n}\n\nexport { isPostgresUrl } from \"./postgres-url.mjs\";\n"],"names":[],"mappings":"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","debug_id":"a35c7e14-f12d-55d7-af9e-1d823fe909af"}
package/dist/utils.d.mts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { IReactorClient } from "@powerhousedao/reactor";
2
2
  import { DriveInput } from "@powerhousedao/shared/document-drive";
3
-
3
+ //#region src/postgres-url.d.mts
4
+ export declare function isPostgresUrl(url: string): boolean;
5
+ //#endregion
4
6
  //#region src/utils.d.mts
5
- declare function addDefaultDrive(client: IReactorClient, drive: DriveInput, serverPort: number): Promise<string>;
6
- declare function addDefaultReactorDrive(client: IReactorClient, drive: DriveInput, serverPort: number): Promise<string>;
7
- declare function isPostgresUrl(url: string): boolean;
7
+ type DefaultDriveLogger = {
8
+ error: (message: string) => void;
9
+ };
10
+ /** Creates a configured drive unless one with its id or slug exists; the
11
+ * URL it is served at, or undefined when another document holds the slug. */
12
+ export declare function addDefaultDrive(client: IReactorClient, drive: DriveInput, serverPort: number, logger?: DefaultDriveLogger): Promise<string | undefined>;
13
+ /** addDefaultDrive for a reactor drive. */
14
+ export declare function addDefaultReactorDrive(client: IReactorClient, drive: DriveInput, serverPort: number, logger?: DefaultDriveLogger): Promise<string | undefined>;
8
15
  //#endregion
9
- export { addDefaultDrive, addDefaultReactorDrive, isPostgresUrl };
16
+ export {};
10
17
  //# sourceMappingURL=utils.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils.mts"],"mappings":";;;;iBAWsB,eAAA,CACpB,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,UAAA,EACP,UAAA,WAAkB,OAAA;AAAA,iBAgEE,sBAAA,CACpB,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,UAAA,EACP,UAAA,WAAkB,OAAA;AAAA,iBA6DJ,aAAA,CAAc,GAAA"}
1
+ {"version":3,"file":"utils.d.mts","names":[],"sources":["../src/postgres-url.mts","../src/utils.mts"],"mappings":";;;wBAAgB,cAAc;;;KCgCzB;EAAuB,QAAQ;;;;wBAiEd,gBACpB,QAAQ,gBACR,OAAO,YACP,oBACA,SAAQ,qBACP;;wBAgFmB,uBACpB,QAAQ,gBACR,OAAO,YACP,oBACA,SAAQ,qBACP"}