@powerhousedao/switchboard 6.2.3-dev.43 → 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.
- 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/observability-signals.test.d.ts +2 -0
- package/.tsbuild/test/observability-signals.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/snapshot-writer.d.ts +18 -0
- package/.tsbuild/test/snapshot-writer.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/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +43 -0
- package/dist/index.mjs +42 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{server-CMAxYG6D.mjs → server-Dvw8_NeM.mjs} +271 -79
- package/dist/server-Dvw8_NeM.mjs.map +1 -0
- package/dist/server.d.mts +3 -1
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +3 -3
- package/package.json +15 -16
- package/test/boot-unsupported-stored-documents.test.ts +5 -5
- package/test/durable-node-fs-pg16.test.ts +80 -0
- package/test/fatal-shutdown.test.ts +33 -0
- package/test/observability-signals.test.ts +131 -0
- package/test/pglite-dialect.test.ts +28 -0
- package/test/pglite-preflight.test.ts +313 -0
- package/test/pglite-version.test.ts +9 -1
- package/test/snapshot-writer.ts +94 -0
- package/test/worker-pool.test.ts +27 -1
- package/test/workflow/resolvers.test.ts +26 -0
- package/test/workflow-reactor-access.test.ts +384 -0
- package/test/workflow-reactor-enforcement.test.ts +805 -0
- package/test/workflow-runtime.test.ts +53 -0
- package/tsconfig.json +0 -3
- package/dist/server-CMAxYG6D.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({
|