VDL Plugin SDK

assertValidIrForEvents

Import from @varavel/vdl-plugin-sdk/utils/events.

function assertValidIrForEvents(ir): ValidatedEvent[];

Asserts that event IR structures follow VPP-4 conventions.

This helper validates @event types in one fail-fast pass and returns resolved events with placeholder metadata for code generation.

Validation covers annotation shape, object payloads, placeholder syntax, top-level field existence, primitive field types and first-appearance parameter order. Every violation throws PluginError.

Parameters

ParameterTypeDescription
irIrSchemaFully resolved VDL IR schema to validate.

Returns

ValidatedEvent[]

Validated events with placeholder metadata, sorted by name.

Example

import { definePlugin } from "@varavel/vdl-plugin-sdk";
import { assertValidIrForEvents } from "@varavel/vdl-plugin-sdk/utils/events";

export const generate = definePlugin((input) => {
  const events = assertValidIrForEvents(input.ir);

  return {
    files: events.map((event) => ({
      path: `${event.name}.ts`,
      content: `// ${event.subjectTemplate}`,
    })),
  };
});