fix(plugin-sdk): validate checks apiVersion and the manifest rules exactly as an install does

The SDK accepted any number as apiVersion while the host refuses anything
but a positive integer no newer than its plugin API, a false green for an
author. The manifest patterns, sets and caps now live in the host's
protocol/manifest-rules.ts, and gen-plugin-facts writes them and
PLUGIN_API_VERSION into the SDK, so check:plugin-facts covers them. One
manifest corpus is judged by both validators in a server test (the SDK may
only be stricter, case by case), and a typecheck test holds the SDK's plugin
API types to the host child's copy, which gains rawBodyBase64.
This commit is contained in:
Maurice
2026-10-10 15:20:42 +02:00
parent 15db688586
commit 81ec7dd28d
18 changed files with 949 additions and 146 deletions
+2 -1
View File
@@ -32,7 +32,8 @@ Because the package ships standalone it cannot import server code, so several fi
|---|---|---|
| `src/generated/host-facts.ts` (permissions, RPC methods, hooks, event catalog, `KNOWN_ADDONS`, the output contract `PLUGIN_ENTITY_FIELDS` / `PLUGIN_ENTITY_NESTED` / `PLUGIN_METHOD_RESULT`) | `server/src/nest/plugins/protocol/envelope.ts`, `protocol/output-contract.ts` and `server/src/addons.ts` via `server/scripts/gen-plugin-facts.ts` (**machine-written, never hand-edit**) | server `check:plugin-facts` CI gate; the entity interfaces in `src/index.ts` are type-checked against `PLUGIN_ENTITY_FIELDS` |
| `src/egress-policy.ts` (pure helpers, kept **byte-identical**) | `server/src/nest/plugins/runtime/egress-policy.ts` | `test/permissions-parity.test.ts` |
| `src/manifest.ts` (validation rules incl. the `trek` version range) | `server/src/nest/plugins/install/` | kept in sync by hand |
| `src/manifest.ts` (validation rules incl. the `trek` version range; its patterns, sets, caps and `PLUGIN_API_VERSION` come from `generated/host-facts.ts`, written from `server/src/nest/plugins/protocol/manifest-rules.ts`) | `server/src/nest/plugins/install/manifest.ts` | the verdicts: `test/fixtures/manifest-corpus.ts`, run here by `test/manifest-corpus.test.ts` and through both validators by `server/tests/unit/plugins/manifest-parity.test.ts` (the SDK may only be stricter, case by case) |
| `src/index.ts` (the plugin API types) | `server/src/nest/plugins/runtime/plugin-sdk.ts` (the child's copy) | `test/host-types.test-d.ts` (vitest typecheck mode, on inside the monorepo): plain shapes equal, ctx-carrying shapes and every ctx namespace with the same members; `test/host-types-names.test.ts` makes it list every shared name |
| `src/cli/checks/*` (registry gates) | TREK-Plugins registry repo (`scripts/validate-entry.mjs`, `check-readme.mjs`) | `test/checks-parity.test.ts` (runs the registry's real script; `TREK_PLUGINS_REPO` points at a checkout) |
| `src/zip.ts` (ZIP writer) | server `safe-extract.ts` reader | format frozen against the reader |
+85
View File
@@ -1,5 +1,6 @@
// GENERATED — do not edit by hand.
// Source: server/src/nest/plugins/protocol/envelope.ts + server/src/plugin-event-sink.ts
// + server/src/nest/plugins/protocol/manifest-rules.ts
// + server/src/nest/plugins/protocol/output-contract.ts + server/src/addons.ts
// + shared/src/plugins/plugin-poi-facts.ts
// Regenerate: node --import tsx server/scripts/gen-plugin-facts.ts
@@ -1029,3 +1030,87 @@ export const PLUGIN_METHOD_RESULT: Readonly<Record<string, string>> = {
'events.emit': 'host',
'settings.get': 'host',
};
/**
* The plugin-API version this TREK implements. A manifest's `apiVersion` must be a
* positive integer no greater than this, or the install refuses it.
*/
export const PLUGIN_API_VERSION = 1 as const;
/**
* The manifest format rules TREK's install loader enforces
* (server/src/nest/plugins/protocol/manifest-rules.ts), so `trek-plugin validate`
* refuses exactly what an install refuses.
*/
export const MANIFEST_ID_RE = /^[a-z][a-z0-9-]{2,39}$/;
export const MANIFEST_RESERVED_IDS: readonly string[] = [
'registry',
'install',
'rescan',
];
export const MANIFEST_SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
export const MANIFEST_TYPES: readonly string[] = [
'integration',
'page',
'widget',
'trip-page',
];
export const MANIFEST_ADDON_ID_RE = /^[a-z][a-z0-9_]{1,39}$/;
export const MANIFEST_HOST_RE = /^(\*\.[a-z0-9-]+(\.[a-z0-9-]+)+|[a-z0-9-]+(\.[a-z0-9-]+)*)$/i;
export const MANIFEST_WIDGET_SLOTS: readonly string[] = [
'sidebar',
'hero',
'place-detail',
'day-detail',
'reservation-detail',
];
export const MANIFEST_REPLACEABLE_TABS: readonly string[] = [
'transports',
'buchungen',
'listen',
'finanzplan',
'dateien',
'collab',
];
export const MANIFEST_TRIP_PAGE_POSITION_MAX = 50;
export const MANIFEST_ROUTE_PROFILES_MAX = 3;
export const MANIFEST_ROUTE_PROFILE_ID_RE = /^[a-z][a-z0-9-]{0,23}$/;
export const MANIFEST_CAPABILITY_NAME_RE = /^[a-zA-Z][a-zA-Z0-9._-]{0,63}$/;
export const MANIFEST_MCP_TOOLS_MAX = 8;
export const MANIFEST_TOOL_NAME_RE = /^[a-z0-9_]{1,48}$/;
export const MANIFEST_SETTING_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/;
export const MANIFEST_RESERVED_SETTING_KEYS: readonly string[] = [
'constructor',
'prototype',
'__proto__',
];
export const MANIFEST_ACTIONS_MAX = 8;
/** Every attribute a settings-field object may carry; the host silently drops anything else. */
export const SETTING_FIELD_KEYS = [
'key',
'label',
'input_type',
'placeholder',
'hint',
'required',
'secret',
'scope',
'options',
'oauth',
'default',
] as const;
/** Events a plugin notification channel may carry. Admin-scoped and in-app-only events are excluded. */
export const CHANNEL_EVENTS: string[] = [
'trip_invite',
'booking_change',
'trip_reminder',
'todo_due',
'vacay_invite',
'collection_invite',
'photos_shared',
'collab_message',
'packing_tagged',
'plugin_notification',
];
+6 -2
View File
@@ -8,8 +8,12 @@
import type { PLUGIN_ENTITY_FIELDS } from './generated/host-facts.js';
/** Bumped on any breaking change to the plugin API surface. Embed as `apiVersion` in your manifest. */
export const PLUGIN_API_VERSION = 1 as const;
/**
* Bumped on any breaking change to the plugin API surface. Embed as `apiVersion` in your
* manifest. Generated from TREK's protocol/envelope.ts, so it is the version the host
* implements, and `validate` refuses a manifest declaring a newer one.
*/
export { PLUGIN_API_VERSION } from './generated/host-facts.js';
// Core entity shapes returned by ctx reads/writes. Only `id` is guaranteed; the rest
// are the fields plugins most commonly use (typed for autocomplete), left optional.
+65 -41
View File
@@ -30,11 +30,8 @@ export interface ManifestSettingField {
}
/** Every attribute a settings-field object may carry — the host silently drops anything else.
* Mirrors `SETTING_FIELD_KEYS` in the host's install/manifest.ts (parity-tested in
* test/permissions-parity.test.ts); change both together. */
export const SETTING_FIELD_KEYS = [
'key', 'label', 'input_type', 'placeholder', 'hint', 'required', 'secret', 'scope', 'options', 'oauth', 'default',
] as const;
* Generated from the host's protocol/manifest-rules.ts (gen:plugin-facts). */
export { SETTING_FIELD_KEYS } from './generated/host-facts.js';
/**
* The `default`s a manifest declares for one settings scope, keyed by field — the
* host's effective value for any field nobody set. `trek-plugin dev` seeds `ctx.config`
@@ -129,13 +126,16 @@ export interface ValidationResult {
manifest?: NormalizedManifest;
}
const ID_RE = /^[a-z][a-z0-9-]{2,39}$/;
// The format rules (patterns, allowed sets, caps) are the host's own
// (server/src/nest/plugins/protocol/manifest-rules.ts), generated into host-facts.ts by
// gen:plugin-facts, so they cannot drift from what an install enforces.
const ID_RE = MANIFEST_ID_RE;
// Ids that would collide with admin API route segments — refused by the server's
// install loader, so surface it locally too.
const RESERVED_IDS = new Set(['registry', 'install', 'rescan']);
const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
const RESERVED_IDS: ReadonlySet<string> = new Set(MANIFEST_RESERVED_IDS);
const SEMVER_RE = MANIFEST_SEMVER_RE;
// Addon-id format (lowercase slug, underscores allowed e.g. `llm_parsing`).
const ADDON_ID_RE = /^[a-z][a-z0-9_]{1,39}$/;
const ADDON_ID_RE = MANIFEST_ADDON_ID_RE;
// The server's ADDON_IDS (server/src/addons.ts), generated into host-facts.ts by
// gen:plugin-facts so it cannot drift again (dawarich, roadtrip and tours had). Used
// so `trek-plugin validate` can WARN on an addon id TREK doesn't know, never a hard
@@ -143,30 +143,19 @@ const ADDON_ID_RE = /^[a-z][a-z0-9_]{1,39}$/;
export { KNOWN_ADDONS } from './generated/host-facts.js';
// An outbound host: exact hostname (single-label sibling or dotted FQDN) or a
// `*.`-wildcard with a multi-label suffix. No `*`, no `*.`, no whole-TLD `*.com`,
// no spaces (mirrors the server manifest validator).
const HOST_RE = /^(\*\.[a-z0-9-]+(\.[a-z0-9-]+)+|[a-z0-9-]+(\.[a-z0-9-]+)*)$/i;
const TYPES = ['integration', 'page', 'widget', 'trip-page'];
// no spaces.
const HOST_RE = MANIFEST_HOST_RE;
const TYPES = MANIFEST_TYPES;
/** Mirrors the server's settings-key rules (install/manifest.ts). */
const SETTING_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/;
const RESERVED_SETTING_KEYS = new Set(['constructor', 'prototype', '__proto__']);
/** The server's settings-key rules. */
const SETTING_KEY_RE = MANIFEST_SETTING_KEY_RE;
const RESERVED_SETTING_KEYS: ReadonlySet<string> = new Set(MANIFEST_RESERVED_SETTING_KEYS);
/**
* Events a plugin notification channel may carry (mirrors the server's
* PLUGIN_CHANNEL_EVENTS). Admin-scoped and in-app-only events are excluded.
* Events a plugin notification channel may carry (the server's PLUGIN_CHANNEL_EVENTS).
* Admin-scoped and in-app-only events are excluded.
*/
export const CHANNEL_EVENTS = [
'trip_invite',
'booking_change',
'trip_reminder',
'todo_due',
'vacay_invite',
'collection_invite',
'photos_shared',
'collab_message',
'packing_tagged',
'plugin_notification',
];
export { CHANNEL_EVENTS } from './generated/host-facts.js';
// Mirror of the server's KNOWN_PERMISSIONS (server envelope.ts) — the host hard-rejects
// anything not in this list at activation, so validate must know the full set.
//
@@ -174,7 +163,31 @@ export const CHANNEL_EVENTS = [
// in cli/ui.ts, which only supplies the grouping and hints), so a permission added here can
// never again go missing from the scaffolder — test/cli.test.ts fails until it has an entry.
export { KNOWN_PERMISSIONS } from './generated/host-facts.js';
import { KNOWN_PERMISSIONS, POI_CATEGORY_ICONS, POI_CATEGORY_LABEL_MAX, POI_CATEGORY_MAX } from './generated/host-facts.js';
import {
CHANNEL_EVENTS,
KNOWN_PERMISSIONS,
MANIFEST_ACTIONS_MAX,
MANIFEST_ADDON_ID_RE,
MANIFEST_CAPABILITY_NAME_RE,
MANIFEST_HOST_RE,
MANIFEST_ID_RE,
MANIFEST_MCP_TOOLS_MAX,
MANIFEST_REPLACEABLE_TABS,
MANIFEST_RESERVED_IDS,
MANIFEST_RESERVED_SETTING_KEYS,
MANIFEST_ROUTE_PROFILE_ID_RE,
MANIFEST_ROUTE_PROFILES_MAX,
MANIFEST_SEMVER_RE,
MANIFEST_SETTING_KEY_RE,
MANIFEST_TOOL_NAME_RE,
MANIFEST_TRIP_PAGE_POSITION_MAX,
MANIFEST_TYPES,
MANIFEST_WIDGET_SLOTS,
PLUGIN_API_VERSION,
POI_CATEGORY_ICONS,
POI_CATEGORY_LABEL_MAX,
POI_CATEGORY_MAX,
} from './generated/host-facts.js';
function isKnownPermission(p: string): boolean {
return KNOWN_PERMISSIONS.includes(p) || p.startsWith('http:outbound:');
@@ -225,7 +238,16 @@ export function validateManifest(raw: unknown): ValidationResult {
: 'missing "trek" — declare the TREK versions this plugin supports, e.g. ">=4.0.0 <5.0.0"',
);
}
if (m.apiVersion !== undefined && typeof m.apiVersion !== 'number') errors.push('apiVersion must be a number');
// The host's rule (install/manifest.ts): a positive integer, and an install refuses one
// newer than the plugin API it implements. A typeof check alone let 0, -1 and 1.5 pass
// here and fail at install.
if (m.apiVersion !== undefined) {
if (typeof m.apiVersion !== 'number' || !Number.isInteger(m.apiVersion) || m.apiVersion < 1) {
errors.push('apiVersion must be a positive integer');
} else if (m.apiVersion > PLUGIN_API_VERSION) {
errors.push(`apiVersion ${m.apiVersion} is newer than the plugin API TREK implements (v${PLUGIN_API_VERSION})`);
}
}
if (m.nativeModules === true) errors.push('native modules are not allowed (v1)');
const permissions = Array.isArray(m.permissions) ? m.permissions.map(String) : [];
@@ -270,21 +292,21 @@ export function validateManifest(raw: unknown): ValidationResult {
errors.push('capabilities.settingsUi must be a boolean');
}
const widget = capabilities?.widget;
if (widget?.slot !== undefined && widget.slot !== 'sidebar' && widget.slot !== 'hero' && widget.slot !== 'place-detail' && widget.slot !== 'day-detail' && widget.slot !== 'reservation-detail') {
if (widget?.slot !== undefined && (typeof widget.slot !== 'string' || !MANIFEST_WIDGET_SLOTS.includes(widget.slot))) {
errors.push(`widget slot must be "sidebar", "hero", "place-detail", "day-detail" or "reservation-detail", got "${String(widget.slot)}"`);
}
// Mirrors the server's REPLACEABLE_TABS — 'plan' is never replaceable.
const tripPage = capabilities?.tripPage;
if (tripPage !== undefined) {
const REPLACEABLE = ['transports', 'buchungen', 'listen', 'finanzplan', 'dateien', 'collab'];
const REPLACEABLE = MANIFEST_REPLACEABLE_TABS;
if (tripPage.replaces !== undefined) {
if (!Array.isArray(tripPage.replaces)) errors.push('capabilities.tripPage.replaces must be an array');
else for (const t of tripPage.replaces) {
if (typeof t !== 'string' || !REPLACEABLE.includes(t)) errors.push(`capabilities.tripPage.replaces: "${String(t)}" is not a replaceable tab (${REPLACEABLE.join(', ')})`);
}
}
if (tripPage.position !== undefined && (typeof tripPage.position !== 'number' || !Number.isInteger(tripPage.position) || tripPage.position < 0 || tripPage.position > 50)) {
errors.push('capabilities.tripPage.position must be an integer between 0 and 50');
if (tripPage.position !== undefined && (typeof tripPage.position !== 'number' || !Number.isInteger(tripPage.position) || tripPage.position < 0 || tripPage.position > MANIFEST_TRIP_PAGE_POSITION_MAX)) {
errors.push(`capabilities.tripPage.position must be an integer between 0 and ${MANIFEST_TRIP_PAGE_POSITION_MAX}`);
}
}
// Mirrors the server's PLUGIN_CHANNEL_EVENTS. Admin-scoped events (version_available)
@@ -319,13 +341,15 @@ export function validateManifest(raw: unknown): ValidationResult {
}
if (!Array.isArray(routeProfiles)) errors.push('capabilities.routeProfiles must be an array');
else {
if (routeProfiles.length > 3) errors.push('capabilities.routeProfiles: at most 3 profiles');
if (routeProfiles.length > MANIFEST_ROUTE_PROFILES_MAX) {
errors.push(`capabilities.routeProfiles: at most ${MANIFEST_ROUTE_PROFILES_MAX} profiles`);
}
const seen = new Set<string>();
normalizedRouteProfiles = [];
for (const v of routeProfiles) {
const p = (v && typeof v === 'object' ? v : {}) as { id?: unknown; label?: unknown; icon?: unknown };
const id = typeof p.id === 'string' ? p.id : '';
if (!/^[a-z][a-z0-9-]{0,23}$/.test(id)) errors.push('capabilities.routeProfiles: id must be lowercase [a-z][a-z0-9-], max 24 chars');
if (!MANIFEST_ROUTE_PROFILE_ID_RE.test(id)) errors.push('capabilities.routeProfiles: id must be lowercase [a-z][a-z0-9-], max 24 chars');
else if (seen.has(id)) errors.push(`capabilities.routeProfiles: duplicate id "${id}"`);
else seen.add(id);
const label = typeof p.label === 'string' ? p.label.trim() : '';
@@ -350,7 +374,7 @@ export function validateManifest(raw: unknown): ValidationResult {
}
if (!Array.isArray(mcpTools)) errors.push('capabilities.mcpTools must be an array');
else {
if (mcpTools.length > 8) errors.push('capabilities.mcpTools: at most 8 tools');
if (mcpTools.length > MANIFEST_MCP_TOOLS_MAX) errors.push(`capabilities.mcpTools: at most ${MANIFEST_MCP_TOOLS_MAX} tools`);
const seenTools = new Set<string>();
for (const v of mcpTools) {
if (!v || typeof v !== 'object' || Array.isArray(v)) {
@@ -359,7 +383,7 @@ export function validateManifest(raw: unknown): ValidationResult {
}
const t = v as Record<string, unknown>;
const name = typeof t.name === 'string' ? t.name : '';
if (!/^[a-z0-9_]{1,48}$/.test(name)) {
if (!MANIFEST_TOOL_NAME_RE.test(name)) {
errors.push('capabilities.mcpTools: name must be lowercase [a-z0-9_], max 48 chars');
continue;
}
@@ -445,7 +469,7 @@ export function validateManifest(raw: unknown): ValidationResult {
if (m.actions !== undefined) {
if (!Array.isArray(m.actions)) errors.push('actions must be an array');
else {
if (m.actions.length > 8) errors.push('at most 8 actions');
if (m.actions.length > MANIFEST_ACTIONS_MAX) errors.push(`at most ${MANIFEST_ACTIONS_MAX} actions`);
const seen = new Set<string>();
for (const a of m.actions as Array<Record<string, unknown>>) {
if (!a || typeof a !== 'object') { errors.push('each action must be an object'); continue; }
@@ -567,7 +591,7 @@ function validatePoiCategories(raw: unknown, permissions: string[], errors: stri
}
// Export/event names exposed to other plugins (dots allowed for event names).
const CAPABILITY_NAME_RE = /^[a-zA-Z][a-zA-Z0-9._-]{0,63}$/;
const CAPABILITY_NAME_RE = MANIFEST_CAPABILITY_NAME_RE;
function validateCapabilityNames(raw: unknown, field: string, errors: string[]): void {
if (raw === undefined) return;
+245
View File
@@ -0,0 +1,245 @@
/**
* One corpus of manifests, judged by both validators: the SDK's `validateManifest`
* (what `trek-plugin validate` says) and the host's `parseManifest` with
* `requireTrek` (what an install says). `test/manifest-corpus.test.ts` runs the SDK
* over it here; `server/tests/unit/plugins/manifest-parity.test.ts` runs both and
* fails on any case where they disagree with the verdicts below.
*
* The verdict that must never happen is the SDK accepting what the host refuses: a
* false green lets an author cut a release the registry then rejects. The SDK may be
* stricter than the host on purpose (a declaration the host installs but never
* uses); each such case carries `sdk` and the reason in `why`.
*
* Plain data, no imports: the server test reaches this file by a relative path.
*/
export type Verdict = 'accept' | 'reject';
export interface ManifestCase {
name: string;
manifest: Record<string, unknown>;
/** What an install answers. */
host: Verdict;
/** What `validate` answers, when it differs from the host (only ever stricter). */
sdk?: Verdict;
/** Why the SDK is stricter here. Required with `sdk`. */
why?: string;
}
const base = {
id: 'demo-plugin',
name: 'Demo',
version: '1.0.0',
type: 'integration',
trek: '>=4.0.0 <5.0.0',
};
const tool = (name: string) => ({ name, description: 'Looks something up.' });
const poi = { id: 'trails', label: 'Trails', icon: 'Footprints', color: '#22aa66' };
export const MANIFEST_CORPUS: ManifestCase[] = [
{ name: 'the minimal manifest', manifest: { ...base }, host: 'accept' },
{ name: 'not an object', manifest: null as unknown as Record<string, unknown>, host: 'reject' },
// apiVersion: a positive integer no newer than the host's plugin API
{ name: 'apiVersion 1', manifest: { ...base, apiVersion: 1 }, host: 'accept' },
{ name: 'apiVersion 0', manifest: { ...base, apiVersion: 0 }, host: 'reject' },
{ name: 'apiVersion -1', manifest: { ...base, apiVersion: -1 }, host: 'reject' },
{ name: 'apiVersion 1.5', manifest: { ...base, apiVersion: 1.5 }, host: 'reject' },
{ name: 'apiVersion as a string', manifest: { ...base, apiVersion: '1' }, host: 'reject' },
{ name: 'apiVersion null', manifest: { ...base, apiVersion: null }, host: 'reject' },
{ name: 'apiVersion newer than the host', manifest: { ...base, apiVersion: 2 }, host: 'reject' },
// id, version, type, trek
{ name: 'id too short', manifest: { ...base, id: 'ab' }, host: 'reject' },
{ name: 'id with capitals', manifest: { ...base, id: 'Demo-plugin' }, host: 'reject' },
{ name: 'reserved id', manifest: { ...base, id: 'registry' }, host: 'reject' },
{ name: 'missing name', manifest: { ...base, name: '' }, host: 'reject' },
{ name: 'version without patch', manifest: { ...base, version: '1.0' }, host: 'reject' },
{ name: 'prerelease version', manifest: { ...base, version: '1.0.0-beta.1' }, host: 'accept' },
{ name: 'version with build metadata', manifest: { ...base, version: '1.0.0+build' }, host: 'reject' },
{ name: 'unknown type', manifest: { ...base, type: 'theme' }, host: 'reject' },
{ name: 'trip-page type', manifest: { ...base, type: 'trip-page' }, host: 'accept' },
{ name: 'missing trek range', manifest: { ...base, trek: undefined }, host: 'reject' },
{ name: 'unsatisfiable trek range', manifest: { ...base, trek: '>=5.0.0 <4.0.0' }, host: 'reject' },
{ name: 'trek range that is not semver', manifest: { ...base, trek: 'latest' }, host: 'reject' },
{ name: 'native modules', manifest: { ...base, nativeModules: true }, host: 'reject' },
// permissions and egress
{ name: 'a known permission', manifest: { ...base, permissions: ['db:read:trips'] }, host: 'accept' },
{ name: 'an unknown permission', manifest: { ...base, permissions: ['db:read:everything'] }, host: 'reject' },
{
name: 'outbound host with its egress',
manifest: { ...base, permissions: ['http:outbound:api.example.com'], egress: ['api.example.com'] },
host: 'accept',
},
{
name: 'outbound to a whole TLD',
manifest: { ...base, permissions: ['http:outbound:*.com'], egress: ['*.com'] },
host: 'reject',
},
{ name: 'outbound without egress', manifest: { ...base, permissions: ['http:outbound'] }, host: 'reject' },
{
name: 'operator egress without hosts',
manifest: { ...base, permissions: ['http:outbound'], operatorEgress: true },
host: 'accept',
},
{ name: 'operator egress not a boolean', manifest: { ...base, operatorEgress: 'yes' }, host: 'reject' },
{ name: 'operator egress without outbound', manifest: { ...base, operatorEgress: true }, host: 'reject' },
{
name: 'bare wildcard egress',
manifest: { ...base, permissions: ['http:outbound'], egress: ['*'] },
host: 'reject',
},
{
name: 'egress host with a scheme',
manifest: { ...base, permissions: ['http:outbound'], egress: ['https://api.example.com'] },
host: 'reject',
},
// capabilities
{ name: 'hero widget', manifest: { ...base, type: 'widget', capabilities: { widget: { slot: 'hero' } } }, host: 'accept' },
{ name: 'unknown widget slot', manifest: { ...base, capabilities: { widget: { slot: 'footer' } } }, host: 'reject' },
{ name: 'trip page replacing collab', manifest: { ...base, capabilities: { tripPage: { replaces: ['collab'] } } }, host: 'accept' },
{ name: 'trip page replacing the plan', manifest: { ...base, capabilities: { tripPage: { replaces: ['plan'] } } }, host: 'reject' },
{ name: 'trip page at position 50', manifest: { ...base, capabilities: { tripPage: { position: 50 } } }, host: 'accept' },
{ name: 'trip page at position 51', manifest: { ...base, capabilities: { tripPage: { position: 51 } } }, host: 'reject' },
{ name: 'settingsUi not a boolean', manifest: { ...base, capabilities: { settingsUi: 'yes' } }, host: 'reject' },
{
name: 'route profiles with their grant',
manifest: { ...base, permissions: ['hook:route-provider'], capabilities: { routeProfiles: [{ id: 'bike', label: 'Bike' }] } },
host: 'accept',
},
{
name: 'four route profiles',
manifest: {
...base,
permissions: ['hook:route-provider'],
capabilities: { routeProfiles: ['a', 'b', 'c', 'd'].map((id) => ({ id, label: id })) },
},
host: 'reject',
},
{
name: 'route profile id with capitals',
manifest: { ...base, permissions: ['hook:route-provider'], capabilities: { routeProfiles: [{ id: 'Bike', label: 'Bike' }] } },
host: 'reject',
},
{
name: 'route profiles without their grant',
manifest: { ...base, capabilities: { routeProfiles: [{ id: 'bike', label: 'Bike' }] } },
host: 'accept',
sdk: 'reject',
why: 'the host installs the declaration but never offers the profiles without hook:route-provider',
},
{
name: 'notification channel with its grant',
manifest: {
...base,
permissions: ['hook:notification-channel'],
capabilities: { notificationChannel: { events: ['trip_invite'] } },
},
host: 'accept',
},
{
name: 'notification channel for an admin-only event',
manifest: {
...base,
permissions: ['hook:notification-channel'],
capabilities: { notificationChannel: { events: ['version_available'] } },
},
host: 'reject',
},
{
name: 'notification channel without its grant',
manifest: { ...base, capabilities: { notificationChannel: { events: ['trip_invite'] } } },
host: 'accept',
sdk: 'reject',
why: 'the host installs the declaration but never delivers to it without hook:notification-channel',
},
{
name: 'MCP tools with their grant',
manifest: { ...base, permissions: ['mcp:tools'], capabilities: { mcpTools: [tool('lookup')] } },
host: 'accept',
},
{
name: 'MCP tools without their grant',
manifest: { ...base, capabilities: { mcpTools: [tool('lookup')] } },
host: 'reject',
},
{
name: 'MCP tool name with a dash',
manifest: { ...base, permissions: ['mcp:tools'], capabilities: { mcpTools: [tool('look-up')] } },
host: 'reject',
},
{
name: 'nine MCP tools',
manifest: {
...base,
permissions: ['mcp:tools'],
capabilities: { mcpTools: Array.from({ length: 9 }, (_, i) => tool(`tool_${i}`)) },
},
host: 'reject',
},
{
name: 'MCP tool without a description',
manifest: { ...base, permissions: ['mcp:tools'], capabilities: { mcpTools: [{ name: 'lookup' }] } },
host: 'reject',
},
{
name: 'POI categories with their grant',
manifest: { ...base, permissions: ['hook:poi-category-provider'], capabilities: { poiCategories: [poi] } },
host: 'accept',
},
{
name: 'POI category with an unknown icon',
manifest: {
...base,
permissions: ['hook:poi-category-provider'],
capabilities: { poiCategories: [{ ...poi, icon: 'NotAnIcon' }] },
},
host: 'reject',
},
{
name: 'POI categories without their grant',
manifest: { ...base, capabilities: { poiCategories: [poi] } },
host: 'accept',
sdk: 'reject',
why: 'the host installs the declaration but never shows the chips without hook:poi-category-provider',
},
{ name: 'provided names', manifest: { ...base, capabilities: { provides: ['rate.updated'] } }, host: 'accept' },
{ name: 'provided name starting with a digit', manifest: { ...base, capabilities: { provides: ['1rate'] } }, host: 'reject' },
// settings and actions
{ name: 'a dotted settings key', manifest: { ...base, settings: [{ key: 'api.key' }] }, host: 'accept' },
{ name: 'a prototype settings key', manifest: { ...base, settings: [{ key: '__proto__' }] }, host: 'reject' },
{ name: 'settings options not a list', manifest: { ...base, settings: [{ key: 'mode', options: 'a,b' }] }, host: 'reject' },
{ name: 'settings option without a value', manifest: { ...base, settings: [{ key: 'mode', options: [{ value: '' }] }] }, host: 'reject' },
{ name: 'string settings options', manifest: { ...base, settings: [{ key: 'mode', options: ['a', 'b'] }] }, host: 'accept' },
{ name: 'an action', manifest: { ...base, actions: [{ key: 'test', label: 'Test' }] }, host: 'accept' },
{
name: 'nine actions',
manifest: { ...base, actions: Array.from({ length: 9 }, (_, i) => ({ key: `a${i}` })) },
host: 'reject',
},
{ name: 'duplicate actions', manifest: { ...base, actions: [{ key: 'test' }, { key: 'test' }] }, host: 'reject' },
{ name: 'action with an unknown scope', manifest: { ...base, actions: [{ key: 'test', scope: 'admin' }] }, host: 'reject' },
// dependencies
{ name: 'a required addon', manifest: { ...base, requiredAddons: ['llm_parsing'] }, host: 'accept' },
{ name: 'a malformed addon id', manifest: { ...base, requiredAddons: ['LLM'] }, host: 'reject' },
{
name: 'a plugin dependency',
manifest: { ...base, pluginDependencies: [{ id: 'other-plugin', version: '^1.0.0' }] },
host: 'accept',
},
{
name: 'a dependency on itself',
manifest: { ...base, pluginDependencies: [{ id: 'demo-plugin', version: '^1.0.0' }] },
host: 'reject',
},
{
name: 'a dependency with a junk range',
manifest: { ...base, pluginDependencies: [{ id: 'other-plugin', version: 'whenever' }] },
host: 'reject',
},
];
+32
View File
@@ -0,0 +1,32 @@
/**
* test/host-types.test-d.ts holds the SDK's plugin API to the host child's copy, name by
* name. This makes sure it names every one: an export both files declare and the type
* test does not list would drift unchecked. Skips outside the monorepo, like the other
* host parity tests.
*/
import { describe, expect, it } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const here = path.dirname(fileURLToPath(import.meta.url));
const hostFile = path.resolve(here, '../../server/src/nest/plugins/runtime/plugin-sdk.ts');
const sdkFile = path.resolve(here, '../src/index.ts');
const typeTest = path.resolve(here, 'host-types.test-d.ts');
const exportsOf = (file: string): Set<string> =>
new Set(
[...fs.readFileSync(file, 'utf8').matchAll(/^export (?:declare )?(?:interface|type|const|function|class|enum) (\w+)/gm)].map(
(m) => m[1],
),
);
describe.skipIf(!fs.existsSync(hostFile))('host type parity covers every shared name', () => {
it('lists each type both sides export', () => {
const host = exportsOf(hostFile);
const shared = [...exportsOf(sdkFile)].filter((name) => host.has(name) && name !== 'definePlugin').sort();
const listed = new Set([...fs.readFileSync(typeTest, 'utf8').matchAll(/expectTypeOf<(?:keyof )?Sdk\.(\w+)>/g)].map((m) => m[1]));
expect(shared.length).toBeGreaterThan(40);
expect(shared.filter((name) => !listed.has(name))).toEqual([]);
});
});
+116
View File
@@ -0,0 +1,116 @@
/**
* Type parity between the SDK's plugin API (src/index.ts) and the copy the host's plugin
* child runs on (server/src/nest/plugins/runtime/plugin-sdk.ts). Both declare the same
* names; vitest's typecheck mode compiles this file (vitest.config.ts enables it only
* inside the monorepo, where the host file exists).
*
* Two kinds of name:
* - the plain shapes (requests, results, contributions) are the same type on both sides;
* - the shapes that carry a `ctx` are refined in the SDK: its PluginContext types the
* entity results (`Trip`, `Place`, …) and some requests where the host's child says
* `unknown`, so those are held to the same members (a method or field on one side
* only is the drift this catches, as `rawBodyBase64` was), not to one type.
*
* test/host-types-names.test.ts checks every name both files export is listed here.
*/
import { expectTypeOf, test } from 'vitest';
import type * as Sdk from '../src/index.js';
import type * as Host from '../../server/src/nest/plugins/runtime/plugin-sdk.js';
test('the plain shapes are one type on both sides', () => {
expectTypeOf<Sdk.PluginResponse>().toEqualTypeOf<Host.PluginResponse>();
expectTypeOf<Sdk.Photo>().toEqualTypeOf<Host.Photo>();
expectTypeOf<Sdk.NotificationMessage>().toEqualTypeOf<Host.NotificationMessage>();
expectTypeOf<Sdk.PluginActionResult>().toEqualTypeOf<Host.PluginActionResult>();
expectTypeOf<Sdk.CalendarEvent>().toEqualTypeOf<Host.CalendarEvent>();
expectTypeOf<Sdk.PlaceDetailItem>().toEqualTypeOf<Host.PlaceDetailItem>();
expectTypeOf<Sdk.SearchResultPlace>().toEqualTypeOf<Host.SearchResultPlace>();
expectTypeOf<Sdk.SearchRequest>().toEqualTypeOf<Host.SearchRequest>();
expectTypeOf<Sdk.TripWarning>().toEqualTypeOf<Host.TripWarning>();
expectTypeOf<Sdk.ContributionTone>().toEqualTypeOf<Host.ContributionTone>();
expectTypeOf<Sdk.TableColumnContribution>().toEqualTypeOf<Host.TableColumnContribution>();
expectTypeOf<Sdk.TableActionContribution>().toEqualTypeOf<Host.TableActionContribution>();
expectTypeOf<Sdk.TableContribution>().toEqualTypeOf<Host.TableContribution>();
expectTypeOf<Sdk.MapMarkerContribution>().toEqualTypeOf<Host.MapMarkerContribution>();
expectTypeOf<Sdk.MapLayerFeature>().toEqualTypeOf<Host.MapLayerFeature>();
expectTypeOf<Sdk.MapLayerContribution>().toEqualTypeOf<Host.MapLayerContribution>();
expectTypeOf<Sdk.RouteWaypoint>().toEqualTypeOf<Host.RouteWaypoint>();
expectTypeOf<Sdk.RouteRequest>().toEqualTypeOf<Host.RouteRequest>();
expectTypeOf<Sdk.RouteLeg>().toEqualTypeOf<Host.RouteLeg>();
expectTypeOf<Sdk.RouteViaPoint>().toEqualTypeOf<Host.RouteViaPoint>();
expectTypeOf<Sdk.RouteProviderResult>().toEqualTypeOf<Host.RouteProviderResult>();
expectTypeOf<Sdk.DayScheduleContribution>().toEqualTypeOf<Host.DayScheduleContribution>();
expectTypeOf<Sdk.DayTintContribution>().toEqualTypeOf<Host.DayTintContribution>();
expectTypeOf<Sdk.PdfSection>().toEqualTypeOf<Host.PdfSection>();
expectTypeOf<Sdk.AtlasLayerCountry>().toEqualTypeOf<Host.AtlasLayerCountry>();
expectTypeOf<Sdk.AtlasLayer>().toEqualTypeOf<Host.AtlasLayer>();
expectTypeOf<Sdk.TripCardContribution>().toEqualTypeOf<Host.TripCardContribution>();
expectTypeOf<Sdk.JournalEntryRow>().toEqualTypeOf<Host.JournalEntryRow>();
expectTypeOf<Sdk.PluginRequest>().toEqualTypeOf<Host.PluginRequest>();
});
test('the shapes that carry a ctx have the same members on both sides', () => {
expectTypeOf<keyof Sdk.PluginContext>().toEqualTypeOf<keyof Host.PluginContext>();
expectTypeOf<keyof Sdk.PluginRoute>().toEqualTypeOf<keyof Host.PluginRoute>();
expectTypeOf<keyof Sdk.PluginJob>().toEqualTypeOf<keyof Host.PluginJob>();
expectTypeOf<keyof Sdk.PhotoProvider>().toEqualTypeOf<keyof Host.PhotoProvider>();
expectTypeOf<keyof Sdk.NotificationChannel>().toEqualTypeOf<keyof Host.NotificationChannel>();
expectTypeOf<keyof Sdk.CalendarSource>().toEqualTypeOf<keyof Host.CalendarSource>();
expectTypeOf<keyof Sdk.PlaceDetailProvider>().toEqualTypeOf<keyof Host.PlaceDetailProvider>();
expectTypeOf<keyof Sdk.SearchProvider>().toEqualTypeOf<keyof Host.SearchProvider>();
expectTypeOf<keyof Sdk.PoiCategoryProvider>().toEqualTypeOf<keyof Host.PoiCategoryProvider>();
expectTypeOf<keyof Sdk.WarningProvider>().toEqualTypeOf<keyof Host.WarningProvider>();
expectTypeOf<keyof Sdk.TableContributor>().toEqualTypeOf<keyof Host.TableContributor>();
expectTypeOf<keyof Sdk.MapMarkerProvider>().toEqualTypeOf<keyof Host.MapMarkerProvider>();
expectTypeOf<keyof Sdk.MapLayerProvider>().toEqualTypeOf<keyof Host.MapLayerProvider>();
expectTypeOf<keyof Sdk.RouteProvider>().toEqualTypeOf<keyof Host.RouteProvider>();
expectTypeOf<keyof Sdk.DayScheduleProvider>().toEqualTypeOf<keyof Host.DayScheduleProvider>();
expectTypeOf<keyof Sdk.DayTintProvider>().toEqualTypeOf<keyof Host.DayTintProvider>();
expectTypeOf<keyof Sdk.PdfSectionProvider>().toEqualTypeOf<keyof Host.PdfSectionProvider>();
expectTypeOf<keyof Sdk.AtlasLayerProvider>().toEqualTypeOf<keyof Host.AtlasLayerProvider>();
expectTypeOf<keyof Sdk.TripCardProvider>().toEqualTypeOf<keyof Host.TripCardProvider>();
expectTypeOf<keyof Sdk.JournalEntryProvider>().toEqualTypeOf<keyof Host.JournalEntryProvider>();
expectTypeOf<keyof Sdk.PluginEventSubscription>().toEqualTypeOf<keyof Host.PluginEventSubscription>();
expectTypeOf<keyof Sdk.PluginExport>().toEqualTypeOf<keyof Host.PluginExport>();
expectTypeOf<keyof Sdk.PluginSubscription>().toEqualTypeOf<keyof Host.PluginSubscription>();
expectTypeOf<keyof Sdk.McpToolProvider>().toEqualTypeOf<keyof Host.McpToolProvider>();
expectTypeOf<keyof Sdk.PluginDefinition>().toEqualTypeOf<keyof Host.PluginDefinition>();
});
test('every ctx namespace offers the same methods on both sides', () => {
type Members<T> = T extends (...args: never[]) => unknown ? never : keyof T;
expectTypeOf<Members<Sdk.PluginContext['id']>>().toEqualTypeOf<Members<Host.PluginContext['id']>>();
expectTypeOf<Members<Sdk.PluginContext['config']>>().toEqualTypeOf<Members<Host.PluginContext['config']>>();
expectTypeOf<Members<Sdk.PluginContext['settings']>>().toEqualTypeOf<Members<Host.PluginContext['settings']>>();
expectTypeOf<Members<Sdk.PluginContext['db']>>().toEqualTypeOf<Members<Host.PluginContext['db']>>();
expectTypeOf<Members<Sdk.PluginContext['trips']>>().toEqualTypeOf<Members<Host.PluginContext['trips']>>();
expectTypeOf<Members<Sdk.PluginContext['reservations']>>().toEqualTypeOf<Members<Host.PluginContext['reservations']>>();
expectTypeOf<Members<Sdk.PluginContext['accommodations']>>().toEqualTypeOf<Members<Host.PluginContext['accommodations']>>();
expectTypeOf<Members<Sdk.PluginContext['packing']>>().toEqualTypeOf<Members<Host.PluginContext['packing']>>();
expectTypeOf<Members<Sdk.PluginContext['files']>>().toEqualTypeOf<Members<Host.PluginContext['files']>>();
expectTypeOf<Members<Sdk.PluginContext['collab']>>().toEqualTypeOf<Members<Host.PluginContext['collab']>>();
expectTypeOf<Members<Sdk.PluginContext['notify']>>().toEqualTypeOf<Members<Host.PluginContext['notify']>>();
expectTypeOf<Members<Sdk.PluginContext['ai']>>().toEqualTypeOf<Members<Host.PluginContext['ai']>>();
expectTypeOf<Members<Sdk.PluginContext['oauth']>>().toEqualTypeOf<Members<Host.PluginContext['oauth']>>();
expectTypeOf<Members<Sdk.PluginContext['scheduler']>>().toEqualTypeOf<Members<Host.PluginContext['scheduler']>>();
expectTypeOf<Members<Sdk.PluginContext['weather']>>().toEqualTypeOf<Members<Host.PluginContext['weather']>>();
expectTypeOf<Members<Sdk.PluginContext['rates']>>().toEqualTypeOf<Members<Host.PluginContext['rates']>>();
expectTypeOf<Members<Sdk.PluginContext['categories']>>().toEqualTypeOf<Members<Host.PluginContext['categories']>>();
expectTypeOf<Members<Sdk.PluginContext['tags']>>().toEqualTypeOf<Members<Host.PluginContext['tags']>>();
expectTypeOf<Members<Sdk.PluginContext['todos']>>().toEqualTypeOf<Members<Host.PluginContext['todos']>>();
expectTypeOf<Members<Sdk.PluginContext['journal']>>().toEqualTypeOf<Members<Host.PluginContext['journal']>>();
expectTypeOf<Members<Sdk.PluginContext['atlas']>>().toEqualTypeOf<Members<Host.PluginContext['atlas']>>();
expectTypeOf<Members<Sdk.PluginContext['vacay']>>().toEqualTypeOf<Members<Host.PluginContext['vacay']>>();
expectTypeOf<Members<Sdk.PluginContext['collections']>>().toEqualTypeOf<Members<Host.PluginContext['collections']>>();
expectTypeOf<Members<Sdk.PluginContext['daynotes']>>().toEqualTypeOf<Members<Host.PluginContext['daynotes']>>();
expectTypeOf<Members<Sdk.PluginContext['costs']>>().toEqualTypeOf<Members<Host.PluginContext['costs']>>();
expectTypeOf<Members<Sdk.PluginContext['places']>>().toEqualTypeOf<Members<Host.PluginContext['places']>>();
expectTypeOf<Members<Sdk.PluginContext['days']>>().toEqualTypeOf<Members<Host.PluginContext['days']>>();
expectTypeOf<Members<Sdk.PluginContext['itinerary']>>().toEqualTypeOf<Members<Host.PluginContext['itinerary']>>();
expectTypeOf<Members<Sdk.PluginContext['meta']>>().toEqualTypeOf<Members<Host.PluginContext['meta']>>();
expectTypeOf<Members<Sdk.PluginContext['users']>>().toEqualTypeOf<Members<Host.PluginContext['users']>>();
expectTypeOf<Members<Sdk.PluginContext['ws']>>().toEqualTypeOf<Members<Host.PluginContext['ws']>>();
expectTypeOf<Members<Sdk.PluginContext['log']>>().toEqualTypeOf<Members<Host.PluginContext['log']>>();
expectTypeOf<Members<Sdk.PluginContext['plugins']>>().toEqualTypeOf<Members<Host.PluginContext['plugins']>>();
expectTypeOf<Members<Sdk.PluginContext['events']>>().toEqualTypeOf<Members<Host.PluginContext['events']>>();
});
+45
View File
@@ -0,0 +1,45 @@
/**
* The SDK half of the manifest parity corpus (test/fixtures/manifest-corpus.ts). It
* runs standalone; the server's manifest-parity test runs the same corpus through
* the host's loader as well, so the two cannot drift apart unseen.
*/
import { describe, expect, it } from 'vitest';
import { validateManifest } from '../src/manifest.js';
import { PLUGIN_API_VERSION } from '../src/index.js';
import { MANIFEST_CORPUS } from './fixtures/manifest-corpus.js';
describe('manifest corpus — validate', () => {
it.each(MANIFEST_CORPUS)('$name', ({ manifest, host, sdk }) => {
const result = validateManifest(manifest);
expect(result.ok ? 'accept' : 'reject', result.errors.join('; ')).toBe(sdk ?? host);
});
it('marks every stricter-than-host case as one, with its reason', () => {
for (const c of MANIFEST_CORPUS) {
if (c.sdk === undefined) continue;
expect(c.sdk, `${c.name}: the SDK may only ever be stricter than the host`).toBe('reject');
expect(c.host, c.name).toBe('accept');
expect(c.why, `${c.name} needs a reason`).toBeTruthy();
}
});
});
describe('apiVersion', () => {
const base = { id: 'demo-plugin', name: 'Demo', version: '1.0.0', type: 'integration', trek: '>=4.0.0 <5.0.0' };
it.each([0, -1, 1.5, '1', null])('refuses %p, which is not a positive integer', (apiVersion) => {
expect(validateManifest({ ...base, apiVersion }).errors).toContain('apiVersion must be a positive integer');
});
it('refuses a version newer than the plugin API TREK implements', () => {
const next = PLUGIN_API_VERSION + 1;
expect(validateManifest({ ...base, apiVersion: next }).errors).toEqual([
`apiVersion ${next} is newer than the plugin API TREK implements (v${PLUGIN_API_VERSION})`,
]);
});
it('keeps an accepted version and defaults a missing one to 1', () => {
expect(validateManifest({ ...base, apiVersion: PLUGIN_API_VERSION }).manifest?.apiVersion).toBe(PLUGIN_API_VERSION);
expect(validateManifest(base).manifest?.apiVersion).toBe(1);
});
});
+5 -3
View File
@@ -99,13 +99,15 @@ describe.skipIf(!inMonorepo)('core event catalog', () => {
});
describe.skipIf(!inMonorepo)('settings-field attribute parity', () => {
it("SETTING_FIELD_KEYS matches the host's install/manifest.ts", () => {
it("SETTING_FIELD_KEYS matches the host's protocol/manifest-rules.ts", () => {
// The `manifest.settings-known-keys` check warns on an attribute the host would
// silently drop, so the list must be the host's — compared whole, both ways round.
const theirsFile = path.resolve(here, '../../server/src/nest/plugins/install/manifest.ts');
// It is generated into host-facts.ts now (check:plugin-facts); this reads the source
// as well so a standalone run of this suite catches a stale artefact.
const theirsFile = path.resolve(here, '../../server/src/nest/plugins/protocol/manifest-rules.ts');
const src = fs.readFileSync(theirsFile, 'utf8');
const block = src.match(/export const SETTING_FIELD_KEYS = \[([\s\S]*?)\] as const/);
expect(block, 'SETTING_FIELD_KEYS not found in install/manifest.ts').toBeTruthy();
expect(block, 'SETTING_FIELD_KEYS not found in protocol/manifest-rules.ts').toBeTruthy();
const theirs = [...block![1].matchAll(/'([^']+)'/g)].map((m) => m[1]);
expect([...SETTING_FIELD_KEYS]).toEqual(theirs);
});
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
},
"include": ["src", "test/**/*.test-d.ts"],
"exclude": ["dist", "node_modules"]
}
+11
View File
@@ -1,7 +1,18 @@
import fs from 'node:fs';
import { defineConfig } from 'vitest/config';
// The host's copy of the plugin API, which test/host-types.test-d.ts compares the SDK's
// types against. It exists only inside the TREK monorepo; a standalone checkout of the
// published package has no server, so the type parity check is off there.
const hostTypes = new URL('../server/src/nest/plugins/runtime/plugin-sdk.ts', import.meta.url);
export default defineConfig({
test: {
typecheck: {
enabled: fs.existsSync(hostTypes),
include: ['test/**/*.test-d.ts'],
tsconfig: './tsconfig.typecheck.json',
},
coverage: {
provider: 'v8',
reporter: ['lcov', 'text'],