Skip to content

@oneplatform/plugin-sdk


@oneplatform/plugin-sdk / HookPayload

Interface: HookPayload\<S>

Defined in: packages/plugin-sdk/src/types/hooks.ts:209

The payload passed to every hook function.

Generic form: HookPayload When S is a key of HookPayloadDataMap, data is narrowed to its specific type. For all other stages data is Record.

Example

async function onBeforeIngestionReceive(
  payload: HookPayload<"before:ingestion.receive">,
  ctx: PluginContext,
): Promise<HookResult<"before:ingestion.receive">> {
  // payload.data is IngestionReceiveData — fully typed
  console.log(payload.data.rawPayload);
  return { data: payload.data };
}

Type Parameters

S

S extends HookStage = HookStage

Properties

context

context: HookContext

Defined in: packages/plugin-sdk/src/types/hooks.ts:220

Metadata about the execution context.


data

data: S extends keyof HookPayloadDataMap ? HookPayloadDataMap[S] : Record\<string, unknown>

Defined in: packages/plugin-sdk/src/types/hooks.ts:217

The data being processed at this stage. Narrowed to a specific type when S is a known stage in HookPayloadDataMap.


stage

stage: S

Defined in: packages/plugin-sdk/src/types/hooks.ts:211

The stage that triggered this hook.