Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# @toolctrl/plugin-sdk
|
||||
# @hivegrid/plugin-sdk
|
||||
|
||||
Phase 06 Task #21 foundation — TypeScript SDK plugin authors import against.
|
||||
|
||||
@@ -9,11 +9,11 @@ Phase 06 Task #21 foundation — TypeScript SDK plugin authors import against.
|
||||
|
||||
## How plugin authors use this
|
||||
|
||||
1. `pnpm add -D @toolctrl/plugin-sdk`
|
||||
1. `pnpm add -D @hivegrid/plugin-sdk`
|
||||
2. Implement a hook handler:
|
||||
|
||||
```ts
|
||||
import type { HookHandler } from "@toolctrl/plugin-sdk";
|
||||
import type { HookHandler } from "@hivegrid/plugin-sdk";
|
||||
|
||||
export const handler: HookHandler<{ name: string }, { greeting: string }> = (input, ctx) => {
|
||||
ctx.log.info({ name: input.name }, "hello");
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
# audit rows for the trigger; the worker handles its own observability.
|
||||
|
||||
schemaVersion = 1
|
||||
id = "de.toolctrl.examples.async-task"
|
||||
id = "de.hivegrid.examples.async-task"
|
||||
version = "0.1.0"
|
||||
name = "Async Task Demo"
|
||||
description = "Enqueues a long-running task via the audit capability, returns immediately."
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
# invocation.
|
||||
|
||||
schemaVersion = 1
|
||||
id = "de.toolctrl.examples.capability-use"
|
||||
id = "de.hivegrid.examples.capability-use"
|
||||
version = "0.1.0"
|
||||
name = "Capability-Use Demo"
|
||||
description = "Calls http.outbound + storage.read + log on every invocation. Exercises the audit trail."
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Hello-World example plugin
|
||||
|
||||
Minimum-viable plugin demonstrating the `@toolctrl/plugin-sdk` shape.
|
||||
Minimum-viable plugin demonstrating the `@hivegrid/plugin-sdk` shape.
|
||||
|
||||
## Files
|
||||
|
||||
|
||||
+2
-2
@@ -2,13 +2,13 @@
|
||||
* Hello-World example plugin source.
|
||||
*
|
||||
* Plugin authors write TypeScript / AssemblyScript / Rust against the
|
||||
* `@toolctrl/plugin-sdk` types, then compile to a single `.wasm` binary
|
||||
* `@hivegrid/plugin-sdk` types, then compile to a single `.wasm` binary
|
||||
* with their toolchain of choice (wasm-pack, AssemblyScript's `asc`,
|
||||
* etc.). The host runtime treats the .wasm as opaque — only its
|
||||
* exports (`handleHello` here) and the `plugin.toml` manifest matter.
|
||||
*
|
||||
* Building this file to WASM is intentionally outside the scope of
|
||||
* the foundation: the `toolctrl plugin build` CLI is deferred (see
|
||||
* the foundation: the `hivegrid plugin build` CLI is deferred (see
|
||||
* `docs/improvement-plan/06-plugin-system/wasm-sandbox.md` Deviations).
|
||||
* Operators wanting a working hello-world today can hand-compile via
|
||||
* AssemblyScript or use any other WASM toolchain that produces a flat
|
||||
|
||||
+3
-3
@@ -1,16 +1,16 @@
|
||||
# Phase 06 #21 — Hello-World example plugin manifest.
|
||||
#
|
||||
# A plugin author ships exactly this file alongside the .wasm binary.
|
||||
# The runtime parses it via @toolctrl/plugin-runtime's PluginManifestSchema
|
||||
# The runtime parses it via @hivegrid/plugin-runtime's PluginManifestSchema
|
||||
# (note: foundation supports both TOML and JSON shape — the schema works
|
||||
# off the parsed object so authors may choose the format their toolchain
|
||||
# emits). The values below are illustrative; the wasmSha256 / signature /
|
||||
# signedBy fields are placeholders that an operator replaces after
|
||||
# signing the actual binary with `toolctrl plugin sign` (deferred CLI,
|
||||
# signing the actual binary with `hivegrid plugin sign` (deferred CLI,
|
||||
# see Deviations in wasm-sandbox.md).
|
||||
|
||||
schemaVersion = 1
|
||||
id = "de.toolctrl.hello"
|
||||
id = "de.hivegrid.hello"
|
||||
version = "1.0.0"
|
||||
name = "Hello World"
|
||||
description = "Returns a greeting. Demonstrates the minimum viable plugin."
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ returns. No external IO.
|
||||
|
||||
1. Compile `handler.ts` to wasm with your toolchain of choice (see
|
||||
`docs/plugins/cli-reference.md#build`).
|
||||
2. `toolctrl-cli plugins sign --wasm plugin.wasm --manifest plugin.json --key <ed25519-priv>`.
|
||||
3. `toolctrl-cli plugins publish --wasm plugin.wasm --manifest plugin.json` → upload the resulting `.tar.gz`.
|
||||
2. `hivegrid-cli plugins sign --wasm plugin.wasm --manifest plugin.json --key <ed25519-priv>`.
|
||||
3. `hivegrid-cli plugins publish --wasm plugin.wasm --manifest plugin.json` → upload the resulting `.tar.gz`.
|
||||
4. Install through the tenant-admin plugins page.
|
||||
5. Create a new tenant; observe the host log line.
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
# pipeline in minutes.
|
||||
|
||||
schemaVersion = 1
|
||||
id = "de.toolctrl.examples.simple-hook-listener"
|
||||
id = "de.hivegrid.examples.simple-hook-listener"
|
||||
version = "0.1.0"
|
||||
name = "Simple Hook Listener"
|
||||
description = "Logs tenant.created events. Demonstrates the smallest viable plugin."
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@toolctrl/plugin-sdk",
|
||||
"name": "@hivegrid/plugin-sdk",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, expectTypeOf, test } from "vitest";
|
||||
import { afterEach, describe, expect, expectTypeOf, test, vi } from "vitest";
|
||||
import {
|
||||
createPluginSettingsClient,
|
||||
defineHook,
|
||||
@@ -33,7 +33,7 @@ function makeContext(overrides: Partial<PluginContext> = {}): PluginContext {
|
||||
error: () => undefined,
|
||||
};
|
||||
return {
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
pluginVersion: "1.0.0",
|
||||
tenantId: "t-1",
|
||||
hookName: "ping",
|
||||
@@ -73,14 +73,14 @@ function makeSettingsFrameWindow() {
|
||||
};
|
||||
}
|
||||
|
||||
describe("@toolctrl/plugin-sdk", () => {
|
||||
describe("@hivegrid/plugin-sdk", () => {
|
||||
test("exports a stable version constant", () => {
|
||||
expect(PLUGIN_SDK_PACKAGE_VERSION).toBe("0.0.0");
|
||||
});
|
||||
|
||||
test("exports the structured payload ABI contract", () => {
|
||||
expect(PLUGIN_PAYLOAD_ABI_VERSION).toBe(1);
|
||||
expect(PLUGIN_PAYLOAD_ABI_IMPORTS).toEqual(["env.toolctrl_payload_len", "env.toolctrl_payload_byte"]);
|
||||
expect(PLUGIN_PAYLOAD_ABI_IMPORTS).toEqual(["env.hivegrid_payload_len", "env.hivegrid_payload_byte"]);
|
||||
});
|
||||
|
||||
test("exports the settings iframe postMessage protocol contract", () => {
|
||||
@@ -90,7 +90,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
const getMessage: PluginSettingsFrameGetMessage = {
|
||||
type: "plugin.settings.get",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "get-1",
|
||||
key: "theme",
|
||||
@@ -98,7 +98,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
const setMessage: PluginSettingsFrameSetMessage = {
|
||||
type: "plugin.settings.set",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "set-1",
|
||||
key: "theme",
|
||||
@@ -107,7 +107,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
const resultMessage: PluginSettingsFrameResultMessage = {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "get-1",
|
||||
ok: true,
|
||||
@@ -127,7 +127,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
test("createPluginSettingsClient posts ready, get, and set messages", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
targetOrigin: "https://app.example.test",
|
||||
requestId: () => "request-1",
|
||||
@@ -144,7 +144,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
message: {
|
||||
type: "plugin.settings.ready",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "ready-1",
|
||||
},
|
||||
@@ -154,7 +154,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
message: {
|
||||
type: "plugin.settings.get",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "request-1",
|
||||
key: "theme",
|
||||
@@ -165,7 +165,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
message: {
|
||||
type: "plugin.settings.set",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "set-1",
|
||||
key: "mode",
|
||||
@@ -179,7 +179,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "request-1",
|
||||
ok: true,
|
||||
@@ -192,7 +192,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "set-1",
|
||||
ok: true,
|
||||
@@ -210,7 +210,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
test("createPluginSettingsClient reads the injected channel meta tag", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
window: frameWindow,
|
||||
document: {
|
||||
querySelector: (selector) => {
|
||||
@@ -227,7 +227,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
test("createPluginSettingsClient ignores result messages that do not match the parent and request scope", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
timeoutMs: 0,
|
||||
window: frameWindow,
|
||||
@@ -235,10 +235,10 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
const promise = client.get("theme", { requestId: "get-1" });
|
||||
|
||||
for (const data of [
|
||||
{ version: 2, pluginId: "de.toolctrl.test", channelId: "channel-1", requestId: "get-1" },
|
||||
{ version: 2, pluginId: "de.hivegrid.test", channelId: "channel-1", requestId: "get-1" },
|
||||
{ version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION, pluginId: "other", channelId: "channel-1", requestId: "get-1" },
|
||||
{ version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION, pluginId: "de.toolctrl.test", channelId: "other", requestId: "get-1" },
|
||||
{ version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION, pluginId: "de.toolctrl.test", channelId: "channel-1", requestId: "other" },
|
||||
{ version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION, pluginId: "de.hivegrid.test", channelId: "other", requestId: "get-1" },
|
||||
{ version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION, pluginId: "de.hivegrid.test", channelId: "channel-1", requestId: "other" },
|
||||
]) {
|
||||
frameWindow.emit({
|
||||
source: frameWindow.parent,
|
||||
@@ -257,7 +257,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "get-1",
|
||||
ok: true,
|
||||
@@ -270,7 +270,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "get-1",
|
||||
ok: true,
|
||||
@@ -286,7 +286,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
test("createPluginSettingsClient rejects host errors and mismatched response keys", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
timeoutMs: 0,
|
||||
window: frameWindow,
|
||||
@@ -298,7 +298,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "set-1",
|
||||
ok: false,
|
||||
@@ -316,7 +316,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId: "get-1",
|
||||
ok: true,
|
||||
@@ -332,7 +332,7 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
test("createPluginSettingsClient rejects timed out requests", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
timeoutMs: 1,
|
||||
window: frameWindow,
|
||||
@@ -459,3 +459,179 @@ describe("@toolctrl/plugin-sdk", () => {
|
||||
expect(result).toEqual({ changed: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("createPluginSettingsClient default-environment + lifecycle coverage", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
test("throws when the default window has no parent postMessage target", () => {
|
||||
vi.stubGlobal("window", undefined);
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", channelId: "channel-1" })).toThrow(
|
||||
"Plugin settings client requires a window with a parent postMessage target"
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores a default window that is missing a parent", () => {
|
||||
vi.stubGlobal("window", { addEventListener: () => undefined, removeEventListener: () => undefined });
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", channelId: "channel-1" })).toThrow(
|
||||
"Plugin settings client requires a window with a parent postMessage target"
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores a default window whose parent is present but lacks addEventListener", () => {
|
||||
vi.stubGlobal("window", { parent: { postMessage: () => undefined }, removeEventListener: () => undefined });
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", channelId: "channel-1" })).toThrow(
|
||||
"Plugin settings client requires a window with a parent postMessage target"
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores a default window that lacks removeEventListener", () => {
|
||||
vi.stubGlobal("window", { parent: { postMessage: () => undefined }, addEventListener: () => undefined });
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", channelId: "channel-1" })).toThrow(
|
||||
"Plugin settings client requires a window with a parent postMessage target"
|
||||
);
|
||||
});
|
||||
|
||||
test("falls back to the default window when no window option is given", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
vi.stubGlobal("window", frameWindow);
|
||||
|
||||
const client = createPluginSettingsClient({ pluginId: "de.hivegrid.test", channelId: "channel-1" });
|
||||
expect(frameWindow.listenerCount()).toBe(1);
|
||||
client.ready();
|
||||
expect(frameWindow.posted).toHaveLength(1);
|
||||
client.destroy();
|
||||
expect(frameWindow.listenerCount()).toBe(0);
|
||||
});
|
||||
|
||||
test("reads the channel id from the default document meta tag", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
vi.stubGlobal("document", {
|
||||
querySelector: (selector: string) => {
|
||||
expect(selector).toBe(`meta[name="${PLUGIN_SETTINGS_FRAME_CHANNEL_META_NAME}"]`);
|
||||
return { getAttribute: () => "default-doc-channel" };
|
||||
},
|
||||
});
|
||||
|
||||
const client = createPluginSettingsClient({ pluginId: "de.hivegrid.test", window: frameWindow });
|
||||
expect(client.channelId).toBe("default-doc-channel");
|
||||
client.destroy();
|
||||
});
|
||||
|
||||
test("throws on a missing channel when the default document has no matching meta tag", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
vi.stubGlobal("document", { querySelector: () => null });
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", window: frameWindow })).toThrow(
|
||||
"Missing plugin settings channel"
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores a default document without a querySelector and throws on the missing channel", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
vi.stubGlobal("document", {});
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", window: frameWindow })).toThrow(
|
||||
"Missing plugin settings channel"
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores an absent default document and throws on the missing channel", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
vi.stubGlobal("document", undefined);
|
||||
expect(() => createPluginSettingsClient({ pluginId: "de.hivegrid.test", window: frameWindow })).toThrow(
|
||||
"Missing plugin settings channel"
|
||||
);
|
||||
});
|
||||
|
||||
test("throws when the channel meta tag is present but empty", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
expect(() =>
|
||||
createPluginSettingsClient({
|
||||
pluginId: "de.hivegrid.test",
|
||||
window: frameWindow,
|
||||
document: { querySelector: () => ({ getAttribute: () => null }) },
|
||||
})
|
||||
).toThrow("Missing plugin settings channel");
|
||||
});
|
||||
|
||||
test("throws when the channel meta tag is absent", () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
expect(() =>
|
||||
createPluginSettingsClient({
|
||||
pluginId: "de.hivegrid.test",
|
||||
window: frameWindow,
|
||||
document: { querySelector: () => null },
|
||||
})
|
||||
).toThrow("Missing plugin settings channel");
|
||||
});
|
||||
|
||||
test("generates sequential request ids when none are provided", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
timeoutMs: 0,
|
||||
window: frameWindow,
|
||||
});
|
||||
|
||||
const first = client.get("a");
|
||||
const second = client.set("b", 7);
|
||||
|
||||
const ids = frameWindow.posted.map((entry) => (entry.message as { requestId?: string }).requestId);
|
||||
expect(ids).toEqual(["plugin-settings-1", "plugin-settings-2"]);
|
||||
|
||||
for (const [requestId, key, value] of [
|
||||
["plugin-settings-1", "a", 1],
|
||||
["plugin-settings-2", "b", 7],
|
||||
] as const) {
|
||||
frameWindow.emit({
|
||||
source: frameWindow.parent,
|
||||
data: {
|
||||
type: "plugin.settings.result",
|
||||
version: PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION,
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
requestId,
|
||||
ok: true,
|
||||
key,
|
||||
value,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await expect(first).resolves.toBe(1);
|
||||
await expect(second).resolves.toBe(7);
|
||||
client.destroy();
|
||||
});
|
||||
|
||||
test("destroy rejects pending requests and clears their active timeouts", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
timeoutMs: 60_000,
|
||||
window: frameWindow,
|
||||
});
|
||||
|
||||
const pending = client.get("theme", { requestId: "get-1" });
|
||||
client.destroy();
|
||||
|
||||
await expect(pending).rejects.toThrow("Plugin settings client destroyed before response: get-1");
|
||||
expect(frameWindow.listenerCount()).toBe(0);
|
||||
});
|
||||
|
||||
test("destroy rejects pending requests that were created without an active timeout", async () => {
|
||||
const frameWindow = makeSettingsFrameWindow();
|
||||
const client = createPluginSettingsClient({
|
||||
pluginId: "de.hivegrid.test",
|
||||
channelId: "channel-1",
|
||||
timeoutMs: 0,
|
||||
window: frameWindow,
|
||||
});
|
||||
|
||||
const pending = client.set("theme", "dark", { requestId: "set-1" });
|
||||
client.destroy();
|
||||
|
||||
await expect(pending).rejects.toThrow("Plugin settings client destroyed before response: set-1");
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @toolctrl/plugin-sdk — Phase 06 Task #21 foundation.
|
||||
* @hivegrid/plugin-sdk — Phase 06 Task #21 foundation.
|
||||
*
|
||||
* Type definitions plugin authors `import` against. The package ships
|
||||
* type-only declarations in this foundation step; the AssemblyScript /
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Authoring shape:
|
||||
*
|
||||
* import type { HookHandler, PluginContext } from "@toolctrl/plugin-sdk";
|
||||
* import type { HookHandler, PluginContext } from "@hivegrid/plugin-sdk";
|
||||
*
|
||||
* export const handleHello: HookHandler<{ name: string }, { greeting: string }> = (
|
||||
* input,
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
export const PLUGIN_SDK_PACKAGE_VERSION = "0.0.0";
|
||||
export const PLUGIN_PAYLOAD_ABI_VERSION = 1;
|
||||
export const PLUGIN_PAYLOAD_ABI_IMPORTS = ["env.toolctrl_payload_len", "env.toolctrl_payload_byte"] as const;
|
||||
export const PLUGIN_PAYLOAD_ABI_IMPORTS = ["env.hivegrid_payload_len", "env.hivegrid_payload_byte"] as const;
|
||||
export const PLUGIN_SETTINGS_FRAME_PROTOCOL_VERSION = 1;
|
||||
export const PLUGIN_SETTINGS_FRAME_CHANNEL_META_NAME = "plugin-settings-channel";
|
||||
|
||||
/**
|
||||
* Capability names a host exposes to a plugin — mirrors the closed enum
|
||||
* in `@toolctrl/plugin-runtime`. Kept duplicated here so plugin authors
|
||||
* in `@hivegrid/plugin-runtime`. Kept duplicated here so plugin authors
|
||||
* don't need to install the runtime package as a build-time dep.
|
||||
*/
|
||||
export type PluginCapabilityName =
|
||||
@@ -44,7 +44,7 @@ export type PluginCapabilityName =
|
||||
/**
|
||||
* Foundation hook names the host can emit. Mirrors the runtime hook
|
||||
* registry so plugin authors can type their handlers without importing
|
||||
* `@toolctrl/plugin-runtime`.
|
||||
* `@hivegrid/plugin-runtime`.
|
||||
*/
|
||||
export type PluginHookName =
|
||||
| "tenant.created"
|
||||
|
||||
Reference in new issue
Block a user