---
title: Events API
description: Generated public TypeScript reference for @relkit/events.
search:
  exclude: true
sidebar:
  icon: braces
---

{/* Generated by apps/docs/scripts/generate.ts. Do not edit. */}

## Common APIs

- [defineEvent](/docs/api/events#defineevent)
- [defineEventFunction](/docs/api/events#defineeventfunction)

For configuration and examples, read [events](/docs/modules/events), [domains](/docs/modules/service/domains), [organization](/docs/modules/service/organization).

For a complete workflow, follow [react to order events](/guides/events/react-to-order-events).

## Public imports

- `@relkit/events` — 44 exports
- `@relkit/events/effect` — 39 exports

## All exported APIs

Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API's inline sample, a maintained repository usage, or the shared module walkthrough.

| API                                                                                     | Kind  | Import from             | Example                                                                |
| --------------------------------------------------------------------------------------- | ----- | ----------------------- | ---------------------------------------------------------------------- |
| [assertEventDescriptor](/docs/api/events#asserteventdescriptor)                         | Value | `@relkit/events`        | [API example](/docs/api/events#asserteventdescriptor)                  |
| [assertEventDescriptorEffect](/docs/api/events#asserteventdescriptoreffect)             | Value | `@relkit/events/effect` | [API example](/docs/api/events#asserteventdescriptoreffect)            |
| [assertOptionalTextEffect](/docs/api/events#assertoptionaltexteffect-1)                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#assertoptionaltexteffect-1)             |
| [assertVersionEffect](/docs/api/events#assertversioneffect-1)                           | Value | `@relkit/events/effect` | [API example](/docs/api/events#assertversioneffect-1)                  |
| [bindFunctionEvents](/docs/api/events#bindfunctionevents)                               | Value | `@relkit/events`        | [API example](/docs/api/events#bindfunctionevents)                     |
| [bindFunctionEventsEffect](/docs/api/events#bindfunctioneventseffect-1)                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#bindfunctioneventseffect-1)             |
| [createEventClient](/docs/api/events#createeventclient)                                 | Value | `@relkit/events`        | [API example](/docs/api/events#createeventclient)                      |
| [createEventClientEffect](/docs/api/events#createeventclienteffect)                     | Value | `@relkit/events/effect` | [API example](/docs/api/events#createeventclienteffect)                |
| [defineEvent](/docs/api/events#defineevent)                                             | Value | `@relkit/events`        | [API example](/docs/api/events#defineevent)                            |
| [defineEventEffect](/docs/api/events#defineeventeffect)                                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#defineeventeffect)                      |
| [defineEventFunction](/docs/api/events#defineeventfunction)                             | Value | `@relkit/events`        | [API example](/docs/api/events#defineeventfunction)                    |
| [defineEventFunctionEffect](/docs/api/events#defineeventfunctioneffect)                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#defineeventfunctioneffect)              |
| [DefineEventFunctionOptions](/docs/api/events#defineeventfunctionoptions-interface)     | Type  | `@relkit/events`        | [API example](/docs/api/events#defineeventfunctionoptions-interface)   |
| [DefineEventOptions](/docs/api/events#defineeventoptions-interface)                     | Type  | `@relkit/events`        | [API example](/docs/api/events#defineeventoptions-interface)           |
| [EventAttributeValue](/docs/api/functions#eventattributevalue-type-alias)               | Type  | `@relkit/events`        | [API example](/docs/api/functions#eventattributevalue-type-alias)      |
| [EventBindingError](/docs/api/events#eventbindingerror-class)                           | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventbindingerror-class)                |
| [EventClient](/docs/api/events#eventclient-interface)                                   | Type  | `@relkit/events`        | [API example](/docs/api/events#eventclient-interface)                  |
| [EventClientOptions](/docs/api/events#eventclientoptions-interface)                     | Type  | `@relkit/events`        | [API example](/docs/api/events#eventclientoptions-interface)           |
| [EventDeclaredEdge](/docs/api/events#eventdeclarededge-interface)                       | Type  | `@relkit/events`        | [API example](/docs/api/events#eventdeclarededge-interface)            |
| [EventDefinitionError](/docs/api/events#eventdefinitionerror-class)                     | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventdefinitionerror-class)             |
| [EventDelivery](/docs/api/events#eventdelivery-type-alias)                              | Type  | `@relkit/events`        | [API example](/docs/api/events#eventdelivery-type-alias)               |
| [eventDeliveryEffect](/docs/api/events#eventdeliveryeffect-1)                           | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventdeliveryeffect-1)                  |
| [EventDependencyError](/docs/api/events#eventdependencyerror-class)                     | Value | `@relkit/events`        | [API example](/docs/api/events#eventdependencyerror-class)             |
| [EventDescriptor](/docs/api/events#eventdescriptor-interface)                           | Type  | `@relkit/events`        | [API example](/docs/api/events#eventdescriptor-interface)              |
| [EventDescriptorAny](/docs/api/events#eventdescriptorany-type-alias)                    | Type  | `@relkit/events`        | [API example](/docs/api/events#eventdescriptorany-type-alias)          |
| [EventDescriptorByName](/docs/api/events#eventdescriptorbyname-type-alias)              | Type  | `@relkit/events`        | [API example](/docs/api/events#eventdescriptorbyname-type-alias)       |
| [EventEnvelope](/docs/api/events#eventenvelope-type-alias)                              | Type  | `@relkit/events`        | [API example](/docs/api/events#eventenvelope-type-alias)               |
| [EventEnvelopeFor](/docs/api/events#eventenvelopefor-type-alias)                        | Type  | `@relkit/events`        | [API example](/docs/api/events#eventenvelopefor-type-alias)            |
| [EventFunctionContext](/docs/api/events#eventfunctioncontext-interface)                 | Type  | `@relkit/events`        | [API example](/docs/api/events#eventfunctioncontext-interface)         |
| [EventFunctionDescriptor](/docs/api/events#eventfunctiondescriptor-interface)           | Type  | `@relkit/events`        | [API example](/docs/api/events#eventfunctiondescriptor-interface)      |
| [EventFunctionDescriptorAny](/docs/api/events#eventfunctiondescriptorany-interface)     | Type  | `@relkit/events`        | [API example](/docs/api/events#eventfunctiondescriptorany-interface)   |
| [EventFunctionHandler](/docs/api/events#eventfunctionhandler-type-alias)                | Type  | `@relkit/events`        | [API example](/docs/api/events#eventfunctionhandler-type-alias)        |
| [EventFunctionTrigger](/docs/api/events#eventfunctiontrigger-interface)                 | Type  | `@relkit/events`        | [API example](/docs/api/events#eventfunctiontrigger-interface)         |
| [EventIdentity](/docs/api/events#eventidentity-class)                                   | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventidentity-class)                    |
| [EventIdentityLive](/docs/api/events#eventidentitylive)                                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventidentitylive)                      |
| [EventIdentityService](/docs/api/events#eventidentityservice-interface)                 | Type  | `@relkit/events/effect` | [API example](/docs/api/events#eventidentityservice-interface)         |
| [EventInputByName](/docs/api/events#eventinputbyname-type-alias)                        | Type  | `@relkit/events`        | [API example](/docs/api/events#eventinputbyname-type-alias)            |
| [EventInvocationBridge](/docs/api/events#eventinvocationbridge-interface)               | Type  | `@relkit/events`        | [API example](/docs/api/events#eventinvocationbridge-interface)        |
| [EventInvocationBridgeOptions](/docs/api/events#eventinvocationbridgeoptions-interface) | Type  | `@relkit/events`        | [API example](/docs/api/events#eventinvocationbridgeoptions-interface) |
| [EventName](/docs/api/events#eventname-type-alias)                                      | Type  | `@relkit/events`        | [API example](/docs/api/events#eventname-type-alias)                   |
| [EventObservedEdge](/docs/api/events#eventobservededge-interface)                       | Type  | `@relkit/events`        | [API example](/docs/api/events#eventobservededge-interface)            |
| [EventOperation](/docs/api/events#eventoperation-type-alias)                            | Type  | `@relkit/events/effect` | [API example](/docs/api/events#eventoperation-type-alias)              |
| [EventOperationCancelledError](/docs/api/events#eventoperationcancellederror-class)     | Value | `@relkit/events`        | [API example](/docs/api/events#eventoperationcancellederror-class)     |
| [EventOperationContext](/docs/api/events#eventoperationcontext-interface)               | Type  | `@relkit/events`        | [API example](/docs/api/events#eventoperationcontext-interface)        |
| [EventOperationTimeoutError](/docs/api/events#eventoperationtimeouterror-class)         | Value | `@relkit/events`        | [API example](/docs/api/events#eventoperationtimeouterror-class)       |
| [EventPayloadValidationError](/docs/api/events#eventpayloadvalidationerror-class)       | Value | `@relkit/events`        | [API example](/docs/api/events#eventpayloadvalidationerror-class)      |
| [EventPayloadValidationFailure](/docs/api/events#eventpayloadvalidationfailure-class)   | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventpayloadvalidationfailure-class)    |
| [eventProfileEffect](/docs/api/events#eventprofileeffect-1)                             | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventprofileeffect-1)                   |
| [EventProfileError](/docs/api/events#eventprofileerror-class)                           | Value | `@relkit/events`        | [API example](/docs/api/events#eventprofileerror-class)                |
| [EventProvider](/docs/api/events#eventprovider-interface)                               | Type  | `@relkit/events`        | [API example](/docs/api/events#eventprovider-interface)                |
| [EventProviderError](/docs/api/events#eventprovidererror-class)                         | Value | `@relkit/events`        | [API example](/docs/api/events#eventprovidererror-class)               |
| [EventProviderResult](/docs/api/events#eventproviderresult-type-alias)                  | Type  | `@relkit/events`        | [API example](/docs/api/events#eventproviderresult-type-alias)         |
| [EventPublisher](/docs/api/events#eventpublisher-class)                                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventpublisher-class)                   |
| [eventPublisherLayer](/docs/api/events#eventpublisherlayer)                             | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventpublisherlayer)                    |
| [EventPublisherService](/docs/api/events#eventpublisherservice-interface)               | Type  | `@relkit/events/effect` | [API example](/docs/api/events#eventpublisherservice-interface)        |
| [EventPublishFailure](/docs/api/events#eventpublishfailure-type-alias)                  | Type  | `@relkit/events/effect` | [API example](/docs/api/events#eventpublishfailure-type-alias)         |
| [EventPublishOptions](/docs/api/functions#eventpublishoptions-interface)                | Type  | `@relkit/events`        | [API example](/docs/api/functions#eventpublishoptions-interface)       |
| [EventPublishResult](/docs/api/functions#eventpublishresult-interface)                  | Type  | `@relkit/events`        | [API example](/docs/api/functions#eventpublishresult-interface)        |
| [EventPublishSetup](/docs/api/events#eventpublishsetup-interface)                       | Type  | `@relkit/events/effect` | [API example](/docs/api/events#eventpublishsetup-interface)            |
| [EventRegistry](/docs/api/events#eventregistry-type-alias)                              | Type  | `@relkit/events`        | [API example](/docs/api/events#eventregistry-type-alias)               |
| [eventRetryEffect](/docs/api/events#eventretryeffect-1)                                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventretryeffect-1)                     |
| [EventRetryPolicy](/docs/api/events#eventretrypolicy-type-alias)                        | Type  | `@relkit/events`        | [API example](/docs/api/events#eventretrypolicy-type-alias)            |
| [EventTelemetry](/docs/api/events#eventtelemetry-class)                                 | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventtelemetry-class)                   |
| [EventTelemetryLive](/docs/api/events#eventtelemetrylive-1)                             | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventtelemetrylive-1)                   |
| [EventTelemetryService](/docs/api/events#eventtelemetryservice-interface)               | Type  | `@relkit/events/effect` | [API example](/docs/api/events#eventtelemetryservice-interface)        |
| [EventVersionByName](/docs/api/events#eventversionbyname-type-alias)                    | Type  | `@relkit/events`        | [API example](/docs/api/events#eventversionbyname-type-alias)          |
| [EventWorkFailed](/docs/api/events#eventworkfailed-class)                               | Value | `@relkit/events/effect` | [API example](/docs/api/events#eventworkfailed-class)                  |
| [isEventDescriptor](/docs/api/events#iseventdescriptor)                                 | Value | `@relkit/events`        | [API example](/docs/api/events#iseventdescriptor)                      |
| [isEventDescriptorEffect](/docs/api/events#iseventdescriptoreffect)                     | Value | `@relkit/events/effect` | [API example](/docs/api/events#iseventdescriptoreffect)                |
| [isEventFunctionDescriptor](/docs/api/events#iseventfunctiondescriptor)                 | Value | `@relkit/events`        | [API example](/docs/api/events#iseventfunctiondescriptor)              |
| [isEventFunctionDescriptorEffect](/docs/api/events#iseventfunctiondescriptoreffect)     | Value | `@relkit/events/effect` | [API example](/docs/api/events#iseventfunctiondescriptoreffect)        |
| [normalizeAttributesEffect](/docs/api/events#normalizeattributeseffect-1)               | Value | `@relkit/events/effect` | [API example](/docs/api/events#normalizeattributeseffect-1)            |
| [normalizeOptionsEffect](/docs/api/events#normalizeoptionseffect-1)                     | Value | `@relkit/events/effect` | [API example](/docs/api/events#normalizeoptionseffect-1)               |
| [normalizeResultEffect](/docs/api/events#normalizeresulteffect)                         | Value | `@relkit/events/effect` | [API example](/docs/api/events#normalizeresulteffect)                  |
| [notifyEffect](/docs/api/events#notifyeffect)                                           | Value | `@relkit/events/effect` | [API example](/docs/api/events#notifyeffect)                           |
| [observeEvent](/docs/api/events#observeevent-1)                                         | Value | `@relkit/events/effect` | [API example](/docs/api/events#observeevent-1)                         |
| [parsePayloadEffect](/docs/api/events#parsepayloadeffect-1)                             | Value | `@relkit/events/effect` | [API example](/docs/api/events#parsepayloadeffect-1)                   |
| [publishEventEffect](/docs/api/events#publisheventeffect)                               | Value | `@relkit/events/effect` | [API example](/docs/api/events#publisheventeffect)                     |
| [rejectEventFunctionFieldsEffect](/docs/api/events#rejecteventfunctionfieldseffect-1)   | Value | `@relkit/events/effect` | [API example](/docs/api/events#rejecteventfunctionfieldseffect-1)      |
| [resolveProviderEffect](/docs/api/events#resolveprovidereffect)                         | Value | `@relkit/events/effect` | [API example](/docs/api/events#resolveprovidereffect)                  |
| [resolveValueEffect](/docs/api/events#resolvevalueeffect)                               | Value | `@relkit/events/effect` | [API example](/docs/api/events#resolvevalueeffect)                     |
| [runAbortableEffect](/docs/api/events#runabortableeffect)                               | Value | `@relkit/events/effect` | [API example](/docs/api/events#runabortableeffect)                     |
| [UnknownEventEnvelope](/docs/api/events#unknowneventenvelope-type-alias)                | Type  | `@relkit/events`        | [API example](/docs/api/events#unknowneventenvelope-type-alias)        |

## `client-errors.ts`

### EventClientValidationError (class)

Other expected client validation failure.

**Example**

```ts
new EventClientValidationError({ message: "Invalid event options" });
```

**Signature**

```ts
declare class EventClientValidationError
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L98)

### EventDependencyError (class)

Publication attempted without a declared event dependency.

**Example**

```ts
new EventDependencyError("orders.created");
```

**Signature**

```ts
declare class EventDependencyError {
  constructor(eventId: string);
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L31)

### code (property)

**Signature**

```ts
readonly code: "RELKIT_EVENT_DEPENDENCY_UNDECLARED"
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L35)

### EventOperationCancelledError (class)

Publication cancelled through its AbortSignal.

**Example**

```ts
new EventOperationCancelledError();
```

**Signature**

```ts
declare class EventOperationCancelledError {
  constructor();
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L70)

### code (property)

**Signature**

```ts
readonly code: "ABORT_ERR"
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L74)

### EventOperationTimeoutError (class)

Publication exceeded its absolute deadline.

**Example**

```ts
new EventOperationTimeoutError();
```

**Signature**

```ts
declare class EventOperationTimeoutError {
  constructor();
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L84)

### code (property)

**Signature**

```ts
readonly code: "ETIMEDOUT"
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L88)

### EventPayloadValidationError (class)

Payload rejected by its Standard Schema validator.

**Example**

```ts
new EventPayloadValidationError([{ message: "Required" }]);
```

**Signature**

```ts
declare class EventPayloadValidationError { constructor(readonly issues: readonly StandardIssue[]) }
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L7)

### code (property)

**Signature**

```ts
readonly code: "RELKIT_EVENT_PAYLOAD_VALIDATION"
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L8)

### EventPayloadValidationFailure (class)

Tagged payload failure used by Effect clients before Promise adaptation.

**Example**

```ts
new EventPayloadValidationFailure([{ message: "Required" }]);
```

**Signature**

```ts
declare class EventPayloadValidationFailure {
  constructor(issues: readonly StandardIssue[]);
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L18)

### issues (property)

**Signature**

```ts
readonly issues: ReadonlyArray<StandardIssue>
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L22)

### EventProfileError (class)

Requested provider profile is missing.

**Example**

```ts
new EventProfileError("default");
```

**Signature**

```ts
declare class EventProfileError {
  constructor(profile: string);
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L44)

### code (property)

**Signature**

```ts
readonly code: "RELKIT_EVENT_PROFILE_UNKNOWN"
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L48)

### EventProviderError (class)

Selected provider cannot publish events.

**Example**

```ts
new EventProviderError();
```

**Signature**

```ts
declare class EventProviderError {
  constructor();
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L57)

### code (property)

**Signature**

```ts
readonly code: "RELKIT_EVENT_PROVIDER_UNAVAILABLE"
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-errors.ts#L61)

## `client-operation.ts`

### EventWorkFailed (class)

Typed failure returned by the work callback.

**Example**

```ts
new EventWorkFailed({ cause: new Error("Provider failed") });
```

**Signature**

```ts
declare class EventWorkFailed
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-operation.ts#L14)

### runAbortable

Promise compatibility adapter for abortable event work.

**Throws**

The established cancellation, timeout, or provider error.

**Example**

```ts
await runAbortable(new AbortController().signal, undefined, async () => 1);
```

**Signature**

```ts
declare const runAbortable: <A>(
  signal: AbortSignal,
  deadlineMs: number | undefined,
  work: () => Promise<A>,
) => Promise<A>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-operation.ts#L116)

### runAbortableEffect

Runs callback work with an owned abort listener and deadline timer.

**Example**

```ts
Effect.runPromise(runAbortableEffect(new AbortController().signal, undefined, async () => 1));
```

**Signature**

```ts
declare const runAbortableEffect: <A>(
  signal: AbortSignal,
  deadlineMs: number | undefined,
  work: (effectSignal: AbortSignal) => Promise<A>,
) => Effect.Effect<
  A,
  | EventClientValidationError
  | EventDependencyError
  | EventOperationCancelledError
  | EventOperationTimeoutError
  | EventPayloadValidationFailure
  | EventWorkFailed,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-operation.ts#L25)

## `client-provider.ts`

### notify

Invokes an edge hook without allowing telemetry failure to replace publication.

**Example**

```ts
notify(onObservedEdge, edge);
```

**Signature**

```ts
declare const notify: <T>(
  hook: ((value: T) => void) | undefined,
  value: T,
  enabled?: boolean,
) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-provider.ts#L67)

### notifyEffect

Effect implementation of best-effort edge notification.

**Example**

```ts
Effect.runSync(notifyEffect(onObservedEdge, edge));
```

**Signature**

```ts
declare const notifyEffect: <T>(
  hook: ((value: T) => void) | undefined,
  value: T,
  enabled?: boolean | undefined,
) => Effect.Effect<void, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-provider.ts#L78)

### resolveProvider

Synchronous provider resolution adapter.

**Throws**

EventProfileError, EventProviderError, or a resolver error.

**Example**

```ts
resolveProvider(provider, "default", undefined);
```

**Signature**

```ts
declare const resolveProvider: (
  source: unknown,
  profile: string,
  resolveProfile: ((profile: string) => unknown) | undefined,
) => EventProvider;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-provider.ts#L46)

### resolveProviderEffect

Resolves a provider for a named profile.

**Example**

```ts
Effect.runSync(resolveProviderEffect(provider, "default", undefined));
```

**Signature**

```ts
declare const resolveProviderEffect: (
  source: unknown,
  profile: string,
  resolveProfile: ((profile: string) => unknown) | undefined,
) => Effect.Effect<
  EventProvider,
  EventClientValidationError | EventProfileError | EventProviderError,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-provider.ts#L18)

### resolveValue

Resolves a fixed or lazy correlation ID.

**Example**

```ts
resolveValue(() => "correlation-1");
```

**Signature**

```ts
declare const resolveValue: (value: EventClientOptions["correlationId"]) => string | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-provider.ts#L98)

### resolveValueEffect

Effect implementation of lazy correlation ID resolution.

**Example**

```ts
Effect.runSync(resolveValueEffect(() => "correlation-1"));
```

**Signature**

```ts
declare const resolveValueEffect: (
  value: string | (() => string | undefined) | undefined,
) => Effect.Effect<string | undefined, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-provider.ts#L113)

## `client-publish.ts`

### EventPublisher (class)

Substitutable provider boundary for Effect event publication.

**Example**

```ts
Effect.provide(publishEventEffect(setup, payload), eventPublisherLayer(provider));
```

**Signature**

```ts
declare class EventPublisher
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.ts#L32)

### eventPublisherLayer

Adapts a Promise provider into a typed Effect service layer.

**Example**

```ts
eventPublisherLayer(provider);
```

**Signature**

```ts
declare const eventPublisherLayer: (provider: EventProvider) => Layer.Layer<EventPublisher>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.ts#L41)

### publishEventEffect

Publishes one event through a supplied provider service.

**Example**

```ts
Effect.runPromise(
  publishEventEffect(setup, payload).pipe(Effect.provide(eventPublisherLayer(provider))),
);
```

**Signature**

```ts
declare const publishEventEffect: <
  Id extends string,
  Version extends number,
  PayloadSchema extends StandardSchemaV1,
>(
  setup: EventPublishSetup<Id, Version, PayloadSchema>,
  payload: InferInput<PayloadSchema>,
  request?: EventPublishOptions,
) => Effect.Effect<
  EventPublishResult<Id, Version, InferOutput<PayloadSchema>>,
  EventPublishFailure,
  EventPublisher
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.ts#L62)

## `client-publish.types.ts`

### EventProvider

**Signature**

```ts
declare const EventProvider: EventProvider;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L5)

### EventPublishFailure (type alias)

Typed failures of an Effect event publication.

**Example**

```ts
Effect.catchTag(publishEventEffect(setup, payload), "EventPayloadValidationFailure", handle);
```

**Signature**

```ts
type EventPublishFailure =
  | EventClientValidationError
  | EventDependencyError
  | EventOperationCancelledError
  | EventOperationTimeoutError
  | EventPayloadValidationFailure
  | EventWorkFailed;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L24)

### EventPublishOptions

**Signature**

```ts
declare const EventPublishOptions: EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L3)

### EventPublishResult

**Signature**

```ts
declare const EventPublishResult: EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L3)

### EventPublishSetup (interface)

Validated state captured by a generated event client.

**Example**

```ts
const setup: EventPublishSetup<"orders.created", 1, typeof schema> = validated;
```

**Signature**

```ts
export interface EventPublishSetup<
  Id extends string,
  Version extends number,
  PayloadSchema extends StandardSchemaV1,
> {
  readonly options: EventClientOptions<Id, Version, PayloadSchema>;
  readonly ownerId: string;
  readonly eventId: Id;
  readonly version: Version;
  readonly profile: string;
  readonly declared: boolean;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L53)

### EventPublisherService (interface)

Provider operation supplied to an Effect publication.

**Example**

```ts
const publisher: EventPublisherService = { publish: () => Effect.succeed(reply) };
```

**Signature**

```ts
export interface EventPublisherService {
  /** Publishes a validated payload.
   * @param payload - Decoded payload.
   * @param options - Validated request options.
   * @param context - Cancellation and trace context.
   * @returns Provider metadata or EventWorkFailed.
   * @example yield* publisher.publish(payload, {}, context)
   */
  readonly publish: (
    payload: unknown,
    options: EventPublishOptions,
    context: EventOperationContext,
  ) => Effect.Effect<EventProviderResult, EventWorkFailed>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L35)

### InferInput

**Signature**

```ts
declare const InferInput: InferInput<S>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L4)

### InferOutput

**Signature**

```ts
declare const InferOutput: InferOutput<S>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L4)

### StandardSchemaV1

**Signature**

```ts
declare const StandardSchemaV1: StandardSchemaV1<TInput, TOutput>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-publish.types.ts#L4)

## `client-record.ts`

### isRecord

Checks a value for a plain record shape.

**Example**

```ts
isRecord({ key: "value" });
```

**Signature**

```ts
declare const isRecord: (value: unknown) => value is Record<string, unknown>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-record.ts#L9)

### isRecordEffect

Effect implementation of the client record predicate.

**Example**

```ts
Effect.runSync(isRecordEffect({ key: "value" }));
```

**Signature**

```ts
declare const isRecordEffect: (value: unknown) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-record.ts#L18)

## `client-result.ts`

### EventIdentity (class)

Substitutable time and identifier boundary for event envelopes.

**Example**

```ts
Effect.provide(
  normalizeResultEffect(reply, payload, {}, context, undefined, "orders.created", 1),
  EventIdentityLive,
);
```

**Signature**

```ts
declare class EventIdentity
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.ts#L17)

### EventIdentityLive

Default wall clock and random UUID source.

**Example**

```ts
Effect.provide(
  normalizeResultEffect(reply, payload, {}, context, undefined, "orders.created", 1),
  EventIdentityLive,
);
```

**Signature**

```ts
declare const EventIdentityLive: Layer.Layer<EventIdentity, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.ts#L28)

### normalizeResult

Synchronous compatibility adapter for provider result normalization.

**Throws**

TypeError when provider metadata cannot be normalized.

**Example**

```ts
normalizeResult(reply, input, {}, context, undefined, "orders.created", 1);
```

**Signature**

```ts
declare const normalizeResult: <Id extends string, Version extends number, Payload>(
  value: EventProviderResult | undefined,
  payload: Payload,
  options: EventPublishOptions,
  context: EventOperationContext,
  now: (() => Date) | undefined,
  eventId: Id,
  version: Version,
) => EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.ts#L105)

### normalizeResultEffect

Builds the accepted event envelope from provider metadata.

**Example**

```ts
Effect.runSync(normalizeResultEffect(reply, input, {}, context, undefined, "orders.created", 1));
```

**Signature**

```ts
declare const normalizeResultEffect: <Id extends string, Version extends number, Payload>(
  value: EventProviderResult | undefined,
  payload: Payload,
  options: EventPublishOptions,
  context: EventOperationContext,
  now: (() => Date) | undefined,
  eventId: Id,
  version: Version,
) => Effect.Effect<EventPublishResult<Id, Version, Payload>, EventClientValidationError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.ts#L41)

## `client-result.types.ts`

Substitutable clock and identifier source for event envelopes.

**Example**

```ts
const identity: EventIdentityService = { now: () => new Date(0), nextId: () => "event-1" };
```

### EventIdentityService (interface)

Substitutable clock and identifier source for event envelopes.

**Example**

```ts
const identity: EventIdentityService = { now: () => new Date(0), nextId: () => "event-1" };
```

**Signature**

```ts
export interface EventIdentityService {
  /** Reads the current wall-clock time.
   * @returns The current date.
   * @example identity.now()
   */
  readonly now: () => Date;
  /** Generates a unique event instance ID.
   * @returns An opaque instance ID.
   * @example identity.nextId()
   */
  readonly nextId: () => string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.types.ts#L4)

### EventOperationContext

**Signature**

```ts
declare const EventOperationContext: EventOperationContext;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.types.ts#L17)

### EventProviderResult

**Signature**

```ts
declare const EventProviderResult: EventProviderResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.types.ts#L17)

### EventPublishOptions

**Signature**

```ts
declare const EventPublishOptions: EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.types.ts#L16)

### EventPublishResult

**Signature**

```ts
declare const EventPublishResult: EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-result.types.ts#L16)

## `client-utils.ts`

### EventClientValidationError

**Signature**

```ts
declare const EventClientValidationError: typeof EventClientValidationError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L2)

### EventDependencyError

**Signature**

```ts
declare const EventDependencyError: typeof EventDependencyError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L3)

### EventOperationCancelledError

**Signature**

```ts
declare const EventOperationCancelledError: typeof EventOperationCancelledError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L4)

### EventOperationTimeoutError

**Signature**

```ts
declare const EventOperationTimeoutError: typeof EventOperationTimeoutError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L5)

### EventPayloadValidationError

**Signature**

```ts
declare const EventPayloadValidationError: typeof EventPayloadValidationError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L6)

### EventProfileError

**Signature**

```ts
declare const EventProfileError: typeof EventProfileError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L7)

### EventProviderError

**Signature**

```ts
declare const EventProviderError: typeof EventProviderError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L8)

### assertOptionalText

**Signature**

```ts
declare const assertOptionalText: (value: unknown, name: string) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L11)

### assertOptionalTextEffect

**Signature**

```ts
declare const assertOptionalTextEffect: (
  value: unknown,
  name: string,
) => Effect<void, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L12)

### assertVersion

**Signature**

```ts
declare const assertVersion: (value: unknown) => asserts value is number;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L13)

### assertVersionEffect

**Signature**

```ts
declare const assertVersionEffect: (
  value: unknown,
) => Effect<number, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L14)

### normalizeAttributesEffect

**Signature**

```ts
declare const normalizeAttributesEffect: (
  value: unknown,
) => Effect<Readonly<Record<string, EventAttributeValue>>, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L15)

### normalizeOptions

**Signature**

```ts
declare const normalizeOptions: (value: unknown) => EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L16)

### normalizeOptionsEffect

**Signature**

```ts
declare const normalizeOptionsEffect: (
  value: unknown,
) => Effect<EventPublishOptions, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L17)

### normalizeResult

**Signature**

```ts
declare const normalizeResult: <Id extends string, Version extends number, Payload>(
  value: EventProviderResult | undefined,
  payload: Payload,
  options: EventPublishOptions,
  context: EventOperationContext,
  now: (() => Date) | undefined,
  eventId: Id,
  version: Version,
) => EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L21)

### normalizeResultEffect

**Signature**

```ts
declare const normalizeResultEffect: <Id extends string, Version extends number, Payload>(
  value: EventProviderResult | undefined,
  payload: Payload,
  options: EventPublishOptions,
  context: EventOperationContext,
  now: (() => Date) | undefined,
  eventId: Id,
  version: Version,
) => Effect<EventPublishResult<Id, Version, Payload>, EventClientValidationError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L21)

### notify

**Signature**

```ts
declare const notify: <T>(
  hook: ((value: T) => void) | undefined,
  value: T,
  enabled?: boolean,
) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L23)

### notifyEffect

**Signature**

```ts
declare const notifyEffect: <T>(
  hook: ((value: T) => void) | undefined,
  value: T,
  enabled?: boolean | undefined,
) => Effect<void, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L24)

### parsePayload

**Signature**

```ts
declare const parsePayload: (
  schema: StandardSchemaV1 | undefined,
  payload: unknown,
) => Promise<unknown>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L18)

### parsePayloadEffect

**Signature**

```ts
declare const parsePayloadEffect: (
  schema: StandardSchemaV1<unknown, unknown> | undefined,
  payload: unknown,
) => Effect<unknown, EventClientValidationError | EventPayloadValidationFailure, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L19)

### resolveProvider

**Signature**

```ts
declare const resolveProvider: (
  source: unknown,
  profile: string,
  resolveProfile: ((profile: string) => unknown) | undefined,
) => EventProvider;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L25)

### resolveProviderEffect

**Signature**

```ts
declare const resolveProviderEffect: (
  source: unknown,
  profile: string,
  resolveProfile: ((profile: string) => unknown) | undefined,
) => Effect<
  EventProvider,
  EventClientValidationError | EventProfileError | EventProviderError,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L26)

### resolveValue

**Signature**

```ts
declare const resolveValue: (value: EventClientOptions["correlationId"]) => string | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L27)

### resolveValueEffect

**Signature**

```ts
declare const resolveValueEffect: (
  value: string | (() => string | undefined) | undefined,
) => Effect<string | undefined, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-utils.ts#L28)

## `client-validation.ts`

### assertOptionalText

Synchronous optional text assertion.

**Throws**

TypeError for empty or non-text input.

**Example**

```ts
assertOptionalText("key", "key");
```

**Signature**

```ts
declare const assertOptionalText: (value: unknown, name: string) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L143)

### assertOptionalTextEffect

Requires optional text to be non-empty when present.

**Example**

```ts
Effect.runSync(assertOptionalTextEffect("key", "key"));
```

**Signature**

```ts
declare const assertOptionalTextEffect: (
  value: unknown,
  name: string,
) => Effect.Effect<void, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L128)

### assertVersion

Synchronous positive version assertion.

**Throws**

TypeError for an invalid version.

**Example**

```ts
assertVersion(1);
```

**Signature**

```ts
declare const assertVersion: (value: unknown) => asserts value is number;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L174)

### assertVersionEffect

Requires a positive safe event version.

**Example**

```ts
Effect.runSync(assertVersionEffect(1));
```

**Signature**

```ts
declare const assertVersionEffect: (
  value: unknown,
) => Effect.Effect<number, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L157)

### normalizeAttributesEffect

Normalizes and sorts bounded event attributes.

**Example**

```ts
Effect.runSync(normalizeAttributesEffect({ source: "checkout" }));
```

**Signature**

```ts
declare const normalizeAttributesEffect: (
  value: unknown,
) => Effect.Effect<
  Readonly<Record<string, EventAttributeValue>>,
  EventClientValidationError,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L99)

### normalizeOptions

Synchronous adapter for request option normalization.

**Throws**

TypeError for malformed options.

**Example**

```ts
normalizeOptions({ key: "order-1" });
```

**Signature**

```ts
declare const normalizeOptions: (value: unknown) => EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L77)

### normalizeOptionsEffect

Validates and freezes publisher request options.

**Example**

```ts
Effect.runSync(normalizeOptionsEffect({ key: "order-1" }));
```

**Signature**

```ts
declare const normalizeOptionsEffect: (
  value: unknown,
) => Effect.Effect<EventPublishOptions, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L64)

### parsePayload

Promise adapter for payload validation.

**Throws**

EventPayloadValidationError or EventClientValidationError.

**Example**

```ts
await parsePayload(schema, payload);
```

**Signature**

```ts
declare const parsePayload: (
  schema: StandardSchemaV1 | undefined,
  payload: unknown,
) => Promise<unknown>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L46)

### parsePayloadEffect

Validates a publication payload with its Standard Schema contract.

**Example**

```ts
await Effect.runPromise(parsePayloadEffect(schema, payload));
```

**Signature**

```ts
declare const parsePayloadEffect: (
  schema: StandardSchemaV1<unknown, unknown> | undefined,
  payload: unknown,
) => Effect.Effect<unknown, EventClientValidationError | EventPayloadValidationFailure, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client-validation.ts#L18)

## `client.ts`

### EventAttributeValue

**Signature**

```ts
declare const EventAttributeValue: EventAttributeValue;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L38)

### EventClient

**Signature**

```ts
declare const EventClient: EventClient<Input, Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L27)

### EventClientOptions

**Signature**

```ts
declare const EventClientOptions: EventClientOptions<Id, Version, PayloadSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L28)

### EventDeclaredEdge

**Signature**

```ts
declare const EventDeclaredEdge: EventDeclaredEdge;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L29)

### EventDependencyError

**Signature**

```ts
declare const EventDependencyError: typeof EventDependencyError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L43)

### EventInvocationBridge

**Signature**

```ts
declare const EventInvocationBridge: EventInvocationBridge;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L30)

### EventInvocationBridgeOptions

**Signature**

```ts
declare const EventInvocationBridgeOptions: EventInvocationBridgeOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L31)

### EventObservedEdge

**Signature**

```ts
declare const EventObservedEdge: EventObservedEdge;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L32)

### EventOperationCancelledError

**Signature**

```ts
declare const EventOperationCancelledError: typeof EventOperationCancelledError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L44)

### EventOperationContext

**Signature**

```ts
declare const EventOperationContext: EventOperationContext;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L33)

### EventOperationTimeoutError

**Signature**

```ts
declare const EventOperationTimeoutError: typeof EventOperationTimeoutError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L45)

### EventPayloadValidationError

**Signature**

```ts
declare const EventPayloadValidationError: typeof EventPayloadValidationError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L46)

### EventProfileError

**Signature**

```ts
declare const EventProfileError: typeof EventProfileError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L47)

### EventProvider

**Signature**

```ts
declare const EventProvider: EventProvider;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L34)

### EventProviderError

**Signature**

```ts
declare const EventProviderError: typeof EventProviderError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L48)

### EventProviderResult

**Signature**

```ts
declare const EventProviderResult: EventProviderResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L35)

### EventPublishOptions

**Signature**

```ts
declare const EventPublishOptions: EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L39)

### EventPublishResult

**Signature**

```ts
declare const EventPublishResult: EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L40)

### createEventClient

Creates a Promise publisher from a validated event contract.

**Throws**

TypeError for malformed client configuration, or a provider profile error.

**Example**

```ts
createEventClient({
  ownerId: "orders.create",
  eventId: "orders.created",
  version: 1,
  source: provider,
});
```

**Signature**

```ts
declare const createEventClient: <
  const Id extends string,
  const Version extends number,
  const PayloadSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: EventClientOptions<Id, Version, PayloadSchema>,
) => EventClient<InferInput<PayloadSchema>, Id, Version, InferOutput<PayloadSchema>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L57)

### createEventClientEffect

Creates an Effect-backed event publisher with typed configuration failures.

**Example**

```ts
Effect.runSync(
  createEventClientEffect({
    ownerId: "orders.create",
    eventId: "orders.created",
    version: 1,
    source: provider,
  }),
);
```

**Signature**

```ts
declare const createEventClientEffect: <
  const Id extends string,
  const Version extends number,
  const PayloadSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: EventClientOptions<Id, Version, PayloadSchema>,
) => Effect.Effect<
  EventClient<InferInput<PayloadSchema>, Id, Version, InferOutput<PayloadSchema>>,
  EventClientValidationError | EventProfileError | EventProviderError
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.ts#L79)

## `client.types.ts`

### EventAttributeValue

**Signature**

```ts
declare const EventAttributeValue: EventAttributeValue;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L5)

### EventClient (interface)

Promise compatibility interface exposed to application handlers.

**Example**

```ts
await client.publish({ orderId: "one" });
```

**Signature**

```ts
export interface EventClient<
  Input = unknown,
  Id extends string = string,
  Version extends number = number,
  Payload = Input,
> {
  /** Publishes a payload and returns the accepted envelope.
   * @param payload - Event payload to decode.
   * @param options - Optional key and attributes.
   * @returns A Promise of the accepted envelope or a rejected domain error.
   * @example await client.publish(payload, { key: "order-1" })
   */
  readonly publish: (
    payload: Input,
    options?: EventPublishOptions,
  ) => Promise<EventPublishResult<Id, Version, Payload>>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L109)

### EventClientOptions (interface)

Dependencies and policy for a generated event publisher.
Provider selection occurs once when the client is created.

**Example**

```ts
const options: EventClientOptions = {
  ownerId: "orders.create",
  eventId: "orders.created",
  version: 1,
  source: provider,
};
```

**Signature**

```ts
export interface EventClientOptions<
  Id extends string = string,
  Version extends number = number,
  PayloadSchema extends StandardSchemaV1 = StandardSchemaV1,
> {
  readonly ownerId: string;
  readonly eventId: Id;
  readonly version: Version;
  readonly source: unknown;
  readonly payloadSchema?: PayloadSchema;
  readonly profile?: string;
  readonly resolveProfile?: (profile: string) => unknown;
  readonly bridge?: EventInvocationBridge;
  readonly signal?: () => AbortSignal;
  readonly deadline?: () => number | undefined;
  readonly correlationId?: string | (() => string | undefined);
  readonly now?: () => Date;
  readonly declared?: boolean;
  readonly onDeclaredEdge?: (edge: EventDeclaredEdge) => void;
  readonly onObservedEdge?: (edge: EventObservedEdge) => void;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L84)

### EventDeclaredEdge (interface)

Static graph edge for a declared publication dependency.

**Example**

```ts
const edge: EventDeclaredEdge = {
  kind: "publishes-event",
  from: "orders.create",
  to: "orders.created",
};
```

**Signature**

```ts
export interface EventDeclaredEdge {
  readonly kind: "publishes-event";
  readonly from: string;
  readonly to: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L130)

### EventInvocationBridge (interface)

Optional invocation bridge that owns a publication span.

**Example**

```ts
await bridge.run(() => provider.publish(payload, {}, context));
```

**Signature**

```ts
export interface EventInvocationBridge {
  /** Runs publication within the invocation context.
   * @param operation - Publication callback.
   * @param options - Producer span metadata.
   * @returns The operation result or rejection.
   * @example await bridge.run(() => Promise.resolve(1))
   */
  readonly run: <A>(
    operation: () => MaybePromise<A>,
    options?: EventInvocationBridgeOptions,
  ) => Promise<A>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L67)

### EventInvocationBridgeOptions (interface)

Trace bridge metadata for a producer operation.

**Example**

```ts
const name = options.name;
```

**Signature**

```ts
export interface EventInvocationBridgeOptions {
  readonly name?: string;
  readonly attributes?: Readonly<Record<string, unknown>>;
  readonly signal?: AbortSignal;
  readonly kind?: "producer";
  readonly input?: unknown;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L56)

### EventObservedEdge (interface)

Runtime graph edge for an attempted publication.

**Example**

```ts
const edge: EventObservedEdge = {
  relationship: "publishes-event",
  from: "orders.create",
  to: "orders.created",
};
```

**Signature**

```ts
export interface EventObservedEdge {
  readonly relationship: "publishes-event";
  readonly from: string;
  readonly to: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L139)

### EventOperationContext (interface)

Context passed to the selected event provider for one publication.
The signal remains valid until the publication settles.

**Example**

```ts
const id = context.eventId;
```

**Signature**

```ts
export interface EventOperationContext {
  readonly operation: "publish";
  readonly eventId: string;
  readonly version: number;
  readonly signal: AbortSignal;
  readonly profile: string;
  readonly deadlineMs?: number;
  readonly propagation?: TracePropagation;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L15)

### EventProvider (interface)

Provider interface selected from a profile for publication.

**Example**

```ts
const provider: EventProvider = {
  publish: async () => ({ accepted: true, instanceId: "event-1" }),
};
```

**Signature**

```ts
export interface EventProvider {
  /** Publishes one validated payload.
   * @param payload - Decoded event payload.
   * @param options - Validated publish options.
   * @param context - Trace and cancellation context.
   * @returns Provider acceptance and metadata, or a rejected Promise.
   * @example await provider.publish(payload, {}, context)
   */
  readonly publish: (
    payload: unknown,
    options: EventPublishOptions,
    context: EventOperationContext,
  ) => MaybePromise<EventProviderResult>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L38)

### EventProviderResult (type alias)

Provider acknowledgement and optional envelope metadata.

**Example**

```ts
const result: EventProviderResult = { accepted: true, instanceId: "event-1" };
```

**Signature**

```ts
type EventProviderResult<
  Id extends string = string,
  Version extends number = number,
  Payload = unknown,
> = Pick<EventPublishResult<Id, Version, Payload>, "instanceId" | "accepted"> &
  Partial<Omit<EventPublishResult<Id, Version, Payload>, "instanceId" | "accepted">>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L28)

### EventPublishOptions

**Signature**

```ts
declare const EventPublishOptions: EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L6)

### EventPublishResult

**Signature**

```ts
declare const EventPublishResult: EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L7)

### InferInput

**Signature**

```ts
declare const InferInput: InferInput<S>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L9)

### InferOutput

**Signature**

```ts
declare const InferOutput: InferOutput<S>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L9)

### StandardSchemaV1

**Signature**

```ts
declare const StandardSchemaV1: StandardSchemaV1<TInput, TOutput>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/client.types.ts#L9)

## `define-event-function.ts`

### defineEventFunction

Defines an independent event-only consumer with inferred input and void success.
Event IDs are supplied by the application's generated EventRegistry.

**Throws**

TypeError for malformed options.

**Example**

```ts
import { defineEvent, defineEventFunction } from "@relkit/app/events";
import { z } from "@relkit/app/schema";

const orderCreated = defineEvent({
  id: "orders.created",
  input: z.object({ orderId: z.string() }),
});

// The application normally generates this declaration with `relkit check`.
declare global {
  namespace Relkit {
    interface EventRegistry {
      "orders.created": typeof orderCreated;
    }
  }
}

const receipt = defineEventFunction({
  id: "receipt.send",
  event: "orders.created",
  handler: async () => {},
});
```

**Signature**

```ts
declare const defineEventFunction: <
  const Id extends string,
  const Event extends EventName,
  const Publishes extends readonly EventName[] = readonly [],
  const Dependencies extends FunctionDependencies = {},
  const Options extends EventFunctionCallOptions<Id, Event, Publishes, Dependencies> =
    EventFunctionCallOptions<Id, Event, Publishes, Dependencies>,
>(
  options: EventFunctionCallOptions<Id, Event, Publishes, Dependencies> &
    Options &
    EventFunctionValidation<NoInfer<Options>>,
) => EventFunctionDescriptor<Id, Event, Publishes, Dependencies, ErrorListOf<Options>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.ts#L59)

Since v0.1.0

### defineEventFunctionEffect

Defines an event-only function in Effect.

**Example**

```ts
Effect.runSync(
  defineEventFunctionEffect({ id: "notify", event: "orders.created", handler: () => {} }),
);
```

**Signature**

```ts
declare const defineEventFunctionEffect: <
  const Id extends string,
  const Event extends EventName,
  const Publishes extends readonly EventName[] = readonly [],
  const Dependencies extends FunctionDependencies = {},
  const Options extends EventFunctionCallOptions<Id, Event, Publishes, Dependencies> =
    EventFunctionCallOptions<Id, Event, Publishes, Dependencies>,
>(
  options: EventFunctionCallOptions<Id, Event, Publishes, Dependencies> &
    Options &
    EventFunctionValidation<NoInfer<Options>>,
) => Effect.Effect<
  EventFunctionDescriptor<Id, Event, Publishes, Dependencies, ErrorListOf<Options>>,
  EventDefinitionError
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.ts#L84)

### isEventFunctionDescriptor

Checks an event-only function descriptor at a synchronous boundary.

**Example**

```ts
isEventFunctionDescriptor(candidate);
```

**Signature**

```ts
declare const isEventFunctionDescriptor: (value: unknown) => value is EventFunctionDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.ts#L145)

### isEventFunctionDescriptorEffect

Checks an unknown value for a valid event-only function descriptor.

**Example**

```ts
Effect.runSync(isEventFunctionDescriptorEffect(candidate));
```

**Signature**

```ts
declare const isEventFunctionDescriptorEffect: (
  value: unknown,
) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.ts#L154)

## `define-event-function.types.ts`

### ErrorDescriptorAny

**Signature**

```ts
declare const ErrorDescriptorAny: ErrorDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L8)

### ErrorListOf (type alias)

Error declarations inferred from a function definition.

**Example**

```ts
type Errors = ErrorListOf<typeof options>;
```

**Signature**

```ts
type ErrorListOf<Options> = Options extends {
  readonly errors: infer Errors extends readonly ErrorDescriptorAny[];
}
  ? Errors
  : readonly [];
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L18)

### EventFunctionCallOptions (type alias)

Handler-aware options for an event function definition.

**Example**

```ts
type Options = EventFunctionCallOptions<"receipt.send", "orders.created", [], {}>;
```

**Signature**

```ts
type EventFunctionCallOptions<
  Id extends string,
  Event extends EventName,
  Publishes extends readonly EventName[],
  Dependencies extends FunctionDependencies,
> = Omit<
  DefineEventFunctionOptions<Id, Event, Publishes, Dependencies, readonly ErrorDescriptorAny[]>,
  "handler"
> & {
  readonly handler: (
    input: EventInputByName<Event>,
    context: EventFunctionContext<Event, Publishes, Dependencies>,
  ) => unknown;
};
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L27)

### EventFunctionDescriptor

**Signature**

```ts
declare const EventFunctionDescriptor: EventFunctionDescriptor<
  Id,
  Event,
  Publishes,
  Dependencies,
  Errors
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L11)

### EventFunctionDescriptorAny

**Signature**

```ts
declare const EventFunctionDescriptorAny: EventFunctionDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L12)

### EventFunctionValidation (type alias)

Validates a handler's result against declared errors and void success.

**Example**

```ts
type Validation = EventFunctionValidation<typeof options>;
```

**Signature**

```ts
type EventFunctionValidation<Options extends { readonly handler: (...args: never[]) => unknown }> =
  FunctionHandlerValidation<Awaited<ReturnType<Options["handler"]>>, void, ErrorListOf<Options>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L45)

### EventName

**Signature**

```ts
declare const EventName: never;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L9)

### FunctionDependencies

**Signature**

```ts
declare const FunctionDependencies: FunctionDependencies;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event-function.types.ts#L8)

## `define-event.ts`

### defineEvent

Defines a versioned event contract used by publishers and event functions.

**Throws**

TypeError when the contract is malformed.

**Example**

```ts
import { defineEvent } from "@relkit/app/events";
import { z } from "@relkit/app/schema";

const created = defineEvent({ id: "orders.created", input: z.object({ orderId: z.string() }) });
void created;
```

**Signature**

```ts
declare const defineEvent: <
  const Id extends string,
  const Version extends number = 1,
  const InputSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: DefineEventOptions<Id, Version, InputSchema>,
) => EventDescriptor<Id, Version, InferOutput<InputSchema>, InputSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L46)

Since v0.1.0

### DefineEventOptions

**Signature**

```ts
declare const DefineEventOptions: DefineEventOptions<Id, Version, InputSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L21)

### EventDescriptor

**Signature**

```ts
declare const EventDescriptor: EventDescriptor<Id, Version, Input, InputSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L22)

### EventDescriptorAny

**Signature**

```ts
declare const EventDescriptorAny: EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L23)

### EventEnvelope

**Signature**

```ts
declare const EventEnvelope: EventEnvelope<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L24)

### EventEnvelopeFor

**Signature**

```ts
declare const EventEnvelopeFor: EventEnvelopeFor<E>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L25)

### UnknownEventEnvelope

**Signature**

```ts
declare const UnknownEventEnvelope: UnknownEventEnvelope;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L26)

### assertEventDescriptor

Requires a valid event descriptor at a synchronous boundary.

**Throws**

TypeError when the candidate is invalid.

**Example**

```ts
assertEventDescriptor(value);
```

**Signature**

```ts
declare const assertEventDescriptor: (value: unknown) => asserts value is EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L164)

### assertEventDescriptorEffect

Requires a valid event descriptor in an Effect workflow.

**Example**

```ts
Effect.runSync(assertEventDescriptorEffect(candidate));
```

**Signature**

```ts
declare const assertEventDescriptorEffect: (
  value: unknown,
) => Effect.Effect<EventDescriptorAny, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L178)

### defineEventEffect

Defines an event contract in Effect with typed validation failure.

**Example**

```ts
Effect.runSync(defineEventEffect({ id: "orders.created", input: z.object({}) }));
```

**Signature**

```ts
declare const defineEventEffect: <
  const Id extends string,
  const Version extends number = 1,
  const InputSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: DefineEventOptions<Id, Version, InputSchema>,
) => Effect.Effect<
  EventDescriptor<Id, Version, InferOutput<InputSchema>, InputSchema>,
  EventDefinitionError
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L66)

### isEventDescriptor

Checks a candidate against the event descriptor contract.

**Example**

```ts
isEventDescriptor(value);
```

**Signature**

```ts
declare const isEventDescriptor: (value: unknown) => value is EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L122)

### isEventDescriptorEffect

Checks whether an unknown value is a valid event descriptor.

**Example**

```ts
Effect.runSync(isEventDescriptorEffect(candidate));
```

**Signature**

```ts
declare const isEventDescriptorEffect: (value: unknown) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.ts#L131)

## `define-event.types.ts`

### DefineEventOptions (interface)

Input accepted by the event descriptor factory.

**Example**

```ts
const options: DefineEventOptions<"orders.created", 1, typeof schema> = {
  id: "orders.created",
  input: schema,
};
```

**Signature**

```ts
export interface DefineEventOptions<
  Id extends string,
  Version extends number,
  InputSchema extends StandardSchemaV1,
> extends DescriptorMetadata {
  readonly id: Id;
  readonly version?: Version;
  readonly input: InputSchema;
  readonly profile?: string;
  readonly sensitiveFields?: readonly string[];
  readonly handler?: never;
  readonly output?: never;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L55)

### EventDescriptor (interface)

Immutable, versioned event contract with no handler or output.

**Example**

```ts
const created: EventDescriptor<"orders.created", 1, { orderId: string }> = defineEvent(options);
```

**Signature**

```ts
export interface EventDescriptor<
  Id extends string,
  Version extends number,
  Input,
  InputSchema extends StandardSchemaV1 = StandardSchemaV1,
>
  extends DescriptorBase<"event", Id>, EventRef<Id, InputSchema> {
  readonly version: Version;
  readonly input: InputSchema;
  readonly profile?: string;
  readonly sensitiveFields?: readonly string[];
  readonly handler?: never;
  readonly output?: never;
  readonly __input?: Input;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L31)

### EventDescriptorAny (type alias)

Event descriptor with erased contract parameters.

**Example**

```ts
const registry: EventDescriptorAny[] = [created];
```

**Signature**

```ts
type EventDescriptorAny = EventDescriptor<string, number, unknown, StandardSchemaV1>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L50)

### EventEnvelope (type alias)

Published event data without the provider acceptance flag.

**Example**

```ts
type Created = EventEnvelope<"orders.created", 1, { orderId: string }>;
```

**Signature**

```ts
type EventEnvelope<
  Id extends string = string,
  Version extends number = number,
  Payload = unknown,
> = Omit<EventPublishResult<Id, Version, Payload>, "accepted">;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L9)

### EventEnvelopeFor (type alias)

Resolves the envelope for a specific event descriptor.

**Example**

```ts
type CreatedEnvelope = EventEnvelopeFor<typeof created>;
```

**Signature**

```ts
type EventEnvelopeFor<E> =
  E extends EventDescriptor<infer Id, infer Version, infer Input, StandardSchemaV1>
    ? EventEnvelope<Id, Version, Input>
    : UnknownEventEnvelope;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L23)

### InferOutput

**Signature**

```ts
declare const InferOutput: InferOutput<S>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L4)

### StandardSchemaV1

**Signature**

```ts
declare const StandardSchemaV1: StandardSchemaV1<TInput, TOutput>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L4)

### UnknownEventEnvelope (type alias)

Event data when its contract is not known statically.

**Example**

```ts
const envelope: UnknownEventEnvelope = received;
```

**Signature**

```ts
type UnknownEventEnvelope = EventEnvelope<string, number, unknown>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/define-event.types.ts#L18)

## `effect.ts`

### EventBindingError

**Signature**

```ts
declare const EventBindingError: typeof EventBindingError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L37)

### EventDefinitionError

**Signature**

```ts
declare const EventDefinitionError: typeof EventDefinitionError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L37)

### EventIdentity

**Signature**

```ts
declare const EventIdentity: typeof EventIdentity;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L26)

### EventIdentityLive

**Signature**

```ts
declare const EventIdentityLive: Layer<EventIdentity, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L26)

### EventIdentityService

**Signature**

```ts
declare const EventIdentityService: EventIdentityService;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L27)

### EventOperation

**Signature**

```ts
declare const EventOperation: EventOperation;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L30)

### EventPayloadValidationFailure

**Signature**

```ts
declare const EventPayloadValidationFailure: typeof EventPayloadValidationFailure;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L38)

### EventPublishFailure

**Signature**

```ts
declare const EventPublishFailure: EventPublishFailure;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L14)

### EventPublishSetup

**Signature**

```ts
declare const EventPublishSetup: EventPublishSetup<Id, Version, PayloadSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L15)

### EventPublisher

**Signature**

```ts
declare const EventPublisher: typeof EventPublisher;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L12)

### EventPublisherService

**Signature**

```ts
declare const EventPublisherService: EventPublisherService;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L16)

### EventTelemetry

**Signature**

```ts
declare const EventTelemetry: typeof EventTelemetry;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L29)

### EventTelemetryLive

**Signature**

```ts
declare const EventTelemetryLive: Layer<EventTelemetry, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L29)

### EventTelemetryService

**Signature**

```ts
declare const EventTelemetryService: EventTelemetryService;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L30)

### EventWorkFailed

**Signature**

```ts
declare const EventWorkFailed: typeof EventWorkFailed;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L18)

### assertEventDescriptorEffect

**Signature**

```ts
declare const assertEventDescriptorEffect: (
  value: unknown,
) => Effect<EventDescriptorAny, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L4)

### assertOptionalTextEffect

**Signature**

```ts
declare const assertOptionalTextEffect: (
  value: unknown,
  name: string,
) => Effect<void, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L23)

### assertVersionEffect

**Signature**

```ts
declare const assertVersionEffect: (
  value: unknown,
) => Effect<number, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L24)

### bindFunctionEventsEffect

**Signature**

```ts
declare const bindFunctionEventsEffect: <T extends FunctionWithEvents>(
  descriptor: T,
  consumed: EventDescriptorAny | undefined,
  published: readonly EventDescriptorAny[],
) => Effect<T, EventBindingError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L10)

### createEventClientEffect

**Signature**

```ts
declare const createEventClientEffect: <
  const Id extends string,
  const Version extends number,
  const PayloadSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: EventClientOptions<Id, Version, PayloadSchema>,
) => Effect<
  EventClient<InferInput<PayloadSchema>, Id, Version, InferOutput<PayloadSchema>>,
  EventClientValidationError | EventProfileError | EventProviderError
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L11)

### defineEventEffect

**Signature**

```ts
declare const defineEventEffect: <
  const Id extends string,
  const Version extends number = 1,
  const InputSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: DefineEventOptions<Id, Version, InputSchema>,
) => Effect<
  EventDescriptor<Id, Version, InferOutput<InputSchema>, InputSchema>,
  EventDefinitionError
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L2)

### defineEventFunctionEffect

**Signature**

```ts
declare const defineEventFunctionEffect: <
  const Id extends string,
  const Event extends EventName,
  const Publishes extends readonly EventName[] = readonly [],
  const Dependencies extends FunctionDependencies = {},
  const Options extends EventFunctionCallOptions<Id, Event, Publishes, Dependencies> =
    EventFunctionCallOptions<Id, Event, Publishes, Dependencies>,
>(
  options: EventFunctionCallOptions<Id, Event, Publishes, Dependencies> &
    Options &
    EventFunctionValidation<NoInfer<Options>>,
) => Effect<
  EventFunctionDescriptor<Id, Event, Publishes, Dependencies, ErrorListOf<Options>>,
  EventDefinitionError
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L7)

### eventDeliveryEffect

**Signature**

```ts
declare const eventDeliveryEffect: (
  value: unknown,
) => Effect<EventDelivery, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L32)

### eventProfileEffect

**Signature**

```ts
declare const eventProfileEffect: (value: unknown) => Effect<string, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L33)

### eventPublisherLayer

**Signature**

```ts
declare const eventPublisherLayer: (provider: EventProvider) => Layer<EventPublisher>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L12)

### eventRetryEffect

**Signature**

```ts
declare const eventRetryEffect: (
  value: unknown,
) => Effect<RetryPolicy, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L34)

### isEventDescriptorEffect

**Signature**

```ts
declare const isEventDescriptorEffect: (value: unknown) => Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L3)

### isEventFunctionDescriptorEffect

**Signature**

```ts
declare const isEventFunctionDescriptorEffect: (value: unknown) => Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L8)

### normalizeAttributesEffect

**Signature**

```ts
declare const normalizeAttributesEffect: (
  value: unknown,
) => Effect<Readonly<Record<string, EventAttributeValue>>, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L21)

### normalizeOptionsEffect

**Signature**

```ts
declare const normalizeOptionsEffect: (
  value: unknown,
) => Effect<EventPublishOptions, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L20)

### normalizeResultEffect

**Signature**

```ts
declare const normalizeResultEffect: <Id extends string, Version extends number, Payload>(
  value: EventProviderResult | undefined,
  payload: Payload,
  options: EventPublishOptions,
  context: EventOperationContext,
  now: (() => Date) | undefined,
  eventId: Id,
  version: Version,
) => Effect<EventPublishResult<Id, Version, Payload>, EventClientValidationError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L26)

### notifyEffect

**Signature**

```ts
declare const notifyEffect: <T>(
  hook: ((value: T) => void) | undefined,
  value: T,
  enabled?: boolean | undefined,
) => Effect<void, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L28)

### observeEvent

**Signature**

```ts
declare const observeEvent: <A, E, R>(
  operation: EventOperation,
  effect: Effect<A, E, R>,
) => Effect<A, E, R>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L29)

### parsePayloadEffect

**Signature**

```ts
declare const parsePayloadEffect: (
  schema: StandardSchemaV1<unknown, unknown> | undefined,
  payload: unknown,
) => Effect<unknown, EventClientValidationError | EventPayloadValidationFailure, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L22)

### publishEventEffect

**Signature**

```ts
declare const publishEventEffect: <
  Id extends string,
  Version extends number,
  PayloadSchema extends StandardSchemaV1,
>(
  setup: EventPublishSetup<Id, Version, PayloadSchema>,
  payload: InferInput<PayloadSchema>,
  request?: EventPublishOptions,
) => Effect<
  EventPublishResult<Id, Version, InferOutput<PayloadSchema>>,
  EventPublishFailure,
  EventPublisher
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L12)

### rejectEventFunctionFieldsEffect

**Signature**

```ts
declare const rejectEventFunctionFieldsEffect: (
  options: Record<PropertyKey, unknown>,
) => Effect<void, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L35)

### resolveProviderEffect

**Signature**

```ts
declare const resolveProviderEffect: (
  source: unknown,
  profile: string,
  resolveProfile: ((profile: string) => unknown) | undefined,
) => Effect<
  EventProvider,
  EventClientValidationError | EventProfileError | EventProviderError,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L28)

### resolveValueEffect

**Signature**

```ts
declare const resolveValueEffect: (
  value: string | (() => string | undefined) | undefined,
) => Effect<string | undefined, EventClientValidationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L28)

### runAbortableEffect

**Signature**

```ts
declare const runAbortableEffect: <A>(
  signal: AbortSignal,
  deadlineMs: number | undefined,
  work: (effectSignal: AbortSignal) => Promise<A>,
) => Effect<
  A,
  | EventClientValidationError
  | EventDependencyError
  | EventOperationCancelledError
  | EventOperationTimeoutError
  | EventPayloadValidationFailure
  | EventWorkFailed,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/effect.ts#L18)

## `event-contract-shape.ts`

### hasOwn

Checks whether a descriptor owns a named property.

**Example**

```ts
hasOwn({ id: "orders.created" }, "id");
```

**Signature**

```ts
declare const hasOwn: (value: object, key: PropertyKey) => boolean;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L51)

### hasOwnEffect

Effect implementation of direct property ownership detection.

**Example**

```ts
Effect.runSync(hasOwnEffect({ id: "orders.created" }, "id"));
```

**Signature**

```ts
declare const hasOwnEffect: (
  value: object,
  key: PropertyKey,
) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L61)

### isPositiveInteger

Checks for a positive safe version number.

**Example**

```ts
isPositiveInteger(1);
```

**Signature**

```ts
declare const isPositiveInteger: (value: unknown) => value is number;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L70)

### isPositiveIntegerEffect

Effect implementation of the positive safe integer predicate.

**Example**

```ts
Effect.runSync(isPositiveIntegerEffect(1));
```

**Signature**

```ts
declare const isPositiveIntegerEffect: (value: unknown) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L79)

### isRecord

Checks whether a value is a non-array object.

**Example**

```ts
isRecord({ id: "orders.created" });
```

**Signature**

```ts
declare const isRecord: (value: unknown) => value is Record<PropertyKey, unknown>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L32)

### isRecordEffect

Effect implementation of the descriptor record predicate.

**Example**

```ts
Effect.runSync(isRecordEffect({ id: "orders.created" }));
```

**Signature**

```ts
declare const isRecordEffect: (value: unknown) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L41)

### isSchema

Checks the Standard Schema v1 runtime contract.

**Example**

```ts
isSchema(schema);
```

**Signature**

```ts
declare const isSchema: (value: unknown) => value is StandardSchemaV1;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L11)

### isSchemaEffect

Effect implementation of the Standard Schema predicate.

**Example**

```ts
Effect.runSync(isSchemaEffect(schema));
```

**Signature**

```ts
declare const isSchemaEffect: (value: unknown) => Effect.Effect<boolean, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L20)

### validateVersion

Requires a positive safe version number.

**Throws**

TypeError for an invalid version.

**Example**

```ts
validateVersion(1);
```

**Signature**

```ts
declare const validateVersion: (value: unknown) => asserts value is number;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L89)

### validateVersionEffect

Requires a positive safe version in the Effect error channel.

**Example**

```ts
Effect.runSync(validateVersionEffect(1));
```

**Signature**

```ts
declare const validateVersionEffect: (
  value: unknown,
) => Effect.Effect<number, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-contract-shape.ts#L103)

## `event-errors.ts`

### EventBindingError (class)

A rejected function-to-event binding with a stable typed tag.

**Example**

```ts
new EventBindingError({ message: "Missing event contract" });
```

**Signature**

```ts
declare class EventBindingError
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-errors.ts#L14)

### EventDefinitionError (class)

A rejected event or event-function descriptor with a stable typed tag.

**Example**

```ts
new EventDefinitionError({ message: "Invalid event descriptor" });
```

**Signature**

```ts
declare class EventDefinitionError
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-errors.ts#L6)

## `event-function-target.ts`

### bindFunctionEvents

Binds validated event contracts into a generated function target.

**Throws**

TypeError if any declared contract is missing or invalid.

**Example**

```ts
bindFunctionEvents(publisher, undefined, [orderCreated]);
```

**Signature**

```ts
declare const bindFunctionEvents: <T extends FunctionWithEvents>(
  descriptor: T,
  consumed: EventDescriptorAny | undefined,
  published: readonly EventDescriptorAny[],
) => T;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-target.ts#L22)

### bindFunctionEventsEffect

Binds event contracts with typed failures in an Effect workflow.

**Example**

```ts
Effect.runSync(bindFunctionEventsEffect(publisher, undefined, [orderCreated]));
```

**Signature**

```ts
declare const bindFunctionEventsEffect: <T extends FunctionWithEvents>(
  descriptor: T,
  consumed: EventDescriptorAny | undefined,
  published: readonly EventDescriptorAny[],
) => Effect.Effect<T, EventBindingError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-target.ts#L42)

## `event-function-target.types.ts`

Minimal function descriptor accepted by event contract binding.

**Example**

```ts
const target: FunctionWithEvents = { id: "orders.create", publishes: ["orders.created"] };
```

### EventDescriptorAny

**Signature**

```ts
declare const EventDescriptorAny: EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-target.types.ts#L11)

### FunctionWithEvents (interface)

Minimal function descriptor accepted by event contract binding.

**Example**

```ts
const target: FunctionWithEvents = { id: "orders.create", publishes: ["orders.created"] };
```

**Signature**

```ts
export interface FunctionWithEvents {
  readonly id: string;
  readonly invocationMode?: "callable" | "event-only";
  readonly event?: string;
  readonly publishes?: readonly string[];
  readonly input?: unknown;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-target.types.ts#L4)

## `event-function-validation.ts`

### eventDelivery

Normalizes event delivery for synchronous authoring.

**Throws**

TypeError for an unsupported mode.

**Example**

```ts
eventDelivery("durable");
```

**Signature**

```ts
declare const eventDelivery: (value: unknown) => EventDelivery;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L22)

### eventDeliveryEffect

Resolves an event function delivery mode.

**Example**

```ts
Effect.runSync(eventDeliveryEffect("durable"));
```

**Signature**

```ts
declare const eventDeliveryEffect: (
  value: unknown,
) => Effect.Effect<EventDelivery, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L31)

### eventProfile

Normalizes a synchronous event provider profile.

**Throws**

TypeError for a malformed profile.

**Example**

```ts
eventProfile("default");
```

**Signature**

```ts
declare const eventProfile: (value: unknown) => string;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L52)

### eventProfileEffect

Resolves the configured event provider profile.

**Example**

```ts
Effect.runSync(eventProfileEffect("default"));
```

**Signature**

```ts
declare const eventProfileEffect: (
  value: unknown,
) => Effect.Effect<string, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L61)

### eventRetry

Normalizes synchronous event retry policy input.

**Throws**

TypeError for invalid retry values.

**Example**

```ts
eventRetry({ maxAttempts: 3 });
```

**Signature**

```ts
declare const eventRetry: (value: unknown) => RetryPolicy;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L80)

### eventRetryEffect

Normalizes an event function retry policy.

**Example**

```ts
Effect.runSync(eventRetryEffect({ maxAttempts: 3 }));
```

**Signature**

```ts
declare const eventRetryEffect: (
  value: unknown,
) => Effect.Effect<RetryPolicy, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L89)

### rejectEventFunctionFields

Rejects descriptor fields reserved for other function kinds.

**Throws**

TypeError when a forbidden field is present.

**Example**

```ts
rejectEventFunctionFields({ event: "orders.created" });
```

**Signature**

```ts
declare const rejectEventFunctionFields: (options: Record<PropertyKey, unknown>) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L121)

### rejectEventFunctionFieldsEffect

Rejects fields owned by other descriptor kinds.

**Example**

```ts
Effect.runSync(rejectEventFunctionFieldsEffect({ event: "orders.created" }));
```

**Signature**

```ts
declare const rejectEventFunctionFieldsEffect: (
  options: Record<PropertyKey, unknown>,
) => Effect.Effect<void, EventDefinitionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function-validation.ts#L130)

## `event-function.types.ts`

### DefineEventFunctionOptions (interface)

Definition options for a versioned event consumer.

**Example**

```ts
const options = { id: "receipt.send", event: "orders.created", handler: () => {} };
```

**Signature**

```ts
export interface DefineEventFunctionOptions<
  Id extends string,
  Event extends EventName,
  Publishes extends readonly EventName[] = readonly [],
  Dependencies extends FunctionDependencies = {},
  Errors extends readonly ErrorDescriptorAny[] = readonly [],
> extends DescriptorMetadata {
  readonly id: Id;
  readonly event: Event;
  readonly delivery?: EventDelivery;
  readonly profile?: string;
  readonly retry?: Partial<EventRetryPolicy>;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
  readonly publishes?: Publishes;
  readonly dependencies?: Dependencies;
  readonly errors?: Errors;
  readonly onBefore?: (
    input: EventInputByName<Event>,
    context: EventFunctionContext<Event, Publishes, Dependencies>,
  ) => MaybePromise<EventInputByName<Event>>;
  readonly onAfter?: (
    output: void,
    context: EventFunctionContext<Event, Publishes, Dependencies>,
  ) => MaybePromise<void>;
  readonly handler: EventFunctionHandler<Event, Publishes, Dependencies, Errors>;
  readonly input?: never;
  readonly output?: never;
  readonly tool?: never;
  readonly trigger?: never;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L76)

### EventDelivery (type alias)

Delivery semantics for an event-only function.

**Example**

```ts
const delivery: EventDelivery = "durable";
```

**Signature**

```ts
type EventDelivery = "ephemeral" | "durable";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L20)

### EventFunctionContext (interface)

Handler context with event trigger and declared dependencies.

**Example**

```ts
const eventId = context.trigger.event.id;
```

**Signature**

```ts
export interface EventFunctionContext<
  Event extends EventName,
  Publishes extends readonly EventName[] = readonly [],
  Dependencies extends FunctionDependencies = {},
> extends FunctionContext<Dependencies, Publishes> {
  readonly trigger: EventFunctionTrigger<Event>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L52)

### EventFunctionDescriptor (interface)

Immutable descriptor emitted by defineEventFunction.

**Example**

```ts
const descriptor = defineEventFunction(options);
```

**Signature**

```ts
export interface EventFunctionDescriptor<
  Id extends string = string,
  Event extends EventName = EventName,
  Publishes extends readonly EventName[] = readonly [],
  Dependencies extends FunctionDependencies = {},
  Errors extends readonly ErrorDescriptorAny[] = readonly ErrorDescriptorAny[],
> extends DescriptorBase<"function", Id> {
  readonly invocationMode: "event-only";
  readonly event: Event;
  readonly delivery: EventDelivery;
  readonly profile: string;
  readonly retry: EventRetryPolicy;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
  readonly publishes?: Publishes;
  readonly dependencies?: Dependencies;
  readonly errors?: Errors;
  readonly handler: EventFunctionHandler<Event, Publishes, Dependencies, Errors>;
  readonly invoke?: never;
  readonly asTool?: never;
  readonly __input?: InferOutput<EventDescriptorByName<Event>["input"]>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L111)

### EventFunctionDescriptorAny (interface)

Event-only descriptor with erased event and dependency types.

**Example**

```ts
const consumer: EventFunctionDescriptorAny = descriptor;
```

**Signature**

```ts
export interface EventFunctionDescriptorAny extends DescriptorBase<"function"> {
  readonly invocationMode: "event-only";
  readonly event: string;
  readonly delivery: EventDelivery;
  readonly profile: string;
  readonly retry: EventRetryPolicy;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
  readonly publishes?: readonly string[];
  readonly handler: (...args: never[]) => unknown;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L137)

### EventFunctionHandler (type alias)

Handler contract for event-only functions; successful handlers return void.

**Example**

```ts
const handler: EventFunctionHandler<"orders.created", [], {}, []> = () => {};
```

**Signature**

```ts
type EventFunctionHandler<
  Event extends EventName,
  Publishes extends readonly EventName[],
  Dependencies extends FunctionDependencies,
  Errors extends readonly ErrorDescriptorAny[],
> = (
  input: EventInputByName<Event>,
  context: EventFunctionContext<Event, Publishes, Dependencies>,
) => MaybePromise<FunctionHandlerResult<void, Errors>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L63)

### EventFunctionTrigger (interface)

Trigger metadata supplied for one event delivery.

**Example**

```ts
const attempt = context.trigger.delivery.attempt;
```

**Signature**

```ts
export interface EventFunctionTrigger<Event extends EventName = EventName> {
  readonly kind: "event";
  readonly event: {
    readonly id: Event;
    readonly version: EventVersionByName<Event>;
    readonly instanceId: string;
    readonly occurredAt: string;
    readonly publishedAt: string;
    readonly key?: string;
    readonly attributes: Readonly<Record<string, string | number | boolean>>;
  };
  readonly delivery: { readonly attempt: number; readonly replayed: boolean };
  readonly trace: {
    readonly traceId: string;
    readonly correlationId?: string;
    readonly causationInvocationId?: string;
  };
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L30)

### EventRetryPolicy (type alias)

Bounded retry policy shared with job handlers.

**Example**

```ts
const retry: EventRetryPolicy = {
  maxAttempts: 1,
  initialDelayMs: 0,
  maxDelayMs: 0,
  multiplier: 1,
  jitter: "none",
};
```

**Signature**

```ts
type EventRetryPolicy = RetryPolicy;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-function.types.ts#L25)

## `event-observability.ts`

### EventTelemetry (class)

Substitutable telemetry for package operations.

**Example**

```ts
Effect.provide(observeEvent("event.define", Effect.void), EventTelemetryLive);
```

**Signature**

```ts
declare class EventTelemetry
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-observability.ts#L7)

### EventTelemetryLive

Default span and metric observer.

**Example**

```ts
Effect.provide(observeEvent("event.define", Effect.void), EventTelemetryLive);
```

**Signature**

```ts
declare const EventTelemetryLive: Layer.Layer<EventTelemetry, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-observability.ts#L14)

### observeEvent

Records a stable span, call count, failure count, and duration.

**Example**

```ts
observeEvent("event.define", Effect.succeed("created"));
```

**Signature**

```ts
declare const observeEvent: <A, E, R>(
  operation: EventOperation,
  effect: Effect.Effect<A, E, R>,
) => Effect.Effect<A, E, R>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-observability.ts#L28)

### runEventSync

Runs a dependency-free compatibility effect and rethrows its typed failure.

**Throws**

The typed failure or an unexpected defect.

**Example**

```ts
runEventSync(Effect.succeed(1));
```

**Signature**

```ts
declare const runEventSync: <A, E>(effect: Effect.Effect<A, E>) => A;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-observability.ts#L67)

## `event-observability.types.ts`

### EventOperation (type alias)

Fixed operation labels used by event authoring and publishing metrics.

**Example**

```ts
const operation: EventOperation = "client.publish";
```

**Signature**

```ts
type EventOperation =
  | "event.define"
  | "event.isDescriptor"
  | "event.assertDescriptor"
  | "function.define"
  | "function.isDescriptor"
  | "function.bindEvents"
  | "function.delivery"
  | "function.profile"
  | "function.retry"
  | "function.rejectFields"
  | "client.create"
  | "client.publish"
  | "client.parsePayload"
  | "client.normalizeOptions"
  | "client.normalizeAttributes"
  | "client.normalizeResult"
  | "client.resolveProvider"
  | "client.notify"
  | "client.resolveValue"
  | "client.assertOptionalText"
  | "client.assertVersion"
  | "client.runAbortable";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-observability.types.ts#L6)

### EventTelemetryService (interface)

Substitutable observer for event operations.
Implementations retain the original success and error channels.

**Example**

```ts
const telemetry: EventTelemetryService = { observe: (_name, effect) => effect };
```

**Signature**

```ts
export interface EventTelemetryService {
  /** Observes one event operation.
   * @param operation - Fixed bounded operation label.
   * @param effect - Operation to observe.
   * @returns The same success and error channels.
   * @example telemetry.observe("event.define", Effect.void)
   */
  readonly observe: <A, E, R>(
    operation: EventOperation,
    effect: Effect.Effect<A, E, R>,
  ) => Effect.Effect<A, E, R>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-observability.types.ts#L34)

## `event-registry.ts`

### EventDescriptorByName (type alias)

Resolves a registered event descriptor from its name.

**Example**

```ts
type Created = EventDescriptorByName<"orders.created">;
```

**Signature**

```ts
type EventDescriptorByName<Name extends EventName> = EventRegistry[Name] extends EventDescriptorAny
  ? EventRegistry[Name]
  : never;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-registry.ts#L24)

### EventInputByName (type alias)

Decoded payload for a registered event name.

**Example**

```ts
type Payload = EventInputByName<"orders.created">;
```

**Signature**

```ts
type EventInputByName<Name extends EventName> = InferOutput<EventDescriptorByName<Name>["input"]>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-registry.ts#L30)

### EventName (type alias)

Event IDs known to the generated application registry.

**Example**

```ts
type Id = EventName;
```

**Signature**

```ts
type EventName = Extract<keyof EventRegistry, string>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-registry.ts#L19)

### EventRegistry (type alias)

Application registry augmented by generated event declarations.

**Example**

```ts
type Events = EventRegistry;
```

**Signature**

```ts
type EventRegistry = Relkit.EventRegistry;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-registry.ts#L14)

### EventVersionByName (type alias)

Version of a registered event contract.

**Example**

```ts
type Version = EventVersionByName<"orders.created">;
```

**Signature**

```ts
type EventVersionByName<Name extends EventName> = EventDescriptorByName<Name>["version"];
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/event-registry.ts#L37)

## `index.ts`

### "./event-function.types.js" (namespace export)

Re-exports all named exports from the "./event-function.types.js" module.

**Signature**

```ts
export * from "./event-function.types.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L35)

### "./event-registry.js" (namespace export)

Re-exports all named exports from the "./event-registry.js" module.

**Signature**

```ts
export * from "./event-registry.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L33)

### DefineEventOptions

**Signature**

```ts
declare const DefineEventOptions: DefineEventOptions<Id, Version, InputSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L3)

### EventAttributeValue

**Signature**

```ts
declare const EventAttributeValue: EventAttributeValue;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L20)

### EventClient

**Signature**

```ts
declare const EventClient: EventClient<Input, Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L21)

### EventClientOptions

**Signature**

```ts
declare const EventClientOptions: EventClientOptions<Id, Version, PayloadSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L22)

### EventDeclaredEdge

**Signature**

```ts
declare const EventDeclaredEdge: EventDeclaredEdge;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L23)

### EventDependencyError

**Signature**

```ts
declare const EventDependencyError: typeof EventDependencyError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L12)

### EventDescriptor

**Signature**

```ts
declare const EventDescriptor: EventDescriptor<Id, Version, Input, InputSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L4)

### EventDescriptorAny

**Signature**

```ts
declare const EventDescriptorAny: EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L5)

### EventEnvelope

**Signature**

```ts
declare const EventEnvelope: EventEnvelope<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L6)

### EventEnvelopeFor

**Signature**

```ts
declare const EventEnvelopeFor: EventEnvelopeFor<E>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L7)

### EventInvocationBridge

**Signature**

```ts
declare const EventInvocationBridge: EventInvocationBridge;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L24)

### EventInvocationBridgeOptions

**Signature**

```ts
declare const EventInvocationBridgeOptions: EventInvocationBridgeOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L25)

### EventObservedEdge

**Signature**

```ts
declare const EventObservedEdge: EventObservedEdge;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L26)

### EventOperationCancelledError

**Signature**

```ts
declare const EventOperationCancelledError: typeof EventOperationCancelledError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L13)

### EventOperationContext

**Signature**

```ts
declare const EventOperationContext: EventOperationContext;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L27)

### EventOperationTimeoutError

**Signature**

```ts
declare const EventOperationTimeoutError: typeof EventOperationTimeoutError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L14)

### EventPayloadValidationError

**Signature**

```ts
declare const EventPayloadValidationError: typeof EventPayloadValidationError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L15)

### EventProfileError

**Signature**

```ts
declare const EventProfileError: typeof EventProfileError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L16)

### EventProvider

**Signature**

```ts
declare const EventProvider: EventProvider;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L28)

### EventProviderError

**Signature**

```ts
declare const EventProviderError: typeof EventProviderError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L17)

### EventProviderResult

**Signature**

```ts
declare const EventProviderResult: EventProviderResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L29)

### EventPublishOptions

**Signature**

```ts
declare const EventPublishOptions: EventPublishOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L30)

### EventPublishResult

**Signature**

```ts
declare const EventPublishResult: EventPublishResult<Id, Version, Payload>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L31)

### UnknownEventEnvelope

**Signature**

```ts
declare const UnknownEventEnvelope: UnknownEventEnvelope;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L8)

### assertEventDescriptor

**Signature**

```ts
declare const assertEventDescriptor: (value: unknown) => asserts value is EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L1)

### bindFunctionEvents

**Signature**

```ts
declare const bindFunctionEvents: <T extends FunctionWithEvents>(
  descriptor: T,
  consumed: EventDescriptorAny | undefined,
  published: readonly EventDescriptorAny[],
) => T;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L36)

### createEventClient

**Signature**

```ts
declare const createEventClient: <
  const Id extends string,
  const Version extends number,
  const PayloadSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: EventClientOptions<Id, Version, PayloadSchema>,
) => EventClient<InferInput<PayloadSchema>, Id, Version, InferOutput<PayloadSchema>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L11)

### defineEvent

**Signature**

```ts
declare const defineEvent: <
  const Id extends string,
  const Version extends number = 1,
  const InputSchema extends StandardSchemaV1 = StandardSchemaV1<unknown, unknown>,
>(
  options: DefineEventOptions<Id, Version, InputSchema>,
) => EventDescriptor<Id, Version, InferOutput<InputSchema>, InputSchema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L1)

### defineEventFunction

**Signature**

```ts
declare const defineEventFunction: <
  const Id extends string,
  const Event extends EventName,
  const Publishes extends readonly EventName[] = readonly [],
  const Dependencies extends FunctionDependencies = {},
  const Options extends EventFunctionCallOptions<Id, Event, Publishes, Dependencies> =
    EventFunctionCallOptions<Id, Event, Publishes, Dependencies>,
>(
  options: EventFunctionCallOptions<Id, Event, Publishes, Dependencies> &
    Options &
    EventFunctionValidation<NoInfer<Options>>,
) => EventFunctionDescriptor<Id, Event, Publishes, Dependencies, ErrorListOf<Options>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L34)

### isEventDescriptor

**Signature**

```ts
declare const isEventDescriptor: (value: unknown) => value is EventDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L1)

### isEventFunctionDescriptor

**Signature**

```ts
declare const isEventFunctionDescriptor: (value: unknown) => value is EventFunctionDescriptorAny;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/events/src/index.ts#L34)
