Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,60 @@
import { describe, expect, test, vi } from "vitest";
import { z } from "zod";
import { emitPluginHook, PluginHookValidationError, type PluginHookOutboxPublisher } from "./emit.js";
import type { PluginHookDefinition } from "./registry.js";
/**
* Coverage for emitPluginHook's outbox-arg defaulting: the tenantId /
* dispatchKey fall back to null when the optional fields are omitted, and
* pass through verbatim when supplied. Plus the validation-failure throw.
*/
type TestPayload = { id: string };
const DEF: PluginHookDefinition<TestPayload> = {
name: "test.created",
outboxEventType: "plugin.hook.test.created",
payloadSchema: z.object({ id: z.string().min(1) }),
};
const TX = { marker: "tx" };
describe("emitPluginHook", () => {
test("forwards explicit tenantId + dispatchKey to the publisher", async () => {
const publish = vi.fn<PluginHookOutboxPublisher>(() => Promise.resolve({ id: "outbox-1" }));
await emitPluginHook(TX, DEF, { id: "abc" }, publish, {
tenantId: "tenant-1",
dispatchKey: "dedupe-1",
});
expect(publish).toHaveBeenCalledWith(TX, {
tenantId: "tenant-1",
type: "plugin.hook.test.created",
payload: { id: "abc" },
dispatchKey: "dedupe-1",
});
});
test("defaults tenantId + dispatchKey to null when options are omitted", async () => {
const publish = vi.fn<PluginHookOutboxPublisher>(() => Promise.resolve(null));
await emitPluginHook(TX, DEF, { id: "abc" }, publish);
expect(publish).toHaveBeenCalledWith(TX, {
tenantId: null,
type: "plugin.hook.test.created",
payload: { id: "abc" },
dispatchKey: null,
});
});
test("throws PluginHookValidationError and never publishes on a bad payload", async () => {
const publish = vi.fn<PluginHookOutboxPublisher>(() => Promise.resolve(null));
await expect(
emitPluginHook(TX, DEF, { id: "" } as TestPayload, publish)
).rejects.toBeInstanceOf(PluginHookValidationError);
expect(publish).not.toHaveBeenCalled();
});
});
@@ -33,7 +33,7 @@ import {
/**
* JSON-compatible value type, structurally identical to
* `Prisma.InputJsonValue` without taking the dependency on
* `@toolctrl/db` (which would cycle through the worker bootstrap).
* `@hivegrid/db` (which would cycle through the worker bootstrap).
*/
export type PluginHookJsonValue =
| string
@@ -55,10 +55,10 @@ export class PluginHookValidationError extends Error {
}
/**
* Minimal publish surface — kept identical to the @toolctrl/db helper
* so this package does not have to depend on @toolctrl/db directly
* Minimal publish surface — kept identical to the @hivegrid/db helper
* so this package does not have to depend on @hivegrid/db directly
* (avoids a cycle with the worker bootstrap that pulls plugin-runtime
* via @toolctrl/db).
* via @hivegrid/db).
*/
export type PluginHookOutboxPublisher = (
tx: unknown,
@@ -84,7 +84,7 @@ export type EmitPluginHookOptions = {
/**
* Validate + publish a plugin-hook outbox event inside a transaction.
* The transaction client is intentionally typed as `unknown` so this
* package keeps zero runtime dependency on @toolctrl/db — the caller
* package keeps zero runtime dependency on @hivegrid/db — the caller
* (a `.server.ts` file in apps/web) already imports the prisma types
* and passes the correct shape.
*/
@@ -233,7 +233,7 @@ describe("plugin hook registry", () => {
errorCode: "workflow_execution_failed",
appliesToAllTenants: false,
occurredAt: "2026-05-26T20:00:00.000Z",
error: "Provider failed with token=sk_live_secret",
error: "Provider failed with token=payment_live_secret",
});
expect(withRawError.ok).toBe(false);
@@ -314,7 +314,7 @@ describe("plugin hook registry", () => {
errorCode: "workflow_execution_failed",
appliesToAllTenants: false,
occurredAt: "2026-05-26T20:00:00.000Z",
error: "Provider failed with token=sk_live_secret",
error: "Provider failed with token=payment_live_secret",
});
expect(withRawError.ok).toBe(false);
});