@powerhousedao/switchboard 6.2.3-dev.44 → 6.2.3-dev.45

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 (32) hide show
  1. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
  2. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
  3. package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
  4. package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
  5. package/.tsbuild/test/snapshot-writer.d.ts +18 -0
  6. package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
  7. package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
  8. package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
  9. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
  10. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
  11. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  12. package/CHANGELOG.md +28 -0
  13. package/dist/index.mjs +1 -1
  14. package/dist/{server-Bk_IZzCn.mjs → server-Dvw8_NeM.mjs} +256 -77
  15. package/dist/server-Dvw8_NeM.mjs.map +1 -0
  16. package/dist/server.d.mts +3 -1
  17. package/dist/server.d.mts.map +1 -1
  18. package/dist/server.mjs +3 -3
  19. package/package.json +15 -16
  20. package/test/boot-unsupported-stored-documents.test.ts +5 -5
  21. package/test/durable-node-fs-pg16.test.ts +80 -0
  22. package/test/pglite-dialect.test.ts +28 -0
  23. package/test/pglite-preflight.test.ts +313 -0
  24. package/test/pglite-version.test.ts +9 -1
  25. package/test/snapshot-writer.ts +94 -0
  26. package/test/worker-pool.test.ts +27 -1
  27. package/test/workflow/resolvers.test.ts +26 -0
  28. package/test/workflow-reactor-access.test.ts +384 -0
  29. package/test/workflow-reactor-enforcement.test.ts +805 -0
  30. package/test/workflow-runtime.test.ts +53 -0
  31. package/tsconfig.json +0 -3
  32. package/dist/server-Bk_IZzCn.mjs.map +0 -1
@@ -29,6 +29,8 @@ import {
29
29
  canReadAttachmentRef,
30
30
  composeWorkflowRuntime,
31
31
  assertWorkflowPackageLoadable,
32
+ hostPrincipalOf,
33
+ reactorAccessOf,
32
34
  resolveWorkflowsEnabled,
33
35
  type BooleanFlagSource,
34
36
  } from "../src/workflow-runtime.mjs";
@@ -367,6 +369,48 @@ describe("composeWorkflowRuntime", () => {
367
369
  });
368
370
  });
369
371
 
372
+ describe("the host's reactor access", () => {
373
+ const signer = { app: { key: "did:key:zHost" }, user: { address: "0xhost" } };
374
+ const moduleWith = (flags?: Record<string, boolean>) =>
375
+ ({
376
+ signer,
377
+ reactorModule: flags ? { featureFlags: flags } : undefined,
378
+ }) as unknown as InProcessReactorClientModule;
379
+
380
+ it("grants the host by key under auth conditions, else by address", () => {
381
+ const byKey = reactorAccessOf(
382
+ moduleWith({ authEnforcement: true, authConditions: true }),
383
+ );
384
+ expect(byKey).toEqual({
385
+ authEnforcement: true,
386
+ authConditions: true,
387
+ identity: { address: "0xhost", key: "did:key:zHost" },
388
+ });
389
+ expect(hostPrincipalOf(byKey)).toEqual({
390
+ match: { eq: [{ attr: "subject.key" }, { lit: "did:key:zHost" }] },
391
+ });
392
+
393
+ const byAddress = reactorAccessOf(
394
+ moduleWith({ authEnforcement: false, authConditions: false }),
395
+ );
396
+ expect(byAddress.authEnforcement).toBe(false);
397
+ expect(hostPrincipalOf(byAddress)).toEqual({ address: "0xhost" });
398
+ });
399
+
400
+ it("reads unknown flags as enforced and a keyless signer as no identity", () => {
401
+ const access = reactorAccessOf({
402
+ signer: {},
403
+ reactorModule: undefined,
404
+ } as unknown as InProcessReactorClientModule);
405
+ expect(access).toEqual({
406
+ authEnforcement: true,
407
+ authConditions: false,
408
+ identity: null,
409
+ });
410
+ expect(hostPrincipalOf(access)).toBeUndefined();
411
+ });
412
+ });
413
+
370
414
  // The GraphQL manager rides on the boot result without being on its public
371
415
  // type, and the subgraph registers late: poll rather than race it.
372
416
  async function pollWorkflowSubgraph(
@@ -408,6 +452,15 @@ describe("booting Switchboard with workflows on", () => {
408
452
  expect(
409
453
  results.map(({ documentModel }) => documentModel.global.id),
410
454
  ).toContain("powerhouse/workflow");
455
+ // With no worker pool or projection worker, workflows alone resolve them.
456
+ expect(
457
+ switchboard.modelManifest().map((entry) => entry.documentType),
458
+ ).toEqual(
459
+ expect.arrayContaining([
460
+ "powerhouse/workflow",
461
+ "powerhouse/connection",
462
+ ]),
463
+ );
411
464
  // The subgraph is registered late, so the schema it joins arrives after
412
465
  // the boot resolves; poll rather than race it.
413
466
  await expect(pollWorkflowSubgraph(switchboard)).resolves.toMatchObject({
package/tsconfig.json CHANGED
@@ -15,9 +15,6 @@
15
15
  {
16
16
  "path": "../../packages/opentelemetry-instrumentation-reactor"
17
17
  },
18
- {
19
- "path": "../../packages/pglite-fs"
20
- },
21
18
  {
22
19
  "path": "../../packages/reactor"
23
20
  },